Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c668b92 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Adding CallVideoClient, used to provide a callback mechanism for the

framework to notify the InCallUI of events related to video calls.

Change-Id: Ife628b27bcefd8e88df2fc899cbbcfa07cfac90b
parent 31e8005e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -332,6 +332,7 @@ LOCAL_SRC_FILES += \
	telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl \
	telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl \
	telecomm/java/com/android/internal/telecomm/ICallVideoProvider.aidl \
	telecomm/java/com/android/internal/telecomm/ICallVideoClient.aidl \
	telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl \
	telecomm/java/com/android/internal/telecomm/IInCallService.aidl \
	telecomm/java/com/android/internal/telecomm/ITelecommService.aidl \
+44 −0
Original line number Diff line number Diff line
@@ -27560,6 +27560,15 @@ package android.telecomm {
    field public final int supportedRouteMask;
  }
  public final class CallCameraCapabilities implements android.os.Parcelable {
    ctor public CallCameraCapabilities(boolean, float);
    method public int describeContents();
    method public float getMaxZoom();
    method public boolean isZoomSupported();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
  }
  public final class CallCapabilities {
    method public static java.lang.String toString(int);
    field public static final int ADD_CALL = 16; // 0x10
@@ -27677,6 +27686,23 @@ package android.telecomm {
    enum_constant public static final android.telecomm.CallState RINGING;
  }
  public abstract class CallVideoClient {
    ctor protected CallVideoClient();
    method public abstract void onCallSessionEvent(int);
    method public abstract void onCameraCapabilitiesChange(android.telecomm.CallCameraCapabilities);
    method public abstract void onReceiveSessionModifyRequest(android.telecomm.VideoCallProfile);
    method public abstract void onReceiveSessionModifyResponse(int, android.telecomm.VideoCallProfile, android.telecomm.VideoCallProfile);
    method public abstract void onUpdateCallDataUsage(int);
    method public abstract void onUpdatedPeerDimensions(int, int);
    field public static final int SESSION_EVENT_RX_PAUSE = 1; // 0x1
    field public static final int SESSION_EVENT_RX_RESUME = 2; // 0x2
    field public static final int SESSION_EVENT_TX_START = 3; // 0x3
    field public static final int SESSION_EVENT_TX_STOP = 4; // 0x4
    field public static final int SESSION_MODIFY_REQUEST_FAIL = 2; // 0x2
    field public static final int SESSION_MODIFY_REQUEST_INVALID = 3; // 0x3
    field public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1; // 0x1
  }
  public class CallVideoProviderWrapper implements android.os.IBinder.DeathRecipient {
    method public void binderDied();
    method public void setCamera(java.lang.String) throws android.os.RemoteException;
@@ -27926,6 +27952,24 @@ package android.telecomm {
  public class TelecommManager {
  }
  public class VideoCallProfile implements android.os.Parcelable {
    ctor public VideoCallProfile(int, int);
    method public int describeContents();
    method public int getQuality();
    method public int getVideoState();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final int QUALITY_DEFAULT = 4; // 0x4
    field public static final int QUALITY_HIGH = 1; // 0x1
    field public static final int QUALITY_LOW = 3; // 0x3
    field public static final int QUALITY_MEDIUM = 2; // 0x2
    field public static final int VIDEO_STATE_AUDIO_ONLY = 0; // 0x0
    field public static final int VIDEO_STATE_BIDIRECTIONAL = 3; // 0x3
    field public static final int VIDEO_STATE_PAUSED = 4; // 0x4
    field public static final int VIDEO_STATE_RX_ENABLED = 2; // 0x2
    field public static final int VIDEO_STATE_TX_ENABLED = 1; // 0x1
  }
}
package android.telephony {
+20 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */


package android.telecomm;

parcelable CallCameraCapabilities;
+113 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package android.telecomm;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Represents the camera capabilities important to a Video Telephony provider.
 * TODO: Add camera capabilities as required.
 */
public final class CallCameraCapabilities implements Parcelable {

    /**
     * Whether the camera supports zoom.
     */
    private final boolean mZoomSupported;

    /**
     * The maximum zoom supported by the camera.
     */
    private final float mMaxZoom;

    /**
     * Create a call camera capabilities instance.
     *
     * @param zoomSupported True when camera supports zoom.
     * @param maxZoom Maximum zoom supported by camera.
     */
    public CallCameraCapabilities(boolean zoomSupported, float maxZoom) {
        mZoomSupported = zoomSupported;
        mMaxZoom = maxZoom;
    }

    /**
     * Responsible for creating CallCameraCapabilities objects from deserialized Parcels.
     **/
    public static final Parcelable.Creator<CallCameraCapabilities> CREATOR =
            new Parcelable.Creator<CallCameraCapabilities> () {
                /**
                 * Creates a CallCameraCapabilities instances from a parcel.
                 *
                 * @param source The parcel.
                 * @return The CallCameraCapabilities.
                 */
                @Override
                public CallCameraCapabilities createFromParcel(Parcel source) {
                    boolean supportsZoom = source.readByte() != 0;
                    float maxZoom = source.readFloat();

                    return new CallCameraCapabilities(supportsZoom, maxZoom);
                }

                @Override
                public CallCameraCapabilities[] newArray(int size) {
                    return new CallCameraCapabilities[size];
                }
            };

    /**
     * Describe the kinds of special objects contained in this Parcelable's
     * marshalled representation.
     *
     * @return a bitmask indicating the set of special object types marshalled
     * by the Parcelable.
     */
    @Override
    public int describeContents() {
        return 0;
    }

    /**
     * Flatten this object in to a Parcel.
     *
     * @param dest  The Parcel in which the object should be written.
     * @param flags Additional flags about how the object should be written.
     *              May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.
     */
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte((byte) (isZoomSupported() ? 1 : 0));
        dest.writeFloat(getMaxZoom());

    }

    /**
     * Whether the camera supports zoom.
     */
    public boolean isZoomSupported() {
        return mZoomSupported;
    }

    /**
     * The maximum zoom supported by the camera.
     */
    public float getMaxZoom() {
        return mMaxZoom;
    }
}
+245 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package android.telecomm;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;

import com.android.internal.os.SomeArgs;
import com.android.internal.telecomm.ICallVideoClient;

/**
 * Base implementation of a CallVideoClient which communicates changes to video properties of a call
 * from the framework to the current InCall-UI.
 */
public abstract class CallVideoClient {

    /**
     * Video is not being received (no protocol pause was issued).
     */
    public static final int SESSION_EVENT_RX_PAUSE = 1;

    /**
     * Video reception has resumed after a SESSION_EVENT_RX_PAUSE.
     */
    public static final int SESSION_EVENT_RX_RESUME = 2;

    /**
     * Video transmission has begun. This occurs after a negotiated start of video transmission
     * when the underlying protocol has actually begun transmitting video to the remote party.
     */
    public static final int SESSION_EVENT_TX_START = 3;

    /**
     * Video transmission has stopped. This occur after a negotiated stop of video transmission when
     * the underlying protocol has actually stopped transmitting video to the remote party.
     */
    public static final int SESSION_EVENT_TX_STOP = 4;

    /**
     * Session modify request was successful.
     */
    public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;

    /**
     * Session modify request failed.
     */
    public static final int SESSION_MODIFY_REQUEST_FAIL = 2;

    /**
     * Session modify request ignored due to invalid parameters.
     */
    public static final int SESSION_MODIFY_REQUEST_INVALID = 3;

    private static final int MSG_ON_RECEIVE_SESSION_MODIFY_REQUEST = 1;
    private static final int MSG_ON_RECEIVE_SESSION_MODIFY_RESPONSE = 2;
    private static final int MSG_ON_CALL_SESSION_EVENT = 3;
    private static final int MSG_ON_UPDATED_PEER_DIMENSIONS = 4;
    private static final int MSG_ON_UPDATE_CALL_DATA_USAGE = 5;
    private static final int MSG_ON_CAMERA_CAPABILITIES_CHANGE = 6;

    /** Default Handler used to consolidate binder method calls onto a single thread. */
    private final Handler mHandler = new Handler(Looper.getMainLooper()) {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_ON_RECEIVE_SESSION_MODIFY_REQUEST:
                    onReceiveSessionModifyRequest((VideoCallProfile) msg.obj);
                    break;
                case MSG_ON_RECEIVE_SESSION_MODIFY_RESPONSE: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    try {
                        int status = (int) args.arg1;
                        VideoCallProfile requestedProfile = (VideoCallProfile) args.arg2;
                        VideoCallProfile responseProfile = (VideoCallProfile) args.arg3;

                        onReceiveSessionModifyResponse(status, requestedProfile,
                                responseProfile);
                    } finally {
                        args.recycle();
                    }
                    break;
                }
                case MSG_ON_CALL_SESSION_EVENT:
                    onCallSessionEvent((int) msg.obj);
                    break;
                case MSG_ON_UPDATED_PEER_DIMENSIONS: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    try {
                        int width = (int) args.arg1;
                        int height = (int) args.arg2;
                        onUpdatedPeerDimensions(width, height);
                    } finally {
                        args.recycle();
                    }
                    break;
                }
                case MSG_ON_UPDATE_CALL_DATA_USAGE:
                    onUpdateCallDataUsage(msg.arg1);
                    break;
                case MSG_ON_CAMERA_CAPABILITIES_CHANGE:
                    onCameraCapabilitiesChange((CallCameraCapabilities) msg.obj);
                    break;
                default:
                    break;
            }
        }
    };

    /**
     * Default ICallVideoClient implementation.
     */
    private final class CallVideoClientBinder extends ICallVideoClient.Stub {
        @Override
        public void onReceiveSessionModifyRequest(VideoCallProfile videoCallProfile) {
            mHandler.obtainMessage(MSG_ON_RECEIVE_SESSION_MODIFY_REQUEST,
                    videoCallProfile).sendToTarget();
        }

        @Override
        public void onReceiveSessionModifyResponse(int status,
                VideoCallProfile requestedProfile, VideoCallProfile responseProfile) {
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = status;
            args.arg2 = requestedProfile;
            args.arg3 = responseProfile;
            mHandler.obtainMessage(MSG_ON_RECEIVE_SESSION_MODIFY_RESPONSE, args).sendToTarget();
        }

        @Override
        public void onCallSessionEvent(int event) {
            mHandler.obtainMessage(MSG_ON_CALL_SESSION_EVENT, event).sendToTarget();
        }

        @Override
        public void onUpdatedPeerDimensions(int width, int height) {
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = width;
            args.arg2 = height;
            mHandler.obtainMessage(MSG_ON_UPDATED_PEER_DIMENSIONS, args).sendToTarget();
        }

        @Override
        public void onUpdateCallDataUsage(int dataUsage) {
            mHandler.obtainMessage(MSG_ON_UPDATE_CALL_DATA_USAGE, dataUsage).sendToTarget();
        }

        @Override
        public void onCameraCapabilitiesChange(CallCameraCapabilities cameraCapabilities) {
            mHandler.obtainMessage(MSG_ON_CAMERA_CAPABILITIES_CHANGE,
                    cameraCapabilities).sendToTarget();
        }
    }

    private final CallVideoClientBinder mBinder;

    protected CallVideoClient() {
        mBinder = new CallVideoClientBinder();
    }

    /**
     * Retrieves the binder.
     *
     * @return The binder.
     * @hide
     */
    public final CallVideoClientBinder getBinder() {
        return mBinder;
    }

    /**
     * Called when an incoming request is received from a remote device to modify the current
     * video call profile.  This could be, for example, a remote request to upgrade from an
     * audio-only call to a video call.
     *
     * @param videoCallProfile The requested video call profile.
     */
    public abstract void onReceiveSessionModifyRequest(VideoCallProfile videoCallProfile);

    /**
     * Called when a response is received to a previously sent request to modify the video call
     * profile.  For example, if a request was previously sent to the other party to upgrade from an
     * audio-only call to a video call, the other party responds to indicate which profile
     * changes were accepted.
     *
     * @param status Status of the session modify request.  Valid values are
     *               {@link CallVideoClient#SESSION_MODIFY_REQUEST_SUCCESS},
     *               {@link CallVideoClient#SESSION_MODIFY_REQUEST_FAIL},
     *               {@link CallVideoClient#SESSION_MODIFY_REQUEST_INVALID}
     * @param requestedProfile The original request which was sent to the remote device.
     * @param responseProfile The actual profile changes made by the remote device.
     */
    public abstract void onReceiveSessionModifyResponse(int status,
            VideoCallProfile requestedProfile, VideoCallProfile responseProfile);

    /**
     * Handles events related to the current session which the client may wish to handle.  These
     * are separate from requested changes to the session due to the underlying protocol or
     * connection.
     * Valid values are: {@link CallVideoClient#SESSION_EVENT_RX_PAUSE},
     * {@link CallVideoClient#SESSION_EVENT_RX_RESUME},
     * {@link CallVideoClient#SESSION_EVENT_TX_START}, {@link CallVideoClient#SESSION_EVENT_TX_STOP}
     *
     * @param event The event.
     */
    public abstract void onCallSessionEvent(int event);

    /**
     * Handles a change to the video dimensions from the remote caller (peer).  This could happen
     * if, for example, the peer changes orientation of their device.
     *
     * @param width  The updated peer video width.
     * @param height The updated peer video height.
     */
    public abstract void onUpdatedPeerDimensions(int width, int height);

    /**
     * Handles an update to the total data used for the current session.
     *
     * @param dataUsage The updated data usage.
     */
    public abstract void onUpdateCallDataUsage(int dataUsage);

    /**
     * Handles a change in camera capabilities.
     *
     * @param callCameraCapabilities The changed camera capabilities.
     */
    public abstract void onCameraCapabilitiesChange(CallCameraCapabilities callCameraCapabilities);
}
Loading