diff --git a/api/current.txt b/api/current.txt index 38909a1c37a95..ba52fa9f1324c 100644 --- a/api/current.txt +++ b/api/current.txt @@ -28562,7 +28562,7 @@ package android.telecom { method public void handleCallSessionEvent(int); method public abstract void onRequestCameraCapabilities(); method public abstract void onRequestConnectionDataUsage(); - method public abstract void onSendSessionModifyRequest(android.telecom.VideoProfile); + method public abstract void onSendSessionModifyRequest(android.telecom.VideoProfile, android.telecom.VideoProfile); method public abstract void onSendSessionModifyResponse(android.telecom.VideoProfile); method public abstract void onSetCamera(java.lang.String); method public abstract void onSetDeviceOrientation(int); diff --git a/api/system-current.txt b/api/system-current.txt index 72f3540ec1a43..547dfe643a6b5 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -30383,7 +30383,7 @@ package android.telecom { method public void handleCallSessionEvent(int); method public abstract void onRequestCameraCapabilities(); method public abstract void onRequestConnectionDataUsage(); - method public abstract void onSendSessionModifyRequest(android.telecom.VideoProfile); + method public abstract void onSendSessionModifyRequest(android.telecom.VideoProfile, android.telecom.VideoProfile); method public abstract void onSendSessionModifyResponse(android.telecom.VideoProfile); method public abstract void onSetCamera(java.lang.String); method public abstract void onSetDeviceOrientation(int); diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index bea4f753b12ae..74bb883e8c9cd 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -925,9 +925,9 @@ public final class Call { } boolean videoCallChanged = parcelableCall.isVideoCallProviderChanged() && - !Objects.equals(mVideoCall, parcelableCall.getVideoCall()); + !Objects.equals(mVideoCall, parcelableCall.getVideoCall(this)); if (videoCallChanged) { - mVideoCall = parcelableCall.getVideoCall(); + mVideoCall = parcelableCall.getVideoCall(this); } int state = stateFromParcelableCallState(parcelableCall.getState()); diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index 97d599b9a9cd1..2fa412468cd1e 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -16,6 +16,7 @@ package android.telecom; +import com.android.internal.os.SomeArgs; import com.android.internal.telecom.IVideoCallback; import com.android.internal.telecom.IVideoProvider; @@ -471,9 +472,16 @@ public abstract class Connection implements IConferenceable { case MSG_SET_ZOOM: onSetZoom((Float) msg.obj); break; - case MSG_SEND_SESSION_MODIFY_REQUEST: - onSendSessionModifyRequest((VideoProfile) msg.obj); + case MSG_SEND_SESSION_MODIFY_REQUEST: { + SomeArgs args = (SomeArgs) msg.obj; + try { + onSendSessionModifyRequest((VideoProfile) args.arg1, + (VideoProfile) args.arg2); + } finally { + args.recycle(); + } break; + } case MSG_SEND_SESSION_MODIFY_RESPONSE: onSendSessionModifyResponse((VideoProfile) msg.obj); break; @@ -527,9 +535,11 @@ public abstract class Connection implements IConferenceable { mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget(); } - public void sendSessionModifyRequest(VideoProfile requestProfile) { - mMessageHandler.obtainMessage( - MSG_SEND_SESSION_MODIFY_REQUEST, requestProfile).sendToTarget(); + public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = fromProfile; + args.arg2 = toProfile; + mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget(); } public void sendSessionModifyResponse(VideoProfile responseProfile) { @@ -606,9 +616,11 @@ public abstract class Connection implements IConferenceable { * Some examples of session modification requests: upgrade connection from audio to video, * downgrade connection from video to audio, pause video. * - * @param requestProfile The requested connection video properties. + * @param fromProfile The video properties prior to the request. + * @param toProfile The video properties with the requested changes made. */ - public abstract void onSendSessionModifyRequest(VideoProfile requestProfile); + public abstract void onSendSessionModifyRequest(VideoProfile fromProfile, + VideoProfile toProfile); /**te * Provides a response to a request to change the current connection session video diff --git a/telecomm/java/android/telecom/ParcelableCall.java b/telecomm/java/android/telecom/ParcelableCall.java index 1a3091011b01e..bb65ce9aa63fd 100644 --- a/telecomm/java/android/telecom/ParcelableCall.java +++ b/telecomm/java/android/telecom/ParcelableCall.java @@ -178,10 +178,10 @@ public final class ParcelableCall implements Parcelable { * Returns an object for remotely communicating through the video call provider's binder. * @return The video call. */ - public InCallService.VideoCall getVideoCall() { + public InCallService.VideoCall getVideoCall(Call call) { if (mVideoCall == null && mVideoCallProvider != null) { try { - mVideoCall = new VideoCallImpl(mVideoCallProvider); + mVideoCall = new VideoCallImpl(mVideoCallProvider, call); } catch (RemoteException ignored) { // Ignore RemoteException. } diff --git a/telecomm/java/android/telecom/RemoteConnection.java b/telecomm/java/android/telecom/RemoteConnection.java index 4ecfd50e705ad..0cbef8f288ec8 100644 --- a/telecomm/java/android/telecom/RemoteConnection.java +++ b/telecomm/java/android/telecom/RemoteConnection.java @@ -349,9 +349,9 @@ public final class RemoteConnection { } } - public void sendSessionModifyRequest(VideoProfile reqProfile) { + public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) { try { - mVideoProviderBinder.sendSessionModifyRequest(reqProfile); + mVideoProviderBinder.sendSessionModifyRequest(fromProfile, toProfile); } catch (RemoteException e) { } } diff --git a/telecomm/java/android/telecom/VideoCallImpl.java b/telecomm/java/android/telecom/VideoCallImpl.java index 3779d1aeca015..a23d4d661efdc 100644 --- a/telecomm/java/android/telecom/VideoCallImpl.java +++ b/telecomm/java/android/telecom/VideoCallImpl.java @@ -47,6 +47,8 @@ public class VideoCallImpl extends VideoCall { private final IVideoProvider mVideoProvider; private final VideoCallListenerBinder mBinder; private VideoCall.Callback mCallback; + private int mVideoQuality = VideoProfile.QUALITY_UNKNOWN; + private Call mCall; private IBinder.DeathRecipient mDeathRecipient = new IBinder.DeathRecipient() { @Override @@ -152,6 +154,7 @@ public class VideoCallImpl extends VideoCall { (CameraCapabilities) msg.obj); break; case MSG_CHANGE_VIDEO_QUALITY: + mVideoQuality = msg.arg1; mCallback.onVideoQualityChanged(msg.arg1); break; default: @@ -161,12 +164,13 @@ public class VideoCallImpl extends VideoCall { }; /** {@hide} */ - VideoCallImpl(IVideoProvider videoProvider) throws RemoteException { + VideoCallImpl(IVideoProvider videoProvider, Call call) throws RemoteException { mVideoProvider = videoProvider; mVideoProvider.asBinder().linkToDeath(mDeathRecipient, 0); mBinder = new VideoCallListenerBinder(); mVideoProvider.addVideoCallback(mBinder); + mCall = call; } /** {@inheritDoc} */ @@ -223,10 +227,24 @@ public class VideoCallImpl extends VideoCall { } } - /** {@inheritDoc} */ + /** + * Sends a session modification request to the video provider. + *

+ * The {@link InCallService} will create the {@code requestProfile} based on the current + * video state (i.e. {@link Call.Details#getVideoState()}). It is, however, possible that the + * video state maintained by the {@link InCallService} could get out of sync with what is known + * by the {@link android.telecom.Connection.VideoProvider}. To remove ambiguity, the + * {@link VideoCallImpl} passes along the pre-modify video profile to the {@code VideoProvider} + * to ensure it has full context of the requested change. + * + * @param requestProfile The requested video profile. + */ public void sendSessionModifyRequest(VideoProfile requestProfile) { try { - mVideoProvider.sendSessionModifyRequest(requestProfile); + VideoProfile originalProfile = new VideoProfile(mCall.getDetails().getVideoState(), + mVideoQuality); + + mVideoProvider.sendSessionModifyRequest(originalProfile, requestProfile); } catch (RemoteException e) { } } diff --git a/telecomm/java/com/android/internal/telecom/IVideoProvider.aidl b/telecomm/java/com/android/internal/telecom/IVideoProvider.aidl index bff3865e8840a..d095744b6b345 100644 --- a/telecomm/java/com/android/internal/telecom/IVideoProvider.aidl +++ b/telecomm/java/com/android/internal/telecom/IVideoProvider.aidl @@ -39,7 +39,7 @@ oneway interface IVideoProvider { void setZoom(float value); - void sendSessionModifyRequest(in VideoProfile reqProfile); + void sendSessionModifyRequest(in VideoProfile fromProfile, in VideoProfile toProfile); void sendSessionModifyResponse(in VideoProfile responseProfile); diff --git a/telephony/java/com/android/ims/internal/IImsVideoCallProvider.aidl b/telephony/java/com/android/ims/internal/IImsVideoCallProvider.aidl index 1fd88e701eb32..4ff0b4367ea56 100644 --- a/telephony/java/com/android/ims/internal/IImsVideoCallProvider.aidl +++ b/telephony/java/com/android/ims/internal/IImsVideoCallProvider.aidl @@ -52,7 +52,7 @@ oneway interface IImsVideoCallProvider { void setZoom(float value); - void sendSessionModifyRequest(in VideoProfile reqProfile); + void sendSessionModifyRequest(in VideoProfile fromProfile, in VideoProfile toProfile); void sendSessionModifyResponse(in VideoProfile responseProfile);