Merge "Update LogBuffer pattern in some keyguard code" into tm-qpr-dev

This commit is contained in:
Hawkwood Glazier
2023-01-10 19:53:41 +00:00
committed by Android (Google) Code Review
15 changed files with 197 additions and 78 deletions

View File

@@ -54,7 +54,6 @@ class AnimatableClockView @JvmOverloads constructor(
defStyleAttr: Int = 0, defStyleAttr: Int = 0,
defStyleRes: Int = 0 defStyleRes: Int = 0
) : TextView(context, attrs, defStyleAttr, defStyleRes) { ) : TextView(context, attrs, defStyleAttr, defStyleRes) {
var tag: String = "UnnamedClockView"
var logBuffer: LogBuffer? = null var logBuffer: LogBuffer? = null
private val time = Calendar.getInstance() private val time = Calendar.getInstance()
@@ -132,7 +131,7 @@ class AnimatableClockView @JvmOverloads constructor(
override fun onAttachedToWindow() { override fun onAttachedToWindow() {
super.onAttachedToWindow() super.onAttachedToWindow()
logBuffer?.log(tag, DEBUG, "onAttachedToWindow") logBuffer?.log(TAG, DEBUG, "onAttachedToWindow")
refreshFormat() refreshFormat()
} }
@@ -148,7 +147,7 @@ class AnimatableClockView @JvmOverloads constructor(
time.timeInMillis = timeOverrideInMillis ?: System.currentTimeMillis() time.timeInMillis = timeOverrideInMillis ?: System.currentTimeMillis()
contentDescription = DateFormat.format(descFormat, time) contentDescription = DateFormat.format(descFormat, time)
val formattedText = DateFormat.format(format, time) val formattedText = DateFormat.format(format, time)
logBuffer?.log(tag, DEBUG, logBuffer?.log(TAG, DEBUG,
{ str1 = formattedText?.toString() }, { str1 = formattedText?.toString() },
{ "refreshTime: new formattedText=$str1" } { "refreshTime: new formattedText=$str1" }
) )
@@ -157,7 +156,7 @@ class AnimatableClockView @JvmOverloads constructor(
// relayout if the text didn't actually change. // relayout if the text didn't actually change.
if (!TextUtils.equals(text, formattedText)) { if (!TextUtils.equals(text, formattedText)) {
text = formattedText text = formattedText
logBuffer?.log(tag, DEBUG, logBuffer?.log(TAG, DEBUG,
{ str1 = formattedText?.toString() }, { str1 = formattedText?.toString() },
{ "refreshTime: done setting new time text to: $str1" } { "refreshTime: done setting new time text to: $str1" }
) )
@@ -167,17 +166,17 @@ class AnimatableClockView @JvmOverloads constructor(
// without being notified TextInterpolator being notified. // without being notified TextInterpolator being notified.
if (layout != null) { if (layout != null) {
textAnimator?.updateLayout(layout) textAnimator?.updateLayout(layout)
logBuffer?.log(tag, DEBUG, "refreshTime: done updating textAnimator layout") logBuffer?.log(TAG, DEBUG, "refreshTime: done updating textAnimator layout")
} }
requestLayout() requestLayout()
logBuffer?.log(tag, DEBUG, "refreshTime: after requestLayout") logBuffer?.log(TAG, DEBUG, "refreshTime: after requestLayout")
} }
} }
fun onTimeZoneChanged(timeZone: TimeZone?) { fun onTimeZoneChanged(timeZone: TimeZone?) {
time.timeZone = timeZone time.timeZone = timeZone
refreshFormat() refreshFormat()
logBuffer?.log(tag, DEBUG, logBuffer?.log(TAG, DEBUG,
{ str1 = timeZone?.toString() }, { str1 = timeZone?.toString() },
{ "onTimeZoneChanged newTimeZone=$str1" } { "onTimeZoneChanged newTimeZone=$str1" }
) )
@@ -194,7 +193,7 @@ class AnimatableClockView @JvmOverloads constructor(
} else { } else {
animator.updateLayout(layout) animator.updateLayout(layout)
} }
logBuffer?.log(tag, DEBUG, "onMeasure") logBuffer?.log(TAG, DEBUG, "onMeasure")
} }
override fun onDraw(canvas: Canvas) { override fun onDraw(canvas: Canvas) {
@@ -206,12 +205,12 @@ class AnimatableClockView @JvmOverloads constructor(
} else { } else {
super.onDraw(canvas) super.onDraw(canvas)
} }
logBuffer?.log(tag, DEBUG, "onDraw lastDraw") logBuffer?.log(TAG, DEBUG, "onDraw")
} }
override fun invalidate() { override fun invalidate() {
super.invalidate() super.invalidate()
logBuffer?.log(tag, DEBUG, "invalidate") logBuffer?.log(TAG, DEBUG, "invalidate")
} }
override fun onTextChanged( override fun onTextChanged(
@@ -221,7 +220,7 @@ class AnimatableClockView @JvmOverloads constructor(
lengthAfter: Int lengthAfter: Int
) { ) {
super.onTextChanged(text, start, lengthBefore, lengthAfter) super.onTextChanged(text, start, lengthBefore, lengthAfter)
logBuffer?.log(tag, DEBUG, logBuffer?.log(TAG, DEBUG,
{ str1 = text.toString() }, { str1 = text.toString() },
{ "onTextChanged text=$str1" } { "onTextChanged text=$str1" }
) )
@@ -238,7 +237,7 @@ class AnimatableClockView @JvmOverloads constructor(
} }
fun animateColorChange() { fun animateColorChange() {
logBuffer?.log(tag, DEBUG, "animateColorChange") logBuffer?.log(TAG, DEBUG, "animateColorChange")
setTextStyle( setTextStyle(
weight = lockScreenWeight, weight = lockScreenWeight,
textSize = -1f, textSize = -1f,
@@ -260,7 +259,7 @@ class AnimatableClockView @JvmOverloads constructor(
} }
fun animateAppearOnLockscreen() { fun animateAppearOnLockscreen() {
logBuffer?.log(tag, DEBUG, "animateAppearOnLockscreen") logBuffer?.log(TAG, DEBUG, "animateAppearOnLockscreen")
setTextStyle( setTextStyle(
weight = dozingWeight, weight = dozingWeight,
textSize = -1f, textSize = -1f,
@@ -285,7 +284,7 @@ class AnimatableClockView @JvmOverloads constructor(
if (isAnimationEnabled && textAnimator == null) { if (isAnimationEnabled && textAnimator == null) {
return return
} }
logBuffer?.log(tag, DEBUG, "animateFoldAppear") logBuffer?.log(TAG, DEBUG, "animateFoldAppear")
setTextStyle( setTextStyle(
weight = lockScreenWeightInternal, weight = lockScreenWeightInternal,
textSize = -1f, textSize = -1f,
@@ -312,7 +311,7 @@ class AnimatableClockView @JvmOverloads constructor(
// Skip charge animation if dozing animation is already playing. // Skip charge animation if dozing animation is already playing.
return return
} }
logBuffer?.log(tag, DEBUG, "animateCharge") logBuffer?.log(TAG, DEBUG, "animateCharge")
val startAnimPhase2 = Runnable { val startAnimPhase2 = Runnable {
setTextStyle( setTextStyle(
weight = if (isDozing()) dozingWeight else lockScreenWeight, weight = if (isDozing()) dozingWeight else lockScreenWeight,
@@ -336,7 +335,7 @@ class AnimatableClockView @JvmOverloads constructor(
} }
fun animateDoze(isDozing: Boolean, animate: Boolean) { fun animateDoze(isDozing: Boolean, animate: Boolean) {
logBuffer?.log(tag, DEBUG, "animateDoze") logBuffer?.log(TAG, DEBUG, "animateDoze")
setTextStyle( setTextStyle(
weight = if (isDozing) dozingWeight else lockScreenWeight, weight = if (isDozing) dozingWeight else lockScreenWeight,
textSize = -1f, textSize = -1f,
@@ -455,7 +454,7 @@ class AnimatableClockView @JvmOverloads constructor(
isSingleLineInternal && !use24HourFormat -> Patterns.sClockView12 isSingleLineInternal && !use24HourFormat -> Patterns.sClockView12
else -> DOUBLE_LINE_FORMAT_12_HOUR else -> DOUBLE_LINE_FORMAT_12_HOUR
} }
logBuffer?.log(tag, DEBUG, logBuffer?.log(TAG, DEBUG,
{ str1 = format?.toString() }, { str1 = format?.toString() },
{ "refreshFormat format=$str1" } { "refreshFormat format=$str1" }
) )
@@ -466,6 +465,7 @@ class AnimatableClockView @JvmOverloads constructor(
fun dump(pw: PrintWriter) { fun dump(pw: PrintWriter) {
pw.println("$this") pw.println("$this")
pw.println(" alpha=$alpha")
pw.println(" measuredWidth=$measuredWidth") pw.println(" measuredWidth=$measuredWidth")
pw.println(" measuredHeight=$measuredHeight") pw.println(" measuredHeight=$measuredHeight")
pw.println(" singleLineInternal=$isSingleLineInternal") pw.println(" singleLineInternal=$isSingleLineInternal")
@@ -626,7 +626,7 @@ class AnimatableClockView @JvmOverloads constructor(
} }
companion object { companion object {
private val TAG = AnimatableClockView::class.simpleName private val TAG = AnimatableClockView::class.simpleName!!
const val ANIMATION_DURATION_FOLD_TO_AOD: Int = 600 const val ANIMATION_DURATION_FOLD_TO_AOD: Int = 600
private const val DOUBLE_LINE_FORMAT_12_HOUR = "hh\nmm" private const val DOUBLE_LINE_FORMAT_12_HOUR = "hh\nmm"
private const val DOUBLE_LINE_FORMAT_24_HOUR = "HH\nmm" private const val DOUBLE_LINE_FORMAT_24_HOUR = "HH\nmm"

View File

@@ -88,13 +88,6 @@ class DefaultClockController(
events.onTimeTick() events.onTimeTick()
} }
override fun setLogBuffer(logBuffer: LogBuffer) {
smallClock.view.tag = "smallClockView"
largeClock.view.tag = "largeClockView"
smallClock.view.logBuffer = logBuffer
largeClock.view.logBuffer = logBuffer
}
open inner class DefaultClockFaceController( open inner class DefaultClockFaceController(
override val view: AnimatableClockView, override val view: AnimatableClockView,
) : ClockFaceController { ) : ClockFaceController {
@@ -104,6 +97,12 @@ class DefaultClockController(
private var isRegionDark = false private var isRegionDark = false
protected var targetRegion: Rect? = null protected var targetRegion: Rect? = null
override var logBuffer: LogBuffer?
get() = view.logBuffer
set(value) {
view.logBuffer = value
}
init { init {
view.setColors(currentColor, currentColor) view.setColors(currentColor, currentColor)
} }

View File

@@ -71,9 +71,6 @@ interface ClockController {
/** Optional method for dumping debug information */ /** Optional method for dumping debug information */
fun dump(pw: PrintWriter) {} fun dump(pw: PrintWriter) {}
/** Optional method for debug logging */
fun setLogBuffer(logBuffer: LogBuffer) {}
} }
/** Interface for a specific clock face version rendered by the clock */ /** Interface for a specific clock face version rendered by the clock */
@@ -83,6 +80,9 @@ interface ClockFaceController {
/** Events specific to this clock face */ /** Events specific to this clock face */
val events: ClockFaceEvents val events: ClockFaceEvents
/** Some clocks may log debug information */
var logBuffer: LogBuffer?
} }
/** Events that should call when various rendering parameters change */ /** Events that should call when various rendering parameters change */

View File

@@ -159,8 +159,13 @@ constructor(
* bug report more actionable, so using the [log] with a messagePrinter to add more detail to * bug report more actionable, so using the [log] with a messagePrinter to add more detail to
* every log may do more to improve overall logging than adding more logs with this method. * every log may do more to improve overall logging than adding more logs with this method.
*/ */
fun log(tag: String, level: LogLevel, @CompileTimeConstant message: String) = @JvmOverloads
log(tag, level, { str1 = message }, { str1!! }) fun log(
tag: String,
level: LogLevel,
@CompileTimeConstant message: String,
exception: Throwable? = null,
) = log(tag, level, { str1 = message }, { str1!! }, exception)
/** /**
* You should call [log] instead of this method. * You should call [log] instead of this method.

View File

@@ -38,9 +38,11 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.log.dagger.KeyguardClockLog import com.android.systemui.log.dagger.KeyguardSmallClockLog
import com.android.systemui.log.dagger.KeyguardLargeClockLog
import com.android.systemui.plugins.ClockController import com.android.systemui.plugins.ClockController
import com.android.systemui.plugins.log.LogBuffer import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel.DEBUG
import com.android.systemui.shared.regionsampling.RegionSampler import com.android.systemui.shared.regionsampling.RegionSampler
import com.android.systemui.statusbar.policy.BatteryController import com.android.systemui.statusbar.policy.BatteryController
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback
@@ -73,16 +75,18 @@ open class ClockEventController @Inject constructor(
private val context: Context, private val context: Context,
@Main private val mainExecutor: Executor, @Main private val mainExecutor: Executor,
@Background private val bgExecutor: Executor, @Background private val bgExecutor: Executor,
@KeyguardClockLog private val logBuffer: LogBuffer?, @KeyguardSmallClockLog private val smallLogBuffer: LogBuffer?,
@KeyguardLargeClockLog private val largeLogBuffer: LogBuffer?,
private val featureFlags: FeatureFlags private val featureFlags: FeatureFlags
) { ) {
var clock: ClockController? = null var clock: ClockController? = null
set(value) { set(value) {
field = value field = value
if (value != null) { if (value != null) {
if (logBuffer != null) { smallLogBuffer?.log(TAG, DEBUG, {}, { "New Clock" })
value.setLogBuffer(logBuffer) value.smallClock.logBuffer = smallLogBuffer
} largeLogBuffer?.log(TAG, DEBUG, {}, { "New Clock" })
value.largeClock.logBuffer = largeLogBuffer
value.initialize(resources, dozeAmount, 0f) value.initialize(resources, dozeAmount, 0f)
updateRegionSamplers(value) updateRegionSamplers(value)
@@ -325,4 +329,8 @@ open class ClockEventController @Inject constructor(
} }
} }
} }
companion object {
private val TAG = ClockEventController::class.simpleName!!
}
} }

View File

@@ -7,7 +7,6 @@ import android.animation.ObjectAnimator;
import android.content.Context; import android.content.Context;
import android.graphics.Rect; import android.graphics.Rect;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
@@ -20,11 +19,15 @@ import com.android.keyguard.dagger.KeyguardStatusViewScope;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.animation.Interpolators; import com.android.systemui.animation.Interpolators;
import com.android.systemui.plugins.ClockController; import com.android.systemui.plugins.ClockController;
import com.android.systemui.plugins.log.LogBuffer;
import com.android.systemui.plugins.log.LogLevel;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import kotlin.Unit;
/** /**
* Switch to show plugin clock when plugin is connected, otherwise it will show default clock. * Switch to show plugin clock when plugin is connected, otherwise it will show default clock.
*/ */
@@ -87,6 +90,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
private int mClockSwitchYAmount; private int mClockSwitchYAmount;
@VisibleForTesting boolean mChildrenAreLaidOut = false; @VisibleForTesting boolean mChildrenAreLaidOut = false;
@VisibleForTesting boolean mAnimateOnLayout = true; @VisibleForTesting boolean mAnimateOnLayout = true;
private LogBuffer mLogBuffer = null;
public KeyguardClockSwitch(Context context, AttributeSet attrs) { public KeyguardClockSwitch(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
@@ -113,6 +117,14 @@ public class KeyguardClockSwitch extends RelativeLayout {
onDensityOrFontScaleChanged(); onDensityOrFontScaleChanged();
} }
public void setLogBuffer(LogBuffer logBuffer) {
mLogBuffer = logBuffer;
}
public LogBuffer getLogBuffer() {
return mLogBuffer;
}
void setClock(ClockController clock, int statusBarState) { void setClock(ClockController clock, int statusBarState) {
mClock = clock; mClock = clock;
@@ -121,12 +133,16 @@ public class KeyguardClockSwitch extends RelativeLayout {
mLargeClockFrame.removeAllViews(); mLargeClockFrame.removeAllViews();
if (clock == null) { if (clock == null) {
Log.e(TAG, "No clock being shown"); if (mLogBuffer != null) {
mLogBuffer.log(TAG, LogLevel.ERROR, "No clock being shown");
}
return; return;
} }
// Attach small and big clock views to hierarchy. // Attach small and big clock views to hierarchy.
Log.i(TAG, "Attached new clock views to switch"); if (mLogBuffer != null) {
mLogBuffer.log(TAG, LogLevel.INFO, "Attached new clock views to switch");
}
mSmallClockFrame.addView(clock.getSmallClock().getView()); mSmallClockFrame.addView(clock.getSmallClock().getView());
mLargeClockFrame.addView(clock.getLargeClock().getView()); mLargeClockFrame.addView(clock.getLargeClock().getView());
updateClockTargetRegions(); updateClockTargetRegions();
@@ -152,8 +168,18 @@ public class KeyguardClockSwitch extends RelativeLayout {
} }
private void updateClockViews(boolean useLargeClock, boolean animate) { private void updateClockViews(boolean useLargeClock, boolean animate) {
Log.i(TAG, "updateClockViews; useLargeClock=" + useLargeClock + "; animate=" + animate if (mLogBuffer != null) {
+ "; mChildrenAreLaidOut=" + mChildrenAreLaidOut); mLogBuffer.log(TAG, LogLevel.DEBUG, (msg) -> {
msg.setBool1(useLargeClock);
msg.setBool2(animate);
msg.setBool3(mChildrenAreLaidOut);
return Unit.INSTANCE;
}, (msg) -> "updateClockViews"
+ "; useLargeClock=" + msg.getBool1()
+ "; animate=" + msg.getBool2()
+ "; mChildrenAreLaidOut=" + msg.getBool3());
}
if (mClockInAnim != null) mClockInAnim.cancel(); if (mClockInAnim != null) mClockInAnim.cancel();
if (mClockOutAnim != null) mClockOutAnim.cancel(); if (mClockOutAnim != null) mClockOutAnim.cancel();
if (mStatusAreaAnim != null) mStatusAreaAnim.cancel(); if (mStatusAreaAnim != null) mStatusAreaAnim.cancel();
@@ -269,7 +295,9 @@ public class KeyguardClockSwitch extends RelativeLayout {
public void dump(PrintWriter pw, String[] args) { public void dump(PrintWriter pw, String[] args) {
pw.println("KeyguardClockSwitch:"); pw.println("KeyguardClockSwitch:");
pw.println(" mSmallClockFrame: " + mSmallClockFrame); pw.println(" mSmallClockFrame: " + mSmallClockFrame);
pw.println(" mSmallClockFrame.alpha: " + mSmallClockFrame.getAlpha());
pw.println(" mLargeClockFrame: " + mLargeClockFrame); pw.println(" mLargeClockFrame: " + mLargeClockFrame);
pw.println(" mLargeClockFrame.alpha: " + mLargeClockFrame.getAlpha());
pw.println(" mStatusArea: " + mStatusArea); pw.println(" mStatusArea: " + mStatusArea);
pw.println(" mDisplayedClockSize: " + mDisplayedClockSize); pw.println(" mDisplayedClockSize: " + mDisplayedClockSize);
} }

View File

@@ -38,8 +38,11 @@ import com.android.systemui.R;
import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager; import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.log.dagger.KeyguardClockLog;
import com.android.systemui.plugins.ClockAnimations; import com.android.systemui.plugins.ClockAnimations;
import com.android.systemui.plugins.ClockController; import com.android.systemui.plugins.ClockController;
import com.android.systemui.plugins.log.LogBuffer;
import com.android.systemui.plugins.log.LogLevel;
import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shared.clocks.ClockRegistry; import com.android.systemui.shared.clocks.ClockRegistry;
import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController; import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController;
@@ -62,6 +65,8 @@ import javax.inject.Inject;
*/ */
public class KeyguardClockSwitchController extends ViewController<KeyguardClockSwitch> public class KeyguardClockSwitchController extends ViewController<KeyguardClockSwitch>
implements Dumpable { implements Dumpable {
private static final String TAG = "KeyguardClockSwitchController";
private final StatusBarStateController mStatusBarStateController; private final StatusBarStateController mStatusBarStateController;
private final ClockRegistry mClockRegistry; private final ClockRegistry mClockRegistry;
private final KeyguardSliceViewController mKeyguardSliceViewController; private final KeyguardSliceViewController mKeyguardSliceViewController;
@@ -70,6 +75,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
private final SecureSettings mSecureSettings; private final SecureSettings mSecureSettings;
private final DumpManager mDumpManager; private final DumpManager mDumpManager;
private final ClockEventController mClockEventController; private final ClockEventController mClockEventController;
private final LogBuffer mLogBuffer;
private FrameLayout mSmallClockFrame; // top aligned clock private FrameLayout mSmallClockFrame; // top aligned clock
private FrameLayout mLargeClockFrame; // centered clock private FrameLayout mLargeClockFrame; // centered clock
@@ -119,7 +125,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
SecureSettings secureSettings, SecureSettings secureSettings,
@Main Executor uiExecutor, @Main Executor uiExecutor,
DumpManager dumpManager, DumpManager dumpManager,
ClockEventController clockEventController) { ClockEventController clockEventController,
@KeyguardClockLog LogBuffer logBuffer) {
super(keyguardClockSwitch); super(keyguardClockSwitch);
mStatusBarStateController = statusBarStateController; mStatusBarStateController = statusBarStateController;
mClockRegistry = clockRegistry; mClockRegistry = clockRegistry;
@@ -131,6 +138,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mKeyguardUnlockAnimationController = keyguardUnlockAnimationController; mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
mDumpManager = dumpManager; mDumpManager = dumpManager;
mClockEventController = clockEventController; mClockEventController = clockEventController;
mLogBuffer = logBuffer;
mView.setLogBuffer(mLogBuffer);
mClockChangedListener = () -> { mClockChangedListener = () -> {
setClock(mClockRegistry.createCurrentClock()); setClock(mClockRegistry.createCurrentClock());
@@ -378,6 +387,10 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
} }
private void setClock(ClockController clock) { private void setClock(ClockController clock) {
if (clock != null && mLogBuffer != null) {
mLogBuffer.log(TAG, LogLevel.INFO, "New Clock");
}
mClockEventController.setClock(clock); mClockEventController.setClock(clock);
mView.setClock(clock, mStatusBarStateController.getState()); mView.setClock(clock, mStatusBarStateController.getState());
} }

View File

@@ -17,36 +17,46 @@
package com.android.keyguard.logging package com.android.keyguard.logging
import com.android.systemui.log.dagger.KeyguardLog import com.android.systemui.log.dagger.KeyguardLog
import com.android.systemui.plugins.log.ConstantStringsLogger
import com.android.systemui.plugins.log.ConstantStringsLoggerImpl
import com.android.systemui.plugins.log.LogBuffer import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel.DEBUG import com.android.systemui.plugins.log.LogLevel
import com.android.systemui.plugins.log.LogLevel.ERROR
import com.android.systemui.plugins.log.LogLevel.INFO
import com.android.systemui.plugins.log.LogLevel.VERBOSE
import com.google.errorprone.annotations.CompileTimeConstant import com.google.errorprone.annotations.CompileTimeConstant
import javax.inject.Inject import javax.inject.Inject
private const val TAG = "KeyguardLog" private const val BIO_TAG = "KeyguardLog"
/** /**
* Generic logger for keyguard that's wrapping [LogBuffer]. This class should be used for adding * Generic logger for keyguard that's wrapping [LogBuffer]. This class should be used for adding
* temporary logs or logs for smaller classes when creating whole new [LogBuffer] wrapper might be * temporary logs or logs for smaller classes when creating whole new [LogBuffer] wrapper might be
* an overkill. * an overkill.
*/ */
class KeyguardLogger @Inject constructor(@KeyguardLog val buffer: LogBuffer) : class KeyguardLogger
ConstantStringsLogger by ConstantStringsLoggerImpl(buffer, TAG) { @Inject
constructor(
@KeyguardLog val buffer: LogBuffer,
) {
@JvmOverloads
fun log(
tag: String,
level: LogLevel,
@CompileTimeConstant msg: String,
ex: Throwable? = null,
) = buffer.log(tag, level, msg, ex)
fun logException(ex: Exception, @CompileTimeConstant logMsg: String) { fun log(
buffer.log(TAG, ERROR, {}, { logMsg }, exception = ex) tag: String,
} level: LogLevel,
@CompileTimeConstant msg: String,
fun v(msg: String, arg: Any) { arg: Any,
buffer.log(TAG, VERBOSE, { str1 = arg.toString() }, { "$msg: $str1" }) ) {
} buffer.log(
tag,
fun i(msg: String, arg: Any) { level,
buffer.log(TAG, INFO, { str1 = arg.toString() }, { "$msg: $str1" }) {
str1 = msg
str2 = arg.toString()
},
{ "$str1: $str2" }
)
} }
@JvmOverloads @JvmOverloads
@@ -56,8 +66,8 @@ class KeyguardLogger @Inject constructor(@KeyguardLog val buffer: LogBuffer) :
msg: String? = null msg: String? = null
) { ) {
buffer.log( buffer.log(
TAG, BIO_TAG,
DEBUG, LogLevel.DEBUG,
{ {
str1 = context str1 = context
str2 = "$msgId" str2 = "$msgId"

View File

@@ -19,11 +19,14 @@ package com.android.systemui.keyguard.domain.interactor
import com.android.keyguard.logging.KeyguardLogger import com.android.keyguard.logging.KeyguardLogger
import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.plugins.log.LogLevel.VERBOSE
import javax.inject.Inject import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
private val TAG = KeyguardTransitionAuditLogger::class.simpleName!!
/** Collect flows of interest for auditing keyguard transitions. */ /** Collect flows of interest for auditing keyguard transitions. */
@SysUISingleton @SysUISingleton
class KeyguardTransitionAuditLogger class KeyguardTransitionAuditLogger
@@ -37,35 +40,47 @@ constructor(
fun start() { fun start() {
scope.launch { scope.launch {
keyguardInteractor.wakefulnessModel.collect { logger.v("WakefulnessModel", it) } keyguardInteractor.wakefulnessModel.collect {
logger.log(TAG, VERBOSE, "WakefulnessModel", it)
}
} }
scope.launch { scope.launch {
keyguardInteractor.isBouncerShowing.collect { logger.v("Bouncer showing", it) } keyguardInteractor.isBouncerShowing.collect {
logger.log(TAG, VERBOSE, "Bouncer showing", it)
}
} }
scope.launch { keyguardInteractor.isDozing.collect { logger.v("isDozing", it) } } scope.launch {
keyguardInteractor.isDozing.collect { logger.log(TAG, VERBOSE, "isDozing", it) }
}
scope.launch { keyguardInteractor.isDreaming.collect { logger.v("isDreaming", it) } } scope.launch {
keyguardInteractor.isDreaming.collect { logger.log(TAG, VERBOSE, "isDreaming", it) }
}
scope.launch { scope.launch {
interactor.finishedKeyguardTransitionStep.collect { interactor.finishedKeyguardTransitionStep.collect {
logger.i("Finished transition", it) logger.log(TAG, VERBOSE, "Finished transition", it)
} }
} }
scope.launch { scope.launch {
interactor.canceledKeyguardTransitionStep.collect { interactor.canceledKeyguardTransitionStep.collect {
logger.i("Canceled transition", it) logger.log(TAG, VERBOSE, "Canceled transition", it)
} }
} }
scope.launch { scope.launch {
interactor.startedKeyguardTransitionStep.collect { logger.i("Started transition", it) } interactor.startedKeyguardTransitionStep.collect {
logger.log(TAG, VERBOSE, "Started transition", it)
}
} }
scope.launch { scope.launch {
keyguardInteractor.dozeTransitionModel.collect { logger.i("Doze transition", it) } keyguardInteractor.dozeTransitionModel.collect {
logger.log(TAG, VERBOSE, "Doze transition", it)
}
} }
} }
} }

View File

@@ -23,3 +23,15 @@ import javax.inject.Qualifier
@MustBeDocumented @MustBeDocumented
@Retention(AnnotationRetention.RUNTIME) @Retention(AnnotationRetention.RUNTIME)
annotation class KeyguardClockLog annotation class KeyguardClockLog
/** A [com.android.systemui.plugins.log.LogBuffer] for small keyguard clock logs. */
@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class KeyguardSmallClockLog
/** A [com.android.systemui.plugins.log.LogBuffer] for large keyguard clock logs. */
@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class KeyguardLargeClockLog

View File

@@ -335,13 +335,33 @@ public class LogModule {
} }
/** /**
* Provides a {@link LogBuffer} for keyguard clock logs. * Provides a {@link LogBuffer} for general keyguard clock logs.
*/ */
@Provides @Provides
@SysUISingleton @SysUISingleton
@KeyguardClockLog @KeyguardClockLog
public static LogBuffer provideKeyguardClockLog(LogBufferFactory factory) { public static LogBuffer provideKeyguardClockLog(LogBufferFactory factory) {
return factory.create("KeyguardClockLog", 500); return factory.create("KeyguardClockLog", 100);
}
/**
* Provides a {@link LogBuffer} for keyguard small clock logs.
*/
@Provides
@SysUISingleton
@KeyguardSmallClockLog
public static LogBuffer provideKeyguardSmallClockLog(LogBufferFactory factory) {
return factory.create("KeyguardSmallClockLog", 100);
}
/**
* Provides a {@link LogBuffer} for keyguard large clock logs.
*/
@Provides
@SysUISingleton
@KeyguardLargeClockLog
public static LogBuffer provideKeyguardLargeClockLog(LogBufferFactory factory) {
return factory.create("KeyguardLargeClockLog", 100);
} }
/** /**

View File

@@ -41,6 +41,7 @@ import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewCont
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_USER_LOCKED; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_USER_LOCKED;
import static com.android.systemui.keyguard.ScreenLifecycle.SCREEN_ON; import static com.android.systemui.keyguard.ScreenLifecycle.SCREEN_ON;
import static com.android.systemui.plugins.FalsingManager.LOW_PENALTY; import static com.android.systemui.plugins.FalsingManager.LOW_PENALTY;
import static com.android.systemui.plugins.log.LogLevel.ERROR;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@@ -1028,7 +1029,7 @@ public class KeyguardIndicationController {
mChargingTimeRemaining = mPowerPluggedIn mChargingTimeRemaining = mPowerPluggedIn
? mBatteryInfo.computeChargeTimeRemaining() : -1; ? mBatteryInfo.computeChargeTimeRemaining() : -1;
} catch (RemoteException e) { } catch (RemoteException e) {
mKeyguardLogger.logException(e, "Error calling IBatteryStats"); mKeyguardLogger.log(TAG, ERROR, "Error calling IBatteryStats", e);
mChargingTimeRemaining = -1; mChargingTimeRemaining = -1;
} }
updateDeviceEntryIndication(!wasPluggedIn && mPowerPluggedInWired); updateDeviceEntryIndication(!wasPluggedIn && mPowerPluggedInWired);

View File

@@ -45,6 +45,7 @@ import com.android.systemui.R;
import com.android.systemui.animation.Interpolators; import com.android.systemui.animation.Interpolators;
import com.android.systemui.battery.BatteryMeterViewController; import com.android.systemui.battery.BatteryMeterViewController;
import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.log.LogLevel;
import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shade.NotificationPanelViewController; import com.android.systemui.shade.NotificationPanelViewController;
import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.CommandQueue;
@@ -76,6 +77,7 @@ import javax.inject.Inject;
/** View Controller for {@link com.android.systemui.statusbar.phone.KeyguardStatusBarView}. */ /** View Controller for {@link com.android.systemui.statusbar.phone.KeyguardStatusBarView}. */
public class KeyguardStatusBarViewController extends ViewController<KeyguardStatusBarView> { public class KeyguardStatusBarViewController extends ViewController<KeyguardStatusBarView> {
private static final String TAG = "KeyguardStatusBarViewController";
private static final AnimationProperties KEYGUARD_HUN_PROPERTIES = private static final AnimationProperties KEYGUARD_HUN_PROPERTIES =
new AnimationProperties().setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD); new AnimationProperties().setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
@@ -422,7 +424,7 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
/** Animate the keyguard status bar in. */ /** Animate the keyguard status bar in. */
public void animateKeyguardStatusBarIn() { public void animateKeyguardStatusBarIn() {
mLogger.d("animating status bar in"); mLogger.log(TAG, LogLevel.DEBUG, "animating status bar in");
if (mDisableStateTracker.isDisabled()) { if (mDisableStateTracker.isDisabled()) {
// If our view is disabled, don't allow us to animate in. // If our view is disabled, don't allow us to animate in.
return; return;
@@ -438,7 +440,7 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
/** Animate the keyguard status bar out. */ /** Animate the keyguard status bar out. */
public void animateKeyguardStatusBarOut(long startDelay, long duration) { public void animateKeyguardStatusBarOut(long startDelay, long duration) {
mLogger.d("animating status bar out"); mLogger.log(TAG, LogLevel.DEBUG, "animating status bar out");
ValueAnimator anim = ValueAnimator.ofFloat(mView.getAlpha(), 0f); ValueAnimator anim = ValueAnimator.ofFloat(mView.getAlpha(), 0f);
anim.addUpdateListener(mAnimatorUpdateListener); anim.addUpdateListener(mAnimatorUpdateListener);
anim.setStartDelay(startDelay); anim.setStartDelay(startDelay);

View File

@@ -84,7 +84,8 @@ class ClockEventControllerTest : SysuiTestCase() {
@Mock private lateinit var transitionRepository: KeyguardTransitionRepository @Mock private lateinit var transitionRepository: KeyguardTransitionRepository
@Mock private lateinit var commandQueue: CommandQueue @Mock private lateinit var commandQueue: CommandQueue
private lateinit var repository: FakeKeyguardRepository private lateinit var repository: FakeKeyguardRepository
@Mock private lateinit var logBuffer: LogBuffer @Mock private lateinit var smallLogBuffer: LogBuffer
@Mock private lateinit var largeLogBuffer: LogBuffer
private lateinit var underTest: ClockEventController private lateinit var underTest: ClockEventController
@Before @Before
@@ -111,7 +112,8 @@ class ClockEventControllerTest : SysuiTestCase() {
context, context,
mainExecutor, mainExecutor,
bgExecutor, bgExecutor,
logBuffer, smallLogBuffer,
largeLogBuffer,
featureFlags featureFlags
) )
underTest.clock = clock underTest.clock = clock

View File

@@ -48,6 +48,7 @@ import com.android.systemui.plugins.ClockAnimations;
import com.android.systemui.plugins.ClockController; import com.android.systemui.plugins.ClockController;
import com.android.systemui.plugins.ClockEvents; import com.android.systemui.plugins.ClockEvents;
import com.android.systemui.plugins.ClockFaceController; import com.android.systemui.plugins.ClockFaceController;
import com.android.systemui.plugins.log.LogBuffer;
import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shared.clocks.AnimatableClockView; import com.android.systemui.shared.clocks.AnimatableClockView;
import com.android.systemui.shared.clocks.ClockRegistry; import com.android.systemui.shared.clocks.ClockRegistry;
@@ -115,6 +116,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
private FrameLayout mLargeClockFrame; private FrameLayout mLargeClockFrame;
@Mock @Mock
private SecureSettings mSecureSettings; private SecureSettings mSecureSettings;
@Mock
private LogBuffer mLogBuffer;
private final View mFakeSmartspaceView = new View(mContext); private final View mFakeSmartspaceView = new View(mContext);
@@ -156,7 +159,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
mSecureSettings, mSecureSettings,
mExecutor, mExecutor,
mDumpManager, mDumpManager,
mClockEventController mClockEventController,
mLogBuffer
); );
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE); when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);