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