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

Commit d071c48a authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Merge "Add SDK compatibility code for new call states"

am: 22027a86

Change-Id: I3f1d667503cb406d04ad5910deb1177583243a36
parents 7dacb11c 22027a86
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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>);
  }
+4 −0
Original line number Diff line number Diff line
@@ -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;
+2 −0
Original line number Diff line number Diff line
@@ -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());
            }
+33 −8
Original line number Diff line number Diff line
@@ -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);
@@ -164,10 +173,26 @@ public final class Phone {
    }

    final void internalUpdateCall(ParcelableCall parcelableCall) {
        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);
            }
        }
    }