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

Commit bfc7480d authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Rename DiagnosticCall to CallDiagnostics." into sc-dev

parents 5ec748f7 066de603
Loading
Loading
Loading
Loading
+25 −21
Original line number Diff line number Diff line
@@ -10452,11 +10452,32 @@ package android.telecom {
    method @Nullable public android.os.IBinder onBind(@NonNull android.content.Intent);
    method public abstract void onBluetoothCallQualityReportReceived(@NonNull android.telecom.BluetoothCallQualityReport);
    method public abstract void onCallAudioStateChanged(@NonNull android.telecom.CallAudioState);
    method @NonNull public abstract android.telecom.DiagnosticCall onInitializeDiagnosticCall(@NonNull android.telecom.Call.Details);
    method public abstract void onRemoveDiagnosticCall(@NonNull android.telecom.DiagnosticCall);
    method @NonNull public abstract android.telecom.CallDiagnostics onInitializeCallDiagnostics(@NonNull android.telecom.Call.Details);
    method public abstract void onRemoveCallDiagnostics(@NonNull android.telecom.CallDiagnostics);
    field public static final String SERVICE_INTERFACE = "android.telecom.CallDiagnosticService";
  }
  public abstract class CallDiagnostics {
    ctor public CallDiagnostics();
    method public final void clearDiagnosticMessage(int);
    method public final void displayDiagnosticMessage(int, @NonNull CharSequence);
    method public abstract void onCallDetailsChanged(@NonNull android.telecom.Call.Details);
    method @Nullable public abstract CharSequence onCallDisconnected(int, int);
    method @Nullable public abstract CharSequence onCallDisconnected(@NonNull android.telephony.ims.ImsReasonInfo);
    method public abstract void onCallQualityReceived(@NonNull android.telephony.CallQuality);
    method public abstract void onReceiveDeviceToDeviceMessage(int, int);
    method public final void sendDeviceToDeviceMessage(int, int);
    field public static final int BATTERY_STATE_CHARGING = 3; // 0x3
    field public static final int BATTERY_STATE_GOOD = 2; // 0x2
    field public static final int BATTERY_STATE_LOW = 1; // 0x1
    field public static final int COVERAGE_GOOD = 2; // 0x2
    field public static final int COVERAGE_POOR = 1; // 0x1
    field public static final int MESSAGE_CALL_AUDIO_CODEC = 2; // 0x2
    field public static final int MESSAGE_CALL_NETWORK_TYPE = 1; // 0x1
    field public static final int MESSAGE_DEVICE_BATTERY_STATE = 3; // 0x3
    field public static final int MESSAGE_DEVICE_NETWORK_COVERAGE = 4; // 0x4
  }
  public static class CallScreeningService.CallResponse.Builder {
    method @NonNull @RequiresPermission(android.Manifest.permission.CAPTURE_AUDIO_OUTPUT) public android.telecom.CallScreeningService.CallResponse.Builder setShouldScreenCallViaAudioProcessing(boolean);
  }
@@ -10517,25 +10538,8 @@ package android.telecom {
    method public final void addExistingConnection(@NonNull android.telecom.PhoneAccountHandle, @NonNull android.telecom.Connection, @NonNull android.telecom.Conference);
  }
  public abstract class DiagnosticCall {
    ctor public DiagnosticCall();
    method public final void clearDiagnosticMessage(int);
    method public final void displayDiagnosticMessage(int, @NonNull CharSequence);
    method public abstract void onCallDetailsChanged(@NonNull android.telecom.Call.Details);
    method @Nullable public abstract CharSequence onCallDisconnected(int, int);
    method @Nullable public abstract CharSequence onCallDisconnected(@NonNull android.telephony.ims.ImsReasonInfo);
    method public abstract void onCallQualityReceived(@NonNull android.telephony.CallQuality);
    method public abstract void onReceiveDeviceToDeviceMessage(int, int);
    method public final void sendDeviceToDeviceMessage(int, int);
    field public static final int BATTERY_STATE_CHARGING = 3; // 0x3
    field public static final int BATTERY_STATE_GOOD = 2; // 0x2
    field public static final int BATTERY_STATE_LOW = 1; // 0x1
    field public static final int COVERAGE_GOOD = 2; // 0x2
    field public static final int COVERAGE_POOR = 1; // 0x1
    field public static final int MESSAGE_CALL_AUDIO_CODEC = 2; // 0x2
    field public static final int MESSAGE_CALL_NETWORK_TYPE = 1; // 0x1
    field public static final int MESSAGE_DEVICE_BATTERY_STATE = 3; // 0x3
    field public static final int MESSAGE_DEVICE_NETWORK_COVERAGE = 4; // 0x4
  @Deprecated public abstract class DiagnosticCall extends android.telecom.CallDiagnostics {
    ctor @Deprecated public DiagnosticCall();
  }
  public abstract class InCallService extends android.app.Service {
+60 −60
Original line number Diff line number Diff line
@@ -27,8 +27,6 @@ import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.IBinder;
import android.os.RemoteException;
import android.telephony.Annotation;
import android.telephony.ims.ImsReasonInfo;
import android.util.ArrayMap;

import com.android.internal.telecom.ICallDiagnosticService;
@@ -59,7 +57,7 @@ import java.util.concurrent.Executor;
 * </pre>
 * <p>
 * <h2>Threading Model</h2>
 * By default, all incoming IPC from Telecom in this service and in the {@link DiagnosticCall}
 * By default, all incoming IPC from Telecom in this service and in the {@link CallDiagnostics}
 * instances will take place on the main thread.  You can override {@link #getExecutor()} in your
 * implementation to provide your own {@link Executor}.
 * @hide
@@ -116,26 +114,28 @@ public abstract class CallDiagnosticService extends Service {
    }

    /**
     * Listens to events raised by a {@link DiagnosticCall}.
     * Listens to events raised by a {@link CallDiagnostics}.
     */
    private android.telecom.DiagnosticCall.Listener mDiagnosticCallListener =
            new android.telecom.DiagnosticCall.Listener() {
    private CallDiagnostics.Listener mDiagnosticCallListener =
            new CallDiagnostics.Listener() {

                @Override
                public void onSendDeviceToDeviceMessage(DiagnosticCall diagnosticCall,
                        @DiagnosticCall.MessageType int message, int value) {
                    handleSendDeviceToDeviceMessage(diagnosticCall, message, value);
                public void onSendDeviceToDeviceMessage(CallDiagnostics callDiagnostics,
                        @CallDiagnostics.MessageType int message, int value) {
                    handleSendDeviceToDeviceMessage(callDiagnostics, message, value);
                }

                @Override
                public void onDisplayDiagnosticMessage(DiagnosticCall diagnosticCall, int messageId,
                public void onDisplayDiagnosticMessage(CallDiagnostics callDiagnostics,
                        int messageId,
                        CharSequence message) {
                    handleDisplayDiagnosticMessage(diagnosticCall, messageId, message);
                    handleDisplayDiagnosticMessage(callDiagnostics, messageId, message);
                }

                @Override
                public void onClearDiagnosticMessage(DiagnosticCall diagnosticCall, int messageId) {
                    handleClearDiagnosticMessage(diagnosticCall, messageId);
                public void onClearDiagnosticMessage(CallDiagnostics callDiagnostics,
                        int messageId) {
                    handleClearDiagnosticMessage(callDiagnostics, messageId);
                }
            };

@@ -149,7 +149,7 @@ public abstract class CallDiagnosticService extends Service {
     * Map which tracks the Telecom calls received from the Telecom stack.
     */
    private final Map<String, Call.Details> mCallByTelecomCallId = new ArrayMap<>();
    private final Map<String, DiagnosticCall> mDiagnosticCallByTelecomCallId = new ArrayMap<>();
    private final Map<String, CallDiagnostics> mDiagnosticCallByTelecomCallId = new ArrayMap<>();
    private final Object mLock = new Object();
    private ICallDiagnosticServiceAdapter mAdapter;

@@ -177,7 +177,7 @@ public abstract class CallDiagnosticService extends Service {
     * executor you want to use for incoming IPC.
     *
     * @return the {@link Executor} to use for incoming IPC from Telecom to
     * {@link CallDiagnosticService} and {@link DiagnosticCall}.
     * {@link CallDiagnosticService} and {@link CallDiagnostics}.
     */
    @SuppressLint("OnNameExpected")
    @NonNull public Executor getExecutor() {
@@ -188,30 +188,30 @@ public abstract class CallDiagnosticService extends Service {
     * Telecom calls this method on the {@link CallDiagnosticService} with details about a new call
     * which was added to Telecom.
     * <p>
     * The {@link CallDiagnosticService} returns an implementation of {@link DiagnosticCall} to be
     * The {@link CallDiagnosticService} returns an implementation of {@link CallDiagnostics} to be
     * used for the lifespan of this call.
     * <p>
     * Calls to this method will use the {@link CallDiagnosticService}'s {@link Executor}; see
     * {@link CallDiagnosticService#getExecutor()} for more information.
     *
     * @param call The details of the new call.
     * @return An instance of {@link DiagnosticCall} which the {@link CallDiagnosticService}
     * @return An instance of {@link CallDiagnostics} which the {@link CallDiagnosticService}
     * provides to be used for the lifespan of the call.
     * @throws IllegalArgumentException if a {@code null} {@link DiagnosticCall} is returned.
     * @throws IllegalArgumentException if a {@code null} {@link CallDiagnostics} is returned.
     */
    public abstract @NonNull DiagnosticCall onInitializeDiagnosticCall(@NonNull
    public abstract @NonNull CallDiagnostics onInitializeCallDiagnostics(@NonNull
            android.telecom.Call.Details call);

    /**
     * Telecom calls this method when a previous created {@link DiagnosticCall} is no longer needed.
     * This happens when Telecom is no longer tracking the call in question.
     * Telecom calls this method when a previous created {@link CallDiagnostics} is no longer
     * needed.  This happens when Telecom is no longer tracking the call in question.
     * <p>
     * Calls to this method will use the {@link CallDiagnosticService}'s {@link Executor}; see
     * {@link CallDiagnosticService#getExecutor()} for more information.
     *
     * @param call The diagnostic call which is no longer tracked by Telecom.
     */
    public abstract void onRemoveDiagnosticCall(@NonNull DiagnosticCall call);
    public abstract void onRemoveCallDiagnostics(@NonNull CallDiagnostics call);

    /**
     * Telecom calls this method when the audio routing or available audio route information
@@ -260,35 +260,35 @@ public abstract class CallDiagnosticService extends Service {
        }

        getExecutor().execute(() -> {
            DiagnosticCall diagnosticCall = onInitializeDiagnosticCall(newCallDetails);
            if (diagnosticCall == null) {
            CallDiagnostics callDiagnostics = onInitializeCallDiagnostics(newCallDetails);
            if (callDiagnostics == null) {
                throw new IllegalArgumentException(
                        "A valid DiagnosticCall instance was not provided.");
            }
            synchronized (mLock) {
                diagnosticCall.setListener(mDiagnosticCallListener);
                diagnosticCall.setCallId(telecomCallId);
                mDiagnosticCallByTelecomCallId.put(telecomCallId, diagnosticCall);
                callDiagnostics.setListener(mDiagnosticCallListener);
                callDiagnostics.setCallId(telecomCallId);
                mDiagnosticCallByTelecomCallId.put(telecomCallId, callDiagnostics);
            }
        });
    }

    /**
     * Handles an update to {@link Call.Details} notified by Telecom.
     * Caches the call details and notifies the {@link DiagnosticCall} of the change via
     * {@link DiagnosticCall#onCallDetailsChanged(Call.Details)}.
     * Caches the call details and notifies the {@link CallDiagnostics} of the change via
     * {@link CallDiagnostics#onCallDetailsChanged(Call.Details)}.
     * @param parcelableCall the new parceled call details from Telecom.
     */
    private void handleCallUpdated(@NonNull ParcelableCall parcelableCall) {
        String telecomCallId = parcelableCall.getId();
        Log.i(this, "handleCallUpdated: callId=%s - updated", telecomCallId);
        Call.Details newCallDetails = Call.Details.createFromParcelableCall(parcelableCall);
        DiagnosticCall diagnosticCall;
        CallDiagnostics callDiagnostics;
        synchronized (mLock) {
            diagnosticCall = mDiagnosticCallByTelecomCallId.get(telecomCallId);
            callDiagnostics = mDiagnosticCallByTelecomCallId.get(telecomCallId);
            mCallByTelecomCallId.put(telecomCallId, newCallDetails);
        }
        getExecutor().execute(() -> diagnosticCall.handleCallUpdated(newCallDetails));
        getExecutor().execute(() -> callDiagnostics.handleCallUpdated(newCallDetails));
    }

    /**
@@ -302,37 +302,37 @@ public abstract class CallDiagnosticService extends Service {
            mCallByTelecomCallId.remove(telecomCallId);
        }

        DiagnosticCall diagnosticCall;
        CallDiagnostics callDiagnostics;
        synchronized (mLock) {
            if (mDiagnosticCallByTelecomCallId.containsKey(telecomCallId)) {
                diagnosticCall = mDiagnosticCallByTelecomCallId.remove(telecomCallId);
                callDiagnostics = mDiagnosticCallByTelecomCallId.remove(telecomCallId);
            } else {
                diagnosticCall = null;
                callDiagnostics = null;
            }
        }

        // Inform the service of the removed call.
        if (diagnosticCall != null) {
            getExecutor().execute(() -> onRemoveDiagnosticCall(diagnosticCall));
        if (callDiagnostics != null) {
            getExecutor().execute(() -> onRemoveCallDiagnostics(callDiagnostics));
        }
    }

    /**
     * Handles an incoming device to device message received from Telecom.  Notifies the
     * {@link DiagnosticCall} via {@link DiagnosticCall#onReceiveDeviceToDeviceMessage(int, int)}.
     * {@link CallDiagnostics} via {@link CallDiagnostics#onReceiveDeviceToDeviceMessage(int, int)}.
     * @param callId
     * @param message
     * @param value
     */
    private void handleReceivedD2DMessage(@NonNull String callId, int message, int value) {
        Log.i(this, "handleReceivedD2DMessage: callId=%s, msg=%d/%d", callId, message, value);
        DiagnosticCall diagnosticCall;
        CallDiagnostics callDiagnostics;
        synchronized (mLock) {
            diagnosticCall = mDiagnosticCallByTelecomCallId.get(callId);
            callDiagnostics = mDiagnosticCallByTelecomCallId.get(callId);
        }
        if (diagnosticCall != null) {
        if (callDiagnostics != null) {
            getExecutor().execute(
                    () -> diagnosticCall.onReceiveDeviceToDeviceMessage(message, value));
                    () -> callDiagnostics.onReceiveDeviceToDeviceMessage(message, value));
        }
    }

@@ -345,12 +345,12 @@ public abstract class CallDiagnosticService extends Service {
    private void handleCallDisconnected(@NonNull String callId,
            @NonNull DisconnectCause disconnectCause) {
        Log.i(this, "handleCallDisconnected: call=%s; cause=%s", callId, disconnectCause);
        DiagnosticCall diagnosticCall = mDiagnosticCallByTelecomCallId.get(callId);
        CallDiagnostics callDiagnostics = mDiagnosticCallByTelecomCallId.get(callId);
        CharSequence message;
        if (disconnectCause.getImsReasonInfo() != null) {
            message = diagnosticCall.onCallDisconnected(disconnectCause.getImsReasonInfo());
            message = callDiagnostics.onCallDisconnected(disconnectCause.getImsReasonInfo());
        } else {
            message = diagnosticCall.onCallDisconnected(
            message = callDiagnostics.onCallDisconnected(
                    disconnectCause.getTelephonyDisconnectCause(),
                    disconnectCause.getTelephonyPreciseDisconnectCause());
        }
@@ -375,15 +375,15 @@ public abstract class CallDiagnosticService extends Service {
    }

    /**
     * Handles a request from a {@link DiagnosticCall} to send a device to device message (received
     * via {@link DiagnosticCall#sendDeviceToDeviceMessage(int, int)}.
     * @param diagnosticCall
     * Handles a request from a {@link CallDiagnostics} to send a device to device message (received
     * via {@link CallDiagnostics#sendDeviceToDeviceMessage(int, int)}.
     * @param callDiagnostics
     * @param message
     * @param value
     */
    private void handleSendDeviceToDeviceMessage(@NonNull DiagnosticCall diagnosticCall,
    private void handleSendDeviceToDeviceMessage(@NonNull CallDiagnostics callDiagnostics,
            int message, int value) {
        String callId = diagnosticCall.getCallId();
        String callId = callDiagnostics.getCallId();
        try {
            mAdapter.sendDeviceToDeviceMessage(callId, message, value);
            Log.i(this, "handleSendDeviceToDeviceMessage: call=%s; msg=%d/%d", callId, message,
@@ -395,15 +395,15 @@ public abstract class CallDiagnosticService extends Service {
    }

    /**
     * Handles a request from a {@link DiagnosticCall} to display an in-call diagnostic message.
     * Originates from {@link DiagnosticCall#displayDiagnosticMessage(int, CharSequence)}.
     * @param diagnosticCall
     * Handles a request from a {@link CallDiagnostics} to display an in-call diagnostic message.
     * Originates from {@link CallDiagnostics#displayDiagnosticMessage(int, CharSequence)}.
     * @param callDiagnostics
     * @param messageId
     * @param message
     */
    private void handleDisplayDiagnosticMessage(DiagnosticCall diagnosticCall, int messageId,
    private void handleDisplayDiagnosticMessage(CallDiagnostics callDiagnostics, int messageId,
            CharSequence message) {
        String callId = diagnosticCall.getCallId();
        String callId = callDiagnostics.getCallId();
        try {
            mAdapter.displayDiagnosticMessage(callId, messageId, message);
            Log.i(this, "handleDisplayDiagnosticMessage: call=%s; msg=%d/%s", callId, messageId,
@@ -415,14 +415,14 @@ public abstract class CallDiagnosticService extends Service {
    }

    /**
     * Handles a request from a {@link DiagnosticCall} to clear a previously shown diagnostic
     * Handles a request from a {@link CallDiagnostics} to clear a previously shown diagnostic
     * message.
     * Originates from {@link DiagnosticCall#clearDiagnosticMessage(int)}.
     * @param diagnosticCall
     * Originates from {@link CallDiagnostics#clearDiagnosticMessage(int)}.
     * @param callDiagnostics
     * @param messageId
     */
    private void handleClearDiagnosticMessage(DiagnosticCall diagnosticCall, int messageId) {
        String callId = diagnosticCall.getCallId();
    private void handleClearDiagnosticMessage(CallDiagnostics callDiagnostics, int messageId) {
        String callId = callDiagnostics.getCallId();
        try {
            mAdapter.clearDiagnosticMessage(callId, messageId);
            Log.i(this, "handleClearDiagnosticMessage: call=%s; msg=%d", callId, messageId);
+374 −0

File added.

Preview size limit exceeded, changes collapsed.

+3 −3
Original line number Diff line number Diff line
@@ -947,7 +947,7 @@ public abstract class Connection extends Conferenceable {
     * {@link CallDiagnosticService} implementation which is active.
     * <p>
     * Likewise, if a {@link CallDiagnosticService} sends a message using
     * {@link DiagnosticCall#sendDeviceToDeviceMessage(int, int)}, it will be routed to telephony
     * {@link CallDiagnostics#sendDeviceToDeviceMessage(int, int)}, it will be routed to telephony
     * via {@link Connection#onCallEvent(String, Bundle)}.  The telephony stack will relay the
     * message to the other device.
     * @hide
@@ -960,7 +960,7 @@ public abstract class Connection extends Conferenceable {
     * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
     * message type.
     *
     * See {@link DiagnosticCall} for more information.
     * See {@link CallDiagnostics} for more information.
     * @hide
     */
    @SystemApi
@@ -971,7 +971,7 @@ public abstract class Connection extends Conferenceable {
     * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
     * message value.
     * <p>
     * See {@link DiagnosticCall} for more information.
     * See {@link CallDiagnostics} for more information.
     * @hide
     */
    @SystemApi
+2 −328

File changed.

Preview size limit exceeded, changes collapsed.