Added logging to debug empty keyguard state
Bug: 21124013
Change-Id: Icdc085e993aae073ed7c42333f49644624971787
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
index de426430..58017d0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
@@ -21,6 +21,7 @@
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.os.SystemProperties;
+import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
@@ -31,6 +32,8 @@
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.StatusBarState;
+import java.lang.reflect.Field;
+
/**
* Encapsulates all logic for the status bar window state management.
*/
@@ -45,6 +48,7 @@
private final boolean mKeyguardScreenRotation;
private final State mCurrentState = new State();
+ private boolean mLogState;
public StatusBarWindowManager(Context context) {
mContext = context;
@@ -129,9 +133,7 @@
}
private void applyHeight(State state) {
- boolean expanded = !state.forceCollapsed && (state.isKeyguardShowingAndNotOccluded()
- || state.panelVisible || state.keyguardFadingAway || state.bouncerShowing
- || state.headsUpShowing);
+ boolean expanded = isExpanded(state);
if (expanded) {
mLpChanged.height = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
@@ -139,6 +141,12 @@
}
}
+ private boolean isExpanded(State state) {
+ return !state.forceCollapsed && (state.isKeyguardShowingAndNotOccluded()
+ || state.panelVisible || state.keyguardFadingAway || state.bouncerShowing
+ || state.headsUpShowing);
+ }
+
private void applyFitsSystemWindows(State state) {
mStatusBarView.setFitsSystemWindows(!state.isKeyguardShowingAndNotOccluded());
}
@@ -176,6 +184,9 @@
applyFitsSystemWindows(state);
applyModalFlag(state);
if (mLp.copyFrom(mLpChanged) != 0) {
+ if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD && mLogState) {
+ logCurrentState();
+ }
mWindowManager.updateViewLayout(mStatusBarView, mLp);
}
}
@@ -272,6 +283,21 @@
apply(mCurrentState);
}
+ public void setLogState(boolean logState) {
+ mLogState = logState;
+ if (logState) {
+ Log.w(PhoneStatusBar.TAG, "===== Started logging WM state changes =====");
+ logCurrentState();
+ } else {
+ Log.w(PhoneStatusBar.TAG, "===== Finished logging WM state changes =====");
+ }
+ }
+
+ private void logCurrentState() {
+ Log.i(PhoneStatusBar.TAG, mCurrentState.toString()
+ + "\n Expanded: " + isExpanded(mCurrentState));
+ }
+
private static class State {
boolean keyguardShowing;
boolean keyguardOccluded;
@@ -294,5 +320,31 @@
private boolean isKeyguardShowingAndNotOccluded() {
return keyguardShowing && !keyguardOccluded;
}
+
+ @Override
+ public String toString() {
+ StringBuilder result = new StringBuilder();
+ String newLine = "\n";
+ result.append("Window State {");
+ result.append(newLine);
+
+ Field[] fields = this.getClass().getDeclaredFields();
+
+ // Print field names paired with their values
+ for (Field field : fields) {
+ result.append(" ");
+ try {
+ result.append(field.getName());
+ result.append(": ");
+ //requires access to private field:
+ result.append(field.get(this));
+ } catch (IllegalAccessException ex) {
+ }
+ result.append(newLine);
+ }
+ result.append("}");
+
+ return result.toString();
+ }
}
}