Rename DiagnosticCall to CallDiagnostics.
Keep DiagnosticAll in a deprecated form to maintain binary compatibility with ongoing work in other repos. Test: run CTS Test: run unit tests Fixes: 182241145 Change-Id: Ia14113bcce344bb589408b74eaab74d413de9e7e
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user