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

Commit 70338952 authored by Hall Liu's avatar Hall Liu Committed by Gerrit Code Review
Browse files

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

* changes:
  Make background call screening compatible with BT
  Add audio processing notification and testapp code
  Add the rest of the background audio screen API
parents d985e1d4 552d52fa
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -48,6 +48,18 @@
         [CHAR LIMIT=18] -->
    <string name="notification_missedCall_message">Message</string>

    <!-- Title for the persistent notification presented when an app has requested that a call
         be put into the background so that the app can access the audio from the call
         [CHAR LIMIT=20] -->
    <string name="notification_audioProcessing_title">Background call</string>
    <!-- Body of the persistent notification presented when an app requests
         that a call be put into the background so that the app can access the audio from the call.
         [CHAR LIMIT=NONE] -->
    <string name="notification_audioProcessing_body">
        <xliff:g id="audio_processing_app_name">%s</xliff:g> has placed a call into the
        background. This app may be accessing and playing audio over the call.
    </string>

    <!-- Content description of the call muted notification icon for
         accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_call_muted">Call muted.</string>
@@ -276,6 +288,8 @@
    <string name="notification_channel_missed_call">Missed calls</string>
    <!-- Notification channel name for a channel containing call blocking notifications. -->
    <string name="notification_channel_call_blocking">Call Blocking</string>
    <!-- Notification channel name for a channel containing background call notifications. -->
    <string name="notification_channel_background_calls">Background calls</string>

    <!-- Alert dialog content used to inform the user that placing a new outgoing call will end the
         ongoing call in the app "other_app". -->
+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) {
+14 −0
Original line number Diff line number Diff line
@@ -544,6 +544,12 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     */
    private Call mHandoverSourceCall = null;

    /**
     * The user-visible app name of the app that requested for this call to be put into the
     * AUDIO_PROCESSING state. Used to display a notification to the user.
     */
    private CharSequence mAudioProcessingRequestingApp = null;

    /**
     * Indicates the current state of this call if it is in the process of a handover.
     */
@@ -2043,6 +2049,14 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        Log.addEvent(this, LogUtils.Events.REQUEST_PICKUP_FOR_AUDIO_PROCESSING);
    }

    public void setAudioProcessingRequestingApp(CharSequence appName) {
        mAudioProcessingRequestingApp = appName;
    }

    public CharSequence getAudioProcessingRequestingApp() {
        return mAudioProcessingRequestingApp;
    }

    /**
     * Deflects the call if it is ringing.
     *
+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.
Loading