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

Commit 59c66ae4 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge changes I0b8b3d53,If3aeb9af into main

* changes:
  Remove DozeUI binder call from main thread
  Ensure smooth dismiss
parents 2487facc f0edb9d6
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -215,14 +215,16 @@ class KeyguardInteractorTest : SysuiTestCase() {
            )

            repository.setStatusBarState(StatusBarState.KEYGUARD)
            shadeRepository.setLegacyShadeExpansion(1f)
            // User begins to swipe up
            shadeRepository.setLegacyShadeExpansion(0.99f)

            // When not dismissable, no alpha value (null) should emit
            repository.setKeyguardDismissible(false)
            assertThat(dismissAlpha).isNull()

            repository.setKeyguardDismissible(true)
            assertThat(dismissAlpha).isGreaterThan(0.95f)
            shadeRepository.setLegacyShadeExpansion(0.98f)
            assertThat(dismissAlpha).isGreaterThan(0.5f)
        }

    @Test
+9 −0
Original line number Diff line number Diff line
@@ -208,6 +208,15 @@ public class DozeLog implements Dumpable {
        mLogger.logTimeTickScheduled(when, triggerAt);
    }

    /**
     * Logs cancelation requests for time ticks
     * @param isPending is an unschedule request pending?
     * @param isTimeTickScheduled is a time tick request scheduled
     */
    public void tracePendingUnscheduleTimeTick(boolean isPending, boolean isTimeTickScheduled) {
        mLogger.logPendingUnscheduleTimeTick(isPending, isTimeTickScheduled);
    }

    /**
     * Appends keyguard visibility change event to the logs
     * @param showing whether the keyguard is now showing
+9 −0
Original line number Diff line number Diff line
@@ -162,6 +162,15 @@ class DozeLogger @Inject constructor(
        })
    }

    fun logPendingUnscheduleTimeTick(isPending: Boolean, isTimeTickScheduled: Boolean) {
        buffer.log(TAG, INFO, {
            bool1 = isPending
            bool2 = isTimeTickScheduled
        }, {
            "Pending unschedule time tick, isPending=$bool1, isTimeTickScheduled:$bool2"
        })
    }

    fun logDozeStateChanged(state: DozeMachine.State) {
        buffer.log(TAG, INFO, {
            str1 = state.name
+12 −6
Original line number Diff line number Diff line
@@ -26,11 +26,12 @@ import android.os.SystemClock;
import android.text.format.Formatter;
import android.util.Log;

import com.android.systemui.DejankUtils;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.dagger.DozeScope;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.util.AlarmTimeout;
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.wakelock.WakeLock;

import java.util.Calendar;
@@ -52,26 +53,31 @@ public class DozeUi implements DozeMachine.Part {
    private final boolean mCanAnimateTransition;
    private final DozeParameters mDozeParameters;
    private final DozeLog mDozeLog;

    private final DelayableExecutor mBgExecutor;
    private long mLastTimeTickElapsed = 0;
    // If time tick is scheduled and there's not a pending runnable to cancel:
    private boolean mTimeTickScheduled;
    private volatile boolean mTimeTickScheduled;
    private final Runnable mCancelTimeTickerRunnable =  new Runnable() {
        @Override
        public void run() {
            mDozeLog.tracePendingUnscheduleTimeTick(false, mTimeTickScheduled);
            if (!mTimeTickScheduled) {
                mTimeTicker.cancel();
            }
        }
    };

    @Inject
    public DozeUi(Context context, AlarmManager alarmManager,
            WakeLock wakeLock, DozeHost host, @Main Handler handler,
            DozeParameters params,
            @Background DelayableExecutor bgExecutor,
            DozeLog dozeLog) {
        mContext = context;
        mWakeLock = wakeLock;
        mHost = host;
        mHandler = handler;
        mBgExecutor = bgExecutor;
        mCanAnimateTransition = !params.getDisplayNeedsBlanking();
        mDozeParameters = params;
        mTimeTicker = new AlarmTimeout(alarmManager, this::onTimeTick, "doze_time_tick", handler);
@@ -166,7 +172,6 @@ public class DozeUi implements DozeMachine.Part {
            return;
        }
        mTimeTickScheduled = true;
        DejankUtils.removeCallbacks(mCancelTimeTickerRunnable);

        long time = System.currentTimeMillis();
        long delta = roundToNextMinute(time) - System.currentTimeMillis();
@@ -182,7 +187,8 @@ public class DozeUi implements DozeMachine.Part {
            return;
        }
        mTimeTickScheduled = false;
        DejankUtils.postAfterTraversal(mCancelTimeTickerRunnable);
        mDozeLog.tracePendingUnscheduleTimeTick(true, mTimeTickScheduled);
        mBgExecutor.execute(mCancelTimeTickerRunnable);
    }

    private void verifyLastTimeTick() {
+10 −4
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.data.repository.ShadeRepository
import com.android.systemui.statusbar.CommandQueue
import com.android.systemui.statusbar.notification.stack.domain.interactor.SharedNotificationContainerInteractor
import com.android.systemui.util.kotlin.Utils.Companion.sample as sampleCombine
import com.android.systemui.util.kotlin.sample
import javax.inject.Inject
import javax.inject.Provider
@@ -209,7 +210,8 @@ constructor(
                keyguardTransitionInteractor
                    .transitionValue(GONE)
                    .map { it == 1f }
                    .onStart { emit(false) },
                    .onStart { emit(false) }
                    .distinctUntilChanged(),
                repository.topClippingBounds
            ) { _, isGone, topClippingBounds ->
                if (!isGone) {
@@ -279,12 +281,16 @@ constructor(
     * signal should be sent directly to transitions.
     */
    val dismissAlpha: Flow<Float?> =
        combine(
                shadeRepository.legacyShadeExpansion,
        shadeRepository.legacyShadeExpansion
            .filter { it < 1f }
            .sampleCombine(
                statusBarState,
                keyguardTransitionInteractor.currentKeyguardState,
                isKeyguardDismissible,
            ) { legacyShadeExpansion, statusBarState, currentKeyguardState, isKeyguardDismissible ->
            )
            .map {
                (legacyShadeExpansion, statusBarState, currentKeyguardState, isKeyguardDismissible)
                ->
                if (
                    statusBarState == StatusBarState.KEYGUARD &&
                        isKeyguardDismissible &&
Loading