Generic refactoring for clarity.
- Log.* was being interspersed with Slog.*.
- WindowState Rects were being converted to local variables making
it harder to find all references to them.
Change-Id: I868a32028604d46dbbc15b005a440f0571336293
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 41efaa5..504413d 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -546,7 +546,7 @@
@Override
public void onProposedRotationChanged(int rotation) {
- if (localLOGV) Log.v(TAG, "onProposedRotationChanged, rotation=" + rotation);
+ if (localLOGV) Slog.v(TAG, "onProposedRotationChanged, rotation=" + rotation);
updateRotation(false);
}
}
@@ -623,7 +623,7 @@
}
//Could have been invoked due to screen turning on or off or
//change of the currently visible window's orientation
- if (localLOGV) Log.v(TAG, "Screen status="+mScreenOnEarly+
+ if (localLOGV) Slog.v(TAG, "Screen status="+mScreenOnEarly+
", current orientation="+mCurrentAppOrientation+
", SensorEnabled="+mOrientationSensorEnabled);
boolean disable = true;
@@ -633,7 +633,7 @@
//enable listener if not already enabled
if (!mOrientationSensorEnabled) {
mOrientationListener.enable();
- if(localLOGV) Log.v(TAG, "Enabling listeners");
+ if(localLOGV) Slog.v(TAG, "Enabling listeners");
mOrientationSensorEnabled = true;
}
}
@@ -641,7 +641,7 @@
//check if sensors need to be disabled
if (disable && mOrientationSensorEnabled) {
mOrientationListener.disable();
- if(localLOGV) Log.v(TAG, "Disabling listeners");
+ if(localLOGV) Slog.v(TAG, "Disabling listeners");
mOrientationSensorEnabled = false;
}
}
@@ -1700,7 +1700,7 @@
}
}
mNavigationBar = win;
- if (DEBUG_LAYOUT) Log.i(TAG, "NAVIGATION BAR: " + mNavigationBar);
+ if (DEBUG_LAYOUT) Slog.i(TAG, "NAVIGATION BAR: " + mNavigationBar);
break;
case TYPE_NAVIGATION_BAR_PANEL:
mContext.enforceCallingOrSelfPermission(
@@ -2713,9 +2713,9 @@
// And compute the final frame.
mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame,
mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame);
- if (DEBUG_LAYOUT) Log.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame);
+ if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame);
}
- if (DEBUG_LAYOUT) Log.i(TAG, String.format("mDock rect: (%d,%d - %d,%d)",
+ if (DEBUG_LAYOUT) Slog.i(TAG, String.format("mDock rect: (%d,%d - %d,%d)",
mDockLeft, mDockTop, mDockRight, mDockBottom));
// decide where the status bar goes ahead of time
@@ -2754,7 +2754,7 @@
mContentLeft = mCurLeft = mDockLeft;
mContentRight = mCurRight = mDockRight;
- if (DEBUG_LAYOUT) Log.v(TAG, "Status bar: " +
+ if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar: " +
String.format(
"dock=[%d,%d][%d,%d] content=[%d,%d][%d,%d] cur=[%d,%d][%d,%d]",
mDockLeft, mDockTop, mDockRight, mDockBottom,
@@ -2872,9 +2872,7 @@
final boolean needsToOffsetInputMethodTarget = isDefaultDisplay &&
(win == mLastInputMethodTargetWindow && mLastInputMethodWindow != null);
if (needsToOffsetInputMethodTarget) {
- if (DEBUG_LAYOUT) {
- Slog.i(TAG, "Offset ime target window by the last ime window state");
- }
+ if (DEBUG_LAYOUT) Slog.i(TAG, "Offset ime target window by the last ime window state");
offsetInputMethodWindowLw(mLastInputMethodWindow);
}
@@ -2918,8 +2916,7 @@
} else {
if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR))
== (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) {
- if (DEBUG_LAYOUT)
- Log.v(TAG, "layoutWindowLw(" + attrs.getTitle()
+ if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle()
+ "): IN_SCREEN, INSET_DECOR");
// This is the case for a normal activity window: we want it
// to cover all of the screen space, and it can take care of
@@ -2949,11 +2946,9 @@
? mRestrictedScreenTop+mRestrictedScreenHeight
: mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
- if (DEBUG_LAYOUT) {
- Log.v(TAG, String.format(
+ if (DEBUG_LAYOUT) Slog.v(TAG, String.format(
"Laying out status bar window: (%d,%d - %d,%d)",
pf.left, pf.top, pf.right, pf.bottom));
- }
} else if ((attrs.flags&FLAG_LAYOUT_IN_OVERSCAN) != 0
&& attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
&& attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
@@ -3035,8 +3030,8 @@
} else if ((fl & FLAG_LAYOUT_IN_SCREEN) != 0 || (sysUiFl
& (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)) != 0) {
- if (DEBUG_LAYOUT)
- Log.v(TAG, "layoutWindowLw(" + attrs.getTitle() + "): IN_SCREEN");
+ if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() +
+ "): IN_SCREEN");
// A window that has requested to fill the entire screen just
// gets everything, period.
if (attrs.type == TYPE_STATUS_BAR_PANEL
@@ -3050,11 +3045,9 @@
pf.bottom = df.bottom = of.bottom = cf.bottom = hasNavBar
? mRestrictedScreenTop+mRestrictedScreenHeight
: mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
- if (DEBUG_LAYOUT) {
- Log.v(TAG, String.format(
+ if (DEBUG_LAYOUT) Slog.v(TAG, String.format(
"Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)",
pf.left, pf.top, pf.right, pf.bottom));
- }
} else if (attrs.type == TYPE_NAVIGATION_BAR
|| attrs.type == TYPE_NAVIGATION_BAR_PANEL) {
// The navigation bar has Real Ultimate Power.
@@ -3064,11 +3057,9 @@
+ mUnrestrictedScreenWidth;
pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop
+ mUnrestrictedScreenHeight;
- if (DEBUG_LAYOUT) {
- Log.v(TAG, String.format(
+ if (DEBUG_LAYOUT) Slog.v(TAG, String.format(
"Laying out navigation bar window: (%d,%d - %d,%d)",
pf.left, pf.top, pf.right, pf.bottom));
- }
} else if ((attrs.type == TYPE_SECURE_SYSTEM_OVERLAY
|| attrs.type == TYPE_BOOT_PROGRESS)
&& ((fl & FLAG_FULLSCREEN) != 0)) {
@@ -3144,14 +3135,14 @@
vf.set(cf);
}
} else if (attached != null) {
- if (DEBUG_LAYOUT)
- Log.v(TAG, "layoutWindowLw(" + attrs.getTitle() + "): attached to " + attached);
+ if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() +
+ "): attached to " + attached);
// A child window should be placed inside of the same visible
// frame that its parent had.
setAttachedWindowFrames(win, fl, adjust, attached, false, pf, df, of, cf, vf);
} else {
- if (DEBUG_LAYOUT)
- Log.v(TAG, "layoutWindowLw(" + attrs.getTitle() + "): normal window");
+ if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() +
+ "): normal window");
// Otherwise, a normal window must be placed inside the content
// of all screen decorations.
if (attrs.type == TYPE_STATUS_BAR_PANEL) {
@@ -3199,7 +3190,7 @@
= vf.right = vf.bottom = 10000;
}
- if (DEBUG_LAYOUT) Log.v(TAG, "Compute frame " + attrs.getTitle()
+ if (DEBUG_LAYOUT) Slog.v(TAG, "Compute frame " + attrs.getTitle()
+ ": sim=#" + Integer.toHexString(sim)
+ " attach=" + attached + " type=" + attrs.type
+ String.format(" flags=0x%08x", fl)
@@ -3229,7 +3220,7 @@
if (mCurBottom > top) {
mCurBottom = top;
}
- if (DEBUG_LAYOUT) Log.v(TAG, "Input method: mDockBottom="
+ if (DEBUG_LAYOUT) Slog.v(TAG, "Input method: mDockBottom="
+ mDockBottom + " mContentBottom="
+ mContentBottom + " mCurBottom=" + mCurBottom);
}
@@ -3296,21 +3287,20 @@
&& attrs.x == 0 && attrs.y == 0
&& attrs.width == WindowManager.LayoutParams.MATCH_PARENT
&& attrs.height == WindowManager.LayoutParams.MATCH_PARENT) {
- if (DEBUG_LAYOUT) Log.v(TAG, "Fullscreen window: " + win);
+ if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win);
mTopFullscreenOpaqueWindowState = win;
if ((attrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0) {
- if (DEBUG_LAYOUT) Log.v(TAG, "Setting mHideLockScreen to true by win " + win);
+ if (DEBUG_LAYOUT) Slog.v(TAG, "Setting mHideLockScreen to true by win " + win);
mHideLockScreen = true;
mForceStatusBarFromKeyguard = false;
}
if ((attrs.flags & FLAG_DISMISS_KEYGUARD) != 0
&& mDismissKeyguard == DISMISS_KEYGUARD_NONE) {
- if (DEBUG_LAYOUT) Log.v(TAG, "Setting mDismissKeyguard to true by win " + win);
+ if (DEBUG_LAYOUT) Slog.v(TAG, "Setting mDismissKeyguard true by win " + win);
mDismissKeyguard = mWinDismissingKeyguard == win ?
DISMISS_KEYGUARD_CONTINUE : DISMISS_KEYGUARD_START;
mWinDismissingKeyguard = win;
- mForceStatusBarFromKeyguard =
- mShowingLockscreen && isKeyguardSecure();
+ mForceStatusBarFromKeyguard = mShowingLockscreen && isKeyguardSecure();
}
if ((attrs.flags & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) {
mAllowLockscreenWhenOn = true;
@@ -3338,17 +3328,17 @@
}
if (mStatusBar != null) {
- if (DEBUG_LAYOUT) Log.i(TAG, "force=" + mForceStatusBar
+ if (DEBUG_LAYOUT) Slog.i(TAG, "force=" + mForceStatusBar
+ " forcefkg=" + mForceStatusBarFromKeyguard
+ " top=" + mTopFullscreenOpaqueWindowState);
if (mForceStatusBar || mForceStatusBarFromKeyguard) {
- if (DEBUG_LAYOUT) Log.v(TAG, "Showing status bar: forced");
+ if (DEBUG_LAYOUT) Slog.v(TAG, "Showing status bar: forced");
if (mStatusBar.showLw(true)) changes |= FINISH_LAYOUT_REDO_LAYOUT;
} else if (mTopFullscreenOpaqueWindowState != null) {
if (localLOGV) {
- Log.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw()
+ Slog.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw()
+ " shown frame: " + mTopFullscreenOpaqueWindowState.getShownFrameLw());
- Log.d(TAG, "attr: " + mTopFullscreenOpaqueWindowState.getAttrs()
+ Slog.d(TAG, "attr: " + mTopFullscreenOpaqueWindowState.getAttrs()
+ " lp.flags=0x" + Integer.toHexString(lp.flags));
}
topIsFullscreen = (lp.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0
@@ -3362,7 +3352,7 @@
changes |= FINISH_LAYOUT_REDO_LAYOUT;
}
} else if (topIsFullscreen) {
- if (DEBUG_LAYOUT) Log.v(TAG, "** HIDING status bar");
+ if (DEBUG_LAYOUT) Slog.v(TAG, "** HIDING status bar");
if (mStatusBar.hideLw(true)) {
changes |= FINISH_LAYOUT_REDO_LAYOUT;
@@ -3379,11 +3369,11 @@
mStatusBarService = null;
}
}});
- } else if (DEBUG_LAYOUT) {
- Log.v(TAG, "Preventing status bar from hiding by policy");
+ } else {
+ if (DEBUG_LAYOUT) Slog.v(TAG, "Policy preventing status bar from hiding");
}
} else {
- if (DEBUG_LAYOUT) Log.v(TAG, "** SHOWING status bar: top is not fullscreen");
+ if (DEBUG_LAYOUT) Slog.v(TAG, "** SHOWING status bar: top is not fullscreen");
if (mStatusBar.showLw(true)) changes |= FINISH_LAYOUT_REDO_LAYOUT;
}
}
@@ -3394,7 +3384,7 @@
// Hide the key guard if a visible window explicitly specifies that it wants to be
// displayed when the screen is locked.
if (mKeyguard != null) {
- if (localLOGV) Log.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard="
+ if (localLOGV) Slog.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard="
+ mHideLockScreen);
if (mDismissKeyguard != DISMISS_KEYGUARD_NONE && !mKeyguardDelegate.isSecure()) {
if (mKeyguard.hideLw(true)) {
@@ -4512,7 +4502,7 @@
? HapticFeedbackConstants.SAFE_MODE_ENABLED
: HapticFeedbackConstants.SAFE_MODE_DISABLED, true);
}
-
+
static long[] getLongIntArray(Resources r, int resid) {
int[] ar = r.getIntArray(resid);
if (ar == null) {
@@ -4524,8 +4514,9 @@
}
return out;
}
-
+
/** {@inheritDoc} */
+ @Override
public void systemReady() {
if (!mHeadless) {
mKeyguardDelegate = new KeyguardServiceDelegate(mContext, null);
@@ -4535,6 +4526,7 @@
updateOrientationListenerLp();
mSystemReady = true;
mHandler.post(new Runnable() {
+ @Override
public void run() {
updateSettings();
}
@@ -4685,6 +4677,7 @@
}
/** {@inheritDoc} */
+ @Override
public void enableScreenAfterBoot() {
readLidState();
applyLidSwitchState();
@@ -4726,7 +4719,7 @@
* <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME
* <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME
* </ul>
- * @return
+ * @return A dock intent.
*/
Intent createHomeDockIntent() {
Intent intent = null;
@@ -4781,7 +4774,7 @@
mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT);
}
-
+
/**
* goes to the home screen
* @return whether it did anything
@@ -4833,7 +4826,8 @@
}
return true;
}
-
+
+ @Override
public void setCurrentOrientationLw(int newOrientation) {
synchronized (mLock) {
if (newOrientation != mCurrentAppOrientation) {
@@ -4857,11 +4851,13 @@
ringTone.setStreamType(AudioManager.STREAM_MUSIC);
ringTone.play();
}
+
private boolean isGlobalAccessibilityGestureEnabled() {
return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, 0) == 1;
}
+ @Override
public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) {
if (!mVibrator.hasVibrator()) {
return false;
@@ -4969,6 +4965,7 @@
mLastFocusNeedsMenu = needsMenu;
mFocusedApp = mFocusedWindow.getAppToken();
mHandler.post(new Runnable() {
+ @Override
public void run() {
try {
IStatusBarService statusbar = getStatusBarService();
@@ -4987,6 +4984,7 @@
// Use this instead of checking config_showNavigationBar so that it can be consistently
// overridden by qemu.hw.mainkeys in the emulator.
+ @Override
public boolean hasNavigationBar() {
return mHasNavigationBar;
}
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java
index 807962b..ac6d65f 100644
--- a/services/java/com/android/server/wm/WindowState.java
+++ b/services/java/com/android/server/wm/WindowState.java
@@ -447,8 +447,7 @@
mContainingFrame.set(pf);
}
- final Rect display = mDisplayFrame;
- display.set(df);
+ mDisplayFrame.set(df);
final int pw = mContainingFrame.width();
final int ph = mContainingFrame.height();
@@ -498,18 +497,12 @@
mContentChanged = true;
}
- final Rect overscan = mOverscanFrame;
- overscan.set(of);
+ mOverscanFrame.set(of);
+ mContentFrame.set(cf);
+ mVisibleFrame.set(vf);
- final Rect content = mContentFrame;
- content.set(cf);
-
- final Rect visible = mVisibleFrame;
- visible.set(vf);
-
- final Rect frame = mFrame;
- final int fw = frame.width();
- final int fh = frame.height();
+ final int fw = mFrame.width();
+ final int fh = mFrame.height();
//System.out.println("In: w=" + w + " h=" + h + " container=" +
// container + " x=" + mAttrs.x + " y=" + mAttrs.y);
@@ -525,61 +518,60 @@
Gravity.apply(mAttrs.gravity, w, h, mContainingFrame,
(int) (x + mAttrs.horizontalMargin * pw),
- (int) (y + mAttrs.verticalMargin * ph), frame);
+ (int) (y + mAttrs.verticalMargin * ph), mFrame);
//System.out.println("Out: " + mFrame);
// Now make sure the window fits in the overall display.
- Gravity.applyDisplay(mAttrs.gravity, df, frame);
+ Gravity.applyDisplay(mAttrs.gravity, df, mFrame);
// Make sure the overscan, content and visible frames are inside of the
// final window frame.
- if (overscan.left < frame.left) overscan.left = frame.left;
- if (overscan.top < frame.top) overscan.top = frame.top;
- if (overscan.right > frame.right) overscan.right = frame.right;
- if (overscan.bottom > frame.bottom) overscan.bottom = frame.bottom;
- if (content.left < frame.left) content.left = frame.left;
- if (content.top < frame.top) content.top = frame.top;
- if (content.right > frame.right) content.right = frame.right;
- if (content.bottom > frame.bottom) content.bottom = frame.bottom;
- if (visible.left < frame.left) visible.left = frame.left;
- if (visible.top < frame.top) visible.top = frame.top;
- if (visible.right > frame.right) visible.right = frame.right;
- if (visible.bottom > frame.bottom) visible.bottom = frame.bottom;
+ mOverscanFrame.set(Math.max(mOverscanFrame.left, mFrame.left),
+ Math.max(mOverscanFrame.top, mFrame.top),
+ Math.min(mOverscanFrame.right, mFrame.right),
+ Math.min(mOverscanFrame.bottom, mFrame.bottom));
- final Rect overscanInsets = mOverscanInsets;
- overscanInsets.left = overscan.left-frame.left;
- overscanInsets.top = overscan.top-frame.top;
- overscanInsets.right = frame.right-overscan.right;
- overscanInsets.bottom = frame.bottom-overscan.bottom;
+ mContentFrame.set(Math.max(mContentFrame.left, mFrame.left),
+ Math.max(mContentFrame.top, mFrame.top),
+ Math.min(mContentFrame.right, mFrame.right),
+ Math.min(mContentFrame.bottom, mFrame.bottom));
- final Rect contentInsets = mContentInsets;
- contentInsets.left = content.left-frame.left;
- contentInsets.top = content.top-frame.top;
- contentInsets.right = frame.right-content.right;
- contentInsets.bottom = frame.bottom-content.bottom;
+ mVisibleFrame.set(Math.max(mVisibleFrame.left, mFrame.left),
+ Math.max(mVisibleFrame.top, mFrame.top),
+ Math.min(mVisibleFrame.right, mFrame.right),
+ Math.min(mVisibleFrame.bottom, mFrame.bottom));
- final Rect visibleInsets = mVisibleInsets;
- visibleInsets.left = visible.left-frame.left;
- visibleInsets.top = visible.top-frame.top;
- visibleInsets.right = frame.right-visible.right;
- visibleInsets.bottom = frame.bottom-visible.bottom;
+ mOverscanInsets.set(mOverscanFrame.left - mFrame.left,
+ mOverscanFrame.top - mFrame.top,
+ mFrame.right - mOverscanFrame.right,
+ mFrame.bottom - mOverscanFrame.bottom);
- mCompatFrame.set(frame);
+ mContentInsets.set(mContentFrame.left - mFrame.left,
+ mContentFrame.top - mFrame.top,
+ mFrame.right - mContentFrame.right,
+ mFrame.bottom - mContentFrame.bottom);
+
+ mVisibleInsets.set(mVisibleFrame.left - mFrame.left,
+ mVisibleFrame.top - mFrame.top,
+ mFrame.right - mVisibleFrame.right,
+ mFrame.bottom - mVisibleFrame.bottom);
+
+ mCompatFrame.set(mFrame);
if (mEnforceSizeCompat) {
// If there is a size compatibility scale being applied to the
// window, we need to apply this to its insets so that they are
// reported to the app in its coordinate space.
- overscanInsets.scale(mInvGlobalScale);
- contentInsets.scale(mInvGlobalScale);
- visibleInsets.scale(mInvGlobalScale);
+ mOverscanInsets.scale(mInvGlobalScale);
+ mContentInsets.scale(mInvGlobalScale);
+ mVisibleInsets.scale(mInvGlobalScale);
// Also the scaled frame that we report to the app needs to be
// adjusted to be in its coordinate space.
mCompatFrame.scale(mInvGlobalScale);
}
- if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) {
+ if (mIsWallpaper && (fw != mFrame.width() || fh != mFrame.height())) {
final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
mService.updateWallpaperOffsetLocked(this, displayInfo.appWidth, displayInfo.appHeight,
false);
@@ -592,8 +584,8 @@
+ mRequestedWidth + ", mRequestedheight="
+ mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph
+ "): frame=" + mFrame.toShortString()
- + " ci=" + contentInsets.toShortString()
- + " vi=" + visibleInsets.toShortString());
+ + " ci=" + mContentInsets.toShortString()
+ + " vi=" + mVisibleInsets.toShortString());
//}
}
}