Merge "Cleanup video provider binder code."

This commit is contained in:
Tyler Gunn
2019-11-12 20:47:38 +00:00
committed by Gerrit Code Review
3 changed files with 42 additions and 6 deletions

View File

@@ -25,8 +25,11 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import com.android.internal.telecom.IVideoProvider;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
@@ -2132,13 +2135,22 @@ public final class Call {
cannedTextResponsesChanged = true;
}
VideoCallImpl newVideoCallImpl = parcelableCall.getVideoCallImpl(mCallingPackage,
mTargetSdkVersion);
boolean videoCallChanged = parcelableCall.isVideoCallProviderChanged() &&
!Objects.equals(mVideoCallImpl, newVideoCallImpl);
IVideoProvider previousVideoProvider = mVideoCallImpl == null ? null :
mVideoCallImpl.getVideoProvider();
IVideoProvider newVideoProvider = parcelableCall.getVideoProvider();
// parcelableCall.isVideoCallProviderChanged is only true when we have a video provider
// specified; so we should check if the actual IVideoProvider changes as well.
boolean videoCallChanged = parcelableCall.isVideoCallProviderChanged()
&& !Objects.equals(previousVideoProvider, newVideoProvider);
if (videoCallChanged) {
mVideoCallImpl = newVideoCallImpl;
if (mVideoCallImpl != null) {
mVideoCallImpl.destroy();
}
mVideoCallImpl = parcelableCall.isVideoCallProviderChanged() ?
parcelableCall.getVideoCallImpl(mCallingPackage, mTargetSdkVersion) : null;
}
if (mVideoCallImpl != null) {
mVideoCallImpl.setVideoState(getDetails().getVideoState());
}

View File

@@ -21,6 +21,7 @@ import android.annotation.UnsupportedAppUsage;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
@@ -225,6 +226,10 @@ public final class ParcelableCall implements Parcelable {
return mVideoCall;
}
public IVideoProvider getVideoProvider() {
return mVideoCallProvider;
}
public boolean getIsRttCallChanged() {
return mIsRttCallChanged;
}

View File

@@ -32,6 +32,8 @@ import com.android.internal.os.SomeArgs;
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 @@ public class VideoCallImpl extends VideoCall {
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 @@ public class VideoCallImpl extends VideoCall {
@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 class VideoCallImpl extends VideoCall {
public void setVideoState(int videoState) {
mVideoState = videoState;
}
/**
* Get the video provider binder.
* @return the video provider binder.
*/
public IVideoProvider getVideoProvider() {
return mVideoProvider;
}
}