Add SDK compatibility code for new call states
Add code that translates the new call states to old call states for in-call UIs that don't yet support background call screening. Test: CTS Bug: 140317205 Change-Id: I104f5f7ab3e3dc075e1d9ed5c64fcd924f9a977b
This commit is contained in:
@@ -2739,6 +2739,10 @@ package android.telecom {
|
||||
method public void exitBackgroundAudioProcessing(boolean);
|
||||
}
|
||||
|
||||
public static class Call.Details {
|
||||
method public String getTelecomCallId();
|
||||
}
|
||||
|
||||
public final class CallAudioState implements android.os.Parcelable {
|
||||
ctor public CallAudioState(boolean, int, int, @Nullable android.bluetooth.BluetoothDevice, @NonNull java.util.Collection<android.bluetooth.BluetoothDevice>);
|
||||
}
|
||||
|
||||
@@ -728,6 +728,7 @@ public final class Call {
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
@TestApi
|
||||
public String getTelecomCallId() {
|
||||
return mTelecomCallId;
|
||||
}
|
||||
@@ -2137,6 +2138,9 @@ public final class Call {
|
||||
}
|
||||
|
||||
int state = parcelableCall.getState();
|
||||
if (mTargetSdkVersion < Phone.SDK_VERSION_R && state == Call.STATE_SIMULATED_RINGING) {
|
||||
state = Call.STATE_RINGING;
|
||||
}
|
||||
boolean stateChanged = mState != state;
|
||||
if (stateChanged) {
|
||||
mState = state;
|
||||
|
||||
@@ -374,6 +374,8 @@ public abstract class CallScreeningService extends Service {
|
||||
new ComponentName(getPackageName(), getClass().getName()));
|
||||
} else if (response.getSilenceCall()) {
|
||||
mCallScreeningAdapter.silenceCall(callDetails.getTelecomCallId());
|
||||
} else if (response.getShouldScreenCallFurther()) {
|
||||
mCallScreeningAdapter.screenCallFurther(callDetails.getTelecomCallId());
|
||||
} else {
|
||||
mCallScreeningAdapter.allowCall(callDetails.getTelecomCallId());
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.annotation.UnsupportedAppUsage;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -111,6 +110,10 @@ public final class Phone {
|
||||
public void onSilenceRinger(Phone phone) { }
|
||||
}
|
||||
|
||||
// TODO: replace all usages of this with the actual R constant from Build.VERSION_CODES
|
||||
/** @hide */
|
||||
public static final int SDK_VERSION_R = 30;
|
||||
|
||||
// A Map allows us to track each Call by its Telecom-specified call ID
|
||||
private final Map<String, Call> mCallByTelecomCallId = new ArrayMap<>();
|
||||
|
||||
@@ -143,6 +146,12 @@ public final class Phone {
|
||||
}
|
||||
|
||||
final void internalAddCall(ParcelableCall parcelableCall) {
|
||||
if (mTargetSdkVersion < SDK_VERSION_R
|
||||
&& parcelableCall.getState() == Call.STATE_AUDIO_PROCESSING) {
|
||||
Log.i(this, "Skipping adding audio processing call for sdk compatibility");
|
||||
return;
|
||||
}
|
||||
|
||||
Call call = new Call(this, parcelableCall.getId(), mInCallAdapter,
|
||||
parcelableCall.getState(), mCallingPackage, mTargetSdkVersion);
|
||||
mCallByTelecomCallId.put(parcelableCall.getId(), call);
|
||||
@@ -150,7 +159,7 @@ public final class Phone {
|
||||
checkCallTree(parcelableCall);
|
||||
call.internalUpdate(parcelableCall, mCallByTelecomCallId);
|
||||
fireCallAdded(call);
|
||||
}
|
||||
}
|
||||
|
||||
final void internalRemoveCall(Call call) {
|
||||
mCallByTelecomCallId.remove(call.internalGetCallId());
|
||||
@@ -164,12 +173,28 @@ public final class Phone {
|
||||
}
|
||||
|
||||
final void internalUpdateCall(ParcelableCall parcelableCall) {
|
||||
Call call = mCallByTelecomCallId.get(parcelableCall.getId());
|
||||
if (call != null) {
|
||||
checkCallTree(parcelableCall);
|
||||
call.internalUpdate(parcelableCall, mCallByTelecomCallId);
|
||||
}
|
||||
}
|
||||
if (mTargetSdkVersion < SDK_VERSION_R
|
||||
&& parcelableCall.getState() == Call.STATE_AUDIO_PROCESSING) {
|
||||
Log.i(this, "removing audio processing call during update for sdk compatibility");
|
||||
Call call = mCallByTelecomCallId.get(parcelableCall.getId());
|
||||
if (call != null) {
|
||||
internalRemoveCall(call);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Call call = mCallByTelecomCallId.get(parcelableCall.getId());
|
||||
if (call != null) {
|
||||
checkCallTree(parcelableCall);
|
||||
call.internalUpdate(parcelableCall, mCallByTelecomCallId);
|
||||
} else {
|
||||
// This call may have come out of audio processing. Try adding it if our target sdk
|
||||
// version is low enough.
|
||||
if (mTargetSdkVersion < SDK_VERSION_R) {
|
||||
internalAddCall(parcelableCall);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final void internalSetPostDialWait(String telecomId, String remaining) {
|
||||
Call call = mCallByTelecomCallId.get(telecomId);
|
||||
|
||||
Reference in New Issue
Block a user