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

Commit 7a8545f7 authored by Thomas Stuart's avatar Thomas Stuart Committed by Android (Google) Code Review
Browse files

Merge "add transactional video state APIs" into main

parents 73c10ee5 26b9bc72
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -42394,6 +42394,7 @@ package android.telecom {
    field public static final int SUPPORTS_SET_INACTIVE = 2; // 0x2
    field public static final int SUPPORTS_STREAM = 4; // 0x4
    field public static final int SUPPORTS_TRANSFER = 8; // 0x8
    field @FlaggedApi("com.android.server.telecom.flags.transactional_video_state") public static final int SUPPORTS_VIDEO_CALLING = 16; // 0x10
    field public static final int VIDEO_CALL = 2; // 0x2
  }
@@ -42429,6 +42430,7 @@ package android.telecom {
    method @NonNull public android.os.ParcelUuid getCallId();
    method public void requestCallEndpointChange(@NonNull android.telecom.CallEndpoint, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
    method @FlaggedApi("com.android.server.telecom.flags.set_mute_state") public void requestMuteState(boolean, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
    method @FlaggedApi("com.android.server.telecom.flags.transactional_video_state") public void requestVideoState(int, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
    method public void sendEvent(@NonNull String, @NonNull android.os.Bundle);
    method public void setActive(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
    method public void setInactive(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
@@ -42477,6 +42479,7 @@ package android.telecom {
    method public void onCallStreamingFailed(int);
    method public void onEvent(@NonNull String, @NonNull android.os.Bundle);
    method public void onMuteStateChanged(boolean);
    method @FlaggedApi("com.android.server.telecom.flags.transactional_video_state") public default void onVideoStateChanged(int);
  }
  public final class CallException extends java.lang.RuntimeException implements android.os.Parcelable {
+11 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.telecom;

import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -24,6 +25,8 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.android.server.telecom.flags.Flags;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
@@ -113,7 +116,8 @@ public final class CallAttributes implements Parcelable {
    public static final int VIDEO_CALL = 2;

    /** @hide */
    @IntDef(value = {SUPPORTS_SET_INACTIVE, SUPPORTS_STREAM, SUPPORTS_TRANSFER}, flag = true)
    @IntDef(value = {SUPPORTS_SET_INACTIVE, SUPPORTS_STREAM, SUPPORTS_TRANSFER,
            SUPPORTS_VIDEO_CALLING}, flag = true)
    @Retention(RetentionPolicy.SOURCE)
    public @interface CallCapability {
    }
@@ -133,6 +137,12 @@ public final class CallAttributes implements Parcelable {
     * The call can be completely transferred from one endpoint to another.
     */
    public static final int SUPPORTS_TRANSFER = 1 << 3;
    /**
     * The call supports video calling. This allows clients to gate video calling on a per call
     * basis as opposed to re-registering the phone account.
     */
    @FlaggedApi(Flags.FLAG_TRANSACTIONAL_VIDEO_STATE)
    public static final int SUPPORTS_VIDEO_CALLING = 1 << 4;

    /**
     * Build an instance of {@link CallAttributes}. In order to build a valid instance, a
+39 −1
Original line number Diff line number Diff line
@@ -293,7 +293,45 @@ public final class CallControl {
        try {
            mServerInterface.setMuteState(isMuted,
                    new CallControlResultReceiver("requestMuteState", executor, callback));
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

     /**
     * Request a new video state for the ongoing call. This can only be changed if the application
     * has registered a {@link PhoneAccount} with the
     * {@link PhoneAccount#CAPABILITY_SUPPORTS_VIDEO_CALLING} and set the
     * {@link CallAttributes#SUPPORTS_VIDEO_CALLING} when adding the call via
     * {@link TelecomManager#addCall(CallAttributes, Executor, OutcomeReceiver,
     *                                                      CallControlCallback, CallEventCallback)}
     *
     * @param videoState to report to Telecom. To see the valid argument to pass,
      *                   see {@link CallAttributes.CallType}.
     * @param executor   The {@link Executor} on which the {@link OutcomeReceiver} callback
     *                   will be called on.
     * @param callback   that will be completed on the Telecom side that details success or failure
     *                   of the requested operation.
     *
     *                   {@link OutcomeReceiver#onResult} will be called if Telecom has successfully
     *                   switched the video state.
     *
     *                   {@link OutcomeReceiver#onError} will be called if Telecom has failed to set
     *                   the new video state.  A {@link CallException} will be passed
     *                   that details why the operation failed.
     * @throws IllegalArgumentException if the argument passed for videoState is invalid.  To see a
     * list of valid states, see {@link CallAttributes.CallType}.
     */
     @FlaggedApi(Flags.FLAG_TRANSACTIONAL_VIDEO_STATE)
     public void requestVideoState(@CallAttributes.CallType int videoState,
             @CallbackExecutor @NonNull Executor executor,
             @NonNull OutcomeReceiver<Void, CallException> callback) {
         validateVideoState(videoState);
         Objects.requireNonNull(executor);
         Objects.requireNonNull(callback);
         try {
             mServerInterface.requestVideoState(videoState, mCallId,
                     new CallControlResultReceiver("requestVideoState", executor, callback));
         } catch (RemoteException e) {
             throw e.rethrowAsRuntimeException();
         }
+11 −0
Original line number Diff line number Diff line
@@ -16,9 +16,12 @@

package android.telecom;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.os.Bundle;

import com.android.server.telecom.flags.Flags;

import java.util.List;

/**
@@ -50,6 +53,14 @@ public interface CallEventCallback {
     */
    void onMuteStateChanged(boolean isMuted);

    /**
     * Called when the video state changes.
     *
     * @param videoState The current video state.
     */
    @FlaggedApi(Flags.FLAG_TRANSACTIONAL_VIDEO_STATE)
    default void onVideoStateChanged(@CallAttributes.CallType int videoState) {}

    /**
     * Telecom is informing the client user requested call streaming but the stream can't be
     * started.
+13 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ import android.telecom.PhoneAccountHandle;
import android.text.TextUtils;
import android.util.Log;

import com.android.server.telecom.flags.Flags;

import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@@ -148,6 +150,7 @@ public class ClientTransactionalServiceWrapper {
        private static final String ON_REQ_ENDPOINT_CHANGE = "onRequestEndpointChange";
        private static final String ON_AVAILABLE_CALL_ENDPOINTS = "onAvailableCallEndpointsChanged";
        private static final String ON_MUTE_STATE_CHANGED = "onMuteStateChanged";
        private static final String ON_VIDEO_STATE_CHANGED = "onVideoStateChanged";
        private static final String ON_CALL_STREAMING_FAILED = "onCallStreamingFailed";
        private static final String ON_EVENT = "onEvent";

@@ -261,6 +264,11 @@ public class ClientTransactionalServiceWrapper {
            handleEventCallback(callId, ON_MUTE_STATE_CHANGED, isMuted);
        }

        @Override
        public void onVideoStateChanged(String callId, int videoState) {
            handleEventCallback(callId, ON_VIDEO_STATE_CHANGED, videoState);
        }

        public void handleEventCallback(String callId, String action, Object arg) {
            Log.d(TAG, TextUtils.formatSimple("hEC: [%s], callId=[%s]", action, callId));
            // lookup the callEventCallback associated with the particular call
@@ -281,6 +289,11 @@ public class ClientTransactionalServiceWrapper {
                            case ON_MUTE_STATE_CHANGED:
                                callback.onMuteStateChanged((boolean) arg);
                                break;
                            case ON_VIDEO_STATE_CHANGED:
                                if (Flags.transactionalVideoState()) {
                                    callback.onVideoStateChanged((int) arg);
                                }
                                break;
                            case ON_CALL_STREAMING_FAILED:
                                callback.onCallStreamingFailed((int) arg /* reason */);
                                break;
Loading