Loading packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java +14 −0 Original line number Diff line number Diff line Loading @@ -23,7 +23,9 @@ import android.content.IntentFilter; import android.content.res.Resources; import android.graphics.Color; import android.icu.text.NumberFormat; import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import com.android.settingslib.Utils; Loading @@ -34,6 +36,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.util.ViewController; import java.io.PrintWriter; import java.util.Locale; import java.util.Objects; import java.util.TimeZone; Loading @@ -43,6 +46,7 @@ import java.util.TimeZone; * {@link KeyguardClockSwitchController}. */ public class AnimatableClockController extends ViewController<AnimatableClockView> { private static final String TAG = "AnimatableClockCtrl"; private static final int FORMAT_NUMBER = 1234567890; private final StatusBarStateController mStatusBarStateController; Loading Loading @@ -140,6 +144,7 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie @Override protected void onViewAttached() { Log.d(TAG, "onViewAttached mView=" + mView); updateLocale(); mBroadcastDispatcher.registerReceiver(mLocaleBroadcastReceiver, new IntentFilter(Intent.ACTION_LOCALE_CHANGED)); Loading @@ -157,6 +162,7 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie @Override protected void onViewDetached() { Log.d(TAG, "onViewDetached mView=" + mView); mBroadcastDispatcher.unregisterReceiver(mLocaleBroadcastReceiver); mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback); mBatteryController.removeCallback(mBatteryCallback); Loading Loading @@ -223,4 +229,12 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie mView.setColors(mDozingColor, mLockScreenColor); mView.animateDoze(mIsDozing, false); } /** * Dump information for debugging */ public void dump(@NonNull PrintWriter pw) { pw.println(this); mView.dump(pw); } } packages/SystemUI/src/com/android/keyguard/AnimatableClockView.kt +33 −0 Original line number Diff line number Diff line Loading @@ -24,10 +24,12 @@ import android.content.Context import android.graphics.Canvas import android.text.format.DateFormat import android.util.AttributeSet import android.util.Log import android.widget.TextView import com.android.systemui.R import com.android.systemui.animation.Interpolators import com.android.systemui.statusbar.notification.stack.StackStateAnimator import java.io.PrintWriter import java.util.Calendar import java.util.Locale import java.util.TimeZone Loading @@ -42,6 +44,9 @@ class AnimatableClockView @JvmOverloads constructor( defStyleAttr: Int = 0, defStyleRes: Int = 0 ) : TextView(context, attrs, defStyleAttr, defStyleRes) { private val tag = "AnimatableClockView" private var lastMeasureCall: CharSequence = "" private val time = Calendar.getInstance() Loading Loading @@ -122,6 +127,11 @@ class AnimatableClockView @JvmOverloads constructor( time.timeInMillis = System.currentTimeMillis() text = DateFormat.format(format, time) contentDescription = DateFormat.format(descFormat, time) Log.d(tag, "refreshTime this=$this" + " currTimeContextDesc=$contentDescription" + " measuredHeight=$measuredHeight" + " lastMeasureCall=$lastMeasureCall" + " isSingleLineInternal=$isSingleLineInternal") } fun onTimeZoneChanged(timeZone: TimeZone?) { Loading @@ -132,6 +142,7 @@ class AnimatableClockView @JvmOverloads constructor( @SuppressLint("DrawAllocation") override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { super.onMeasure(widthMeasureSpec, heightMeasureSpec) lastMeasureCall = DateFormat.format(descFormat, System.currentTimeMillis()) val animator = textAnimator if (animator == null) { textAnimator = TextAnimator(layout) { invalidate() } Loading @@ -140,9 +151,20 @@ class AnimatableClockView @JvmOverloads constructor( } else { animator.updateLayout(layout) } Log.v(tag, "onMeasure this=$this" + " currTimeContextDesc=$contentDescription" + " heightMeasureSpecMode=${MeasureSpec.getMode(heightMeasureSpec)}" + " heightMeasureSpecSize=${MeasureSpec.getSize(heightMeasureSpec)}" + " measuredWidth=$measuredWidth" + " measuredHeight=$measuredHeight" + " isSingleLineInternal=$isSingleLineInternal") } override fun onDraw(canvas: Canvas) { // intentionally doesn't call super.onDraw here or else the text will be rendered twice Log.d(tag, "onDraw this=$this" + " currTimeContextDesc=$contentDescription" + " isSingleLineInternal=$isSingleLineInternal") textAnimator?.draw(canvas) } Loading Loading @@ -329,6 +351,17 @@ class AnimatableClockView @JvmOverloads constructor( refreshTime() } fun dump(pw: PrintWriter) { pw.println("$this") pw.println(" measuredWidth=$measuredWidth") pw.println(" measuredHeight=$measuredHeight") pw.println(" singleLineInternal=$isSingleLineInternal") pw.println(" lastMeasureCall=$lastMeasureCall") pw.println(" currText=$text") pw.println(" currTimeContextDesc=$contentDescription") pw.println(" time=$time") } // DateFormat.getBestDateTimePattern is extremely expensive, and refresh is called often. // This is an optimization to ensure we only recompute the patterns when the inputs change. private object Patterns { Loading packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +24 −6 Original line number Diff line number Diff line Loading @@ -33,12 +33,16 @@ import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.RelativeLayout; import androidx.annotation.NonNull; import com.android.internal.colorextraction.ColorExtractor; import com.android.keyguard.clock.ClockManager; import com.android.systemui.Dumpable; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.plugins.ClockPlugin; import com.android.systemui.plugins.statusbar.StatusBarStateController; Loading @@ -46,13 +50,14 @@ import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.notification.stack.AnimationProperties; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationIconAreaController; import com.android.systemui.statusbar.phone.NotificationIconContainer; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.util.ViewController; import com.android.systemui.util.settings.SecureSettings; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.HashSet; import java.util.Locale; import java.util.Set; Loading @@ -64,7 +69,8 @@ import javax.inject.Inject; /** * Injectable controller for {@link KeyguardClockSwitch}. */ public class KeyguardClockSwitchController extends ViewController<KeyguardClockSwitch> { public class KeyguardClockSwitchController extends ViewController<KeyguardClockSwitch> implements Dumpable { private static final boolean CUSTOM_CLOCKS_ENABLED = true; private final StatusBarStateController mStatusBarStateController; Loading @@ -77,6 +83,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private final LockscreenSmartspaceController mSmartspaceController; private final Resources mResources; private final SecureSettings mSecureSettings; private final DumpManager mDumpManager; /** * Clock for both small and large sizes Loading @@ -90,7 +97,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private int mCurrentClockSize = SMALL; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final KeyguardBypassController mBypassController; private int mKeyguardClockTopMargin = 0; Loading Loading @@ -135,12 +141,12 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS BroadcastDispatcher broadcastDispatcher, BatteryController batteryController, KeyguardUpdateMonitor keyguardUpdateMonitor, KeyguardBypassController bypassController, LockscreenSmartspaceController smartspaceController, KeyguardUnlockAnimationController keyguardUnlockAnimationController, SecureSettings secureSettings, @Main Executor uiExecutor, @Main Resources resources) { @Main Resources resources, DumpManager dumpManager) { super(keyguardClockSwitch); mStatusBarStateController = statusBarStateController; mColorExtractor = colorExtractor; Loading @@ -150,12 +156,12 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mBroadcastDispatcher = broadcastDispatcher; mBatteryController = batteryController; mKeyguardUpdateMonitor = keyguardUpdateMonitor; mBypassController = bypassController; mSmartspaceController = smartspaceController; mResources = resources; mSecureSettings = secureSettings; mUiExecutor = uiExecutor; mKeyguardUnlockAnimationController = keyguardUnlockAnimationController; mDumpManager = dumpManager; mKeyguardUnlockAnimationController.addKeyguardUnlockAnimationListener( new KeyguardUnlockAnimationController.KeyguardUnlockAnimationListener() { @Override Loading Loading @@ -210,6 +216,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mKeyguardUpdateMonitor, mResources); mLargeClockViewController.init(); mDumpManager.unregisterDumpable(getClass().toString()); // unregister previous clocks mDumpManager.registerDumpable(getClass().toString(), this); } @Override Loading Loading @@ -486,4 +495,13 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mStatusArea.setClipChildren(clip); } } @Override public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) { pw.println("currentClockSizeLarge=" + (mCurrentClockSize == LARGE)); pw.println("mCanShowDoubleLineClock=" + mCanShowDoubleLineClock); mClockViewController.dump(pw); mLargeClockViewController.dump(pw); } } packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dump.DumpManager; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.plugins.ClockPlugin; import com.android.systemui.plugins.statusbar.StatusBarStateController; Loading Loading @@ -101,6 +102,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { private ClockPlugin mClockPlugin; @Mock ColorExtractor.GradientColors mGradientColors; @Mock DumpManager mDumpManager; @Mock private NotificationIconContainer mNotificationIcons; Loading Loading @@ -149,12 +152,12 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { mBroadcastDispatcher, mBatteryController, mKeyguardUpdateMonitor, mBypassController, mSmartspaceController, mKeyguardUnlockAnimationController, mSecureSettings, mExecutor, mResources mResources, mDumpManager ); when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE); Loading Loading
packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java +14 −0 Original line number Diff line number Diff line Loading @@ -23,7 +23,9 @@ import android.content.IntentFilter; import android.content.res.Resources; import android.graphics.Color; import android.icu.text.NumberFormat; import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import com.android.settingslib.Utils; Loading @@ -34,6 +36,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.util.ViewController; import java.io.PrintWriter; import java.util.Locale; import java.util.Objects; import java.util.TimeZone; Loading @@ -43,6 +46,7 @@ import java.util.TimeZone; * {@link KeyguardClockSwitchController}. */ public class AnimatableClockController extends ViewController<AnimatableClockView> { private static final String TAG = "AnimatableClockCtrl"; private static final int FORMAT_NUMBER = 1234567890; private final StatusBarStateController mStatusBarStateController; Loading Loading @@ -140,6 +144,7 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie @Override protected void onViewAttached() { Log.d(TAG, "onViewAttached mView=" + mView); updateLocale(); mBroadcastDispatcher.registerReceiver(mLocaleBroadcastReceiver, new IntentFilter(Intent.ACTION_LOCALE_CHANGED)); Loading @@ -157,6 +162,7 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie @Override protected void onViewDetached() { Log.d(TAG, "onViewDetached mView=" + mView); mBroadcastDispatcher.unregisterReceiver(mLocaleBroadcastReceiver); mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback); mBatteryController.removeCallback(mBatteryCallback); Loading Loading @@ -223,4 +229,12 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie mView.setColors(mDozingColor, mLockScreenColor); mView.animateDoze(mIsDozing, false); } /** * Dump information for debugging */ public void dump(@NonNull PrintWriter pw) { pw.println(this); mView.dump(pw); } }
packages/SystemUI/src/com/android/keyguard/AnimatableClockView.kt +33 −0 Original line number Diff line number Diff line Loading @@ -24,10 +24,12 @@ import android.content.Context import android.graphics.Canvas import android.text.format.DateFormat import android.util.AttributeSet import android.util.Log import android.widget.TextView import com.android.systemui.R import com.android.systemui.animation.Interpolators import com.android.systemui.statusbar.notification.stack.StackStateAnimator import java.io.PrintWriter import java.util.Calendar import java.util.Locale import java.util.TimeZone Loading @@ -42,6 +44,9 @@ class AnimatableClockView @JvmOverloads constructor( defStyleAttr: Int = 0, defStyleRes: Int = 0 ) : TextView(context, attrs, defStyleAttr, defStyleRes) { private val tag = "AnimatableClockView" private var lastMeasureCall: CharSequence = "" private val time = Calendar.getInstance() Loading Loading @@ -122,6 +127,11 @@ class AnimatableClockView @JvmOverloads constructor( time.timeInMillis = System.currentTimeMillis() text = DateFormat.format(format, time) contentDescription = DateFormat.format(descFormat, time) Log.d(tag, "refreshTime this=$this" + " currTimeContextDesc=$contentDescription" + " measuredHeight=$measuredHeight" + " lastMeasureCall=$lastMeasureCall" + " isSingleLineInternal=$isSingleLineInternal") } fun onTimeZoneChanged(timeZone: TimeZone?) { Loading @@ -132,6 +142,7 @@ class AnimatableClockView @JvmOverloads constructor( @SuppressLint("DrawAllocation") override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { super.onMeasure(widthMeasureSpec, heightMeasureSpec) lastMeasureCall = DateFormat.format(descFormat, System.currentTimeMillis()) val animator = textAnimator if (animator == null) { textAnimator = TextAnimator(layout) { invalidate() } Loading @@ -140,9 +151,20 @@ class AnimatableClockView @JvmOverloads constructor( } else { animator.updateLayout(layout) } Log.v(tag, "onMeasure this=$this" + " currTimeContextDesc=$contentDescription" + " heightMeasureSpecMode=${MeasureSpec.getMode(heightMeasureSpec)}" + " heightMeasureSpecSize=${MeasureSpec.getSize(heightMeasureSpec)}" + " measuredWidth=$measuredWidth" + " measuredHeight=$measuredHeight" + " isSingleLineInternal=$isSingleLineInternal") } override fun onDraw(canvas: Canvas) { // intentionally doesn't call super.onDraw here or else the text will be rendered twice Log.d(tag, "onDraw this=$this" + " currTimeContextDesc=$contentDescription" + " isSingleLineInternal=$isSingleLineInternal") textAnimator?.draw(canvas) } Loading Loading @@ -329,6 +351,17 @@ class AnimatableClockView @JvmOverloads constructor( refreshTime() } fun dump(pw: PrintWriter) { pw.println("$this") pw.println(" measuredWidth=$measuredWidth") pw.println(" measuredHeight=$measuredHeight") pw.println(" singleLineInternal=$isSingleLineInternal") pw.println(" lastMeasureCall=$lastMeasureCall") pw.println(" currText=$text") pw.println(" currTimeContextDesc=$contentDescription") pw.println(" time=$time") } // DateFormat.getBestDateTimePattern is extremely expensive, and refresh is called often. // This is an optimization to ensure we only recompute the patterns when the inputs change. private object Patterns { Loading
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +24 −6 Original line number Diff line number Diff line Loading @@ -33,12 +33,16 @@ import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.RelativeLayout; import androidx.annotation.NonNull; import com.android.internal.colorextraction.ColorExtractor; import com.android.keyguard.clock.ClockManager; import com.android.systemui.Dumpable; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.plugins.ClockPlugin; import com.android.systemui.plugins.statusbar.StatusBarStateController; Loading @@ -46,13 +50,14 @@ import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.notification.stack.AnimationProperties; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationIconAreaController; import com.android.systemui.statusbar.phone.NotificationIconContainer; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.util.ViewController; import com.android.systemui.util.settings.SecureSettings; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.HashSet; import java.util.Locale; import java.util.Set; Loading @@ -64,7 +69,8 @@ import javax.inject.Inject; /** * Injectable controller for {@link KeyguardClockSwitch}. */ public class KeyguardClockSwitchController extends ViewController<KeyguardClockSwitch> { public class KeyguardClockSwitchController extends ViewController<KeyguardClockSwitch> implements Dumpable { private static final boolean CUSTOM_CLOCKS_ENABLED = true; private final StatusBarStateController mStatusBarStateController; Loading @@ -77,6 +83,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private final LockscreenSmartspaceController mSmartspaceController; private final Resources mResources; private final SecureSettings mSecureSettings; private final DumpManager mDumpManager; /** * Clock for both small and large sizes Loading @@ -90,7 +97,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private int mCurrentClockSize = SMALL; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final KeyguardBypassController mBypassController; private int mKeyguardClockTopMargin = 0; Loading Loading @@ -135,12 +141,12 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS BroadcastDispatcher broadcastDispatcher, BatteryController batteryController, KeyguardUpdateMonitor keyguardUpdateMonitor, KeyguardBypassController bypassController, LockscreenSmartspaceController smartspaceController, KeyguardUnlockAnimationController keyguardUnlockAnimationController, SecureSettings secureSettings, @Main Executor uiExecutor, @Main Resources resources) { @Main Resources resources, DumpManager dumpManager) { super(keyguardClockSwitch); mStatusBarStateController = statusBarStateController; mColorExtractor = colorExtractor; Loading @@ -150,12 +156,12 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mBroadcastDispatcher = broadcastDispatcher; mBatteryController = batteryController; mKeyguardUpdateMonitor = keyguardUpdateMonitor; mBypassController = bypassController; mSmartspaceController = smartspaceController; mResources = resources; mSecureSettings = secureSettings; mUiExecutor = uiExecutor; mKeyguardUnlockAnimationController = keyguardUnlockAnimationController; mDumpManager = dumpManager; mKeyguardUnlockAnimationController.addKeyguardUnlockAnimationListener( new KeyguardUnlockAnimationController.KeyguardUnlockAnimationListener() { @Override Loading Loading @@ -210,6 +216,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mKeyguardUpdateMonitor, mResources); mLargeClockViewController.init(); mDumpManager.unregisterDumpable(getClass().toString()); // unregister previous clocks mDumpManager.registerDumpable(getClass().toString(), this); } @Override Loading Loading @@ -486,4 +495,13 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mStatusArea.setClipChildren(clip); } } @Override public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) { pw.println("currentClockSizeLarge=" + (mCurrentClockSize == LARGE)); pw.println("mCanShowDoubleLineClock=" + mCanShowDoubleLineClock); mClockViewController.dump(pw); mLargeClockViewController.dump(pw); } }
packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dump.DumpManager; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.plugins.ClockPlugin; import com.android.systemui.plugins.statusbar.StatusBarStateController; Loading Loading @@ -101,6 +102,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { private ClockPlugin mClockPlugin; @Mock ColorExtractor.GradientColors mGradientColors; @Mock DumpManager mDumpManager; @Mock private NotificationIconContainer mNotificationIcons; Loading Loading @@ -149,12 +152,12 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { mBroadcastDispatcher, mBatteryController, mKeyguardUpdateMonitor, mBypassController, mSmartspaceController, mKeyguardUnlockAnimationController, mSecureSettings, mExecutor, mResources mResources, mDumpManager ); when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE); Loading