diff options
6 files changed, 49 insertions, 14 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt index f78fbd16daf9..1dd5d073bef3 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt @@ -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 diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java index 424bd0a3e23b..9a9e698e0138 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java @@ -209,6 +209,15 @@ public class DozeLog implements Dumpable { } /** + * 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 */ diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt b/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt index 75b8e513c14a..9d6693efffa3 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt @@ -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 diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeUi.java b/packages/SystemUI/src/com/android/systemui/doze/DozeUi.java index 34a80e867153..95012a2643a5 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeUi.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeUi.java @@ -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,14 +53,17 @@ 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() { - mTimeTicker.cancel(); + mDozeLog.tracePendingUnscheduleTimeTick(false, mTimeTickScheduled); + if (!mTimeTickScheduled) { + mTimeTicker.cancel(); + } } }; @@ -67,11 +71,13 @@ public class DozeUi implements DozeMachine.Part { 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() { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt index e384bfb7a36e..c4769488646d 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt @@ -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 && diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java index 7311f4a5ef71..e7caf000ef67 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java @@ -41,6 +41,8 @@ import androidx.test.runner.AndroidJUnit4; import com.android.systemui.DejankUtils; import com.android.systemui.SysuiTestCase; import com.android.systemui.statusbar.phone.DozeParameters; +import com.android.systemui.util.concurrency.FakeExecutor; +import com.android.systemui.util.time.FakeSystemClock; import com.android.systemui.util.wakelock.WakeLockFake; import org.junit.After; @@ -69,6 +71,7 @@ public class DozeUiTest extends SysuiTestCase { private Handler mHandler; private HandlerThread mHandlerThread; private DozeUi mDozeUi; + private FakeExecutor mFakeExecutor; @Before public void setUp() throws Exception { @@ -80,9 +83,9 @@ public class DozeUiTest extends SysuiTestCase { mHandlerThread.start(); mWakeLock = new WakeLockFake(); mHandler = mHandlerThread.getThreadHandler(); - + mFakeExecutor = new FakeExecutor(new FakeSystemClock()); mDozeUi = new DozeUi(mContext, mAlarmManager, mWakeLock, mHost, mHandler, - mDozeParameters, mDozeLog); + mDozeParameters, mFakeExecutor, mDozeLog); mDozeUi.setDozeMachine(mMachine); } |