Merge "Add LogBuffers to KeyguardViewMediator"

This commit is contained in:
Brad Hinegardner
2022-08-25 16:11:18 +00:00
committed by Android (Google) Code Review
10 changed files with 895 additions and 174 deletions

View File

@@ -45,7 +45,7 @@ class KeyguardUpdateMonitorLogger @Inject constructor(
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)

View File

@@ -0,0 +1,690 @@
/*
* 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 android.os.RemoteException
import android.view.WindowManagerPolicyConstants
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogLevel.DEBUG
import com.android.systemui.log.LogLevel.ERROR
import com.android.systemui.log.LogLevel.INFO
import com.android.systemui.log.LogLevel.WARNING
import com.android.systemui.log.LogLevel.WTF
import com.android.systemui.log.dagger.KeyguardViewMediatorLog
import javax.inject.Inject
private const val TAG = "KeyguardViewMediatorLog"
@SysUISingleton
class KeyguardViewMediatorLogger @Inject constructor(
@KeyguardViewMediatorLog private val logBuffer: LogBuffer,
) {
fun logFailedLoadLockSound(soundPath: String) {
logBuffer.log(
TAG,
WARNING,
{ str1 = soundPath },
{ "failed to load lock sound from $str1" }
)
}
fun logFailedLoadUnlockSound(soundPath: String) {
logBuffer.log(
TAG,
WARNING,
{ str1 = soundPath },
{ "failed to load unlock sound from $str1" }
)
}
fun logFailedLoadTrustedSound(soundPath: String) {
logBuffer.log(
TAG,
WARNING,
{ str1 = soundPath },
{ "failed to load trusted sound from $str1" }
)
}
fun logOnSystemReady() {
logBuffer.log(TAG, DEBUG, "onSystemReady")
}
fun logOnStartedGoingToSleep(offReason: Int) {
val offReasonString = WindowManagerPolicyConstants.offReasonToString(offReason)
logBuffer.log(
TAG,
DEBUG,
{ str1 = offReasonString },
{ "onStartedGoingToSleep($str1)" }
)
}
fun logPendingExitSecureCallbackCancelled() {
logBuffer.log(TAG, DEBUG, "pending exit secure callback cancelled")
}
fun logFailedOnKeyguardExitResultFalse(remoteException: RemoteException) {
logBuffer.log(
TAG,
WARNING,
"Failed to call onKeyguardExitResult(false)",
remoteException
)
}
fun logOnFinishedGoingToSleep(offReason: Int) {
val offReasonString = WindowManagerPolicyConstants.offReasonToString(offReason)
logBuffer.log(
TAG,
DEBUG,
{ str1 = offReasonString },
{ "onFinishedGoingToSleep($str1)" }
)
}
fun logPinLockRequestedStartingKeyguard() {
logBuffer.log(TAG, INFO, "PIN lock requested, starting keyguard")
}
fun logUserSwitching(userId: Int) {
logBuffer.log(
TAG,
DEBUG,
{ int1 = userId },
{ "onUserSwitching $int1" }
)
}
fun logOnUserSwitchComplete(userId: Int) {
logBuffer.log(
TAG,
DEBUG,
{ int1 = userId },
{ "onUserSwitchComplete $int1" }
)
}
fun logOnSimStateChanged(subId: Int, slotId: Int, simState: String) {
logBuffer.log(
TAG,
DEBUG,
{
int1 = subId
int2 = slotId
str1 = simState
},
{ "onSimStateChanged(subId=$int1, slotId=$int2, state=$str1)" }
)
}
fun logFailedToCallOnSimSecureStateChanged(remoteException: RemoteException) {
logBuffer.log(
TAG,
WARNING,
"Failed to call onSimSecureStateChanged",
remoteException
)
}
fun logIccAbsentIsNotShowing() {
logBuffer.log(TAG, DEBUG, "ICC_ABSENT isn't showing, we need to show the " +
"keyguard since the device isn't provisioned yet.")
}
fun logSimMovedToAbsent() {
logBuffer.log(TAG, DEBUG, "SIM moved to ABSENT when the " +
"previous state was locked. Reset the state.")
}
fun logIntentValueIccLocked() {
logBuffer.log(TAG, DEBUG, "INTENT_VALUE_ICC_LOCKED and keyguard isn't " +
"showing; need to show keyguard so user can enter sim pin")
}
fun logPermDisabledKeyguardNotShowing() {
logBuffer.log(TAG, DEBUG, "PERM_DISABLED and keyguard isn't showing.")
}
fun logPermDisabledResetStateLocked() {
logBuffer.log(TAG, DEBUG, "PERM_DISABLED, resetStateLocked to show permanently " +
"disabled message in lockscreen.")
}
fun logReadyResetState(showing: Boolean) {
logBuffer.log(
TAG,
DEBUG,
{ bool1 = showing },
{ "READY, reset state? $bool1"}
)
}
fun logSimMovedToReady() {
logBuffer.log(TAG, DEBUG, "SIM moved to READY when the previously was locked. " +
"Reset the state.")
}
fun logUnspecifiedSimState(simState: Int) {
logBuffer.log(
TAG,
DEBUG,
{ int1 = simState },
{ "Unspecific state: $int1" }
)
}
fun logOccludeLaunchAnimationCancelled(occluded: Boolean) {
logBuffer.log(
TAG,
DEBUG,
{ bool1 = occluded },
{ "Occlude launch animation cancelled. Occluded state is now: $bool1"}
)
}
fun logActivityLaunchAnimatorLaunchContainerChanged() {
logBuffer.log(TAG, WTF, "Someone tried to change the launch container for the " +
"ActivityLaunchAnimator, which should never happen.")
}
fun logVerifyUnlock() {
logBuffer.log(TAG, DEBUG, "verifyUnlock")
}
fun logIgnoreUnlockDeviceNotProvisioned() {
logBuffer.log(TAG, DEBUG, "ignoring because device isn't provisioned")
}
fun logFailedToCallOnKeyguardExitResultFalse(remoteException: RemoteException) {
logBuffer.log(
TAG,
WARNING,
"Failed to call onKeyguardExitResult(false)",
remoteException
)
}
fun logVerifyUnlockCalledNotExternallyDisabled() {
logBuffer.log(TAG, WARNING, "verifyUnlock called when not externally disabled")
}
fun logSetOccluded(isOccluded: Boolean) {
logBuffer.log(
TAG,
DEBUG,
{ bool1 = isOccluded },
{ "setOccluded($bool1)" }
)
}
fun logHandleSetOccluded(isOccluded: Boolean) {
logBuffer.log(
TAG,
DEBUG,
{ bool1 = isOccluded },
{ "handleSetOccluded($bool1)" }
)
}
fun logIgnoreHandleShow() {
logBuffer.log(TAG, DEBUG, "ignoring handleShow because system is not ready.")
}
fun logHandleShow() {
logBuffer.log(TAG, DEBUG, "handleShow")
}
fun logHandleHide() {
logBuffer.log(TAG, DEBUG, "handleHide")
}
fun logSplitSystemUserQuitUnlocking() {
logBuffer.log(TAG, DEBUG, "Split system user, quit unlocking.")
}
fun logHandleStartKeyguardExitAnimation(startTime: Long, fadeoutDuration: Long) {
logBuffer.log(
TAG,
DEBUG,
{
long1 = startTime
long2 = fadeoutDuration
},
{ "handleStartKeyguardExitAnimation startTime=$long1 fadeoutDuration=$long2" }
)
}
fun logHandleVerifyUnlock() {
logBuffer.log(TAG, DEBUG, "handleVerifyUnlock")
}
fun logHandleNotifyStartedGoingToSleep() {
logBuffer.log(TAG, DEBUG, "handleNotifyStartedGoingToSleep")
}
fun logHandleNotifyFinishedGoingToSleep() {
logBuffer.log(TAG, DEBUG, "handleNotifyFinishedGoingToSleep")
}
fun logHandleNotifyWakingUp() {
logBuffer.log(TAG, DEBUG, "handleNotifyWakingUp")
}
fun logHandleReset() {
logBuffer.log(TAG, DEBUG, "handleReset")
}
fun logKeyguardDone() {
logBuffer.log(TAG, DEBUG, "keyguardDone")
}
fun logKeyguardDonePending() {
logBuffer.log(TAG, DEBUG, "keyguardDonePending")
}
fun logKeyguardGone() {
logBuffer.log(TAG, DEBUG, "keyguardGone")
}
fun logUnoccludeAnimationCancelled(isOccluded: Boolean) {
logBuffer.log(
TAG,
DEBUG,
{ bool1 = isOccluded },
{ "Unocclude animation cancelled. Occluded state is now: $bool1" }
)
}
fun logShowLocked() {
logBuffer.log(TAG, DEBUG, "showLocked")
}
fun logHideLocked() {
logBuffer.log(TAG, DEBUG, "hideLocked")
}
fun logResetStateLocked() {
logBuffer.log(TAG, DEBUG, "resetStateLocked")
}
fun logNotifyStartedGoingToSleep() {
logBuffer.log(TAG, DEBUG, "notifyStartedGoingToSleep")
}
fun logNotifyFinishedGoingToSleep() {
logBuffer.log(TAG, DEBUG, "notifyFinishedGoingToSleep")
}
fun logNotifyStartedWakingUp() {
logBuffer.log(TAG, DEBUG, "notifyStartedWakingUp")
}
fun logDoKeyguardShowingLockScreen() {
logBuffer.log(TAG, DEBUG, "doKeyguard: showing the lock screen")
}
fun logDoKeyguardNotShowingLockScreenOff() {
logBuffer.log(TAG, DEBUG, "doKeyguard: not showing because lockscreen is off")
}
fun logDoKeyguardNotShowingDeviceNotProvisioned() {
logBuffer.log(TAG, DEBUG, "doKeyguard: not showing because device isn't " +
"provisioned and the sim is not locked or missing")
}
fun logDoKeyguardNotShowingAlreadyShowing() {
logBuffer.log(TAG, DEBUG, "doKeyguard: not showing because it is already showing")
}
fun logDoKeyguardNotShowingBootingCryptkeeper() {
logBuffer.log(TAG, DEBUG, "doKeyguard: not showing because booting to cryptkeeper")
}
fun logDoKeyguardNotShowingExternallyDisabled() {
logBuffer.log(TAG, DEBUG, "doKeyguard: not showing because externally disabled")
}
fun logFailedToCallOnDeviceProvisioned(remoteException: RemoteException) {
logBuffer.log(
TAG,
WARNING,
"Failed to call onDeviceProvisioned",
remoteException
)
}
fun logMaybeHandlePendingLockNotHandling() {
logBuffer.log(TAG, DEBUG, "#maybeHandlePendingLock: not handling because the " +
"screen off animation's isKeyguardShowDelayed() returned true. This should be " +
"handled soon by #onStartedWakingUp, or by the end actions of the " +
"screen off animation.")
}
fun logMaybeHandlePendingLockKeyguardGoingAway() {
logBuffer.log(TAG, DEBUG, "#maybeHandlePendingLock: not handling because the " +
"keyguard is going away. This should be handled shortly by " +
"StatusBar#finishKeyguardFadingAway.")
}
fun logMaybeHandlePendingLockHandling() {
logBuffer.log(TAG, DEBUG, "#maybeHandlePendingLock: handling pending lock; " +
"locking keyguard.")
}
fun logSetAlarmToTurnOffKeyguard(delayedShowingSequence: Int) {
logBuffer.log(
TAG,
DEBUG,
{ int1 = delayedShowingSequence },
{ "setting alarm to turn off keyguard, seq = $int1" }
)
}
fun logOnStartedWakingUp(delayedShowingSequence: Int) {
logBuffer.log(
TAG,
DEBUG,
{ int1 = delayedShowingSequence },
{ "onStartedWakingUp, seq = $int1" }
)
}
fun logSetKeyguardEnabled(enabled: Boolean) {
logBuffer.log(
TAG,
DEBUG,
{ bool1 = enabled },
{ "setKeyguardEnabled($bool1)" }
)
}
fun logIgnoreVerifyUnlockRequest() {
logBuffer.log(TAG, DEBUG, "in process of verifyUnlock request, ignoring")
}
fun logRememberToReshowLater() {
logBuffer.log(TAG, DEBUG, "remembering to reshow, hiding keyguard, disabling " +
"status bar expansion")
}
fun logPreviouslyHiddenReshow() {
logBuffer.log(TAG, DEBUG, "previously hidden, reshowing, reenabling status " +
"bar expansion")
}
fun logOnKeyguardExitResultFalseResetting() {
logBuffer.log(TAG, DEBUG, "onKeyguardExitResult(false), resetting")
}
fun logWaitingUntilKeyguardVisibleIsFalse() {
logBuffer.log(TAG, DEBUG, "waiting until mWaitingUntilKeyguardVisible is false")
}
fun logDoneWaitingUntilKeyguardVisible() {
logBuffer.log(TAG, DEBUG, "done waiting for mWaitingUntilKeyguardVisible")
}
fun logUnoccludeAnimatorOnAnimationStart() {
logBuffer.log(TAG, DEBUG, "UnoccludeAnimator#onAnimationStart. " +
"Set occluded = false.")
}
fun logNoAppsProvidedToUnoccludeRunner() {
logBuffer.log(TAG, DEBUG, "No apps provided to unocclude runner; " +
"skipping animation and unoccluding.")
}
fun logReceivedDelayedKeyguardAction(sequence: Int, delayedShowingSequence: Int) {
logBuffer.log(
TAG,
DEBUG,
{
int1 = sequence
int2 = delayedShowingSequence
},
{
"received DELAYED_KEYGUARD_ACTION with seq = $int1 " +
"mDelayedShowingSequence = $int2"
}
)
}
fun logTimeoutWhileActivityDrawn() {
logBuffer.log(TAG, WARNING, "Timeout while waiting for activity drawn")
}
fun logTryKeyguardDonePending(
keyguardDonePending: Boolean,
hideAnimationRun: Boolean,
hideAnimationRunning: Boolean
) {
logBuffer.log(TAG, DEBUG,
{
bool1 = keyguardDonePending
bool2 = hideAnimationRun
bool3 = hideAnimationRunning
},
{ "tryKeyguardDone: pending - $bool1, animRan - $bool2 animRunning - $bool3" }
)
}
fun logTryKeyguardDonePreHideAnimation() {
logBuffer.log(TAG, DEBUG, "tryKeyguardDone: starting pre-hide animation")
}
fun logHandleKeyguardDone() {
logBuffer.log(TAG, DEBUG, "handleKeyguardDone")
}
fun logDeviceGoingToSleep() {
logBuffer.log(TAG, INFO, "Device is going to sleep, aborting keyguardDone")
}
fun logFailedToCallOnKeyguardExitResultTrue(remoteException: RemoteException) {
logBuffer.log(
TAG,
WARNING,
"Failed to call onKeyguardExitResult(true)",
remoteException
)
}
fun logHandleKeyguardDoneDrawing() {
logBuffer.log(TAG, DEBUG, "handleKeyguardDoneDrawing")
}
fun logHandleKeyguardDoneDrawingNotifyingKeyguardVisible() {
logBuffer.log(TAG, DEBUG, "handleKeyguardDoneDrawing: notifying " +
"mWaitingUntilKeyguardVisible")
}
fun logUpdateActivityLockScreenState(showing: Boolean, aodShowing: Boolean) {
logBuffer.log(
TAG,
DEBUG,
{
bool1 = showing
bool2 = aodShowing
},
{ "updateActivityLockScreenState($bool1, $bool2)" }
)
}
fun logFailedToCallSetLockScreenShown(remoteException: RemoteException) {
logBuffer.log(
TAG,
WARNING,
"Failed to call setLockScreenShown",
remoteException
)
}
fun logKeyguardGoingAway() {
logBuffer.log(TAG, DEBUG, "keyguardGoingAway")
}
fun logFailedToCallKeyguardGoingAway(keyguardFlag: Int, remoteException: RemoteException) {
logBuffer.log(
TAG,
ERROR,
{ int1 = keyguardFlag },
{ "Failed to call keyguardGoingAway($int1)" },
remoteException
)
}
fun logHideAnimationFinishedRunnable() {
logBuffer.log(TAG, WARNING, "mHideAnimationFinishedRunnable#run")
}
fun logFailedToCallOnAnimationFinished(remoteException: RemoteException) {
logBuffer.log(
TAG,
WARNING,
"Failed to call onAnimationFinished",
remoteException
)
}
fun logFailedToCallOnAnimationStart(remoteException: RemoteException) {
logBuffer.log(
TAG,
WARNING,
"Failed to call onAnimationStart",
remoteException
)
}
fun logOnKeyguardExitRemoteAnimationFinished() {
logBuffer.log(TAG, DEBUG, "onKeyguardExitRemoteAnimationFinished")
}
fun logSkipOnKeyguardExitRemoteAnimationFinished(
cancelled: Boolean,
surfaceBehindRemoteAnimationRunning: Boolean,
surfaceBehindRemoteAnimationRequested: Boolean
) {
logBuffer.log(
TAG,
DEBUG,
{
bool1 = cancelled
bool2 = surfaceBehindRemoteAnimationRunning
bool3 = surfaceBehindRemoteAnimationRequested
},
{
"skip onKeyguardExitRemoteAnimationFinished cancelled=$bool1 " +
"surfaceAnimationRunning=$bool2 " +
"surfaceAnimationRequested=$bool3"
}
)
}
fun logOnKeyguardExitRemoteAnimationFinishedHideKeyguardView() {
logBuffer.log(TAG, DEBUG, "onKeyguardExitRemoteAnimationFinished" +
"#hideKeyguardViewAfterRemoteAnimation")
}
fun logSkipHideKeyguardViewAfterRemoteAnimation(
dismissingFromSwipe: Boolean,
wasShowing: Boolean
) {
logBuffer.log(
TAG,
DEBUG,
{
bool1 = dismissingFromSwipe
bool2 = wasShowing
},
{
"skip hideKeyguardViewAfterRemoteAnimation dismissFromSwipe=$bool1 " +
"wasShowing=$bool2"
}
)
}
fun logCouldNotGetStatusBarManager() {
logBuffer.log(TAG, WARNING, "Could not get status bar manager")
}
fun logAdjustStatusBarLocked(
showing: Boolean,
occluded: Boolean,
secure: Boolean,
forceHideHomeRecentsButtons: Boolean,
flags: String
) {
logBuffer.log(
TAG,
DEBUG,
{
bool1 = showing
bool2 = occluded
bool3 = secure
bool4 = forceHideHomeRecentsButtons
str3 = flags
},
{
"adjustStatusBarLocked: mShowing=$bool1 mOccluded=$bool2 isSecure=$bool3 " +
"force=$bool4 --> flags=0x$str3"
}
)
}
fun logFailedToCallOnShowingStateChanged(remoteException: RemoteException) {
logBuffer.log(
TAG,
WARNING,
"Failed to call onShowingStateChanged",
remoteException
)
}
fun logFailedToCallNotifyTrustedChangedLocked(remoteException: RemoteException) {
logBuffer.log(
TAG,
WARNING,
"Failed to call notifyTrustedChangedLocked",
remoteException
)
}
fun logFailedToCallIKeyguardStateCallback(remoteException: RemoteException) {
logBuffer.log(
TAG,
WARNING,
"Failed to call to IKeyguardStateCallback",
remoteException
)
}
fun logOccludeAnimatorOnAnimationStart() {
logBuffer.log(TAG, DEBUG, "OccludeAnimator#onAnimationStart. Set occluded = true.")
}
fun logOccludeAnimationCancelledByWm(isKeyguardOccluded: Boolean) {
logBuffer.log(
TAG,
DEBUG,
{ bool1 = isKeyguardOccluded },
{ "Occlude animation cancelled by WM. Setting occluded state to: $bool1" }
)
}
}

View File

@@ -73,8 +73,6 @@ import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.EventLog;
import android.util.Log;
import android.util.Slog;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import android.view.IRemoteAnimationFinishedCallback;
@@ -106,6 +104,7 @@ import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.KeyguardViewController;
import com.android.keyguard.ViewMediatorCallback;
import com.android.keyguard.logging.KeyguardViewMediatorLogger;
import com.android.keyguard.mediator.ScreenOnCoordinator;
import com.android.systemui.CoreStartable;
import com.android.systemui.DejankUtils;
@@ -513,8 +512,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
public void onKeyguardVisibilityChanged(boolean showing) {
synchronized (KeyguardViewMediator.this) {
if (!showing && mPendingPinLock) {
Log.i(TAG, "PIN lock requested, starting keyguard");
mLogger.logPinLockRequestedStartingKeyguard();
// Bring the keyguard back in order to show the PIN lock
mPendingPinLock = false;
doKeyguardLocked(null);
@@ -524,7 +522,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
@Override
public void onUserSwitching(int userId) {
if (DEBUG) Log.d(TAG, String.format("onUserSwitching %d", userId));
mLogger.logUserSwitching(userId);
// Note that the mLockPatternUtils user has already been updated from setCurrentUser.
// We need to force a reset of the views, since lockNow (called by
// ActivityManagerService) will not reconstruct the keyguard if it is already showing.
@@ -542,7 +540,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
@Override
public void onUserSwitchComplete(int userId) {
if (DEBUG) Log.d(TAG, String.format("onUserSwitchComplete %d", userId));
mLogger.logOnUserSwitchComplete(userId);
if (userId != UserHandle.USER_SYSTEM) {
UserInfo info = UserManager.get(mContext).getUserInfo(userId);
// Don't try to dismiss if the user has Pin/Pattern/Password set
@@ -570,8 +568,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
public void onSimStateChanged(int subId, int slotId, int simState) {
if (DEBUG_SIM_STATES) {
Log.d(TAG, "onSimStateChanged(subId=" + subId + ", slotId=" + slotId
+ ",state=" + simState + ")");
mLogger.logOnSimStateChanged(subId, slotId, String.valueOf(simState));
}
int size = mKeyguardStateCallbacks.size();
@@ -580,7 +577,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
mKeyguardStateCallbacks.get(i).onSimSecureStateChanged(simPinSecure);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onSimSecureStateChanged", e);
mLogger.logFailedToCallOnSimSecureStateChanged(e);
if (e instanceof DeadObjectException) {
mKeyguardStateCallbacks.remove(i);
}
@@ -603,9 +600,9 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
synchronized (KeyguardViewMediator.this) {
if (shouldWaitForProvisioning()) {
if (!mShowing) {
if (DEBUG_SIM_STATES) Log.d(TAG, "ICC_ABSENT isn't showing,"
+ " we need to show the keyguard since the "
+ "device isn't provisioned yet.");
if (DEBUG_SIM_STATES) {
mLogger.logIccAbsentIsNotShowing();
}
doKeyguardLocked(null);
} else {
resetStateLocked();
@@ -615,8 +612,9 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
// MVNO SIMs can become transiently NOT_READY when switching networks,
// so we should only lock when they are ABSENT.
if (lastSimStateWasLocked) {
if (DEBUG_SIM_STATES) Log.d(TAG, "SIM moved to ABSENT when the "
+ "previous state was locked. Reset the state.");
if (DEBUG_SIM_STATES) {
mLogger.logSimMovedToAbsent();
}
resetStateLocked();
}
mSimWasLocked.append(slotId, false);
@@ -629,9 +627,9 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
mSimWasLocked.append(slotId, true);
mPendingPinLock = true;
if (!mShowing) {
if (DEBUG_SIM_STATES) Log.d(TAG,
"INTENT_VALUE_ICC_LOCKED and keygaurd isn't "
+ "showing; need to show keyguard so user can enter sim pin");
if (DEBUG_SIM_STATES) {
mLogger.logIntentValueIccLocked();
}
doKeyguardLocked(null);
} else {
resetStateLocked();
@@ -641,29 +639,36 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
case TelephonyManager.SIM_STATE_PERM_DISABLED:
synchronized (KeyguardViewMediator.this) {
if (!mShowing) {
if (DEBUG_SIM_STATES) Log.d(TAG, "PERM_DISABLED and "
+ "keygaurd isn't showing.");
if (DEBUG_SIM_STATES) {
mLogger.logPermDisabledKeyguardNotShowing();
}
doKeyguardLocked(null);
} else {
if (DEBUG_SIM_STATES) Log.d(TAG, "PERM_DISABLED, resetStateLocked to"
+ "show permanently disabled message in lockscreen.");
if (DEBUG_SIM_STATES) {
mLogger.logPermDisabledResetStateLocked();
}
resetStateLocked();
}
}
break;
case TelephonyManager.SIM_STATE_READY:
synchronized (KeyguardViewMediator.this) {
if (DEBUG_SIM_STATES) Log.d(TAG, "READY, reset state? " + mShowing);
if (DEBUG_SIM_STATES) {
mLogger.logReadyResetState(mShowing);
}
if (mShowing && mSimWasLocked.get(slotId, false)) {
if (DEBUG_SIM_STATES) Log.d(TAG, "SIM moved to READY when the "
+ "previously was locked. Reset the state.");
if (DEBUG_SIM_STATES) {
mLogger.logSimMovedToReady();
}
mSimWasLocked.append(slotId, false);
resetStateLocked();
}
}
break;
default:
if (DEBUG_SIM_STATES) Log.v(TAG, "Unspecific state: " + simState);
if (DEBUG_SIM_STATES) {
mLogger.logUnspecifiedSimState(simState);
}
break;
}
}
@@ -708,7 +713,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
if (targetUserId != ActivityManager.getCurrentUser()) {
return;
}
if (DEBUG) Log.d(TAG, "keyguardDone");
mLogger.logKeyguardDone();
tryKeyguardDone();
}
@@ -727,7 +732,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
@Override
public void keyguardDonePending(boolean strongAuth, int targetUserId) {
Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#keyguardDonePending");
if (DEBUG) Log.d(TAG, "keyguardDonePending");
mLogger.logKeyguardDonePending();
if (targetUserId != ActivityManager.getCurrentUser()) {
Trace.endSection();
return;
@@ -746,7 +751,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
@Override
public void keyguardGone() {
Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#keyguardGone");
if (DEBUG) Log.d(TAG, "keyguardGone");
mLogger.logKeyguardGone();
mKeyguardViewControllerLazy.get().setKeyguardGoingAwayState(false);
mKeyguardDisplayManager.hide();
Trace.endSection();
@@ -832,8 +837,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
@Override
public void onLaunchAnimationCancelled() {
Log.d(TAG, "Occlude launch animation cancelled. Occluded state is now: "
+ mOccluded);
mLogger.logOccludeLaunchAnimationCancelled(mOccluded);
}
@Override
@@ -853,8 +857,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
@Override
public void setLaunchContainer(@NonNull ViewGroup launchContainer) {
// No-op, launch container is always the shade.
Log.wtf(TAG, "Someone tried to change the launch container for the "
+ "ActivityLaunchAnimator, which should never happen.");
mLogger.logActivityLaunchAnimatorLaunchContainerChanged();
}
@NonNull
@@ -905,8 +908,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
}
setOccluded(isKeyguardOccluded /* isOccluded */, false /* animate */);
Log.d(TAG, "Unocclude animation cancelled. Occluded state is now: "
+ mOccluded);
mLogger.logUnoccludeAnimationCancelled(mOccluded);
}
@Override
@@ -914,12 +916,11 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
RemoteAnimationTarget[] wallpapers,
RemoteAnimationTarget[] nonApps,
IRemoteAnimationFinishedCallback finishedCallback) throws RemoteException {
Log.d(TAG, "UnoccludeAnimator#onAnimationStart. Set occluded = false.");
mLogger.logUnoccludeAnimatorOnAnimationStart();
setOccluded(false /* isOccluded */, true /* animate */);
if (apps == null || apps.length == 0 || apps[0] == null) {
Log.d(TAG, "No apps provided to unocclude runner; "
+ "skipping animation and unoccluding.");
mLogger.logNoAppsProvidedToUnoccludeRunner();
finishedCallback.onAnimationFinished();
return;
}
@@ -1007,6 +1008,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
private ScreenOnCoordinator mScreenOnCoordinator;
private Lazy<ActivityLaunchAnimator> mActivityLaunchAnimator;
private KeyguardViewMediatorLogger mLogger;
/**
* Injected constructor. See {@link KeyguardModule}.
@@ -1035,7 +1037,8 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
InteractionJankMonitor interactionJankMonitor,
DreamOverlayStateController dreamOverlayStateController,
Lazy<NotificationShadeWindowController> notificationShadeWindowControllerLazy,
Lazy<ActivityLaunchAnimator> activityLaunchAnimator) {
Lazy<ActivityLaunchAnimator> activityLaunchAnimator,
KeyguardViewMediatorLogger logger) {
super(context);
mFalsingCollector = falsingCollector;
mLockPatternUtils = lockPatternUtils;
@@ -1078,6 +1081,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
mDreamOverlayStateController = dreamOverlayStateController;
mActivityLaunchAnimator = activityLaunchAnimator;
mLogger = logger;
mPowerButtonY = context.getResources().getDimensionPixelSize(
R.dimen.physical_power_button_center_screen_location_y);
@@ -1141,21 +1145,21 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
mLockSoundId = mLockSounds.load(soundPath, 1);
}
if (soundPath == null || mLockSoundId == 0) {
Log.w(TAG, "failed to load lock sound from " + soundPath);
mLogger.logFailedLoadLockSound(soundPath);
}
soundPath = Settings.Global.getString(cr, Settings.Global.UNLOCK_SOUND);
if (soundPath != null) {
mUnlockSoundId = mLockSounds.load(soundPath, 1);
}
if (soundPath == null || mUnlockSoundId == 0) {
Log.w(TAG, "failed to load unlock sound from " + soundPath);
mLogger.logFailedLoadUnlockSound(soundPath);
}
soundPath = Settings.Global.getString(cr, Settings.Global.TRUSTED_SOUND);
if (soundPath != null) {
mTrustedSoundId = mLockSounds.load(soundPath, 1);
}
if (soundPath == null || mTrustedSoundId == 0) {
Log.w(TAG, "failed to load trusted sound from " + soundPath);
mLogger.logFailedLoadTrustedSound(soundPath);
}
int lockSoundDefaultAttenuation = mContext.getResources().getInteger(
@@ -1184,7 +1188,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
private void handleSystemReady() {
synchronized (this) {
if (DEBUG) Log.d(TAG, "onSystemReady");
mLogger.logOnSystemReady();
mSystemReady = true;
doKeyguardLocked(null);
mUpdateMonitor.registerCallback(mUpdateCallback);
@@ -1202,7 +1206,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
* {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_TIMEOUT}.
*/
public void onStartedGoingToSleep(@WindowManagerPolicyConstants.OffReason int offReason) {
if (DEBUG) Log.d(TAG, "onStartedGoingToSleep(" + offReason + ")");
mLogger.logOnStartedGoingToSleep(offReason);
synchronized (this) {
mDeviceInteractive = false;
mPowerGestureIntercepted = false;
@@ -1218,11 +1222,11 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
long timeout = getLockTimeout(KeyguardUpdateMonitor.getCurrentUser());
mLockLater = false;
if (mExitSecureCallback != null) {
if (DEBUG) Log.d(TAG, "pending exit secure callback cancelled");
mLogger.logPendingExitSecureCallbackCancelled();
try {
mExitSecureCallback.onKeyguardExitResult(false);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
mLogger.logFailedOnKeyguardExitResultFalse(e);
}
mExitSecureCallback = null;
if (!mExternallyEnabled) {
@@ -1267,7 +1271,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
*/
public void onFinishedGoingToSleep(
@WindowManagerPolicyConstants.OffReason int offReason, boolean cameraGestureTriggered) {
if (DEBUG) Log.d(TAG, "onFinishedGoingToSleep(" + offReason + ")");
mLogger.logOnFinishedGoingToSleep(offReason);
synchronized (this) {
mDeviceInteractive = false;
mGoingToSleep = false;
@@ -1325,13 +1329,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
// - The screen off animation is cancelled by the device waking back up. We will call
// maybeHandlePendingLock from KeyguardViewMediator#onStartedWakingUp.
if (mScreenOffAnimationController.isKeyguardShowDelayed()) {
if (DEBUG) {
Log.d(TAG, "#maybeHandlePendingLock: not handling because the screen off "
+ "animation's isKeyguardShowDelayed() returned true. This should be "
+ "handled soon by #onStartedWakingUp, or by the end actions of the "
+ "screen off animation.");
}
mLogger.logMaybeHandlePendingLockNotHandling();
return;
}
@@ -1341,18 +1339,11 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
// StatusBar#finishKeyguardFadingAway, which is always responsible for setting
// isKeyguardGoingAway to false.
if (mKeyguardStateController.isKeyguardGoingAway()) {
if (DEBUG) {
Log.d(TAG, "#maybeHandlePendingLock: not handling because the keyguard is "
+ "going away. This should be handled shortly by "
+ "StatusBar#finishKeyguardFadingAway.");
}
mLogger.logMaybeHandlePendingLockKeyguardGoingAway();
return;
}
if (DEBUG) {
Log.d(TAG, "#maybeHandlePendingLock: handling pending lock; locking keyguard.");
}
mLogger.logMaybeHandlePendingLockHandling();
doKeyguardLocked(null);
setPendingLock(false);
@@ -1421,8 +1412,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
PendingIntent sender = PendingIntent.getBroadcast(mContext,
0, intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
mAlarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, sender);
if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = "
+ mDelayedShowingSequence);
mLogger.logSetAlarmToTurnOffKeyguard(mDelayedShowingSequence);
doKeyguardLaterForChildProfilesLocked();
}
@@ -1482,7 +1472,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
mAnimatingScreenOff = false;
cancelDoKeyguardLaterLocked();
cancelDoKeyguardForChildProfilesLocked();
if (DEBUG) Log.d(TAG, "onStartedWakingUp, seq = " + mDelayedShowingSequence);
mLogger.logOnStartedWakingUp(mDelayedShowingSequence);
notifyStartedWakingUp();
}
mUpdateMonitor.dispatchStartedWakingUp();
@@ -1542,37 +1532,35 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
*/
public void setKeyguardEnabled(boolean enabled) {
synchronized (this) {
if (DEBUG) Log.d(TAG, "setKeyguardEnabled(" + enabled + ")");
mLogger.logSetKeyguardEnabled(enabled);
mExternallyEnabled = enabled;
if (!enabled && mShowing) {
if (mExitSecureCallback != null) {
if (DEBUG) Log.d(TAG, "in process of verifyUnlock request, ignoring");
mLogger.logIgnoreVerifyUnlockRequest();
// we're in the process of handling a request to verify the user
// can get past the keyguard. ignore extraneous requests to disable / re-enable
return;
}
// hiding keyguard that is showing, remember to reshow later
if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, "
+ "disabling status bar expansion");
mLogger.logRememberToReshowLater();
mNeedToReshowWhenReenabled = true;
updateInputRestrictedLocked();
hideLocked();
} else if (enabled && mNeedToReshowWhenReenabled) {
// re-enabled after previously hidden, reshow
if (DEBUG) Log.d(TAG, "previously hidden, reshowing, reenabling "
+ "status bar expansion");
mLogger.logPreviouslyHiddenReshow();
mNeedToReshowWhenReenabled = false;
updateInputRestrictedLocked();
if (mExitSecureCallback != null) {
if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting");
mLogger.logOnKeyguardExitResultFalseResetting();
try {
mExitSecureCallback.onKeyguardExitResult(false);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
mLogger.logFailedToCallOnKeyguardExitResultFalse(e);
}
mExitSecureCallback = null;
resetStateLocked();
@@ -1584,7 +1572,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
// and causing an ANR).
mWaitingUntilKeyguardVisible = true;
mHandler.sendEmptyMessageDelayed(KEYGUARD_DONE_DRAWING, KEYGUARD_DONE_DRAWING_TIMEOUT_MS);
if (DEBUG) Log.d(TAG, "waiting until mWaitingUntilKeyguardVisible is false");
mLogger.logWaitingUntilKeyguardVisibleIsFalse();
while (mWaitingUntilKeyguardVisible) {
try {
wait();
@@ -1592,7 +1580,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
Thread.currentThread().interrupt();
}
}
if (DEBUG) Log.d(TAG, "done waiting for mWaitingUntilKeyguardVisible");
mLogger.logDoneWaitingUntilKeyguardVisible();
}
}
}
@@ -1604,31 +1592,31 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
public void verifyUnlock(IKeyguardExitCallback callback) {
Trace.beginSection("KeyguardViewMediator#verifyUnlock");
synchronized (this) {
if (DEBUG) Log.d(TAG, "verifyUnlock");
mLogger.logVerifyUnlock();
if (shouldWaitForProvisioning()) {
// don't allow this api when the device isn't provisioned
if (DEBUG) Log.d(TAG, "ignoring because device isn't provisioned");
mLogger.logIgnoreUnlockDeviceNotProvisioned();
try {
callback.onKeyguardExitResult(false);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
mLogger.logFailedToCallOnKeyguardExitResultFalse(e);
}
} else if (mExternallyEnabled) {
// this only applies when the user has externally disabled the
// keyguard. this is unexpected and means the user is not
// using the api properly.
Log.w(TAG, "verifyUnlock called when not externally disabled");
mLogger.logVerifyUnlockCalledNotExternallyDisabled();
try {
callback.onKeyguardExitResult(false);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
mLogger.logFailedToCallOnKeyguardExitResultFalse(e);
}
} else if (mExitSecureCallback != null) {
// already in progress with someone else
try {
callback.onKeyguardExitResult(false);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
mLogger.logFailedToCallOnKeyguardExitResultFalse(e);
}
} else if (!isSecure()) {
@@ -1640,7 +1628,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
callback.onKeyguardExitResult(true);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
mLogger.logFailedToCallOnKeyguardExitResultFalse(e);
}
} else {
@@ -1649,7 +1637,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
callback.onKeyguardExitResult(false);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e);
mLogger.logFailedToCallOnKeyguardExitResultFalse(e);
}
}
}
@@ -1667,10 +1655,8 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
* Notify us when the keyguard is occluded by another window
*/
public void setOccluded(boolean isOccluded, boolean animate) {
Log.d(TAG, "setOccluded(" + isOccluded + ")");
Trace.beginSection("KeyguardViewMediator#setOccluded");
if (DEBUG) Log.d(TAG, "setOccluded " + isOccluded);
mLogger.logSetOccluded(isOccluded);
mInteractionJankMonitor.cancel(CUJ_LOCKSCREEN_TRANSITION_FROM_AOD);
mHandler.removeMessages(SET_OCCLUDED);
Message msg = mHandler.obtainMessage(SET_OCCLUDED, isOccluded ? 1 : 0, animate ? 1 : 0);
@@ -1699,7 +1685,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
*/
private void handleSetOccluded(boolean isOccluded, boolean animate) {
Trace.beginSection("KeyguardViewMediator#handleSetOccluded");
Log.d(TAG, "handleSetOccluded(" + isOccluded + ")");
mLogger.logHandleSetOccluded(isOccluded);
synchronized (KeyguardViewMediator.this) {
if (mHiding && isOccluded) {
// We're in the process of going away but WindowManager wants to show a
@@ -1756,7 +1742,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
callback.onInputRestrictedStateChanged(inputRestricted);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onDeviceProvisioned", e);
mLogger.logFailedToCallOnDeviceProvisioned(e);
if (e instanceof DeadObjectException) {
mKeyguardStateCallbacks.remove(callback);
}
@@ -1771,8 +1757,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
private void doKeyguardLocked(Bundle options) {
// if another app is disabling us, don't show
if (!mExternallyEnabled) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled");
mLogger.logDoKeyguardNotShowingExternallyDisabled();
mNeedToReshowWhenReenabled = true;
return;
}
@@ -1781,7 +1766,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
// to account for the hiding animation which results in a delay and discrepancy
// between flags
if (mShowing && mKeyguardViewControllerLazy.get().isShowing()) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing");
mLogger.logDoKeyguardNotShowingAlreadyShowing();
resetStateLocked();
return;
}
@@ -1800,20 +1785,19 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
|| ((absent || disabled) && requireSim);
if (!lockedOrMissing && shouldWaitForProvisioning()) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because device isn't provisioned"
+ " and the sim is not locked or missing");
mLogger.logDoKeyguardNotShowingDeviceNotProvisioned();
return;
}
boolean forceShow = options != null && options.getBoolean(OPTION_FORCE_SHOW, false);
if (mLockPatternUtils.isLockScreenDisabled(KeyguardUpdateMonitor.getCurrentUser())
&& !lockedOrMissing && !forceShow) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off");
mLogger.logDoKeyguardNotShowingLockScreenOff();
return;
}
}
if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
mLogger.logDoKeyguardShowingLockScreen();
showLocked(options);
}
@@ -1851,32 +1835,23 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
* @see #handleReset
*/
private void resetStateLocked() {
if (DEBUG) Log.e(TAG, "resetStateLocked");
mLogger.logResetStateLocked();
Message msg = mHandler.obtainMessage(RESET);
mHandler.sendMessage(msg);
}
/**
* Send message to keyguard telling it to verify unlock
* @see #handleVerifyUnlock()
*/
private void verifyUnlockLocked() {
if (DEBUG) Log.d(TAG, "verifyUnlockLocked");
mHandler.sendEmptyMessage(VERIFY_UNLOCK);
}
private void notifyStartedGoingToSleep() {
if (DEBUG) Log.d(TAG, "notifyStartedGoingToSleep");
mLogger.logNotifyStartedGoingToSleep();
mHandler.sendEmptyMessage(NOTIFY_STARTED_GOING_TO_SLEEP);
}
private void notifyFinishedGoingToSleep() {
if (DEBUG) Log.d(TAG, "notifyFinishedGoingToSleep");
mLogger.logNotifyFinishedGoingToSleep();
mHandler.sendEmptyMessage(NOTIFY_FINISHED_GOING_TO_SLEEP);
}
private void notifyStartedWakingUp() {
if (DEBUG) Log.d(TAG, "notifyStartedWakingUp");
mLogger.logNotifyStartedWakingUp();
mHandler.sendEmptyMessage(NOTIFY_STARTED_WAKING_UP);
}
@@ -1886,7 +1861,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
*/
private void showLocked(Bundle options) {
Trace.beginSection("KeyguardViewMediator#showLocked acquiring mShowKeyguardWakeLock");
if (DEBUG) Log.d(TAG, "showLocked");
mLogger.logShowLocked();
// ensure we stay awake until we are finished displaying the keyguard
mShowKeyguardWakeLock.acquire();
Message msg = mHandler.obtainMessage(SHOW, options);
@@ -1903,7 +1878,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
*/
private void hideLocked() {
Trace.beginSection("KeyguardViewMediator#hideLocked");
if (DEBUG) Log.d(TAG, "hideLocked");
mLogger.logHideLocked();
Message msg = mHandler.obtainMessage(HIDE);
mHandler.sendMessage(msg);
Trace.endSection();
@@ -1982,8 +1957,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
public void onReceive(Context context, Intent intent) {
if (DELAYED_KEYGUARD_ACTION.equals(intent.getAction())) {
final int sequence = intent.getIntExtra("seq", 0);
if (DEBUG) Log.d(TAG, "received DELAYED_KEYGUARD_ACTION with seq = "
+ sequence + ", mDelayedShowingSequence = " + mDelayedShowingSequence);
mLogger.logReceivedDelayedKeyguardAction(sequence, mDelayedShowingSequence);
synchronized (KeyguardViewMediator.this) {
if (mDelayedShowingSequence == sequence) {
doKeyguardLocked(null);
@@ -2016,7 +1990,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
private void keyguardDone() {
Trace.beginSection("KeyguardViewMediator#keyguardDone");
if (DEBUG) Log.d(TAG, "keyguardDone()");
mLogger.logKeyguardDone();
userActivity();
EventLog.writeEvent(70000, 2);
Message msg = mHandler.obtainMessage(KEYGUARD_DONE);
@@ -2108,7 +2082,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
case KEYGUARD_DONE_PENDING_TIMEOUT:
Trace.beginSection("KeyguardViewMediator#handleMessage"
+ " KEYGUARD_DONE_PENDING_TIMEOUT");
Log.w(TAG, "Timeout while waiting for activity drawn!");
mLogger.logTimeoutWhileActivityDrawn();
Trace.endSection();
break;
case SYSTEM_READY:
@@ -2119,14 +2093,15 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
};
private void tryKeyguardDone() {
if (DEBUG) {
Log.d(TAG, "tryKeyguardDone: pending - " + mKeyguardDonePending + ", animRan - "
+ mHideAnimationRun + " animRunning - " + mHideAnimationRunning);
}
mLogger.logTryKeyguardDonePending(
mKeyguardDonePending,
mHideAnimationRun,
mHideAnimationRunning
);
if (!mKeyguardDonePending && mHideAnimationRun && !mHideAnimationRunning) {
handleKeyguardDone();
} else if (!mHideAnimationRun) {
if (DEBUG) Log.d(TAG, "tryKeyguardDone: starting pre-hide animation");
mLogger.logTryKeyguardDonePreHideAnimation();
mHideAnimationRun = true;
mHideAnimationRunning = true;
mKeyguardViewControllerLazy.get()
@@ -2146,14 +2121,14 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
mLockPatternUtils.getDevicePolicyManager().reportKeyguardDismissed(currentUser);
}
});
if (DEBUG) Log.d(TAG, "handleKeyguardDone");
mLogger.logHandleKeyguardDone();
synchronized (this) {
resetKeyguardDonePendingLocked();
}
if (mGoingToSleep) {
mUpdateMonitor.clearBiometricRecognizedWhenKeyguardDone(currentUser);
Log.i(TAG, "Device is going to sleep, aborting keyguardDone");
mLogger.logDeviceGoingToSleep();
return;
}
setPendingLock(false); // user may have authenticated during the screen off animation
@@ -2161,7 +2136,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
mExitSecureCallback.onKeyguardExitResult(true /* authenciated */);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onKeyguardExitResult()", e);
mLogger.logFailedToCallOnKeyguardExitResultTrue(e);
}
mExitSecureCallback = null;
@@ -2204,9 +2179,9 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
private void handleKeyguardDoneDrawing() {
Trace.beginSection("KeyguardViewMediator#handleKeyguardDoneDrawing");
synchronized(this) {
if (DEBUG) Log.d(TAG, "handleKeyguardDoneDrawing");
mLogger.logHandleKeyguardDoneDrawing();
if (mWaitingUntilKeyguardVisible) {
if (DEBUG) Log.d(TAG, "handleKeyguardDoneDrawing: notifying mWaitingUntilKeyguardVisible");
mLogger.logHandleKeyguardDoneDrawingNotifyingKeyguardVisible();
mWaitingUntilKeyguardVisible = false;
notifyAll();
@@ -2256,12 +2231,11 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
private void updateActivityLockScreenState(boolean showing, boolean aodShowing) {
mUiBgExecutor.execute(() -> {
if (DEBUG) {
Log.d(TAG, "updateActivityLockScreenState(" + showing + ", " + aodShowing + ")");
}
mLogger.logUpdateActivityLockScreenState(showing, aodShowing);
try {
ActivityTaskManager.getService().setLockScreenShown(showing, aodShowing);
} catch (RemoteException e) {
mLogger.logFailedToCallSetLockScreenShown(e);
}
});
}
@@ -2278,10 +2252,10 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
}
synchronized (KeyguardViewMediator.this) {
if (!mSystemReady) {
if (DEBUG) Log.d(TAG, "ignoring handleShow because system is not ready.");
mLogger.logIgnoreHandleShow();
return;
} else {
if (DEBUG) Log.d(TAG, "handleShow");
mLogger.logHandleShow();
}
mHiding = false;
@@ -2313,7 +2287,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
@Override
public void run() {
Trace.beginSection("KeyguardViewMediator.mKeyGuardGoingAwayRunnable");
if (DEBUG) Log.d(TAG, "keyguardGoingAway");
mLogger.logKeyguardGoingAway();
mKeyguardViewControllerLazy.get().keyguardGoingAway();
int flags = 0;
@@ -2357,7 +2331,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
ActivityTaskManager.getService().keyguardGoingAway(keyguardFlag);
} catch (RemoteException e) {
Log.e(TAG, "Error while calling WindowManager", e);
mLogger.logFailedToCallKeyguardGoingAway(keyguardFlag, e);
}
});
Trace.endSection();
@@ -2365,7 +2339,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
};
private final Runnable mHideAnimationFinishedRunnable = () -> {
Log.e(TAG, "mHideAnimationFinishedRunnable#run");
mLogger.logHideAnimationFinishedRunnable();
mHideAnimationRunning = false;
tryKeyguardDone();
};
@@ -2385,14 +2359,14 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
}
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleHide");
mLogger.logHandleHide();
if (mustNotUnlockCurrentUser()) {
// In split system user mode, we never unlock system user. The end user has to
// switch to another user.
// TODO: We should stop it early by disabling the swipe up flow. Right now swipe up
// still completes and makes the screen blank.
if (DEBUG) Log.d(TAG, "Split system user, quit unlocking.");
mLogger.logSplitSystemUserQuitUnlocking();
mKeyguardExitAnimationRunner = null;
return;
}
@@ -2424,8 +2398,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
RemoteAnimationTarget[] apps, RemoteAnimationTarget[] wallpapers,
RemoteAnimationTarget[] nonApps, IRemoteAnimationFinishedCallback finishedCallback) {
Trace.beginSection("KeyguardViewMediator#handleStartKeyguardExitAnimation");
Log.d(TAG, "handleStartKeyguardExitAnimation startTime=" + startTime
+ " fadeoutDuration=" + fadeoutDuration);
mLogger.logHandleStartKeyguardExitAnimation(startTime, fadeoutDuration);
synchronized (KeyguardViewMediator.this) {
// Tell ActivityManager that we canceled the keyguard animation if
@@ -2441,7 +2414,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
finishedCallback.onAnimationFinished();
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onAnimationFinished", e);
mLogger.logFailedToCallOnAnimationFinished(e);
}
}
setShowingLocked(mShowing, true /* force */);
@@ -2464,7 +2437,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
finishedCallback.onAnimationFinished();
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onAnimationFinished", e);
mLogger.logFailedToCallOnAnimationFinished(e);
}
onKeyguardExitFinished();
mKeyguardViewControllerLazy.get().hide(0 /* startTime */,
@@ -2483,7 +2456,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
runner.onAnimationStart(WindowManager.TRANSIT_KEYGUARD_GOING_AWAY, apps,
wallpapers, nonApps, callback);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onAnimationStart", e);
mLogger.logFailedToCallOnAnimationStart(e);
}
// When remaining on the shade, there's no need to do a fancy remote animation,
@@ -2548,7 +2521,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
finishedCallback.onAnimationFinished();
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException");
mLogger.logFailedToCallOnAnimationFinished(e);
} finally {
mInteractionJankMonitor.end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
}
@@ -2559,7 +2532,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
finishedCallback.onAnimationFinished();
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException");
mLogger.logFailedToCallOnAnimationFinished(e);
} finally {
mInteractionJankMonitor.cancel(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
}
@@ -2628,11 +2601,9 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
* @param cancelled {@code true} if the animation was cancelled before it finishes.
*/
public void onKeyguardExitRemoteAnimationFinished(boolean cancelled) {
Log.d(TAG, "onKeyguardExitRemoteAnimationFinished");
mLogger.logOnKeyguardExitRemoteAnimationFinished();
if (!mSurfaceBehindRemoteAnimationRunning && !mSurfaceBehindRemoteAnimationRequested) {
Log.d(TAG, "skip onKeyguardExitRemoteAnimationFinished cancelled=" + cancelled
+ " surfaceAnimationRunning=" + mSurfaceBehindRemoteAnimationRunning
+ " surfaceAnimationRequested=" + mSurfaceBehindRemoteAnimationRequested);
mLogger.logSkipOnKeyguardExitRemoteAnimationFinished(cancelled, false, false);
return;
}
@@ -2646,13 +2617,13 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
onKeyguardExitFinished();
if (mKeyguardStateController.isDismissingFromSwipe() || wasShowing) {
Log.d(TAG, "onKeyguardExitRemoteAnimationFinished"
+ "#hideKeyguardViewAfterRemoteAnimation");
mLogger.logOnKeyguardExitRemoteAnimationFinishedHideKeyguardView();
mKeyguardUnlockAnimationControllerLazy.get().hideKeyguardViewAfterRemoteAnimation();
} else {
Log.d(TAG, "skip hideKeyguardViewAfterRemoteAnimation"
+ " dismissFromSwipe=" + mKeyguardStateController.isDismissingFromSwipe()
+ " wasShowing=" + wasShowing);
mLogger.logSkipHideKeyguardViewAfterRemoteAnimation(
mKeyguardStateController.isDismissingFromSwipe(),
wasShowing
);
}
finishSurfaceBehindRemoteAnimation(cancelled);
@@ -2749,7 +2720,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
}
if (mStatusBarManager == null) {
Log.w(TAG, "Could not get status bar manager");
mLogger.logCouldNotGetStatusBarManager();
} else {
// Disable aspects of the system/status/navigation bars that must not be re-enabled by
// windows that appear on top, ever
@@ -2767,12 +2738,13 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
}
flags |= StatusBarManager.DISABLE_RECENT;
}
if (DEBUG) {
Log.d(TAG, "adjustStatusBarLocked: mShowing=" + mShowing + " mOccluded=" + mOccluded
+ " isSecure=" + isSecure() + " force=" + forceHideHomeRecentsButtons
+ " --> flags=0x" + Integer.toHexString(flags));
}
mLogger.logAdjustStatusBarLocked(
mShowing,
mOccluded,
isSecure(),
forceHideHomeRecentsButtons,
Integer.toHexString(flags)
);
mStatusBarManager.disable(flags);
}
@@ -2784,7 +2756,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
*/
private void handleReset() {
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleReset");
mLogger.logHandleReset();
mKeyguardViewControllerLazy.get().reset(true /* hideBouncerWhenShowing */);
}
}
@@ -2796,7 +2768,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
private void handleVerifyUnlock() {
Trace.beginSection("KeyguardViewMediator#handleVerifyUnlock");
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleVerifyUnlock");
mLogger.logHandleVerifyUnlock();
setShowingLocked(true);
mKeyguardViewControllerLazy.get().dismissAndCollapse();
}
@@ -2805,7 +2777,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
private void handleNotifyStartedGoingToSleep() {
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleNotifyStartedGoingToSleep");
mLogger.logHandleNotifyStartedGoingToSleep();
mKeyguardViewControllerLazy.get().onStartedGoingToSleep();
}
}
@@ -2816,7 +2788,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
*/
private void handleNotifyFinishedGoingToSleep() {
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleNotifyFinishedGoingToSleep");
mLogger.logHandleNotifyFinishedGoingToSleep();
mKeyguardViewControllerLazy.get().onFinishedGoingToSleep();
}
}
@@ -2824,7 +2796,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
private void handleNotifyStartedWakingUp() {
Trace.beginSection("KeyguardViewMediator#handleMotifyStartedWakingUp");
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleNotifyWakingUp");
mLogger.logHandleNotifyWakingUp();
mKeyguardViewControllerLazy.get().onStartedWakingUp();
}
Trace.endSection();
@@ -3090,7 +3062,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
callback.onShowingStateChanged(showing, KeyguardUpdateMonitor.getCurrentUser());
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onShowingStateChanged", e);
mLogger.logFailedToCallOnShowingStateChanged(e);
if (e instanceof DeadObjectException) {
mKeyguardStateCallbacks.remove(callback);
}
@@ -3109,7 +3081,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
mKeyguardStateCallbacks.get(i).onTrustedChanged(trusted);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call notifyTrustedChangedLocked", e);
mLogger.logFailedToCallNotifyTrustedChangedLocked(e);
if (e instanceof DeadObjectException) {
mKeyguardStateCallbacks.remove(i);
}
@@ -3132,7 +3104,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
callback.onTrustedChanged(mUpdateMonitor.getUserHasTrust(
KeyguardUpdateMonitor.getCurrentUser()));
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call to IKeyguardStateCallback", e);
mLogger.logFailedToCallIKeyguardStateCallback(e);
}
}
}
@@ -3209,7 +3181,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
// internal state to reflect that immediately, vs. waiting for the launch animator to
// begin. Otherwise, calls to setShowingLocked, etc. will not know that we're about to
// be occluded and might re-show the keyguard.
Log.d(TAG, "OccludeAnimator#onAnimationStart. Set occluded = true.");
mLogger.logOccludeAnimatorOnAnimationStart();
setOccluded(true /* isOccluded */, false /* animate */);
}
@@ -3217,8 +3189,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
public void onAnimationCancelled(boolean isKeyguardOccluded) throws RemoteException {
super.onAnimationCancelled(isKeyguardOccluded);
Log.d(TAG, "Occlude animation cancelled by WM. "
+ "Setting occluded state to: " + isKeyguardOccluded);
mLogger.logOccludeAnimationCancelledByWm(isKeyguardOccluded);
setOccluded(isKeyguardOccluded /* occluded */, false /* animate */);
}

View File

@@ -30,6 +30,7 @@ import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent;
import com.android.keyguard.dagger.KeyguardStatusBarViewComponent;
import com.android.keyguard.dagger.KeyguardStatusViewComponent;
import com.android.keyguard.dagger.KeyguardUserSwitcherComponent;
import com.android.keyguard.logging.KeyguardViewMediatorLogger;
import com.android.keyguard.mediator.ScreenOnCoordinator;
import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.broadcast.BroadcastDispatcher;
@@ -105,7 +106,8 @@ public class KeyguardModule {
InteractionJankMonitor interactionJankMonitor,
DreamOverlayStateController dreamOverlayStateController,
Lazy<NotificationShadeWindowController> notificationShadeWindowController,
Lazy<ActivityLaunchAnimator> activityLaunchAnimator) {
Lazy<ActivityLaunchAnimator> activityLaunchAnimator,
KeyguardViewMediatorLogger logger) {
return new KeyguardViewMediator(
context,
falsingCollector,
@@ -132,7 +134,8 @@ public class KeyguardModule {
interactionJankMonitor,
dreamOverlayStateController,
notificationShadeWindowController,
activityLaunchAnimator);
activityLaunchAnimator,
logger);
}
/** */

View File

@@ -158,8 +158,13 @@ class LogBuffer @JvmOverloads constructor(
* add more detail to 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) =
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.

View File

@@ -1,4 +1,7 @@
package com.android.systemui.log.dagger
import javax.inject.Qualifier
/** A [com.android.systemui.log.LogBuffer] for KeyguardUpdateMonitor. */
@Qualifier
annotation class KeyguardUpdateMonitorLog

View File

@@ -0,0 +1,23 @@
/*
* 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.systemui.log.dagger
import javax.inject.Qualifier
/** A [com.android.systemui.log.LogBuffer] for KeyguardViewMediator. */
@Qualifier
annotation class KeyguardViewMediatorLog

View File

@@ -305,4 +305,15 @@ public class LogModule {
public static LogBuffer provideKeyguardUpdateMonitorLogBuffer(LogBufferFactory factory) {
return factory.create("KeyguardUpdateMonitorLog", 200);
}
/**
* Provides a {@link LogBuffer} for use by
* {@link com.android.systemui.keyguard.KeyguardViewMediator}.
*/
@Provides
@SysUISingleton
@KeyguardViewMediatorLog
public static LogBuffer provideKeyguardViewMediatorLogBuffer(LogBufferFactory factory) {
return factory.create("KeyguardViewMediatorLog", 100);
}
}

View File

@@ -48,6 +48,7 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardDisplayManager;
import com.android.keyguard.KeyguardSecurityView;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.logging.KeyguardViewMediatorLogger;
import com.android.keyguard.mediator.ScreenOnCoordinator;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.animation.ActivityLaunchAnimator;
@@ -106,6 +107,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
private @Mock Lazy<NotificationShadeWindowController> mNotificationShadeWindowControllerLazy;
private @Mock DreamOverlayStateController mDreamOverlayStateController;
private @Mock ActivityLaunchAnimator mActivityLaunchAnimator;
private @Mock KeyguardViewMediatorLogger mLogger;
private DeviceConfigProxy mDeviceConfig = new DeviceConfigProxyFake();
private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock());
@@ -262,7 +264,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
mInteractionJankMonitor,
mDreamOverlayStateController,
mNotificationShadeWindowControllerLazy,
() -> mActivityLaunchAnimator);
() -> mActivityLaunchAnimator,
mLogger);
mViewMediator.start();
}
}

View File

@@ -40,6 +40,18 @@ class LogBufferTest : SysuiTestCase() {
assertThat(dumpedString).contains("Some test message")
}
@Test
fun log_shouldSaveLogToBufferWithException() {
val exception = createTestException("Some exception test message", "SomeExceptionTestClass")
buffer.log("Test", LogLevel.INFO, "Some test message", exception)
val dumpedString = dumpBuffer()
assertThat(dumpedString).contains("Some test message")
assertThat(dumpedString).contains("Some exception test message")
assertThat(dumpedString).contains("SomeExceptionTestClass")
}
@Test
fun log_shouldRotateIfLogBufferIsFull() {
buffer.log("Test", LogLevel.INFO, "This should be rotated")