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
break;
case R.id.buttonInit:
Log.i(TAG, "R.id.buttonInit");
String audioPlugin = service.getCurrentAudioOutputPlugin();
Log.i(TAG, "Current Audio Plugin: " + audioPlugin);
break;
case R.id.buttonService:
if (!serviceIsOn) {
......
......@@ -9,4 +9,5 @@ interface ISipService {
Map getAccountDetails(in String accountID);
void setAccountDetails(in String accountId, in Map accountDetails);
void setAudioPlugin(in String callID);
String getCurrentAudioOutputPlugin();
}
......@@ -114,7 +114,23 @@ public class SipService extends Service {
Log.i(TAG, "SipService.setAudioPlugin() thread running...");
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
......@@ -132,8 +148,6 @@ public class SipService extends Service {
public HashMap<String,String> getAccountDetails(final String accountID) {
StringMap swigmap = configurationManagerJNI.getAccountDetails(accountID);
Log.i(TAG, "===================== Swig Map Size " + swigmap.size());
HashMap<String, String> nativemap = new HashMap<String, String>();
nativemap.put(ServiceConstants.CONFIG_ACCOUNT_ALIAS, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_ALIAS));
......@@ -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 {
@Override
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