Cleanup video provider binder code.
1. Ensure we always unlink for death from the VideoCallImpl.
2. Ensure we compare the binders in the Call instance properly so that
we are not always replacing the VideoCallImpl used.
3. Ensure we cleanup the VideoCallImpl when its being removed.
Test: Manual testing of video calls for regressions.
Bug: 121156974
Change-Id: I440e8fb4ab9a5051ee02358933c495de736e2bd0
diff --git a/telecomm/java/android/telecom/VideoCallImpl.java b/telecomm/java/android/telecom/VideoCallImpl.java
index cb74012..4a1aa0a 100644
--- a/telecomm/java/android/telecom/VideoCallImpl.java
+++ b/telecomm/java/android/telecom/VideoCallImpl.java
@@ -32,6 +32,8 @@
import com.android.internal.telecom.IVideoCallback;
import com.android.internal.telecom.IVideoProvider;
+import java.util.NoSuchElementException;
+
/**
* Implementation of a Video Call, which allows InCallUi to communicate commands to the underlying
* {@link Connection.VideoProvider}, and direct callbacks from the
@@ -53,7 +55,11 @@
private IBinder.DeathRecipient mDeathRecipient = new IBinder.DeathRecipient() {
@Override
public void binderDied() {
- mVideoProvider.asBinder().unlinkToDeath(this, 0);
+ try {
+ mVideoProvider.asBinder().unlinkToDeath(this, 0);
+ } catch (NoSuchElementException nse) {
+ // Already unlinked in destroy below.
+ }
}
};
@@ -222,6 +228,11 @@
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 127403196)
public void destroy() {
unregisterCallback(mCallback);
+ try {
+ mVideoProvider.asBinder().unlinkToDeath(mDeathRecipient, 0);
+ } catch (NoSuchElementException nse) {
+ // Already unlinked in binderDied above.
+ }
}
/** {@inheritDoc} */
@@ -353,4 +364,12 @@
public void setVideoState(int videoState) {
mVideoState = videoState;
}
+
+ /**
+ * Get the video provider binder.
+ * @return the video provider binder.
+ */
+ public IVideoProvider getVideoProvider() {
+ return mVideoProvider;
+ }
}