Add keyguardIndication debug logs

Test: Take a dumpsys of sysui, see keyguardIndication
logs
Bug: 264143996

Change-Id: I80994a38818e24515486a3cdf3717cb0f456eb10
This commit is contained in:
Beverly
2023-02-01 20:24:19 +00:00
parent d2fe4b9e81
commit c66723bdba
5 changed files with 110 additions and 8 deletions

View File

@@ -16,9 +16,11 @@
package com.android.keyguard.logging
import com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController
import com.android.systemui.log.dagger.KeyguardLog
import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel
import com.android.systemui.statusbar.KeyguardIndicationController
import com.google.errorprone.annotations.CompileTimeConstant
import javax.inject.Inject
@@ -76,4 +78,46 @@ constructor(
{ "$str1 msgId: $str2 msg: $str3" }
)
}
fun logUpdateDeviceEntryIndication(
animate: Boolean,
visible: Boolean,
dozing: Boolean,
) {
buffer.log(
KeyguardIndicationController.TAG,
LogLevel.DEBUG,
{
bool1 = animate
bool2 = visible
bool3 = dozing
},
{ "updateDeviceEntryIndication animate:$bool1 visible:$bool2 dozing $bool3" }
)
}
fun logKeyguardSwitchIndication(
type: Int,
message: String?,
) {
buffer.log(
KeyguardIndicationController.TAG,
LogLevel.DEBUG,
{
int1 = type
str1 = message
},
{ "keyguardSwitchIndication ${getKeyguardSwitchIndicationNonSensitiveLog(int1, str1)}" }
)
}
fun getKeyguardSwitchIndicationNonSensitiveLog(type: Int, message: String?): String {
// only show the battery string. other strings may contain sensitive info
return if (type == KeyguardIndicationRotateTextViewController.INDICATION_TYPE_BATTERY) {
"type=${KeyguardIndicationRotateTextViewController.indicationTypeToString(type)}" +
" message=$message"
} else {
"type=${KeyguardIndicationRotateTextViewController.indicationTypeToString(type)}"
}
}
}

View File

@@ -24,6 +24,7 @@ import android.text.TextUtils;
import androidx.annotation.IntDef;
import com.android.keyguard.logging.KeyguardLogger;
import com.android.systemui.Dumpable;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -64,6 +65,7 @@ public class KeyguardIndicationRotateTextViewController extends
2000L + KeyguardIndicationTextView.Y_IN_DURATION;
private final StatusBarStateController mStatusBarStateController;
private final KeyguardLogger mLogger;
private final float mMaxAlpha;
private final ColorStateList mInitialTextColorState;
@@ -85,7 +87,8 @@ public class KeyguardIndicationRotateTextViewController extends
public KeyguardIndicationRotateTextViewController(
KeyguardIndicationTextView view,
@Main DelayableExecutor executor,
StatusBarStateController statusBarStateController
StatusBarStateController statusBarStateController,
KeyguardLogger logger
) {
super(view);
mMaxAlpha = view.getAlpha();
@@ -93,6 +96,7 @@ public class KeyguardIndicationRotateTextViewController extends
mInitialTextColorState = mView != null
? mView.getTextColors() : ColorStateList.valueOf(Color.WHITE);
mStatusBarStateController = statusBarStateController;
mLogger = logger;
init();
}
@@ -259,6 +263,8 @@ public class KeyguardIndicationRotateTextViewController extends
mLastIndicationSwitch = SystemClock.uptimeMillis();
if (!TextUtils.equals(previousMessage, mCurrMessage)
|| previousIndicationType != mCurrIndicationType) {
mLogger.logKeyguardSwitchIndication(type,
mCurrMessage != null ? mCurrMessage.toString() : null);
mView.switchIndication(mIndicationMessages.get(type));
}
@@ -352,9 +358,10 @@ public class KeyguardIndicationRotateTextViewController extends
@Override
public void dump(PrintWriter pw, String[] args) {
pw.println("KeyguardIndicationRotatingTextViewController:");
pw.println(" currentMessage=" + mView.getText());
pw.println(" currentTextViewMessage=" + mView.getText());
pw.println(" currentStoredMessage=" + mView.getMessage());
pw.println(" dozing:" + mIsDozing);
pw.println(" queue:" + mIndicationQueue.toString());
pw.println(" queue:" + mIndicationQueue);
pw.println(" showNextIndicationRunnable:" + mShowNextIndicationRunnable);
if (hasIndications()) {
@@ -398,4 +405,40 @@ public class KeyguardIndicationRotateTextViewController extends
})
@Retention(RetentionPolicy.SOURCE)
public @interface IndicationType{}
/**
* Get human-readable string representation of the indication type.
*/
public static String indicationTypeToString(@IndicationType int type) {
switch (type) {
case INDICATION_TYPE_NONE:
return "none";
case INDICATION_TYPE_DISCLOSURE:
return "disclosure";
case INDICATION_TYPE_OWNER_INFO:
return "owner_info";
case INDICATION_TYPE_LOGOUT:
return "logout";
case INDICATION_TYPE_BATTERY:
return "battery";
case INDICATION_TYPE_ALIGNMENT:
return "alignment";
case INDICATION_TYPE_TRANSIENT:
return "transient";
case INDICATION_TYPE_TRUST:
return "trust";
case INDICATION_TYPE_PERSISTENT_UNLOCK_MESSAGE:
return "persistent_unlock_message";
case INDICATION_TYPE_USER_LOCKED:
return "user_locked";
case INDICATION_TYPE_REVERSE_CHARGING:
return "reverse_charging";
case INDICATION_TYPE_BIOMETRIC_MESSAGE:
return "biometric_message";
case INDICATION_TYPE_BIOMETRIC_MESSAGE_FOLLOW_UP:
return "biometric_message_followup";
default:
return "unknown[" + type + "]";
}
}
}

View File

@@ -94,6 +94,7 @@ import com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.log.LogLevel;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
@@ -126,7 +127,7 @@ import javax.inject.Inject;
@SysUISingleton
public class KeyguardIndicationController {
private static final String TAG = "KeyguardIndication";
public static final String TAG = "KeyguardIndication";
private static final boolean DEBUG_CHARGING_SPEED = false;
private static final int MSG_SHOW_ACTION_TO_UNLOCK = 1;
@@ -326,9 +327,11 @@ public class KeyguardIndicationController {
mInitialTextColorState = mTopIndicationView != null
? mTopIndicationView.getTextColors() : ColorStateList.valueOf(Color.WHITE);
mRotateTextViewController = new KeyguardIndicationRotateTextViewController(
mLockScreenIndicationView,
mExecutor,
mStatusBarStateController);
mLockScreenIndicationView,
mExecutor,
mStatusBarStateController,
mKeyguardLogger
);
updateDeviceEntryIndication(false /* animate */);
updateOrganizedOwnedDevice();
if (mBroadcastReceiver == null) {
@@ -827,6 +830,7 @@ public class KeyguardIndicationController {
* may continuously be cycled through.
*/
protected final void updateDeviceEntryIndication(boolean animate) {
mKeyguardLogger.logUpdateDeviceEntryIndication(animate, mVisible, mDozing);
if (!mVisible) {
return;
}
@@ -1396,6 +1400,7 @@ public class KeyguardIndicationController {
public void onKeyguardShowingChanged() {
// All transient messages are gone the next time keyguard is shown
if (!mKeyguardStateController.isShowing()) {
mKeyguardLogger.log(TAG, LogLevel.DEBUG, "clear messages");
mTopIndicationView.clearMessages();
mRotateTextViewController.clearMessages();
} else {

View File

@@ -165,6 +165,13 @@ public class KeyguardIndicationTextView extends TextView {
}
}
/**
* Get the message that should be shown after the previous text animates out.
*/
public CharSequence getMessage() {
return mMessage;
}
private AnimatorSet getOutAnimator() {
AnimatorSet animatorSet = new AnimatorSet();
Animator fadeOut = ObjectAnimator.ofFloat(this, View.ALPHA, 0f);

View File

@@ -38,6 +38,7 @@ import android.testing.TestableLooper.RunWithLooper;
import androidx.test.filters.SmallTest;
import com.android.keyguard.logging.KeyguardLogger;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
@@ -66,6 +67,8 @@ public class KeyguardIndicationRotateTextViewControllerTest extends SysuiTestCas
private KeyguardIndicationTextView mView;
@Mock
private StatusBarStateController mStatusBarStateController;
@Mock
private KeyguardLogger mLogger;
@Captor
private ArgumentCaptor<StatusBarStateController.StateListener> mStatusBarStateListenerCaptor;
@@ -77,7 +80,7 @@ public class KeyguardIndicationRotateTextViewControllerTest extends SysuiTestCas
MockitoAnnotations.initMocks(this);
when(mView.getTextColors()).thenReturn(ColorStateList.valueOf(Color.WHITE));
mController = new KeyguardIndicationRotateTextViewController(mView, mExecutor,
mStatusBarStateController);
mStatusBarStateController, mLogger);
mController.onViewAttached();
verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture());