Skip to content
Snippets Groups Projects
Commit 31d27c68 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#16331: Implement JAVA thread handler returning requested values from JNI

parent 718d49fb
No related branches found
No related tags found
No related merge requests found
...@@ -448,6 +448,8 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC ...@@ -448,6 +448,8 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
break; break;
case R.id.buttonInit: case R.id.buttonInit:
Log.i(TAG, "R.id.buttonInit"); Log.i(TAG, "R.id.buttonInit");
String audioPlugin = service.getCurrentAudioOutputPlugin();
Log.i(TAG, "Current Audio Plugin: " + audioPlugin);
break; break;
case R.id.buttonService: case R.id.buttonService:
if (!serviceIsOn) { if (!serviceIsOn) {
......
...@@ -9,4 +9,5 @@ interface ISipService { ...@@ -9,4 +9,5 @@ interface ISipService {
Map getAccountDetails(in String accountID); Map getAccountDetails(in String accountID);
void setAccountDetails(in String accountId, in Map accountDetails); void setAccountDetails(in String accountId, in Map accountDetails);
void setAudioPlugin(in String callID); void setAudioPlugin(in String callID);
String getCurrentAudioOutputPlugin();
} }
...@@ -114,7 +114,23 @@ public class SipService extends Service { ...@@ -114,7 +114,23 @@ public class SipService extends Service {
Log.i(TAG, "SipService.setAudioPlugin() thread running..."); Log.i(TAG, "SipService.setAudioPlugin() thread running...");
configurationManagerJNI.setAudioPlugin(audioPlugin); configurationManagerJNI.setAudioPlugin(audioPlugin);
} }
}); });
}
@Override
public String getCurrentAudioOutputPlugin() {
class CurrentAudioPlugin extends SipRunnableWithReturn {
@Override
protected String doRun() throws SameThreadException {
Log.i(TAG, "SipService.getCurrentAudioOutputPlugin() thread running...");
return configurationManagerJNI.getCurrentAudioOutputPlugin();
}
};
CurrentAudioPlugin runInstance = new CurrentAudioPlugin();
getExecutor().execute(runInstance);
while(!runInstance.isDone()) {}
return (String) runInstance.getVal();
} }
@Override @Override
...@@ -132,8 +148,6 @@ public class SipService extends Service { ...@@ -132,8 +148,6 @@ public class SipService extends Service {
public HashMap<String,String> getAccountDetails(final String accountID) { public HashMap<String,String> getAccountDetails(final String accountID) {
StringMap swigmap = configurationManagerJNI.getAccountDetails(accountID); StringMap swigmap = configurationManagerJNI.getAccountDetails(accountID);
Log.i(TAG, "===================== Swig Map Size " + swigmap.size());
HashMap<String, String> nativemap = new HashMap<String, String>(); HashMap<String, String> nativemap = new HashMap<String, String>();
nativemap.put(ServiceConstants.CONFIG_ACCOUNT_ALIAS, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_ALIAS)); nativemap.put(ServiceConstants.CONFIG_ACCOUNT_ALIAS, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_ALIAS));
...@@ -444,6 +458,30 @@ public class SipService extends Service { ...@@ -444,6 +458,30 @@ public class SipService extends Service {
} }
} }
public abstract static class SipRunnableWithReturn implements Runnable {
Object obj = null;
boolean done = false;
protected abstract Object doRun() throws SameThreadException;
public Object getVal() {
return obj;
}
public boolean isDone() {
return done;
}
public void run() {
try {
obj = doRun();
done = true;
}catch(SameThreadException e) {
Log.e(TAG, "Not done from same thread");
}
}
}
class StartRunnable extends SipRunnable { class StartRunnable extends SipRunnable {
@Override @Override
protected void doRun() throws SameThreadException { protected void doRun() throws SameThreadException {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment