Merge "Migrate KeyguardIndicationController to use LogBuffer" into tm-qpr-dev am: d7d2d977a6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20402427

Change-Id: Idc63a77194ef125b6e94ea96e2ddf024d203611f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-11-14 16:39:32 +00:00
committed by Automerger Merge Worker
3 changed files with 54 additions and 33 deletions

View File

@@ -18,14 +18,11 @@ 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.LogBuffer import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel
import com.android.systemui.plugins.log.LogLevel.DEBUG import com.android.systemui.plugins.log.LogLevel.DEBUG
import com.android.systemui.plugins.log.LogLevel.ERROR import com.android.systemui.plugins.log.LogLevel.ERROR
import com.android.systemui.plugins.log.LogLevel.INFO import com.android.systemui.plugins.log.LogLevel.INFO
import com.android.systemui.plugins.log.LogLevel.VERBOSE import com.android.systemui.plugins.log.LogLevel.VERBOSE
import com.android.systemui.plugins.log.LogLevel.WARNING import com.android.systemui.plugins.log.LogLevel.WARNING
import com.android.systemui.plugins.log.MessageInitializer
import com.android.systemui.plugins.log.MessagePrinter
import com.google.errorprone.annotations.CompileTimeConstant import com.google.errorprone.annotations.CompileTimeConstant
import javax.inject.Inject import javax.inject.Inject
@@ -37,18 +34,16 @@ private const val TAG = "KeyguardLog"
* an overkill. * an overkill.
*/ */
class KeyguardLogger @Inject constructor(@KeyguardLog private val buffer: LogBuffer) { class KeyguardLogger @Inject constructor(@KeyguardLog private val buffer: LogBuffer) {
fun d(@CompileTimeConstant msg: String) = log(msg, DEBUG) fun d(@CompileTimeConstant msg: String) = buffer.log(TAG, DEBUG, msg)
fun e(@CompileTimeConstant msg: String) = log(msg, ERROR) fun e(@CompileTimeConstant msg: String) = buffer.log(TAG, ERROR, msg)
fun v(@CompileTimeConstant msg: String) = log(msg, VERBOSE) fun v(@CompileTimeConstant msg: String) = buffer.log(TAG, VERBOSE, msg)
fun w(@CompileTimeConstant msg: String) = log(msg, WARNING) fun w(@CompileTimeConstant msg: String) = buffer.log(TAG, WARNING, msg)
fun log(msg: String, level: LogLevel) = buffer.log(TAG, level, msg) fun logException(ex: Exception, @CompileTimeConstant logMsg: String) {
buffer.log(TAG, ERROR, {}, { logMsg }, exception = ex)
private fun debugLog(messageInitializer: MessageInitializer, messagePrinter: MessagePrinter) {
buffer.log(TAG, DEBUG, messageInitializer, messagePrinter)
} }
fun v(msg: String, arg: Any) { fun v(msg: String, arg: Any) {
@@ -61,17 +56,24 @@ class KeyguardLogger @Inject constructor(@KeyguardLog private val buffer: LogBuf
// TODO: remove after b/237743330 is fixed // TODO: remove after b/237743330 is fixed
fun logStatusBarCalculatedAlpha(alpha: Float) { fun logStatusBarCalculatedAlpha(alpha: Float) {
debugLog({ double1 = alpha.toDouble() }, { "Calculated new alpha: $double1" }) buffer.log(TAG, DEBUG, { double1 = alpha.toDouble() }, { "Calculated new alpha: $double1" })
} }
// TODO: remove after b/237743330 is fixed // TODO: remove after b/237743330 is fixed
fun logStatusBarExplicitAlpha(alpha: Float) { fun logStatusBarExplicitAlpha(alpha: Float) {
debugLog({ double1 = alpha.toDouble() }, { "new mExplicitAlpha value: $double1" }) buffer.log(
TAG,
DEBUG,
{ double1 = alpha.toDouble() },
{ "new mExplicitAlpha value: $double1" }
)
} }
// TODO: remove after b/237743330 is fixed // TODO: remove after b/237743330 is fixed
fun logStatusBarAlphaVisibility(visibility: Int, alpha: Float, state: String) { fun logStatusBarAlphaVisibility(visibility: Int, alpha: Float, state: String) {
debugLog( buffer.log(
TAG,
DEBUG,
{ {
int1 = visibility int1 = visibility
double1 = alpha.toDouble() double1 = alpha.toDouble()
@@ -80,4 +82,22 @@ class KeyguardLogger @Inject constructor(@KeyguardLog private val buffer: LogBuf
{ "changing visibility to $int1 with alpha $double1 in state: $str1" } { "changing visibility to $int1 with alpha $double1 in state: $str1" }
) )
} }
@JvmOverloads
fun logBiometricMessage(
@CompileTimeConstant context: String,
msgId: Int? = null,
msg: String? = null
) {
buffer.log(
TAG,
DEBUG,
{
str1 = context
str2 = "$msgId"
str3 = msg
},
{ "$str1 msgId: $str2 msg: $str3" }
)
}
} }

View File

@@ -55,7 +55,6 @@ import android.hardware.biometrics.BiometricSourceType;
import android.hardware.face.FaceManager; import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager; import android.hardware.fingerprint.FingerprintManager;
import android.os.BatteryManager; import android.os.BatteryManager;
import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
@@ -64,7 +63,6 @@ import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.format.Formatter; import android.text.format.Formatter;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
@@ -76,6 +74,7 @@ import com.android.internal.app.IBatteryStats;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
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.settingslib.Utils; import com.android.settingslib.Utils;
import com.android.settingslib.fuelgauge.BatteryStatus; import com.android.settingslib.fuelgauge.BatteryStatus;
import com.android.systemui.R; import com.android.systemui.R;
@@ -123,7 +122,6 @@ public class KeyguardIndicationController {
private static final String TAG = "KeyguardIndication"; private static final String TAG = "KeyguardIndication";
private static final boolean DEBUG_CHARGING_SPEED = false; private static final boolean DEBUG_CHARGING_SPEED = false;
private static final boolean DEBUG = Build.IS_DEBUGGABLE;
private static final int MSG_HIDE_TRANSIENT = 1; private static final int MSG_HIDE_TRANSIENT = 1;
private static final int MSG_SHOW_ACTION_TO_UNLOCK = 2; private static final int MSG_SHOW_ACTION_TO_UNLOCK = 2;
@@ -139,6 +137,7 @@ public class KeyguardIndicationController {
protected final StatusBarStateController mStatusBarStateController; protected final StatusBarStateController mStatusBarStateController;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final AuthController mAuthController; private final AuthController mAuthController;
private final KeyguardLogger mKeyguardLogger;
private ViewGroup mIndicationArea; private ViewGroup mIndicationArea;
private KeyguardIndicationTextView mTopIndicationView; private KeyguardIndicationTextView mTopIndicationView;
private KeyguardIndicationTextView mLockScreenIndicationView; private KeyguardIndicationTextView mLockScreenIndicationView;
@@ -229,7 +228,8 @@ public class KeyguardIndicationController {
ScreenLifecycle screenLifecycle, ScreenLifecycle screenLifecycle,
KeyguardBypassController keyguardBypassController, KeyguardBypassController keyguardBypassController,
AccessibilityManager accessibilityManager, AccessibilityManager accessibilityManager,
FaceHelpMessageDeferral faceHelpMessageDeferral) { FaceHelpMessageDeferral faceHelpMessageDeferral,
KeyguardLogger keyguardLogger) {
mContext = context; mContext = context;
mBroadcastDispatcher = broadcastDispatcher; mBroadcastDispatcher = broadcastDispatcher;
mDevicePolicyManager = devicePolicyManager; mDevicePolicyManager = devicePolicyManager;
@@ -249,6 +249,7 @@ public class KeyguardIndicationController {
mKeyguardBypassController = keyguardBypassController; mKeyguardBypassController = keyguardBypassController;
mAccessibilityManager = accessibilityManager; mAccessibilityManager = accessibilityManager;
mScreenLifecycle = screenLifecycle; mScreenLifecycle = screenLifecycle;
mKeyguardLogger = keyguardLogger;
mScreenLifecycle.addObserver(mScreenObserver); mScreenLifecycle.addObserver(mScreenObserver);
mFaceAcquiredMessageDeferral = faceHelpMessageDeferral; mFaceAcquiredMessageDeferral = faceHelpMessageDeferral;
@@ -1024,7 +1025,7 @@ public class KeyguardIndicationController {
mChargingTimeRemaining = mPowerPluggedIn mChargingTimeRemaining = mPowerPluggedIn
? mBatteryInfo.computeChargeTimeRemaining() : -1; ? mBatteryInfo.computeChargeTimeRemaining() : -1;
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling IBatteryStats: ", e); mKeyguardLogger.logException(e, "Error calling IBatteryStats");
mChargingTimeRemaining = -1; mChargingTimeRemaining = -1;
} }
updateDeviceEntryIndication(!wasPluggedIn && mPowerPluggedInWired); updateDeviceEntryIndication(!wasPluggedIn && mPowerPluggedInWired);
@@ -1072,8 +1073,10 @@ public class KeyguardIndicationController {
final boolean isCoExFaceAcquisitionMessage = final boolean isCoExFaceAcquisitionMessage =
faceAuthSoftError && isUnlockWithFingerprintPossible; faceAuthSoftError && isUnlockWithFingerprintPossible;
if (isCoExFaceAcquisitionMessage && !mCoExFaceAcquisitionMsgIdsToShow.contains(msgId)) { if (isCoExFaceAcquisitionMessage && !mCoExFaceAcquisitionMsgIdsToShow.contains(msgId)) {
debugLog("skip showing msgId=" + msgId + " helpString=" + helpString mKeyguardLogger.logBiometricMessage(
+ ", due to co-ex logic"); "skipped showing help message due to co-ex logic",
msgId,
helpString);
} else if (mStatusBarKeyguardViewManager.isBouncerShowing()) { } else if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
mStatusBarKeyguardViewManager.setKeyguardMessage(helpString, mStatusBarKeyguardViewManager.setKeyguardMessage(helpString,
mInitialTextColorState); mInitialTextColorState);
@@ -1131,7 +1134,7 @@ public class KeyguardIndicationController {
CharSequence deferredFaceMessage = mFaceAcquiredMessageDeferral.getDeferredMessage(); CharSequence deferredFaceMessage = mFaceAcquiredMessageDeferral.getDeferredMessage();
mFaceAcquiredMessageDeferral.reset(); mFaceAcquiredMessageDeferral.reset();
if (shouldSuppressFaceError(msgId, mKeyguardUpdateMonitor)) { if (shouldSuppressFaceError(msgId, mKeyguardUpdateMonitor)) {
debugLog("suppressingFaceError msgId=" + msgId + " errString= " + errString); mKeyguardLogger.logBiometricMessage("suppressingFaceError", msgId, errString);
return; return;
} }
if (msgId == FaceManager.FACE_ERROR_TIMEOUT) { if (msgId == FaceManager.FACE_ERROR_TIMEOUT) {
@@ -1145,8 +1148,9 @@ public class KeyguardIndicationController {
private void onFingerprintAuthError(int msgId, String errString) { private void onFingerprintAuthError(int msgId, String errString) {
if (shouldSuppressFingerprintError(msgId, mKeyguardUpdateMonitor)) { if (shouldSuppressFingerprintError(msgId, mKeyguardUpdateMonitor)) {
debugLog("suppressingFingerprintError msgId=" + msgId mKeyguardLogger.logBiometricMessage("suppressingFingerprintError",
+ " errString= " + errString); msgId,
errString);
} else { } else {
showErrorMessageNowOrLater(errString, null); showErrorMessageNowOrLater(errString, null);
} }
@@ -1282,7 +1286,8 @@ public class KeyguardIndicationController {
} }
private void handleFaceAuthTimeoutError(@Nullable CharSequence deferredFaceMessage) { private void handleFaceAuthTimeoutError(@Nullable CharSequence deferredFaceMessage) {
debugLog("showDeferredFaceMessage msgId=" + deferredFaceMessage); mKeyguardLogger.logBiometricMessage("deferred message after face auth timeout",
null, String.valueOf(deferredFaceMessage));
if (canUnlockWithFingerprint()) { if (canUnlockWithFingerprint()) {
// Co-ex: show deferred message OR nothing // Co-ex: show deferred message OR nothing
// if we're on the lock screen (bouncer isn't showing), show the deferred msg // if we're on the lock screen (bouncer isn't showing), show the deferred msg
@@ -1294,7 +1299,8 @@ public class KeyguardIndicationController {
); );
} else { } else {
// otherwise, don't show any message // otherwise, don't show any message
debugLog("skip showing FACE_ERROR_TIMEOUT due to co-ex logic"); mKeyguardLogger.logBiometricMessage(
"skip showing FACE_ERROR_TIMEOUT due to co-ex logic");
} }
} else if (deferredFaceMessage != null) { } else if (deferredFaceMessage != null) {
// Face-only: The face timeout message is not very actionable, let's ask the // Face-only: The face timeout message is not very actionable, let's ask the
@@ -1315,12 +1321,6 @@ public class KeyguardIndicationController {
KeyguardUpdateMonitor.getCurrentUser()); KeyguardUpdateMonitor.getCurrentUser());
} }
private void debugLog(String logMsg) {
if (DEBUG) {
Log.d(TAG, logMsg);
}
}
private void showErrorMessageNowOrLater(String errString, @Nullable String followUpMsg) { private void showErrorMessageNowOrLater(String errString, @Nullable String followUpMsg) {
if (mStatusBarKeyguardViewManager.isBouncerShowing()) { if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
mStatusBarKeyguardViewManager.setKeyguardMessage(errString, mInitialTextColorState); mStatusBarKeyguardViewManager.setKeyguardMessage(errString, mInitialTextColorState);

View File

@@ -87,6 +87,7 @@ import com.android.internal.app.IBatteryStats;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
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.settingslib.fuelgauge.BatteryStatus; import com.android.settingslib.fuelgauge.BatteryStatus;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.SysuiTestCase; import com.android.systemui.SysuiTestCase;
@@ -271,7 +272,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
mUserManager, mExecutor, mExecutor, mFalsingManager, mUserManager, mExecutor, mExecutor, mFalsingManager,
mAuthController, mLockPatternUtils, mScreenLifecycle, mAuthController, mLockPatternUtils, mScreenLifecycle,
mKeyguardBypassController, mAccessibilityManager, mKeyguardBypassController, mAccessibilityManager,
mFaceHelpMessageDeferral); mFaceHelpMessageDeferral, mock(KeyguardLogger.class));
mController.init(); mController.init();
mController.setIndicationArea(mIndicationArea); mController.setIndicationArea(mIndicationArea);
verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture()); verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture());