Loading packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +9 −6 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags.DOZING_MIGRATION_1 import com.android.systemui.flags.Flags.REGION_SAMPLING import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor Loading Loading @@ -221,8 +222,11 @@ open class ClockEventController @Inject constructor( disposableHandle = parent.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.STARTED) { listenForDozing(this) listenForDozeAmount(this) if (featureFlags.isEnabled(DOZING_MIGRATION_1)) { listenForDozeAmountTransition(this) } else { listenForDozeAmount(this) } } } } Loading Loading @@ -265,10 +269,9 @@ open class ClockEventController @Inject constructor( @VisibleForTesting internal fun listenForDozeAmountTransition(scope: CoroutineScope): Job { return scope.launch { keyguardTransitionInteractor.aodToLockscreenTransition.collect { // Would eventually run this: // dozeAmount = it.value // clock?.animations?.doze(dozeAmount) keyguardTransitionInteractor.dozeAmountTransition.collect { dozeAmount = it.value clock?.animations?.doze(dozeAmount) } } } Loading packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +59 −15 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import static com.android.keyguard.LockIconView.ICON_LOCK; import static com.android.keyguard.LockIconView.ICON_UNLOCK; import static com.android.systemui.classifier.Classifier.LOCK_ICON; import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; import static com.android.systemui.flags.Flags.DOZING_MIGRATION_1; import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow; import android.content.res.Configuration; import android.content.res.Resources; Loading @@ -44,6 +46,7 @@ import android.view.accessibility.AccessibilityNodeInfo; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; import com.android.systemui.Dumpable; Loading @@ -53,6 +56,10 @@ import com.android.systemui.biometrics.AuthRippleController; import com.android.systemui.biometrics.UdfpsController; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor; import com.android.systemui.keyguard.shared.model.TransitionStep; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.StatusBarState; Loading @@ -65,6 +72,7 @@ import com.android.systemui.util.concurrency.DelayableExecutor; import java.io.PrintWriter; import java.util.Objects; import java.util.function.Consumer; import javax.inject.Inject; Loading Loading @@ -101,6 +109,9 @@ public class LockIconViewController extends ViewController<LockIconView> impleme @NonNull private CharSequence mLockedLabel; @NonNull private final VibratorHelper mVibrator; @Nullable private final AuthRippleController mAuthRippleController; @NonNull private final FeatureFlags mFeatureFlags; @NonNull private final KeyguardTransitionInteractor mTransitionInteractor; @NonNull private final KeyguardInteractor mKeyguardInteractor; // Tracks the velocity of a touch to help filter out the touches that move too fast. private VelocityTracker mVelocityTracker; Loading Loading @@ -137,6 +148,20 @@ public class LockIconViewController extends ViewController<LockIconView> impleme private boolean mDownDetected; private final Rect mSensorTouchLocation = new Rect(); @VisibleForTesting final Consumer<TransitionStep> mDozeTransitionCallback = (TransitionStep step) -> { mInterpolatedDarkAmount = step.getValue(); mView.setDozeAmount(step.getValue()); updateBurnInOffsets(); }; @VisibleForTesting final Consumer<Boolean> mIsDozingCallback = (Boolean isDozing) -> { mIsDozing = isDozing; updateBurnInOffsets(); updateVisibility(); }; @Inject public LockIconViewController( @Nullable LockIconView view, Loading @@ -152,7 +177,10 @@ public class LockIconViewController extends ViewController<LockIconView> impleme @NonNull @Main DelayableExecutor executor, @NonNull VibratorHelper vibrator, @Nullable AuthRippleController authRippleController, @NonNull @Main Resources resources @NonNull @Main Resources resources, @NonNull KeyguardTransitionInteractor transitionInteractor, @NonNull KeyguardInteractor keyguardInteractor, @NonNull FeatureFlags featureFlags ) { super(view); mStatusBarStateController = statusBarStateController; Loading @@ -166,6 +194,9 @@ public class LockIconViewController extends ViewController<LockIconView> impleme mExecutor = executor; mVibrator = vibrator; mAuthRippleController = authRippleController; mTransitionInteractor = transitionInteractor; mKeyguardInteractor = keyguardInteractor; mFeatureFlags = featureFlags; mMaxBurnInOffsetX = resources.getDimensionPixelSize(R.dimen.udfps_burn_in_offset_x); mMaxBurnInOffsetY = resources.getDimensionPixelSize(R.dimen.udfps_burn_in_offset_y); Loading @@ -182,6 +213,12 @@ public class LockIconViewController extends ViewController<LockIconView> impleme @Override protected void onInit() { mView.setAccessibilityDelegate(mAccessibilityDelegate); if (mFeatureFlags.isEnabled(DOZING_MIGRATION_1)) { collectFlow(mView, mTransitionInteractor.getDozeAmountTransition(), mDozeTransitionCallback); collectFlow(mView, mKeyguardInteractor.isDozing(), mIsDozingCallback); } } @Override Loading Loading @@ -377,7 +414,10 @@ public class LockIconViewController extends ViewController<LockIconView> impleme pw.println(" mShowUnlockIcon: " + mShowUnlockIcon); pw.println(" mShowLockIcon: " + mShowLockIcon); pw.println(" mShowAodUnlockedIcon: " + mShowAodUnlockedIcon); pw.println(); pw.println(" mIsDozing: " + mIsDozing); pw.println(" isFlagEnabled(DOZING_MIGRATION_1): " + mFeatureFlags.isEnabled(DOZING_MIGRATION_1)); pw.println(" mIsBouncerShowing: " + mIsBouncerShowing); pw.println(" mUserUnlockedWithBiometric: " + mUserUnlockedWithBiometric); pw.println(" mRunningFPS: " + mRunningFPS); Loading Loading @@ -425,17 +465,21 @@ public class LockIconViewController extends ViewController<LockIconView> impleme new StatusBarStateController.StateListener() { @Override public void onDozeAmountChanged(float linear, float eased) { if (!mFeatureFlags.isEnabled(DOZING_MIGRATION_1)) { mInterpolatedDarkAmount = eased; mView.setDozeAmount(eased); updateBurnInOffsets(); } } @Override public void onDozingChanged(boolean isDozing) { if (!mFeatureFlags.isEnabled(DOZING_MIGRATION_1)) { mIsDozing = isDozing; updateBurnInOffsets(); updateVisibility(); } } @Override public void onStateChanged(int statusBarState) { Loading packages/SystemUI/src/com/android/systemui/flags/Flags.kt +6 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,12 @@ object Flags { */ @JvmField val STEP_CLOCK_ANIMATION = UnreleasedFlag(212) /** * Migration from the legacy isDozing/dozeAmount paths to the new KeyguardTransitionRepository * will occur in stages. This is one stage of many to come. */ @JvmField val DOZING_MIGRATION_1 = UnreleasedFlag(213, teamfood = true) // 300 - power menu // TODO(b/254512600): Tracking Bug @JvmField val POWER_MENU_LITE = ReleasedFlag(300) Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractor.kt +15 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN import com.android.systemui.keyguard.shared.model.TransitionStep import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.merge /** Encapsulates business-logic related to the keyguard transitions. */ @SysUISingleton Loading @@ -34,4 +36,17 @@ constructor( ) { /** AOD->LOCKSCREEN transition information. */ val aodToLockscreenTransition: Flow<TransitionStep> = repository.transition(AOD, LOCKSCREEN) /** LOCKSCREEN->AOD transition information. */ val lockscreenToAodTransition: Flow<TransitionStep> = repository.transition(LOCKSCREEN, AOD) /** * AOD<->LOCKSCREEN transition information, mapped to dozeAmount range of AOD (1f) <-> * Lockscreen (0f). */ val dozeAmountTransition: Flow<TransitionStep> = merge( aodToLockscreenTransition.map { step -> step.copy(value = 1f - step.value) }, lockscreenToAodTransition, ) } packages/SystemUI/src/com/android/systemui/util/kotlin/JavaAdapter.kt 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.android.systemui.util.kotlin import android.view.View import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle import com.android.systemui.lifecycle.repeatWhenAttached import java.util.function.Consumer import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect /** * Collect information for the given [flow], calling [consumer] for each emitted event. Defaults to * [LifeCycle.State.CREATED] to better align with legacy ViewController usage of attaching listeners * during onViewAttached() and removing during onViewRemoved() */ @JvmOverloads fun <T> collectFlow( view: View, flow: Flow<T>, consumer: Consumer<T>, state: Lifecycle.State = Lifecycle.State.CREATED, ) { view.repeatWhenAttached { repeatOnLifecycle(state) { flow.collect { consumer.accept(it) } } } } Loading
packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +9 −6 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags.DOZING_MIGRATION_1 import com.android.systemui.flags.Flags.REGION_SAMPLING import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor Loading Loading @@ -221,8 +222,11 @@ open class ClockEventController @Inject constructor( disposableHandle = parent.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.STARTED) { listenForDozing(this) listenForDozeAmount(this) if (featureFlags.isEnabled(DOZING_MIGRATION_1)) { listenForDozeAmountTransition(this) } else { listenForDozeAmount(this) } } } } Loading Loading @@ -265,10 +269,9 @@ open class ClockEventController @Inject constructor( @VisibleForTesting internal fun listenForDozeAmountTransition(scope: CoroutineScope): Job { return scope.launch { keyguardTransitionInteractor.aodToLockscreenTransition.collect { // Would eventually run this: // dozeAmount = it.value // clock?.animations?.doze(dozeAmount) keyguardTransitionInteractor.dozeAmountTransition.collect { dozeAmount = it.value clock?.animations?.doze(dozeAmount) } } } Loading
packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +59 −15 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import static com.android.keyguard.LockIconView.ICON_LOCK; import static com.android.keyguard.LockIconView.ICON_UNLOCK; import static com.android.systemui.classifier.Classifier.LOCK_ICON; import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; import static com.android.systemui.flags.Flags.DOZING_MIGRATION_1; import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow; import android.content.res.Configuration; import android.content.res.Resources; Loading @@ -44,6 +46,7 @@ import android.view.accessibility.AccessibilityNodeInfo; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; import com.android.systemui.Dumpable; Loading @@ -53,6 +56,10 @@ import com.android.systemui.biometrics.AuthRippleController; import com.android.systemui.biometrics.UdfpsController; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor; import com.android.systemui.keyguard.shared.model.TransitionStep; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.StatusBarState; Loading @@ -65,6 +72,7 @@ import com.android.systemui.util.concurrency.DelayableExecutor; import java.io.PrintWriter; import java.util.Objects; import java.util.function.Consumer; import javax.inject.Inject; Loading Loading @@ -101,6 +109,9 @@ public class LockIconViewController extends ViewController<LockIconView> impleme @NonNull private CharSequence mLockedLabel; @NonNull private final VibratorHelper mVibrator; @Nullable private final AuthRippleController mAuthRippleController; @NonNull private final FeatureFlags mFeatureFlags; @NonNull private final KeyguardTransitionInteractor mTransitionInteractor; @NonNull private final KeyguardInteractor mKeyguardInteractor; // Tracks the velocity of a touch to help filter out the touches that move too fast. private VelocityTracker mVelocityTracker; Loading Loading @@ -137,6 +148,20 @@ public class LockIconViewController extends ViewController<LockIconView> impleme private boolean mDownDetected; private final Rect mSensorTouchLocation = new Rect(); @VisibleForTesting final Consumer<TransitionStep> mDozeTransitionCallback = (TransitionStep step) -> { mInterpolatedDarkAmount = step.getValue(); mView.setDozeAmount(step.getValue()); updateBurnInOffsets(); }; @VisibleForTesting final Consumer<Boolean> mIsDozingCallback = (Boolean isDozing) -> { mIsDozing = isDozing; updateBurnInOffsets(); updateVisibility(); }; @Inject public LockIconViewController( @Nullable LockIconView view, Loading @@ -152,7 +177,10 @@ public class LockIconViewController extends ViewController<LockIconView> impleme @NonNull @Main DelayableExecutor executor, @NonNull VibratorHelper vibrator, @Nullable AuthRippleController authRippleController, @NonNull @Main Resources resources @NonNull @Main Resources resources, @NonNull KeyguardTransitionInteractor transitionInteractor, @NonNull KeyguardInteractor keyguardInteractor, @NonNull FeatureFlags featureFlags ) { super(view); mStatusBarStateController = statusBarStateController; Loading @@ -166,6 +194,9 @@ public class LockIconViewController extends ViewController<LockIconView> impleme mExecutor = executor; mVibrator = vibrator; mAuthRippleController = authRippleController; mTransitionInteractor = transitionInteractor; mKeyguardInteractor = keyguardInteractor; mFeatureFlags = featureFlags; mMaxBurnInOffsetX = resources.getDimensionPixelSize(R.dimen.udfps_burn_in_offset_x); mMaxBurnInOffsetY = resources.getDimensionPixelSize(R.dimen.udfps_burn_in_offset_y); Loading @@ -182,6 +213,12 @@ public class LockIconViewController extends ViewController<LockIconView> impleme @Override protected void onInit() { mView.setAccessibilityDelegate(mAccessibilityDelegate); if (mFeatureFlags.isEnabled(DOZING_MIGRATION_1)) { collectFlow(mView, mTransitionInteractor.getDozeAmountTransition(), mDozeTransitionCallback); collectFlow(mView, mKeyguardInteractor.isDozing(), mIsDozingCallback); } } @Override Loading Loading @@ -377,7 +414,10 @@ public class LockIconViewController extends ViewController<LockIconView> impleme pw.println(" mShowUnlockIcon: " + mShowUnlockIcon); pw.println(" mShowLockIcon: " + mShowLockIcon); pw.println(" mShowAodUnlockedIcon: " + mShowAodUnlockedIcon); pw.println(); pw.println(" mIsDozing: " + mIsDozing); pw.println(" isFlagEnabled(DOZING_MIGRATION_1): " + mFeatureFlags.isEnabled(DOZING_MIGRATION_1)); pw.println(" mIsBouncerShowing: " + mIsBouncerShowing); pw.println(" mUserUnlockedWithBiometric: " + mUserUnlockedWithBiometric); pw.println(" mRunningFPS: " + mRunningFPS); Loading Loading @@ -425,17 +465,21 @@ public class LockIconViewController extends ViewController<LockIconView> impleme new StatusBarStateController.StateListener() { @Override public void onDozeAmountChanged(float linear, float eased) { if (!mFeatureFlags.isEnabled(DOZING_MIGRATION_1)) { mInterpolatedDarkAmount = eased; mView.setDozeAmount(eased); updateBurnInOffsets(); } } @Override public void onDozingChanged(boolean isDozing) { if (!mFeatureFlags.isEnabled(DOZING_MIGRATION_1)) { mIsDozing = isDozing; updateBurnInOffsets(); updateVisibility(); } } @Override public void onStateChanged(int statusBarState) { Loading
packages/SystemUI/src/com/android/systemui/flags/Flags.kt +6 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,12 @@ object Flags { */ @JvmField val STEP_CLOCK_ANIMATION = UnreleasedFlag(212) /** * Migration from the legacy isDozing/dozeAmount paths to the new KeyguardTransitionRepository * will occur in stages. This is one stage of many to come. */ @JvmField val DOZING_MIGRATION_1 = UnreleasedFlag(213, teamfood = true) // 300 - power menu // TODO(b/254512600): Tracking Bug @JvmField val POWER_MENU_LITE = ReleasedFlag(300) Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractor.kt +15 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN import com.android.systemui.keyguard.shared.model.TransitionStep import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.merge /** Encapsulates business-logic related to the keyguard transitions. */ @SysUISingleton Loading @@ -34,4 +36,17 @@ constructor( ) { /** AOD->LOCKSCREEN transition information. */ val aodToLockscreenTransition: Flow<TransitionStep> = repository.transition(AOD, LOCKSCREEN) /** LOCKSCREEN->AOD transition information. */ val lockscreenToAodTransition: Flow<TransitionStep> = repository.transition(LOCKSCREEN, AOD) /** * AOD<->LOCKSCREEN transition information, mapped to dozeAmount range of AOD (1f) <-> * Lockscreen (0f). */ val dozeAmountTransition: Flow<TransitionStep> = merge( aodToLockscreenTransition.map { step -> step.copy(value = 1f - step.value) }, lockscreenToAodTransition, ) }
packages/SystemUI/src/com/android/systemui/util/kotlin/JavaAdapter.kt 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.android.systemui.util.kotlin import android.view.View import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle import com.android.systemui.lifecycle.repeatWhenAttached import java.util.function.Consumer import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect /** * Collect information for the given [flow], calling [consumer] for each emitted event. Defaults to * [LifeCycle.State.CREATED] to better align with legacy ViewController usage of attaching listeners * during onViewAttached() and removing during onViewRemoved() */ @JvmOverloads fun <T> collectFlow( view: View, flow: Flow<T>, consumer: Consumer<T>, state: Lifecycle.State = Lifecycle.State.CREATED, ) { view.repeatWhenAttached { repeatOnLifecycle(state) { flow.collect { consumer.accept(it) } } } }