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

Commit 7ad9d67a authored by Beverly Tai's avatar Beverly Tai Committed by Automerger Merge Worker
Browse files

Merge "Add additional debug logs to clock view" into tm-dev am: a8065ea6

parents 10bdef8c a8065ea6
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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;
@@ -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));
@@ -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);
@@ -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);
    }
}
+33 −0
Original line number Diff line number Diff line
@@ -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
@@ -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()

@@ -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?) {
@@ -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() }
@@ -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)
    }

@@ -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 {
+24 −6
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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;
@@ -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
@@ -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;

@@ -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;
@@ -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
@@ -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
@@ -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);
    }
}
+5 −2
Original line number Diff line number Diff line
@@ -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;
@@ -101,6 +102,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
    private ClockPlugin mClockPlugin;
    @Mock
    ColorExtractor.GradientColors mGradientColors;
    @Mock
    DumpManager mDumpManager;

    @Mock
    private NotificationIconContainer mNotificationIcons;
@@ -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);