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

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

Merge "Don't trigger lift-to-wake on wireless charger"

parents 3565a7bd a874fa40
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.systemui.dock.DockManager;
import com.android.systemui.doze.DozeMachine.State;
import com.android.systemui.doze.dagger.DozeScope;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.Assert;
@@ -96,6 +97,7 @@ public class DozeTriggers implements DozeMachine.Part {
    private final AuthController mAuthController;
    private final DelayableExecutor mMainExecutor;
    private final KeyguardStateController mKeyguardStateController;
    private final BatteryController mBatteryController;
    private final UiEventLogger mUiEventLogger;
    private final DevicePostureController mDevicePostureController;

@@ -187,7 +189,8 @@ public class DozeTriggers implements DozeMachine.Part {
            @Main DelayableExecutor mainExecutor,
            UiEventLogger uiEventLogger,
            KeyguardStateController keyguardStateController,
            DevicePostureController devicePostureController) {
            DevicePostureController devicePostureController,
            BatteryController batteryController) {
        mContext = context;
        mDozeHost = dozeHost;
        mConfig = config;
@@ -210,6 +213,7 @@ public class DozeTriggers implements DozeMachine.Part {
        mMainExecutor = mainExecutor;
        mUiEventLogger = uiEventLogger;
        mKeyguardStateController = keyguardStateController;
        mBatteryController = batteryController;
    }
    private final DevicePostureController.Callback mDevicePostureCallback =
            posture -> {
@@ -320,7 +324,12 @@ public class DozeTriggers implements DozeMachine.Part {
                    gentleWakeUp(pulseReason);
                } else if (isPickup) {
                    if (shouldDropPickupEvent())  {
                        mDozeLog.traceSensorEventDropped(pulseReason, "keyguard occluded");
                        mDozeLog.traceSensorEventDropped(
                                pulseReason,
                                "keyguardOccluded="
                                        + mKeyguardStateController.isOccluded()
                                        + " pluggedInWireless="
                                        + mBatteryController.isPluggedInWireless());
                        return;
                    }
                    gentleWakeUp(pulseReason);
@@ -351,7 +360,7 @@ public class DozeTriggers implements DozeMachine.Part {
    }

    private boolean shouldDropPickupEvent() {
        return mKeyguardStateController.isOccluded();
        return mKeyguardStateController.isOccluded() || mBatteryController.isPluggedInWireless();
    }

    private void gentleWakeUp(int reason) {
+22 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dock.DockManager;
import com.android.systemui.doze.DozeTriggers.DozingUpdateUiEvent;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.concurrency.FakeExecutor;
@@ -90,6 +91,8 @@ public class DozeTriggersTest extends SysuiTestCase {
    private KeyguardStateController mKeyguardStateController;
    @Mock
    private DevicePostureController mDevicePostureController;
    @Mock
    private BatteryController mBatteryController;

    private DozeTriggers mTriggers;
    private FakeSensorManager mSensors;
@@ -122,7 +125,7 @@ public class DozeTriggersTest extends SysuiTestCase {
                asyncSensorManager, wakeLock, mDockManager, mProximitySensor,
                mProximityCheck, mock(DozeLog.class), mBroadcastDispatcher, new FakeSettings(),
                mAuthController, mExecutor, mUiEventLogger, mKeyguardStateController,
                mDevicePostureController);
                mDevicePostureController, mBatteryController);
        mTriggers.setDozeMachine(mMachine);
        waitForSensorManager();
    }
@@ -230,7 +233,9 @@ public class DozeTriggersTest extends SysuiTestCase {
        when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE);

        // WHEN the pick up gesture is triggered and keyguard isn't occluded
        // and device isn't on a wireless charger
        when(mKeyguardStateController.isOccluded()).thenReturn(false);
        when(mBatteryController.isPluggedInWireless()).thenReturn(false);
        mTriggers.onSensor(DozeLog.REASON_SENSOR_PICKUP, 100, 100, null);

        // THEN wakeup
@@ -244,6 +249,22 @@ public class DozeTriggersTest extends SysuiTestCase {

        // WHEN the pick up gesture is triggered and keyguard IS occluded
        when(mKeyguardStateController.isOccluded()).thenReturn(true);
        when(mBatteryController.isPluggedInWireless()).thenReturn(false);
        mTriggers.onSensor(DozeLog.REASON_SENSOR_PICKUP, 100, 100, null);

        // THEN never wakeup
        verify(mMachine, never()).wakeUp();
    }

    @Test
    public void testPickupGestureWirelessCharger() {
        // GIVEN device is in doze (screen blank, but running doze sensors)
        when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE);

        // WHEN the pick up gesture is triggered
        // and device IS on a wireless charger
        when(mKeyguardStateController.isOccluded()).thenReturn(false);
        when(mBatteryController.isPluggedInWireless()).thenReturn(true);
        mTriggers.onSensor(DozeLog.REASON_SENSOR_PICKUP, 100, 100, null);

        // THEN never wakeup
+18 −5
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static android.content.pm.PackageManager.FEATURE_LEANBACK;
import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE;
import static android.content.pm.PackageManager.FEATURE_WATCH;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.BatteryManager.BATTERY_PLUGGED_WIRELESS;
import static android.os.Build.VERSION_CODES.M;
import static android.os.Build.VERSION_CODES.O;
import static android.provider.Settings.Secure.VOLUME_HUSH_OFF;
@@ -129,6 +130,7 @@ import android.media.AudioManagerInternal;
import android.media.AudioSystem;
import android.media.IAudioService;
import android.media.session.MediaSessionLegacyHelper;
import android.os.BatteryManagerInternal;
import android.os.Binder;
import android.os.Bundle;
import android.os.DeviceIdleManager;
@@ -392,11 +394,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    PowerManagerInternal mPowerManagerInternal;
    IStatusBarService mStatusBarService;
    StatusBarManagerInternal mStatusBarManagerInternal;
    BatteryManagerInternal mBatteryManagerInternal;
    AudioManagerInternal mAudioManagerInternal;
    DisplayManager mDisplayManager;
    DisplayManagerInternal mDisplayManagerInternal;
    boolean mPreloadedRecentApps;
    final Object mServiceAquireLock = new Object();
    final Object mServiceAcquireLock = new Object();
    Vibrator mVibrator; // Vibrator for giving feedback of orientation changes
    SearchManager mSearchManager;
    AccessibilityManager mAccessibilityManager;
@@ -782,7 +785,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        @Override
        public void onWakeUp() {
            synchronized (mLock) {
                if (shouldEnableWakeGestureLp()) {
                if (shouldEnableWakeGestureLp()
                        && mBatteryManagerInternal.getPlugType() != BATTERY_PLUGGED_WIRELESS) {
                    performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, false,
                            "Wake Up");
                    wakeUp(SystemClock.uptimeMillis(), mAllowTheaterModeWakeFromWakeGesture,
@@ -811,7 +815,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    IStatusBarService getStatusBarService() {
        synchronized (mServiceAquireLock) {
        synchronized (mServiceAcquireLock) {
            if (mStatusBarService == null) {
                mStatusBarService = IStatusBarService.Stub.asInterface(
                        ServiceManager.getService("statusbar"));
@@ -821,7 +825,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    StatusBarManagerInternal getStatusBarManagerInternal() {
        synchronized (mServiceAquireLock) {
        synchronized (mServiceAcquireLock) {
            if (mStatusBarManagerInternal == null) {
                mStatusBarManagerInternal =
                        LocalServices.getService(StatusBarManagerInternal.class);
@@ -831,7 +835,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    AudioManagerInternal getAudioManagerInternal() {
        synchronized (mServiceAquireLock) {
        synchronized (mServiceAcquireLock) {
            if (mAudioManagerInternal == null) {
                mAudioManagerInternal = LocalServices.getService(AudioManagerInternal.class);
            }
@@ -839,6 +843,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    BatteryManagerInternal getBatteryManagerInternal() {
        synchronized (mServiceAcquireLock) {
            if (mBatteryManagerInternal == null) {
                mBatteryManagerInternal =
                        LocalServices.getService(BatteryManagerInternal.class);
            }
            return mBatteryManagerInternal;
        }
    }

    // returns true if the key was handled and should not be passed to the user
    private boolean backKeyPress() {