Merge "Change testapps to reflect API fixes"
diff --git a/testapps/EmbmsServiceTestApp/src/com/android/phone/testapps/embmsmw/AppActiveStreams.java b/testapps/EmbmsServiceTestApp/src/com/android/phone/testapps/embmsmw/AppActiveStreams.java
index 4d2c62c..5da8145 100644
--- a/testapps/EmbmsServiceTestApp/src/com/android/phone/testapps/embmsmw/AppActiveStreams.java
+++ b/testapps/EmbmsServiceTestApp/src/com/android/phone/testapps/embmsmw/AppActiveStreams.java
@@ -16,7 +16,6 @@
package com.android.phone.testapps.embmsmw;
-import android.os.RemoteException;
import android.telephony.mbms.StreamingService;
import android.telephony.mbms.StreamingServiceCallback;
@@ -94,25 +93,17 @@
mStreamStates.put(serviceId,
new StreamCallbackWithState(callback, StreamingService.STATE_STARTED,
StreamingService.UNICAST_METHOD));
- try {
- callback.streamStateUpdated(StreamingService.STATE_STARTED, reason);
- updateStreamingMethod(serviceId);
- } catch (RemoteException e) {
- dispose(serviceId);
- }
+ callback.onStreamStateUpdated(StreamingService.STATE_STARTED, reason);
+ updateStreamingMethod(serviceId);
}
public void stopStreaming(String serviceId, int reason) {
StreamCallbackWithState entry = mStreamStates.get(serviceId);
if (entry != null) {
- try {
- if (entry.getState() != StreamingService.STATE_STOPPED) {
- entry.setState(StreamingService.STATE_STOPPED);
- entry.getCallback().streamStateUpdated(StreamingService.STATE_STOPPED, reason);
- }
- } catch (RemoteException e) {
- dispose(serviceId);
+ if (entry.getState() != StreamingService.STATE_STOPPED) {
+ entry.setState(StreamingService.STATE_STOPPED);
+ entry.getCallback().onStreamStateUpdated(StreamingService.STATE_STOPPED, reason);
}
}
}
@@ -133,11 +124,7 @@
}
if (newMethod != oldMethod || callbackWithState.isMethodSet()) {
callbackWithState.setMethod(newMethod);
- try {
- callbackWithState.getCallback().streamMethodUpdated(newMethod);
- } catch (RemoteException e) {
- dispose(serviceId);
- }
+ callbackWithState.getCallback().onStreamMethodUpdated(newMethod);
}
}
}
diff --git a/testapps/EmbmsServiceTestApp/src/com/android/phone/testapps/embmsmw/EmbmsTestStreamingService.java b/testapps/EmbmsServiceTestApp/src/com/android/phone/testapps/embmsmw/EmbmsTestStreamingService.java
index 73a13e9..7a9dd03 100644
--- a/testapps/EmbmsServiceTestApp/src/com/android/phone/testapps/embmsmw/EmbmsTestStreamingService.java
+++ b/testapps/EmbmsServiceTestApp/src/com/android/phone/testapps/embmsmw/EmbmsTestStreamingService.java
@@ -56,7 +56,7 @@
private static final int SEND_STREAMING_SERVICES_LIST = 1;
- private final Map<FrontendAppIdentifier, IMbmsStreamingManagerCallback> mAppCallbacks =
+ private final Map<FrontendAppIdentifier, MbmsStreamingManagerCallback> mAppCallbacks =
new HashMap<>();
private HandlerThread mHandlerThread;
@@ -67,20 +67,16 @@
SomeArgs args = (SomeArgs) msg.obj;
FrontendAppIdentifier appKey = (FrontendAppIdentifier) args.arg1;
List<StreamingServiceInfo> services = (List) args.arg2;
- IMbmsStreamingManagerCallback appCallback = mAppCallbacks.get(appKey);
+ MbmsStreamingManagerCallback appCallback = mAppCallbacks.get(appKey);
if (appCallback != null) {
- try {
- appCallback.streamingServicesUpdated(services);
- } catch (RemoteException e) {
- // Assume app has gone away and clean up.
- }
+ appCallback.onStreamingServicesUpdated(services);
}
break;
}
return true;
};
- private final IMbmsStreamingService.Stub mBinder = new MbmsStreamingServiceBase() {
+ private final MbmsStreamingServiceBase mBinder = new MbmsStreamingServiceBase() {
@Override
public int initialize(MbmsStreamingManagerCallback listener, int subId) {
int packageUid = Binder.getCallingUid();
@@ -98,20 +94,11 @@
if (!mAppCallbacks.containsKey(appKey)) {
mAppCallbacks.put(appKey, listener);
} else {
- try {
- listener.error(
- MbmsException.InitializationErrors.ERROR_DUPLICATE_INITIALIZE, "");
- } catch (RemoteException e) {
- // ignore, it was an error anyway
- }
+ listener.onError(
+ MbmsException.InitializationErrors.ERROR_DUPLICATE_INITIALIZE, "");
return;
}
- try {
- listener.middlewareReady();
- } catch (RemoteException e) {
- StreamStateTracker.disposeAll(appKey);
- mAppCallbacks.remove(appKey);
- }
+ listener.onMiddlewareReady();
}, INITIALIZATION_DELAY);
return MbmsException.SUCCESS;
}
@@ -202,6 +189,15 @@
StreamStateTracker.disposeAll(appKey);
mAppCallbacks.remove(appKey);
}
+
+ @Override
+ public void onAppCallbackDied(int uid, int subscriptionId) {
+ FrontendAppIdentifier appKey = new FrontendAppIdentifier(uid, subscriptionId);
+
+ Log.i(TAG, "Disposing app " + appKey + " due to binder death");
+ StreamStateTracker.disposeAll(appKey);
+ mAppCallbacks.remove(appKey);
+ }
};
@Override
diff --git a/testapps/EmbmsTestStreamingApp/src/com/android/phone/testapps/embmsfrontend/EmbmsTestStreamingApp.java b/testapps/EmbmsTestStreamingApp/src/com/android/phone/testapps/embmsfrontend/EmbmsTestStreamingApp.java
index b19e004..1505846 100644
--- a/testapps/EmbmsTestStreamingApp/src/com/android/phone/testapps/embmsfrontend/EmbmsTestStreamingApp.java
+++ b/testapps/EmbmsTestStreamingApp/src/com/android/phone/testapps/embmsfrontend/EmbmsTestStreamingApp.java
@@ -45,7 +45,7 @@
public class EmbmsTestStreamingApp extends Activity {
private MbmsStreamingManagerCallback mStreamingListener = new MbmsStreamingManagerCallback() {
@Override
- public void streamingServicesUpdated(List<StreamingServiceInfo> services) {
+ public void onStreamingServicesUpdated(List<StreamingServiceInfo> services) {
EmbmsTestStreamingApp.this.runOnUiThread(() ->
Toast.makeText(EmbmsTestStreamingApp.this,
"Got services length " + services.size(),
@@ -54,7 +54,7 @@
}
@Override
- public void middlewareReady() {
+ public void onMiddlewareReady() {
runOnUiThread(() -> Toast.makeText(EmbmsTestStreamingApp.this, "Successfully bound",
Toast.LENGTH_SHORT).show());
}
@@ -158,7 +158,7 @@
bindButton.setOnClickListener((view) -> {
try {
mStreamingManager = MbmsStreamingManager.create(
- EmbmsTestStreamingApp.this, mStreamingListener);
+ EmbmsTestStreamingApp.this, mStreamingListener, mHandler);
} catch (MbmsException e) {
Toast.makeText(EmbmsTestStreamingApp.this,
"Init error: " + e.getErrorCode(), Toast.LENGTH_SHORT).show();
diff --git a/testapps/EmbmsTestStreamingApp/src/com/android/phone/testapps/embmsfrontend/StreamingServiceTracker.java b/testapps/EmbmsTestStreamingApp/src/com/android/phone/testapps/embmsfrontend/StreamingServiceTracker.java
index b247076..4821bee 100644
--- a/testapps/EmbmsTestStreamingApp/src/com/android/phone/testapps/embmsfrontend/StreamingServiceTracker.java
+++ b/testapps/EmbmsTestStreamingApp/src/com/android/phone/testapps/embmsfrontend/StreamingServiceTracker.java
@@ -27,20 +27,20 @@
public class StreamingServiceTracker {
private class Callback extends StreamingServiceCallback {
@Override
- public void error(int errorCode, String message) {
+ public void onError(int errorCode, String message) {
String toastMessage = "Error: " + errorCode + ": " + message;
mActivity.runOnUiThread(() ->
Toast.makeText(mActivity, toastMessage, Toast.LENGTH_SHORT).show());
}
@Override
- public void streamStateUpdated(int state, int reason) {
- onStreamStateUpdated(state, reason);
+ public void onStreamStateUpdated(int state, int reason) {
+ StreamingServiceTracker.this.onStreamStateUpdated(state, reason);
}
@Override
- public void streamMethodUpdated(int method) {
- onStreamMethodUpdated(method);
+ public void onStreamMethodUpdated(int method) {
+ StreamingServiceTracker.this.onStreamMethodUpdated(method);
}
}
@@ -60,7 +60,7 @@
public boolean startStreaming(MbmsStreamingManager streamingManager) {
try {
mStreamingService =
- streamingManager.startStreaming(mStreamingServiceInfo, new Callback());
+ streamingManager.startStreaming(mStreamingServiceInfo, new Callback(), null);
return true;
} catch (MbmsException e) {
Toast.makeText(mActivity,