From d9d714873097c5c263f310a9955e52434e309d62 Mon Sep 17 00:00:00 2001 From: Robin Lee Date: Thu, 25 Jul 2024 14:46:13 +0200 Subject: Move writeWmSetKeyguardShown to a method Writing this out by hand each time is verbose and error-prone, and confusing if some of the values are provisional instead of the real state at the time of the log. Bug: 354647472 Flag: EXEMPT mechanical refactor Test: atest CtsWindowManagerDeviceActivity Change-Id: Iaf1468fd4a9ab09e2b627c62af0144a4037a98f9 --- .../com/android/server/wm/KeyguardController.java | 38 ++++++++-------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/services/core/java/com/android/server/wm/KeyguardController.java b/services/core/java/com/android/server/wm/KeyguardController.java index 872b4e102565..ea4ad1ff492b 100644 --- a/services/core/java/com/android/server/wm/KeyguardController.java +++ b/services/core/java/com/android/server/wm/KeyguardController.java @@ -198,14 +198,6 @@ class KeyguardController { setWakeTransitionReady(); return; } - EventLogTags.writeWmSetKeyguardShown( - displayId, - keyguardShowing ? 1 : 0, - aodShowing ? 1 : 0, - state.mKeyguardGoingAway ? 1 : 0, - state.mOccluded ? 1 : 0, - "setKeyguardShown"); - // Update the task snapshot if the screen will not be turned off. To make sure that the // unlocking animation can animate consistent content. The conditions are: // - Either AOD or keyguard changes to be showing. So if the states change individually, @@ -224,6 +216,7 @@ class KeyguardController { state.mKeyguardShowing = keyguardShowing; state.mAodShowing = aodShowing; + state.writeEventLog("setKeyguardShown"); if (keyguardChanged) { // Irrelevant to AOD. @@ -284,13 +277,7 @@ class KeyguardController { mService.deferWindowLayout(); state.mKeyguardGoingAway = true; try { - EventLogTags.writeWmSetKeyguardShown( - displayId, - state.mKeyguardShowing ? 1 : 0, - state.mAodShowing ? 1 : 0, - 1 /* keyguardGoingAway */, - state.mOccluded ? 1 : 0, - "keyguardGoingAway"); + state.writeEventLog("keyguardGoingAway"); final int transitFlags = convertTransitFlags(flags); final DisplayContent dc = mRootWindowContainer.getDefaultDisplay(); dc.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, transitFlags); @@ -646,6 +633,16 @@ class KeyguardController { mSleepTokenAcquirer.release(mDisplayId); } + void writeEventLog(String reason) { + EventLogTags.writeWmSetKeyguardShown( + mDisplayId, + mKeyguardShowing ? 1 : 0, + mAodShowing ? 1 : 0, + mKeyguardGoingAway ? 1 : 0, + mOccluded ? 1 : 0, + reason); + } + /** * Updates keyguard status if the top task could be visible. The top task may occlude * keyguard, request to dismiss keyguard or make insecure keyguard go away based on its @@ -716,18 +713,11 @@ class KeyguardController { boolean hasChange = false; if (lastOccluded != mOccluded) { - if (mDisplayId == DEFAULT_DISPLAY) { - EventLogTags.writeWmSetKeyguardShown( - mDisplayId, - mKeyguardShowing ? 1 : 0, - mAodShowing ? 1 : 0, - mKeyguardGoingAway ? 1 : 0, - mOccluded ? 1 : 0, - "updateVisibility"); - } + writeEventLog("updateVisibility"); controller.handleOccludedChanged(mDisplayId, mTopOccludesActivity); hasChange = true; } else if (!lastKeyguardGoingAway && mKeyguardGoingAway) { + writeEventLog("dismissIfInsecure"); controller.handleKeyguardGoingAwayChanged(display); hasChange = true; } -- cgit v1.2.3-59-g8ed1b