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

Commit 81d99756 authored by Matt Pietal's avatar Matt Pietal
Browse files

Ensure dozeTimeTick refreshes clock

... by sending a time update via the KeyguardUpdateMonitor path.
Smartspace also listens to this signal.

Also, cleanup flag for backgrounding the alarm

Fixes: 393470511
Test: manual - observe prolonged AOD state
Flag: EXEMPT bugfix
Change-Id: Ic2d7658f2bbb40521f2e95fb2157affd6f753979
parent 06312a45
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -1442,16 +1442,6 @@ flag {
   }
}

flag {
  name: "dozeui_scheduling_alarms_background_execution"
  namespace: "systemui"
  description: "Decide whether to execute binder calls to schedule alarms in background thread"
  bug: "330492575"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
    name: "media_lockscreen_launch_animation"
    namespace : "systemui"
+3 −16
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.doze;

import static com.android.systemui.doze.DozeMachine.State.DOZE;
import static com.android.systemui.doze.DozeMachine.State.DOZE_AOD_PAUSED;
import static com.android.systemui.Flags.dozeuiSchedulingAlarmsBackgroundExecution;

import android.app.AlarmManager;
import android.content.Context;
@@ -84,13 +83,7 @@ public class DozeUi implements DozeMachine.Part {
        mBgExecutor = bgExecutor;
        mCanAnimateTransition = !params.getDisplayNeedsBlanking();
        mDozeParameters = params;
        if (dozeuiSchedulingAlarmsBackgroundExecution()) {
            mTimeTicker = new AlarmTimeout(alarmManager, this::onTimeTick, "doze_time_tick",
                    bgHandler);
        } else {
            mTimeTicker = new AlarmTimeout(alarmManager, this::onTimeTick, "doze_time_tick",
                    handler);
        }
        mTimeTicker = new AlarmTimeout(alarmManager, this::onTimeTick, "doze_time_tick", bgHandler);
        mDozeLog = dozeLog;
    }

@@ -184,7 +177,7 @@ public class DozeUi implements DozeMachine.Part {
        mTimeTickScheduled = true;

        long time = System.currentTimeMillis();
        long delta = roundToNextMinute(time) - System.currentTimeMillis();
        long delta = roundToNextMinute(time) - time;
        boolean scheduled = mTimeTicker.schedule(delta, AlarmTimeout.MODE_RESCHEDULE_IF_SCHEDULED);
        if (scheduled) {
            mDozeLog.traceTimeTickScheduled(time, time + delta);
@@ -224,14 +217,8 @@ public class DozeUi implements DozeMachine.Part {
    private void onTimeTick() {
        verifyLastTimeTick();

        if (dozeuiSchedulingAlarmsBackgroundExecution()) {
            mHandler.post(mHost::dozeTimeTick);
        } else {
            mHost.dozeTimeTick();
        }

        // Keep wakelock until a frame has been pushed.
        mHandler.post(mWakeLock.wrap(() -> {}));
        mHandler.post(mWakeLock.wrap(mHost::dozeTimeTick));

        mTimeTickScheduled = false;
        scheduleTimeTick();
+7 −0
Original line number Diff line number Diff line
@@ -1744,6 +1744,9 @@ public class KeyguardViewMediator implements CoreStartable,
        mJavaAdapter.alwaysCollectFlow(
                mWallpaperRepository.getWallpaperSupportsAmbientMode(),
                this::setWallpaperSupportsAmbientMode);
        mJavaAdapter.alwaysCollectFlow(
                mKeyguardInteractor.getDozeTimeTick(),
                this::triggerTimeUpdate);
    }

    @Override
@@ -4056,6 +4059,10 @@ public class KeyguardViewMediator implements CoreStartable,
        mWallpaperSupportsAmbientMode = supportsAmbientMode;
    }

    private void triggerTimeUpdate(long timeInMillis) {
        mUpdateMonitor.triggerTimeUpdate();
    }

    private static class StartKeyguardExitAnimParams {

        @WindowManager.TransitionOldType int mTransit;
+1 −8
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.os.SystemClock;
 */
public class AlarmTimeout implements AlarmManager.OnAlarmListener {

    public static final int MODE_CRASH_IF_SCHEDULED = 0;
    public static final int MODE_IGNORE_IF_SCHEDULED = 1;
    public static final int MODE_RESCHEDULE_IF_SCHEDULED = 2;

@@ -48,17 +47,11 @@ public class AlarmTimeout implements AlarmManager.OnAlarmListener {
     * Schedules an alarm in {@code timeout} milliseconds in the future.
     *
     * @param timeout How long to wait from now.
     * @param mode {@link #MODE_CRASH_IF_SCHEDULED}, {@link #MODE_IGNORE_IF_SCHEDULED} or
     *             {@link #MODE_RESCHEDULE_IF_SCHEDULED}.
     * @param mode {@link #MODE_IGNORE_IF_SCHEDULED} or {@link #MODE_RESCHEDULE_IF_SCHEDULED}.
     * @return {@code true} when scheduled successfully, {@code false} otherwise.
     */
    public boolean schedule(long timeout, int mode) {
        switch (mode) {
            case MODE_CRASH_IF_SCHEDULED:
                if (mScheduled) {
                    throw new IllegalStateException(mTag + " timeout is already scheduled");
                }
                break;
            case MODE_IGNORE_IF_SCHEDULED:
                if (mScheduled) {
                    return false;
+1 −3
Original line number Diff line number Diff line
@@ -101,7 +101,6 @@ import com.android.systemui.dreams.ui.viewmodel.DreamViewModel;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FakeFeatureFlags;
import com.android.systemui.flags.SystemPropertiesHelper;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionBootInteractor;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.log.SessionTracker;
@@ -207,7 +206,6 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
    private @Mock ShadeWindowLogger mShadeWindowLogger;
    private @Mock SelectedUserInteractor mSelectedUserInteractor;
    private @Mock UserTracker.Callback mUserTrackerCallback;
    private @Mock KeyguardInteractor mKeyguardInteractor;
    private @Mock KeyguardTransitionBootInteractor mKeyguardTransitionBootInteractor;
    private @Captor ArgumentCaptor<KeyguardStateController.Callback>
            mKeyguardStateControllerCallback;
@@ -1499,7 +1497,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
                mSystemPropertiesHelper,
                () -> mock(WindowManagerLockscreenVisibilityManager.class),
                mSelectedUserInteractor,
                mKeyguardInteractor,
                mKosmos.getKeyguardInteractor(),
                mKeyguardTransitionBootInteractor,
                mKosmos::getCommunalSceneInteractor,
                mock(WindowManagerOcclusionManager.class));