Merge "Adding general KeyguardLogger and more logs to keyguard status bar" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
85d4d0912c
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* 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.keyguard.logging
|
||||||
|
|
||||||
|
import com.android.systemui.log.LogBuffer
|
||||||
|
import com.android.systemui.log.LogLevel
|
||||||
|
import com.android.systemui.log.LogLevel.DEBUG
|
||||||
|
import com.android.systemui.log.LogLevel.ERROR
|
||||||
|
import com.android.systemui.log.LogLevel.VERBOSE
|
||||||
|
import com.android.systemui.log.LogLevel.WARNING
|
||||||
|
import com.android.systemui.log.MessageInitializer
|
||||||
|
import com.android.systemui.log.MessagePrinter
|
||||||
|
import com.android.systemui.log.dagger.KeyguardLog
|
||||||
|
import com.google.errorprone.annotations.CompileTimeConstant
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
private const val TAG = "KeyguardLog"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* an overkill.
|
||||||
|
*/
|
||||||
|
class KeyguardLogger @Inject constructor(@KeyguardLog private val buffer: LogBuffer) {
|
||||||
|
fun d(@CompileTimeConstant msg: String) = log(msg, DEBUG)
|
||||||
|
|
||||||
|
fun e(@CompileTimeConstant msg: String) = log(msg, ERROR)
|
||||||
|
|
||||||
|
fun v(@CompileTimeConstant msg: String) = log(msg, VERBOSE)
|
||||||
|
|
||||||
|
fun w(@CompileTimeConstant msg: String) = log(msg, WARNING)
|
||||||
|
|
||||||
|
fun log(msg: String, level: LogLevel) = buffer.log(TAG, level, msg)
|
||||||
|
|
||||||
|
private fun debugLog(messageInitializer: MessageInitializer, messagePrinter: MessagePrinter) {
|
||||||
|
buffer.log(TAG, DEBUG, messageInitializer, messagePrinter)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove after b/237743330 is fixed
|
||||||
|
fun logStatusBarCalculatedAlpha(alpha: Float) {
|
||||||
|
debugLog({ double1 = alpha.toDouble() }, { "Calculated new alpha: $double1" })
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove after b/237743330 is fixed
|
||||||
|
fun logStatusBarExplicitAlpha(alpha: Float) {
|
||||||
|
debugLog({ double1 = alpha.toDouble() }, { "new mExplicitAlpha value: $double1" })
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove after b/237743330 is fixed
|
||||||
|
fun logStatusBarAlphaVisibility(visibility: Int, alpha: Float, state: String) {
|
||||||
|
debugLog(
|
||||||
|
{
|
||||||
|
int1 = visibility
|
||||||
|
double1 = alpha.toDouble()
|
||||||
|
str1 = state
|
||||||
|
},
|
||||||
|
{ "changing visibility to $int1 with alpha $double1 in state: $str1" }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -45,7 +45,7 @@ class KeyguardUpdateMonitorLogger @Inject constructor(
|
|||||||
|
|
||||||
fun e(@CompileTimeConstant msg: String) = log(msg, ERROR)
|
fun e(@CompileTimeConstant msg: String) = log(msg, ERROR)
|
||||||
|
|
||||||
fun v(@CompileTimeConstant msg: String) = log(msg, ERROR)
|
fun v(@CompileTimeConstant msg: String) = log(msg, VERBOSE)
|
||||||
|
|
||||||
fun w(@CompileTimeConstant msg: String) = log(msg, WARNING)
|
fun w(@CompileTimeConstant msg: String) = log(msg, WARNING)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.android.systemui.log.dagger
|
||||||
|
|
||||||
|
import javax.inject.Qualifier
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [com.android.systemui.log.LogBuffer] for keyguard-related stuff. Should be used mostly for
|
||||||
|
* adding temporary logs or logging from smaller classes when creating new separate log class might
|
||||||
|
* be an overkill.
|
||||||
|
*/
|
||||||
|
@Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class KeyguardLog
|
||||||
@@ -334,4 +334,14 @@ public class LogModule {
|
|||||||
public static LogBuffer providerBluetoothLogBuffer(LogBufferFactory factory) {
|
public static LogBuffer providerBluetoothLogBuffer(LogBufferFactory factory) {
|
||||||
return factory.create("BluetoothLog", 50);
|
return factory.create("BluetoothLog", 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a {@link LogBuffer} for general keyguard-related logs.
|
||||||
|
*/
|
||||||
|
@Provides
|
||||||
|
@SysUISingleton
|
||||||
|
@KeyguardLog
|
||||||
|
public static LogBuffer provideKeyguardLogBuffer(LogBufferFactory factory) {
|
||||||
|
return factory.create("KeyguardLog", 250);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4696,6 +4696,8 @@ public final class NotificationPanelViewController extends PanelViewController {
|
|||||||
if (!animatingUnlockedShadeToKeyguard) {
|
if (!animatingUnlockedShadeToKeyguard) {
|
||||||
// Only make the status bar visible if we're not animating the screen off, since
|
// Only make the status bar visible if we're not animating the screen off, since
|
||||||
// we only want to be showing the clock/notifications during the animation.
|
// we only want to be showing the clock/notifications during the animation.
|
||||||
|
mShadeLog.v("Updating keyguard status bar state to "
|
||||||
|
+ (keyguardShowing ? "visible" : "invisible"));
|
||||||
mKeyguardStatusBarViewController.updateViewState(
|
mKeyguardStatusBarViewController.updateViewState(
|
||||||
/* alpha= */ 1f,
|
/* alpha= */ 1f,
|
||||||
keyguardShowing ? View.VISIBLE : View.INVISIBLE);
|
keyguardShowing ? View.VISIBLE : View.INVISIBLE);
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
import com.android.keyguard.CarrierTextController;
|
import com.android.keyguard.CarrierTextController;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||||
|
import com.android.keyguard.logging.KeyguardLogger;
|
||||||
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.battery.BatteryMeterViewController;
|
import com.android.systemui.battery.BatteryMeterViewController;
|
||||||
@@ -116,6 +117,7 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
private final CommandQueue mCommandQueue;
|
private final CommandQueue mCommandQueue;
|
||||||
private final Executor mMainExecutor;
|
private final Executor mMainExecutor;
|
||||||
private final Object mLock = new Object();
|
private final Object mLock = new Object();
|
||||||
|
private final KeyguardLogger mLogger;
|
||||||
|
|
||||||
private final ConfigurationController.ConfigurationListener mConfigurationListener =
|
private final ConfigurationController.ConfigurationListener mConfigurationListener =
|
||||||
new ConfigurationController.ConfigurationListener() {
|
new ConfigurationController.ConfigurationListener() {
|
||||||
@@ -279,7 +281,8 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
StatusBarUserInfoTracker statusBarUserInfoTracker,
|
StatusBarUserInfoTracker statusBarUserInfoTracker,
|
||||||
SecureSettings secureSettings,
|
SecureSettings secureSettings,
|
||||||
CommandQueue commandQueue,
|
CommandQueue commandQueue,
|
||||||
@Main Executor mainExecutor
|
@Main Executor mainExecutor,
|
||||||
|
KeyguardLogger logger
|
||||||
) {
|
) {
|
||||||
super(view);
|
super(view);
|
||||||
mCarrierTextController = carrierTextController;
|
mCarrierTextController = carrierTextController;
|
||||||
@@ -304,6 +307,7 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
mSecureSettings = secureSettings;
|
mSecureSettings = secureSettings;
|
||||||
mCommandQueue = commandQueue;
|
mCommandQueue = commandQueue;
|
||||||
mMainExecutor = mainExecutor;
|
mMainExecutor = mainExecutor;
|
||||||
|
mLogger = logger;
|
||||||
|
|
||||||
mFirstBypassAttempt = mKeyguardBypassController.getBypassEnabled();
|
mFirstBypassAttempt = mKeyguardBypassController.getBypassEnabled();
|
||||||
mKeyguardStateController.addCallback(
|
mKeyguardStateController.addCallback(
|
||||||
@@ -430,6 +434,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");
|
||||||
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;
|
||||||
@@ -445,6 +450,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");
|
||||||
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);
|
||||||
@@ -481,6 +487,9 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
newAlpha = Math.min(getKeyguardContentsAlpha(), alphaQsExpansion)
|
newAlpha = Math.min(getKeyguardContentsAlpha(), alphaQsExpansion)
|
||||||
* mKeyguardStatusBarAnimateAlpha
|
* mKeyguardStatusBarAnimateAlpha
|
||||||
* (1.0f - mKeyguardHeadsUpShowingAmount);
|
* (1.0f - mKeyguardHeadsUpShowingAmount);
|
||||||
|
if (newAlpha != mView.getAlpha() && (newAlpha == 0 || newAlpha == 1)) {
|
||||||
|
mLogger.logStatusBarCalculatedAlpha(newAlpha);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hideForBypass =
|
boolean hideForBypass =
|
||||||
@@ -503,6 +512,10 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
if (mDisableStateTracker.isDisabled()) {
|
if (mDisableStateTracker.isDisabled()) {
|
||||||
visibility = View.INVISIBLE;
|
visibility = View.INVISIBLE;
|
||||||
}
|
}
|
||||||
|
if (visibility != mView.getVisibility()) {
|
||||||
|
mLogger.logStatusBarAlphaVisibility(visibility, alpha,
|
||||||
|
StatusBarState.toString(mStatusBarState));
|
||||||
|
}
|
||||||
mView.setAlpha(alpha);
|
mView.setAlpha(alpha);
|
||||||
mView.setVisibility(visibility);
|
mView.setVisibility(visibility);
|
||||||
}
|
}
|
||||||
@@ -596,6 +609,8 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
pw.println("KeyguardStatusBarView:");
|
pw.println("KeyguardStatusBarView:");
|
||||||
pw.println(" mBatteryListening: " + mBatteryListening);
|
pw.println(" mBatteryListening: " + mBatteryListening);
|
||||||
pw.println(" mExplicitAlpha: " + mExplicitAlpha);
|
pw.println(" mExplicitAlpha: " + mExplicitAlpha);
|
||||||
|
pw.println(" alpha: " + mView.getAlpha());
|
||||||
|
pw.println(" visibility: " + mView.getVisibility());
|
||||||
mView.dump(pw, args);
|
mView.dump(pw, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -605,6 +620,10 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
* @param alpha a value between 0 and 1. -1 if the value is to be reset/ignored.
|
* @param alpha a value between 0 and 1. -1 if the value is to be reset/ignored.
|
||||||
*/
|
*/
|
||||||
public void setAlpha(float alpha) {
|
public void setAlpha(float alpha) {
|
||||||
|
if (mExplicitAlpha != alpha && (mExplicitAlpha == -1 || alpha == -1)) {
|
||||||
|
// logged if value changed to ignored or from ignored
|
||||||
|
mLogger.logStatusBarExplicitAlpha(alpha);
|
||||||
|
}
|
||||||
mExplicitAlpha = alpha;
|
mExplicitAlpha = alpha;
|
||||||
updateViewState();
|
updateViewState();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import androidx.test.filters.SmallTest;
|
|||||||
import com.android.keyguard.CarrierTextController;
|
import com.android.keyguard.CarrierTextController;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||||
|
import com.android.keyguard.logging.KeyguardLogger;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.battery.BatteryMeterViewController;
|
import com.android.systemui.battery.BatteryMeterViewController;
|
||||||
@@ -123,6 +124,7 @@ public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
|
|||||||
private StatusBarUserInfoTracker mStatusBarUserInfoTracker;
|
private StatusBarUserInfoTracker mStatusBarUserInfoTracker;
|
||||||
@Mock private SecureSettings mSecureSettings;
|
@Mock private SecureSettings mSecureSettings;
|
||||||
@Mock private CommandQueue mCommandQueue;
|
@Mock private CommandQueue mCommandQueue;
|
||||||
|
@Mock private KeyguardLogger mLogger;
|
||||||
|
|
||||||
private TestNotificationPanelViewStateProvider mNotificationPanelViewStateProvider;
|
private TestNotificationPanelViewStateProvider mNotificationPanelViewStateProvider;
|
||||||
private KeyguardStatusBarView mKeyguardStatusBarView;
|
private KeyguardStatusBarView mKeyguardStatusBarView;
|
||||||
@@ -172,7 +174,8 @@ public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
|
|||||||
mStatusBarUserInfoTracker,
|
mStatusBarUserInfoTracker,
|
||||||
mSecureSettings,
|
mSecureSettings,
|
||||||
mCommandQueue,
|
mCommandQueue,
|
||||||
mFakeExecutor
|
mFakeExecutor,
|
||||||
|
mLogger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user