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

Commit 166b56c6 authored by Sindhu B's avatar Sindhu B Committed by Android (Google) Code Review
Browse files

Merge "Dispatch doze ticks on main thread after they've been handled" into main

parents 91622e6c d84179bc
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.doze;

import android.annotation.NonNull;

import androidx.annotation.MainThread;

/**
 * Interface the doze service uses to communicate with the rest of system UI.
 */
@@ -27,6 +29,7 @@ public interface DozeHost {
    void startDozing();
    void pulseWhileDozing(@NonNull PulseCallback callback, int reason);
    void stopDozing();
    @MainThread
    void dozeTimeTick();
    boolean isPowerSaveActive();
    boolean isPulsingBlocked();
+9 −2
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import android.os.SystemClock;
import android.text.format.Formatter;
import android.util.Log;

import androidx.annotation.AnyThread;

import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.dagger.DozeScope;
@@ -55,7 +57,7 @@ public class DozeUi implements DozeMachine.Part {
    private final DozeParameters mDozeParameters;
    private final DozeLog mDozeLog;
    private final DelayableExecutor mBgExecutor;
    private long mLastTimeTickElapsed = 0;
    private volatile long mLastTimeTickElapsed = 0;
    // If time tick is scheduled and there's not a pending runnable to cancel:
    private volatile boolean mTimeTickScheduled;
    private final Runnable mCancelTimeTickerRunnable =  new Runnable() {
@@ -218,10 +220,15 @@ public class DozeUi implements DozeMachine.Part {
        return calendar.getTimeInMillis();
    }

    @AnyThread
    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(() -> {}));
+15 −7
Original line number Diff line number Diff line
@@ -29,8 +29,10 @@ import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.MainThread;
import androidx.annotation.Nullable;

import com.android.app.tracing.TraceUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.assist.AssistManager;
@@ -61,6 +63,8 @@ import com.android.systemui.util.IListenerSet;

import dagger.Lazy;

import kotlin.Unit;

import kotlinx.coroutines.ExperimentalCoroutinesApi;

import javax.inject.Inject;
@@ -109,7 +113,7 @@ public final class DozeServiceHost implements DozeHost {
    private CentralSurfaces mCentralSurfaces;
    private boolean mAlwaysOnSuppressed;
    private boolean mPulsePending;
    private DozeInteractor mDozeInteractor;
    private final DozeInteractor mDozeInteractor;

    @Inject
    public DozeServiceHost(DozeLog dozeLog, PowerManager powerManager,
@@ -337,13 +341,17 @@ public final class DozeServiceHost implements DozeHost {
    }

    @Override
    @MainThread
    public void dozeTimeTick() {
        TraceUtils.trace("DozeServiceHost#dozeTimeTick", () -> {
            mDozeInteractor.dozeTimeTick();
            mShadeLockscreenInteractor.dozeTimeTick();
            mAuthController.dozeTimeTick();
            if (mAmbientIndicationContainer instanceof DozeReceiver) {
                ((DozeReceiver) mAmbientIndicationContainer).dozeTimeTick();
            }
            return Unit.INSTANCE;
        });
    }

    @Override