Merge "Add SDK compatibility code for new call states" am: 22027a86e2 am: d071c48af9
am: 6355d3947f
Change-Id: If5c12292793afc5b76fb74a869353d92ce8dcb85
This commit is contained in:
@@ -2740,6 +2740,10 @@ package android.telecom {
|
|||||||
method public void exitBackgroundAudioProcessing(boolean);
|
method public void exitBackgroundAudioProcessing(boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Call.Details {
|
||||||
|
method public String getTelecomCallId();
|
||||||
|
}
|
||||||
|
|
||||||
public final class CallAudioState implements android.os.Parcelable {
|
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>);
|
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} */
|
/** {@hide} */
|
||||||
|
@TestApi
|
||||||
public String getTelecomCallId() {
|
public String getTelecomCallId() {
|
||||||
return mTelecomCallId;
|
return mTelecomCallId;
|
||||||
}
|
}
|
||||||
@@ -2137,6 +2138,9 @@ public final class Call {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int state = parcelableCall.getState();
|
int state = parcelableCall.getState();
|
||||||
|
if (mTargetSdkVersion < Phone.SDK_VERSION_R && state == Call.STATE_SIMULATED_RINGING) {
|
||||||
|
state = Call.STATE_RINGING;
|
||||||
|
}
|
||||||
boolean stateChanged = mState != state;
|
boolean stateChanged = mState != state;
|
||||||
if (stateChanged) {
|
if (stateChanged) {
|
||||||
mState = state;
|
mState = state;
|
||||||
|
|||||||
@@ -374,6 +374,8 @@ public abstract class CallScreeningService extends Service {
|
|||||||
new ComponentName(getPackageName(), getClass().getName()));
|
new ComponentName(getPackageName(), getClass().getName()));
|
||||||
} else if (response.getSilenceCall()) {
|
} else if (response.getSilenceCall()) {
|
||||||
mCallScreeningAdapter.silenceCall(callDetails.getTelecomCallId());
|
mCallScreeningAdapter.silenceCall(callDetails.getTelecomCallId());
|
||||||
|
} else if (response.getShouldScreenCallFurther()) {
|
||||||
|
mCallScreeningAdapter.screenCallFurther(callDetails.getTelecomCallId());
|
||||||
} else {
|
} else {
|
||||||
mCallScreeningAdapter.allowCall(callDetails.getTelecomCallId());
|
mCallScreeningAdapter.allowCall(callDetails.getTelecomCallId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import android.annotation.UnsupportedAppUsage;
|
|||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -111,6 +110,10 @@ public final class Phone {
|
|||||||
public void onSilenceRinger(Phone 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
|
// A Map allows us to track each Call by its Telecom-specified call ID
|
||||||
private final Map<String, Call> mCallByTelecomCallId = new ArrayMap<>();
|
private final Map<String, Call> mCallByTelecomCallId = new ArrayMap<>();
|
||||||
|
|
||||||
@@ -143,6 +146,12 @@ public final class Phone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final void internalAddCall(ParcelableCall parcelableCall) {
|
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,
|
Call call = new Call(this, parcelableCall.getId(), mInCallAdapter,
|
||||||
parcelableCall.getState(), mCallingPackage, mTargetSdkVersion);
|
parcelableCall.getState(), mCallingPackage, mTargetSdkVersion);
|
||||||
mCallByTelecomCallId.put(parcelableCall.getId(), call);
|
mCallByTelecomCallId.put(parcelableCall.getId(), call);
|
||||||
@@ -150,7 +159,7 @@ public final class Phone {
|
|||||||
checkCallTree(parcelableCall);
|
checkCallTree(parcelableCall);
|
||||||
call.internalUpdate(parcelableCall, mCallByTelecomCallId);
|
call.internalUpdate(parcelableCall, mCallByTelecomCallId);
|
||||||
fireCallAdded(call);
|
fireCallAdded(call);
|
||||||
}
|
}
|
||||||
|
|
||||||
final void internalRemoveCall(Call call) {
|
final void internalRemoveCall(Call call) {
|
||||||
mCallByTelecomCallId.remove(call.internalGetCallId());
|
mCallByTelecomCallId.remove(call.internalGetCallId());
|
||||||
@@ -164,12 +173,28 @@ public final class Phone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final void internalUpdateCall(ParcelableCall parcelableCall) {
|
final void internalUpdateCall(ParcelableCall parcelableCall) {
|
||||||
Call call = mCallByTelecomCallId.get(parcelableCall.getId());
|
if (mTargetSdkVersion < SDK_VERSION_R
|
||||||
if (call != null) {
|
&& parcelableCall.getState() == Call.STATE_AUDIO_PROCESSING) {
|
||||||
checkCallTree(parcelableCall);
|
Log.i(this, "removing audio processing call during update for sdk compatibility");
|
||||||
call.internalUpdate(parcelableCall, mCallByTelecomCallId);
|
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) {
|
final void internalSetPostDialWait(String telecomId, String remaining) {
|
||||||
Call call = mCallByTelecomCallId.get(telecomId);
|
Call call = mCallByTelecomCallId.get(telecomId);
|
||||||
|
|||||||
Reference in New Issue
Block a user