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

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

Merge changes from topic "hookup-callscreening-api-2"

am: 70338952

Change-Id: I4d42b6f5e27deb829c2866a7babafd23e8d9100f
parents 974406e6 70338952
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -78,12 +78,15 @@ public class BluetoothPhoneServiceImpl {
    // Add all held calls to a conference
    private static final int CHLD_TYPE_ADDHELDTOCONF = 3;

    // Indicates that no call is ringing
    private static final int DEFAULT_RINGING_ADDRESS_TYPE = 128;

    private int mNumActiveCalls = 0;
    private int mNumHeldCalls = 0;
    private int mNumChildrenOfActiveCall = 0;
    private int mBluetoothCallState = CALL_STATE_IDLE;
    private String mRingingAddress = null;
    private int mRingingAddressType = 0;
    private String mRingingAddress = "";
    private int mRingingAddressType = DEFAULT_RINGING_ADDRESS_TYPE;
    private Call mOldHeldCall = null;
    private boolean mIsDisconnectedTonePlaying = false;

@@ -101,7 +104,7 @@ public class BluetoothPhoneServiceImpl {
                long token = Binder.clearCallingIdentity();
                try {
                    Log.i(TAG, "BT - answering call");
                    Call call = mCallsManager.getRingingCall();
                    Call call = mCallsManager.getRingingOrSimulatedRingingCall();
                    if (call != null) {
                        mCallsManager.answerCall(call, VideoProfile.STATE_AUDIO_ONLY);
                        return true;
@@ -493,7 +496,7 @@ public class BluetoothPhoneServiceImpl {

    private boolean processChld(int chld) {
        Call activeCall = mCallsManager.getActiveCall();
        Call ringingCall = mCallsManager.getRingingCall();
        Call ringingCall = mCallsManager.getRingingOrSimulatedRingingCall();
        Call heldCall = mCallsManager.getHeldCall();

        // TODO: Keeping as Log.i for now.  Move to Log.d after L release if BT proves stable.
@@ -699,13 +702,13 @@ public class BluetoothPhoneServiceImpl {
     */
    private void updateHeadsetWithCallState(boolean force) {
        Call activeCall = mCallsManager.getActiveCall();
        Call ringingCall = mCallsManager.getRingingCall();
        Call ringingCall = mCallsManager.getRingingOrSimulatedRingingCall();
        Call heldCall = mCallsManager.getHeldCall();

        int bluetoothCallState = getBluetoothCallStateForUpdate();

        String ringingAddress = null;
        int ringingAddressType = 128;
        int ringingAddressType = DEFAULT_RINGING_ADDRESS_TYPE;
        String ringingName = null;
        if (ringingCall != null && ringingCall.getHandle() != null
            && !ringingCall.isSilentRingingRequested()) {
@@ -832,7 +835,7 @@ public class BluetoothPhoneServiceImpl {
    }

    private int getBluetoothCallStateForUpdate() {
        Call ringingCall = mCallsManager.getRingingCall();
        Call ringingCall = mCallsManager.getRingingOrSimulatedRingingCall();
        Call dialingCall = mCallsManager.getOutgoingCall();
        boolean hasOnlyDisconnectedCalls = mCallsManager.hasOnlyDisconnectedCalls();

@@ -862,6 +865,7 @@ public class BluetoothPhoneServiceImpl {
            case CallState.NEW:
            case CallState.ABORTED:
            case CallState.DISCONNECTED:
            case CallState.AUDIO_PROCESSING:
                return CALL_STATE_IDLE;

            case CallState.ACTIVE:
@@ -885,6 +889,7 @@ public class BluetoothPhoneServiceImpl {

            case CallState.RINGING:
            case CallState.ANSWERED:
            case CallState.SIMULATED_RINGING:
                if (call.isSilentRingingRequested()) {
                    return CALL_STATE_IDLE;
                } else if (isForeground) {
+9 −6
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ public class CallAudioManager extends CallsManagerListenerBase {
        if (newBinForCall != null) {
            newBinForCall.add(call);
        }
        sendCallStatusToBluetoothStateReceiver();

        updateForegroundCall();
        if (shouldPlayDisconnectTone(oldState, newState)) {
@@ -158,9 +159,7 @@ public class CallAudioManager extends CallsManagerListenerBase {
        }
        updateForegroundCall();
        mCalls.add(call);
        if (mCalls.size() == 1) {
            mBluetoothStateReceiver.setIsInCall(true);
        }
        sendCallStatusToBluetoothStateReceiver();

        onCallEnteringState(call, call.getState());
    }
@@ -177,13 +176,17 @@ public class CallAudioManager extends CallsManagerListenerBase {

        updateForegroundCall();
        mCalls.remove(call);
        if (mCalls.size() == 0) {
            mBluetoothStateReceiver.setIsInCall(false);
        }
        sendCallStatusToBluetoothStateReceiver();

        onCallLeavingState(call, call.getState());
    }

    private void sendCallStatusToBluetoothStateReceiver() {
        // We're in a call if there are calls in mCalls that are not in mAudioProcessingCalls.
        boolean isInCall = !mAudioProcessingCalls.containsAll(mCalls);
        mBluetoothStateReceiver.setIsInCall(isInCall);
    }

    /**
     * Handles changes to the external state of a call.  External calls which become regular calls
     * should be tracked, and regular calls which become external should no longer be tracked.
+2 −4
Original line number Diff line number Diff line
@@ -329,8 +329,7 @@ public class CallAudioModeStateMachine extends StateMachine {
                    transitionTo(mOtherFocusState);
                    return HANDLED;
                case NEW_AUDIO_PROCESSING_CALL:
                    Log.w(LOG_TAG, "Unexpected behavior! New audio processing call appeared while"
                            + " in audio processing state.");
                    // Can happen as a duplicate message
                    return HANDLED;
                case TONE_STARTED_PLAYING:
                    // This shouldn't happen either, but perform the action anyway.
@@ -404,8 +403,7 @@ public class CallAudioModeStateMachine extends StateMachine {
                                + "ringing");
                    }
                case NEW_RINGING_CALL:
                    Log.w(LOG_TAG, "Unexpected behavior! New ringing call appeared while in " +
                            "ringing state.");
                    // Can happen as a duplicate message
                    return HANDLED;
                case NEW_HOLDING_CALL:
                    // This really shouldn't happen, but transition to the focused state anyway.
+8 −2
Original line number Diff line number Diff line
@@ -2741,6 +2741,11 @@ public class CallsManager extends Call.ListenerBase
        return getFirstCallWithState(CallState.RINGING, CallState.ANSWERED) != null;
    }

    boolean hasRingingOrSimulatedRingingCall() {
        return getFirstCallWithState(
                CallState.SIMULATED_RINGING, CallState.RINGING, CallState.ANSWERED) != null;
    }

    @VisibleForTesting
    public boolean onMediaButton(int type) {
        if (hasAnyCalls()) {
@@ -2843,8 +2848,9 @@ public class CallsManager extends Call.ListenerBase
    }

    @VisibleForTesting
    public Call getRingingCall() {
        return getFirstCallWithState(CallState.RINGING, CallState.ANSWERED);
    public Call getRingingOrSimulatedRingingCall() {
        return getFirstCallWithState(CallState.RINGING,
                CallState.ANSWERED, CallState.SIMULATED_RINGING);
    }

    public Call getActiveCall() {
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public class InCallWakeLockController extends CallsManagerListenerBase {

    private void handleWakeLock() {
        // We grab a full lock as long as there exists a ringing call.
        Call ringingCall = mCallsManager.getRingingCall();
        Call ringingCall = mCallsManager.getRingingOrSimulatedRingingCall();
        if (ringingCall != null) {
            mTelecomWakeLock.acquire();
            Log.i(this, "Acquiring full wake lock");
Loading