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

Commit 064bd031 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove auto-DND while in call." into oc-dev

parents 04d2710c cca957f3
Loading
Loading
Loading
Loading
+0 −111
Original line number Diff line number Diff line
@@ -18,11 +18,7 @@ package com.android.server.telecom;


import android.app.ActivityManager;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.UserInfo;
import android.media.AudioManager;
import android.media.IAudioService;
@@ -158,49 +154,6 @@ public class CallAudioRouteStateMachine extends StateMachine {
        put(RUN_RUNNABLE, "RUN_RUNNABLE");
    }};

    /**
     * BroadcastReceiver used to track changes in the notification interruption filter.  This
     * ensures changes to the notification interruption filter made by the user during a call are
     * respected when restoring the notification interruption filter state.
     */
    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.startSession("CARSM.oR");
            try {
                String action = intent.getAction();

                if (action.equals(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED)) {
                    // We get an this broadcast any time the notification filter is changed, even if
                    // we are the initiator of the change.
                    // So, we'll look at who the initiator of the manual zen rule is in the
                    // notification manager.  If its us, then we can just exit now.
                    String initiator =
                            mInterruptionFilterProxy.getInterruptionModeInitiator();

                    if (TELECOM_PACKAGE.equals(initiator)) {
                        // We are the initiator of this change, so ignore it.
                        Log.i(this, "interruptionFilterChanged - ignoring own change");
                        return;
                    }

                    if (mAreNotificationSuppressed) {
                        // If we've already set the interruption filter, and the user changes it to
                        // something other than INTERRUPTION_FILTER_ALARMS, assume we will no longer
                        // try to change it back if the audio route changes.
                        mAreNotificationSuppressed =
                                mInterruptionFilterProxy.getCurrentInterruptionFilter()
                                        == NotificationManager.INTERRUPTION_FILTER_ALARMS;
                        Log.i(this, "interruptionFilterChanged - changing to %b",
                                mAreNotificationSuppressed);
                    }
                }
            } finally {
                Log.endSession();
            }
        }
    };

    private static final String ACTIVE_EARPIECE_ROUTE_NAME = "ActiveEarpieceRoute";
    private static final String ACTIVE_BLUETOOTH_ROUTE_NAME = "ActiveBluetoothRoute";
    private static final String ACTIVE_SPEAKER_ROUTE_NAME = "ActiveSpeakerRoute";
@@ -315,21 +268,12 @@ public class CallAudioRouteStateMachine extends StateMachine {
            super.enter();
            setSpeakerphoneOn(false);
            setBluetoothOn(false);
            if (mAudioFocusType == ACTIVE_FOCUS) {
                setNotificationsSuppressed(true);
            }
            CallAudioState newState = new CallAudioState(mIsMuted, ROUTE_EARPIECE,
                    mAvailableRoutes);
            setSystemAudioState(newState, true);
            updateInternalCallAudioState();
        }

        @Override
        public void exit() {
            super.exit();
            setNotificationsSuppressed(false);
        }

        @Override
        public void updateSystemAudioState() {
            updateInternalCallAudioState();
@@ -368,10 +312,6 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    transitionTo(mActiveSpeakerRoute);
                    return HANDLED;
                case SWITCH_FOCUS:
                    if (msg.arg1 == ACTIVE_FOCUS) {
                        setNotificationsSuppressed(true);
                    }

                    if (msg.arg1 == NO_FOCUS) {
                        reinitialize();
                    }
@@ -1151,7 +1091,6 @@ public class CallAudioRouteStateMachine extends StateMachine {
    private int mAudioFocusType;
    private boolean mWasOnSpeaker;
    private boolean mIsMuted;
    private boolean mAreNotificationSuppressed = false;

    private final Context mContext;
    private final CallsManager mCallsManager;
@@ -1160,7 +1099,6 @@ public class CallAudioRouteStateMachine extends StateMachine {
    private final WiredHeadsetManager mWiredHeadsetManager;
    private final StatusBarNotifier mStatusBarNotifier;
    private final CallAudioManager.AudioServiceFactory mAudioServiceFactory;
    private final InterruptionFilterProxy mInterruptionFilterProxy;
    private final boolean mDoesDeviceSupportEarpieceRoute;
    private final TelecomSystem.SyncRoot mLock;
    private boolean mHasUserExplicitlyLeftBluetooth = false;
@@ -1180,7 +1118,6 @@ public class CallAudioRouteStateMachine extends StateMachine {
            WiredHeadsetManager wiredHeadsetManager,
            StatusBarNotifier statusBarNotifier,
            CallAudioManager.AudioServiceFactory audioServiceFactory,
            InterruptionFilterProxy interruptionFilterProxy,
            boolean doesDeviceSupportEarpieceRoute) {
        super(NAME);
        addState(mActiveEarpieceRoute);
@@ -1200,11 +1137,6 @@ public class CallAudioRouteStateMachine extends StateMachine {
        mWiredHeadsetManager = wiredHeadsetManager;
        mStatusBarNotifier = statusBarNotifier;
        mAudioServiceFactory = audioServiceFactory;
        mInterruptionFilterProxy = interruptionFilterProxy;
        // Register for misc other intent broadcasts.
        IntentFilter intentFilter =
                new IntentFilter(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED);
        context.registerReceiver(mReceiver, intentFilter);
        mDoesDeviceSupportEarpieceRoute = doesDeviceSupportEarpieceRoute;
        mLock = callsManager.getLock();

@@ -1327,49 +1259,6 @@ public class CallAudioRouteStateMachine extends StateMachine {
        return mBluetoothRouteManager.isBluetoothAvailable();
    }

    /**
     * Sets whether notifications should be suppressed or not.  Used when in a call to ensure the
     * device will not vibrate due to notifications.
     * Alarm-only filtering is activated when
     *
     * @param on {@code true} when notification suppression should be activated, {@code false} when
     *                       it should be deactivated.
     */
    private void setNotificationsSuppressed(boolean on) {
        if (mInterruptionFilterProxy == null) {
            return;
        }

        Log.i(this, "setNotificationsSuppressed: on=%s; suppressed=%s", (on ? "yes" : "no"),
                (mAreNotificationSuppressed ? "yes" : "no"));
        if (on) {
            if (!mAreNotificationSuppressed) {
                // Enabling suppression of notifications.
                int interruptionFilter = mInterruptionFilterProxy.getCurrentInterruptionFilter();
                if (interruptionFilter == NotificationManager.INTERRUPTION_FILTER_ALL) {
                    // No interruption filter is specified, so suppress notifications by setting the
                    // current filter to alarms-only.
                    mAreNotificationSuppressed = true;
                    mInterruptionFilterProxy.setInterruptionFilter(
                            NotificationManager.INTERRUPTION_FILTER_ALARMS);
                } else {
                    // Interruption filter is already chosen by the user, so do not attempt to change
                    // it.
                    mAreNotificationSuppressed = false;
                }
            }
        } else {
            // Disabling suppression of notifications.
            if (mAreNotificationSuppressed) {
                // We have implemented the alarms-only policy and the user has not changed it since
                // we originally set it, so reset the notification filter.
                mInterruptionFilterProxy.setInterruptionFilter(
                        NotificationManager.INTERRUPTION_FILTER_ALL);
            }
            mAreNotificationSuppressed = false;
        }
    }

    private void setSpeakerphoneOn(boolean on) {
        if (mAudioManager.isSpeakerphoneOn() != on) {
            Log.i(this, "turning speaker phone %s", on);
+0 −6
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server.telecom;

import android.app.ActivityManager;
import android.app.NotificationManager;
import android.content.Context;
import android.content.pm.UserInfo;
import android.content.Intent;
@@ -258,7 +257,6 @@ public class CallsManager extends Call.ListenerBase
    private final DefaultDialerCache mDefaultDialerCache;
    private final Timeouts.Adapter mTimeoutsAdapter;
    private final PhoneNumberUtilsAdapter mPhoneNumberUtilsAdapter;
    private final NotificationManager mNotificationManager;
    private final Set<Call> mLocallyDisconnectingCalls = new HashSet<>();
    private final Set<Call> mPendingCallsToDisconnect = new HashSet<>();
    /* Handler tied to thread in which CallManager was initialized. */
@@ -307,7 +305,6 @@ public class CallsManager extends Call.ListenerBase
            Timeouts.Adapter timeoutsAdapter,
            AsyncRingtonePlayer asyncRingtonePlayer,
            PhoneNumberUtilsAdapter phoneNumberUtilsAdapter,
            InterruptionFilterProxy interruptionFilterProxy,
            EmergencyCallHelper emergencyCallHelper) {
        mContext = context;
        mLock = lock;
@@ -329,8 +326,6 @@ public class CallsManager extends Call.ListenerBase

        mDtmfLocalTonePlayer =
                new DtmfLocalTonePlayer(new DtmfLocalTonePlayer.ToneGeneratorProxy());
        mNotificationManager = (NotificationManager) context.getSystemService(
                Context.NOTIFICATION_SERVICE);
        CallAudioRouteStateMachine callAudioRouteStateMachine = new CallAudioRouteStateMachine(
                context,
                this,
@@ -338,7 +333,6 @@ public class CallsManager extends Call.ListenerBase
                wiredHeadsetManager,
                statusBarNotifier,
                audioServiceFactory,
                interruptionFilterProxy,
                CallAudioRouteStateMachine.doesDeviceSupportEarpieceRoute()
        );
        callAudioRouteStateMachine.initialize();
+0 −2
Original line number Diff line number Diff line
@@ -189,7 +189,6 @@ public class TelecomSystem {
            Timeouts.Adapter timeoutsAdapter,
            AsyncRingtonePlayer asyncRingtonePlayer,
            PhoneNumberUtilsAdapter phoneNumberUtilsAdapter,
            InterruptionFilterProxy interruptionFilterProxy,
            IncomingCallNotifier incomingCallNotifier) {
        mContext = context.getApplicationContext();
        LogUtils.initLogging(mContext);
@@ -254,7 +253,6 @@ public class TelecomSystem {
                timeoutsAdapter,
                asyncRingtonePlayer,
                phoneNumberUtilsAdapter,
                interruptionFilterProxy,
                emergencyCallHelper);

        mIncomingCallNotifier = incomingCallNotifier;
+0 −27
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.server.telecom.components;

import android.app.NotificationManager;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
@@ -25,9 +24,7 @@ import android.media.IAudioService;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.ServiceManager;
import android.service.notification.ZenModeConfig;
import android.telecom.Log;
import android.telecom.PhoneAccountHandle;

import com.android.internal.telephony.CallerInfoAsyncQuery;
import com.android.server.telecom.AsyncRingtonePlayer;
@@ -40,7 +37,6 @@ import com.android.server.telecom.HeadsetMediaButton;
import com.android.server.telecom.HeadsetMediaButtonFactory;
import com.android.server.telecom.InCallWakeLockControllerFactory;
import com.android.server.telecom.CallAudioManager;
import com.android.server.telecom.InterruptionFilterProxy;
import com.android.server.telecom.PhoneAccountRegistrar;
import com.android.server.telecom.PhoneNumberUtilsAdapterImpl;
import com.android.server.telecom.ProximitySensorManagerFactory;
@@ -79,9 +75,6 @@ public class TelecomService extends Service implements TelecomSystem.Component {
     */
    static void initializeTelecomSystem(Context context) {
        if (TelecomSystem.getInstance() == null) {
            final NotificationManager notificationManager =
                    (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

            NotificationChannelManager notificationChannelManager =
                    new NotificationChannelManager();
            notificationChannelManager.createChannels(context);
@@ -165,26 +158,6 @@ public class TelecomService extends Service implements TelecomSystem.Component {
                            new Timeouts.Adapter(),
                            new AsyncRingtonePlayer(),
                            new PhoneNumberUtilsAdapterImpl(),
                            new InterruptionFilterProxy() {
                                @Override
                                public void setInterruptionFilter(int interruptionFilter) {
                                    notificationManager.setInterruptionFilter(interruptionFilter);
                                }

                                @Override
                                public int getCurrentInterruptionFilter() {
                                    return notificationManager.getCurrentInterruptionFilter();
                                }

                                @Override
                                public String getInterruptionModeInitiator() {
                                    ZenModeConfig config = notificationManager.getZenModeConfig();
                                    if (config.manualRule != null) {
                                        return config.manualRule.enabler;
                                    }
                                    return null;
                                }
                            },
                            new IncomingCallNotifier(context)
                    ));
        }
+2 −160

File changed.

Preview size limit exceeded, changes collapsed.

Loading