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

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

Add the rest of the background audio screen API am: 8951278d am: efeefd04

am: dd93624b

Change-Id: I83d1eaa93f43a3137731287cf56038d1187f313a
parents 910ccfea dd93624b
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -2020,6 +2020,37 @@ public class CallsManager extends Call.ListenerBase

    }

    /**
     * Instructs Telecom to bring a call into the AUDIO_PROCESSING state.
     *
     * Used by the background audio call screener (also the default dialer) to signal that
     * they want to manually enter the AUDIO_PROCESSING state. The user will be aware that there is
     * an ongoing call at this time.
     *
     * @param call The call to manipulate
     */
    public void enterBackgroundAudioProcessing(Call call) {
        if (!mCalls.contains(call)) {
            Log.w(this, "Trying to exit audio processing on an untracked call");
            return;
        }

        Call activeCall = getActiveCall();
        if (activeCall != call) {
            Log.w(this, "Ignoring enter audio processing because there's already a call active");
        }

        // We only want this to work on active or ringing calls
        if (call.getState() == CallState.RINGING) {
            // After the connection service sets up the call with the other end, it'll set the call
            // state to AUDIO_PROCESSING
            answerCallForAudioProcessing(call);
        } else if (call.getState() == CallState.ACTIVE) {
            setCallState(call, CallState.AUDIO_PROCESSING,
                    "audio processing set by dialer request");
        }
    }

    /**
     * Instructs Telecom to bring a call out of the AUDIO_PROCESSING state.
     *
+16 −1
Original line number Diff line number Diff line
@@ -321,7 +321,22 @@ class InCallAdapter extends IInCallAdapter.Stub {

    @Override
    public void enterBackgroundAudioProcessing(String callId) {
        // TODO: implement this
        try {
            Log.startSession(LogUtils.Sessions.ICA_ENTER_AUDIO_PROCESSING, mOwnerComponentName);
            // TODO: enforce the extra permission.
            Binder.withCleanCallingIdentity(() -> {
                synchronized (mLock) {
                    Call call = mCallIdMapper.getCall(callId);
                    if (call != null) {
                        mCallsManager.enterBackgroundAudioProcessing(call);
                    } else {
                        Log.w(this, "enterBackgroundAudioProcessing, unknown call id: %s", callId);
                    }
                }
            });
        } finally {
            Log.endSession();
        }
    }

    @Override