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

Commit 39591f83 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove functionality that disables AOD when car mode is enabled" into main

parents 75ce70f8 9608dd18
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -25,6 +25,16 @@ flag {
   }
}

flag {
    name: "remove_aod_car_mode"
    namespace: "systemui"
    description: "Remove functionality of car mode disabling AOD."
    bug: "297462331"
    metadata {
         purpose: PURPOSE_BUGFIX
    }
 }

flag {
   name: "fingerprint_cancel_race_mitigation"
   namespace: "systemui"
+8 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import static org.mockito.Mockito.when;
import android.app.ActivityManager;
import android.content.res.Configuration;
import android.hardware.display.AmbientDisplayConfiguration;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.view.Display;

import androidx.annotation.NonNull;
@@ -55,6 +56,7 @@ import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.systemui.Flags;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.dock.DockManager;
import com.android.systemui.keyguard.WakefulnessLifecycle;
@@ -496,6 +498,7 @@ public class DozeMachineTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testTransitionToInitialized_carModeIsEnabled() {
        Configuration configuration = configWithCarNightUiMode();

@@ -508,6 +511,7 @@ public class DozeMachineTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testTransitionToFinish_carModeIsEnabled() {
        Configuration configuration = configWithCarNightUiMode();

@@ -519,6 +523,7 @@ public class DozeMachineTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testDozeToDozeSuspendTriggers_carModeIsEnabled() {
        Configuration configuration = configWithCarNightUiMode();

@@ -530,6 +535,7 @@ public class DozeMachineTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testDozeAoDToDozeSuspendTriggers_carModeIsEnabled() {
        Configuration configuration = configWithCarNightUiMode();

@@ -541,6 +547,7 @@ public class DozeMachineTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testDozePulsingBrightDozeSuspendTriggers_carModeIsEnabled() {
        Configuration configuration = configWithCarNightUiMode();

@@ -552,6 +559,7 @@ public class DozeMachineTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testDozeAodDockedDozeSuspendTriggers_carModeIsEnabled() {
        Configuration configuration = configWithCarNightUiMode();

+10 −1
Original line number Diff line number Diff line
@@ -38,11 +38,13 @@ import static org.mockito.Mockito.when;

import android.app.ActivityManager;
import android.hardware.display.AmbientDisplayConfiguration;
import android.platform.test.annotations.RequiresFlagsDisabled;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.systemui.Flags;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.phone.BiometricUnlockController;
@@ -122,6 +124,7 @@ public class DozeSuppressorTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testSuspendTriggersDoze_carMode() {
        // GIVEN car mode
        mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR);
@@ -136,6 +139,7 @@ public class DozeSuppressorTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testSuspendTriggersDoze_enterCarMode() {
        // GIVEN currently dozing
        mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED);
@@ -149,6 +153,7 @@ public class DozeSuppressorTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testDozeResume_exitCarMode() {
        // GIVEN currently suspended, with AOD not enabled
        mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR);
@@ -164,6 +169,7 @@ public class DozeSuppressorTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testDozeAoDResume_exitCarMode() {
        // GIVEN currently suspended, with AOD not enabled
        mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR);
@@ -179,6 +185,7 @@ public class DozeSuppressorTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testUiModeDoesNotChange_noStateTransition() {
        mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED);
        clearInvocations(mDozeMachine);
@@ -193,6 +200,7 @@ public class DozeSuppressorTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testUiModeTypeChange_whenDozeMachineIsNotReady_doesNotDoAnything() {
        when(mDozeMachine.isUninitializedOrFinished()).thenReturn(true);

@@ -202,6 +210,7 @@ public class DozeSuppressorTest extends SysuiTestCase {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REMOVE_AOD_CAR_MODE)
    public void testUiModeTypeChange_CarModeEnabledAndDozeMachineNotReady_suspendsTriggersAfter() {
        when(mDozeMachine.isUninitializedOrFinished()).thenReturn(true);
        mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR);
+8 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.doze;

import static com.android.systemui.Flags.removeAodCarMode;
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWAKE;
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_WAKING;

@@ -380,10 +381,14 @@ public class DozeMachine {
        }
        if (mUiModeType == Configuration.UI_MODE_TYPE_CAR
                && (requestedState.canPulse() || requestedState.staysAwake())) {
            if (removeAodCarMode()) {
                Log.d(TAG, "skip applying car mode");
            } else {
                Log.i(TAG, "Doze is suppressed with all triggers disabled as car mode is active");
                mDozeLog.traceCarModeStarted();
                return State.DOZE_SUSPEND_TRIGGERS;
            }
        }
        if (mDozeHost.isAlwaysOnSuppressed() && requestedState.isAlwaysOn()) {
            Log.i(TAG, "Doze is suppressed by an app. Suppressing state: " + requestedState);
            mDozeLog.traceAlwaysOnSuppressed(requestedState, "app");
+7 −0
Original line number Diff line number Diff line
@@ -18,9 +18,12 @@ package com.android.systemui.doze;

import static android.content.res.Configuration.UI_MODE_TYPE_CAR;

import static com.android.systemui.Flags.removeAodCarMode;

import android.hardware.display.AmbientDisplayConfiguration;
import android.os.PowerManager;
import android.text.TextUtils;
import android.util.Log;

import com.android.systemui.doze.dagger.DozeScope;
import com.android.systemui.settings.UserTracker;
@@ -77,6 +80,10 @@ public class DozeSuppressor implements DozeMachine.Part {

    @Override
    public void onUiModeTypeChanged(int newUiModeType) {
        if (removeAodCarMode()) {
            Log.d("DozeSuppressor", "skip applying new ui mode");
            return;
        }
        boolean isCarModeEnabled = newUiModeType == UI_MODE_TYPE_CAR;
        if (mIsCarModeEnabled == isCarModeEnabled) {
            return;