am cb89ac84: Merge "Support for devices with a chin." into cw-d-mr1-dev

* commit 'cb89ac84c621e047d81873428325dfd747b90a6b':
  Support for devices with a chin.
This commit is contained in:
Filip Gruszczynski
2015-05-20 22:54:14 +00:00
committed by Android Git Automerger
18 changed files with 195 additions and 81 deletions

View File

@@ -18,7 +18,6 @@ package android.service.wallpaper;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.os.SystemProperties;
import android.view.WindowInsets;
import com.android.internal.R;
@@ -161,9 +160,11 @@ public abstract class WallpaperService extends Service {
final Rect mOverscanInsets = new Rect();
final Rect mContentInsets = new Rect();
final Rect mStableInsets = new Rect();
final Rect mOutsets = new Rect();
final Rect mDispatchedOverscanInsets = new Rect();
final Rect mDispatchedContentInsets = new Rect();
final Rect mDispatchedStableInsets = new Rect();
final Rect mDispatchedOutsets = new Rect();
final Rect mFinalSystemInsets = new Rect();
final Rect mFinalStableInsets = new Rect();
final Configuration mConfiguration = new Configuration();
@@ -270,7 +271,7 @@ public abstract class WallpaperService extends Service {
final BaseIWindow mWindow = new BaseIWindow() {
@Override
public void resized(Rect frame, Rect overscanInsets, Rect contentInsets,
Rect visibleInsets, Rect stableInsets, boolean reportDraw,
Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
Configuration newConfig) {
Message msg = mCaller.obtainMessageI(MSG_WINDOW_RESIZED,
reportDraw ? 1 : 0);
@@ -661,30 +662,35 @@ public abstract class WallpaperService extends Service {
mInputEventReceiver = new WallpaperInputEventReceiver(
mInputChannel, Looper.myLooper());
}
mSurfaceHolder.mSurfaceLock.lock();
mDrawingAllowed = true;
if (!fixedSize) {
mLayout.surfaceInsets.set(mIWallpaperEngine.mDisplayPadding);
mLayout.surfaceInsets.left += mOutsets.left;
mLayout.surfaceInsets.top += mOutsets.top;
mLayout.surfaceInsets.right += mOutsets.right;
mLayout.surfaceInsets.bottom += mOutsets.bottom;
} else {
mLayout.surfaceInsets.set(0, 0, 0, 0);
}
final int relayoutResult = mSession.relayout(
mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
View.VISIBLE, 0, mWinFrame, mOverscanInsets, mContentInsets,
mVisibleInsets, mStableInsets, mConfiguration, mSurfaceHolder.mSurface);
mVisibleInsets, mStableInsets, mOutsets, mConfiguration,
mSurfaceHolder.mSurface);
if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface
+ ", frame=" + mWinFrame);
int w = mWinFrame.width();
int h = mWinFrame.height();
if (!fixedSize) {
final Rect padding = mIWallpaperEngine.mDisplayPadding;
w += padding.left + padding.right;
h += padding.top + padding.bottom;
w += padding.left + padding.right + mOutsets.left + mOutsets.right;
h += padding.top + padding.bottom + mOutsets.top + mOutsets.bottom;
mOverscanInsets.left += padding.left;
mOverscanInsets.top += padding.top;
mOverscanInsets.right += padding.right;
@@ -708,9 +714,14 @@ public abstract class WallpaperService extends Service {
mCurHeight = h;
}
if (DEBUG) {
Log.v(TAG, "Wallpaper size has changed: (" + mCurWidth + ", " + mCurHeight);
}
insetsChanged |= !mDispatchedOverscanInsets.equals(mOverscanInsets);
insetsChanged |= !mDispatchedContentInsets.equals(mContentInsets);
insetsChanged |= !mDispatchedStableInsets.equals(mStableInsets);
insetsChanged |= !mDispatchedOutsets.equals(mOutsets);
mSurfaceHolder.setSurfaceFrameSize(w, h);
mSurfaceHolder.mSurfaceLock.unlock();
@@ -770,13 +781,20 @@ public abstract class WallpaperService extends Service {
if (insetsChanged) {
mDispatchedOverscanInsets.set(mOverscanInsets);
mDispatchedOverscanInsets.left += mOutsets.left;
mDispatchedOverscanInsets.top += mOutsets.top;
mDispatchedOverscanInsets.right += mOutsets.right;
mDispatchedOverscanInsets.bottom += mOutsets.bottom;
mDispatchedContentInsets.set(mContentInsets);
mDispatchedStableInsets.set(mStableInsets);
mDispatchedOutsets.set(mOutsets);
mFinalSystemInsets.set(mDispatchedOverscanInsets);
mFinalStableInsets.set(mDispatchedStableInsets);
mFinalSystemInsets.bottom = mIWallpaperEngine.mDisplayPadding.bottom;
WindowInsets insets = new WindowInsets(mFinalSystemInsets,
null, mFinalStableInsets, mWindowIsRound);
if (DEBUG) {
Log.v(TAG, "dispatching insets=" + insets);
}
onApplyWindowInsets(insets);
}

View File

@@ -46,7 +46,7 @@ oneway interface IWindow {
void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor);
void resized(in Rect frame, in Rect overscanInsets, in Rect contentInsets,
in Rect visibleInsets, in Rect stableInsets, boolean reportDraw,
in Rect visibleInsets, in Rect stableInsets, in Rect outsets, boolean reportDraw,
in Configuration newConfig);
void moved(int newX, int newY);
void dispatchAppVisibility(boolean visible);

View File

@@ -79,11 +79,13 @@ interface IWindowSession {
* contents to make sure the user can see it. This is different than
* <var>outContentInsets</var> in that these insets change transiently,
* so complex relayout of the window should not happen based on them.
* @param outOutsets Rect in which is placed the dead area of the screen that we would like to
* treat as real display. Example of such area is a chin in some models of wearable devices.
* @param outConfiguration New configuration of window, if it is now
* becoming visible and the global configuration has changed since it
* was last displayed.
* @param outSurface Object in which is placed the new display surface.
*
*
* @return int Result flags: {@link WindowManagerGlobal#RELAYOUT_SHOW_FOCUS},
* {@link WindowManagerGlobal#RELAYOUT_FIRST_TIME}.
*/
@@ -91,7 +93,7 @@ interface IWindowSession {
int requestedWidth, int requestedHeight, int viewVisibility,
int flags, out Rect outFrame, out Rect outOverscanInsets,
out Rect outContentInsets, out Rect outVisibleInsets, out Rect outStableInsets,
out Configuration outConfig, out Surface outSurface);
out Rect outOutsets, out Configuration outConfig, out Surface outSurface);
/**
* If a call to relayout() asked to have the surface destroy deferred,

View File

@@ -106,6 +106,7 @@ public class SurfaceView extends View {
final Rect mOverscanInsets = new Rect();
final Rect mContentInsets = new Rect();
final Rect mStableInsets = new Rect();
final Rect mOutsets = new Rect();
final Configuration mConfiguration = new Configuration();
static final int KEEP_SCREEN_ON_MSG = 1;
@@ -519,7 +520,8 @@ public class SurfaceView extends View {
visible ? VISIBLE : GONE,
WindowManagerGlobal.RELAYOUT_DEFER_SURFACE_DESTROY,
mWinFrame, mOverscanInsets, mContentInsets,
mVisibleInsets, mStableInsets, mConfiguration, mNewSurface);
mVisibleInsets, mStableInsets, mOutsets, mConfiguration,
mNewSurface);
if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) {
mReportDrawNeeded = true;
}
@@ -654,7 +656,7 @@ public class SurfaceView extends View {
@Override
public void resized(Rect frame, Rect overscanInsets, Rect contentInsets,
Rect visibleInsets, Rect stableInsets, boolean reportDraw,
Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
Configuration newConfig) {
SurfaceView surfaceView = mSurfaceView.get();
if (surfaceView != null) {

View File

@@ -6666,6 +6666,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
setFlags(OPTIONAL_FITS_SYSTEM_WINDOWS, OPTIONAL_FITS_SYSTEM_WINDOWS);
}
/**
* Returns the outsets, which areas of the device that aren't a surface, but we would like to
* treat them as such.
* @hide
*/
public void getOutsets(Rect outOutsetRect) {
outOutsetRect.set(mAttachInfo.mOutsets);
}
/**
* Returns the visibility status for this view.
*
@@ -20311,6 +20320,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*/
final Rect mStableInsets = new Rect();
/**
* For windows that include areas that are not covered by real surface these are the outsets
* for real surface.
*/
final Rect mOutsets = new Rect();
/**
* The internal insets given by this window. This value is
* supplied by the client (through

View File

@@ -261,6 +261,7 @@ public final class ViewRootImpl implements ViewParent,
final Rect mPendingVisibleInsets = new Rect();
final Rect mPendingStableInsets = new Rect();
final Rect mPendingContentInsets = new Rect();
final Rect mPendingOutsets = new Rect();
final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
= new ViewTreeObserver.InternalInsetsInfo();
@@ -1222,8 +1223,14 @@ public final class ViewRootImpl implements ViewParent,
void dispatchApplyInsets(View host) {
mDispatchContentInsets.set(mAttachInfo.mContentInsets);
mDispatchStableInsets.set(mAttachInfo.mStableInsets);
host.dispatchApplyWindowInsets(new WindowInsets(
mDispatchContentInsets, null /* windowDecorInsets */,
Rect outsets = mAttachInfo.mOutsets;
Rect contentInsets = mDispatchContentInsets;
if (outsets.left > 0 || outsets.top > 0 || outsets.right > 0 || outsets.bottom > 0) {
contentInsets = new Rect(contentInsets.left + outsets.left,
contentInsets.top + outsets.top, contentInsets.right + outsets.right,
contentInsets.bottom + outsets.bottom);
}
host.dispatchApplyWindowInsets(new WindowInsets(contentInsets, null /* windowDecorInsets */,
mDispatchStableInsets, mWindowIsRound));
}
@@ -1369,6 +1376,9 @@ public final class ViewRootImpl implements ViewParent,
if (DEBUG_LAYOUT) Log.v(TAG, "Visible insets changing to: "
+ mAttachInfo.mVisibleInsets);
}
if (!mPendingOutsets.equals(mAttachInfo.mOutsets)) {
insetsChanged = true;
}
if (lp.width == ViewGroup.LayoutParams.WRAP_CONTENT
|| lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
windowSizeMayChange = true;
@@ -1545,6 +1555,7 @@ public final class ViewRootImpl implements ViewParent,
mAttachInfo.mVisibleInsets);
final boolean stableInsetsChanged = !mPendingStableInsets.equals(
mAttachInfo.mStableInsets);
final boolean outsetsChanged = !mPendingOutsets.equals(mAttachInfo.mOutsets);
if (contentInsetsChanged) {
if (mWidth > 0 && mHeight > 0 && lp != null &&
((lp.systemUiVisibility|lp.subtreeSystemUiVisibility)
@@ -1628,9 +1639,11 @@ public final class ViewRootImpl implements ViewParent,
}
if (contentInsetsChanged || mLastSystemUiVisibility !=
mAttachInfo.mSystemUiVisibility || mApplyInsetsRequested
|| mLastOverscanRequested != mAttachInfo.mOverscanRequested) {
|| mLastOverscanRequested != mAttachInfo.mOverscanRequested
|| outsetsChanged) {
mLastSystemUiVisibility = mAttachInfo.mSystemUiVisibility;
mLastOverscanRequested = mAttachInfo.mOverscanRequested;
mAttachInfo.mOutsets.set(mPendingOutsets);
mApplyInsetsRequested = false;
dispatchApplyInsets(host);
}
@@ -3201,6 +3214,7 @@ public final class ViewRootImpl implements ViewParent,
&& mPendingContentInsets.equals(args.arg2)
&& mPendingStableInsets.equals(args.arg6)
&& mPendingVisibleInsets.equals(args.arg3)
&& mPendingOutsets.equals(args.arg7)
&& args.arg4 == null) {
break;
}
@@ -3219,6 +3233,7 @@ public final class ViewRootImpl implements ViewParent,
mPendingContentInsets.set((Rect) args.arg2);
mPendingStableInsets.set((Rect) args.arg6);
mPendingVisibleInsets.set((Rect) args.arg3);
mPendingOutsets.set((Rect) args.arg7);
args.recycle();
@@ -5317,7 +5332,7 @@ public final class ViewRootImpl implements ViewParent,
(int) (mView.getMeasuredHeight() * appScale + 0.5f),
viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
mWinFrame, mPendingOverscanInsets, mPendingContentInsets, mPendingVisibleInsets,
mPendingStableInsets, mPendingConfiguration, mSurface);
mPendingStableInsets, mPendingOutsets, mPendingConfiguration, mSurface);
//Log.d(TAG, "<<<<<< BACK FROM relayout");
if (restore) {
params.restore();
@@ -5593,7 +5608,8 @@ public final class ViewRootImpl implements ViewParent,
}
public void dispatchResized(Rect frame, Rect overscanInsets, Rect contentInsets,
Rect visibleInsets, Rect stableInsets, boolean reportDraw, Configuration newConfig) {
Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
Configuration newConfig) {
if (DEBUG_LAYOUT) Log.v(TAG, "Resizing " + this + ": frame=" + frame.toShortString()
+ " contentInsets=" + contentInsets.toShortString()
+ " visibleInsets=" + visibleInsets.toShortString()
@@ -5613,6 +5629,7 @@ public final class ViewRootImpl implements ViewParent,
args.arg4 = sameProcessCall && newConfig != null ? new Configuration(newConfig) : newConfig;
args.arg5 = sameProcessCall ? new Rect(overscanInsets) : overscanInsets;
args.arg6 = sameProcessCall ? new Rect(stableInsets) : stableInsets;
args.arg7 = sameProcessCall ? new Rect(outsets) : outsets;
msg.obj = args;
mHandler.sendMessage(msg);
}
@@ -6492,12 +6509,12 @@ public final class ViewRootImpl implements ViewParent,
@Override
public void resized(Rect frame, Rect overscanInsets, Rect contentInsets,
Rect visibleInsets, Rect stableInsets, boolean reportDraw,
Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
Configuration newConfig) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
viewAncestor.dispatchResized(frame, overscanInsets, contentInsets,
visibleInsets, stableInsets, reportDraw, newConfig);
visibleInsets, stableInsets, outsets, reportDraw, newConfig);
}
}

View File

@@ -158,10 +158,12 @@ public interface WindowManagerPolicy {
* @param decorFrame The decor frame specified by policy specific to this window,
* to use for proper cropping during animation.
* @param stableFrame The frame around which stable system decoration is positioned.
* @param outsetFrame The frame that includes areas that aren't part of the surface but we
* want to treat them as such.
*/
public void computeFrameLw(Rect parentFrame, Rect displayFrame,
Rect overlayFrame, Rect contentFrame, Rect visibleFrame, Rect decorFrame,
Rect stableFrame);
Rect stableFrame, Rect outsetFrame);
/**
* Retrieve the current frame of the window that has been assigned by

View File

@@ -46,6 +46,7 @@ public final class SomeArgs {
public Object arg4;
public Object arg5;
public Object arg6;
public Object arg7;
public int argi1;
public int argi2;
public int argi3;
@@ -97,6 +98,7 @@ public final class SomeArgs {
arg4 = null;
arg5 = null;
arg6 = null;
arg7 = null;
argi1 = 0;
argi2 = 0;
argi3 = 0;

View File

@@ -18,20 +18,14 @@ public class ScreenShapeHelper {
/**
* Return the bottom pixel window outset of a window given its style attributes.
* @param displayMetrics Display metrics of the current device
* @param windowStyle Window style attributes for the window.
* @return An outset dimension in pixels or 0 if no outset should be applied.
*/
public static int getWindowOutsetBottomPx(DisplayMetrics displayMetrics,
TypedArray windowStyle) {
public static int getWindowOutsetBottomPx(Resources resources) {
if (IS_EMULATOR) {
return SystemProperties.getInt(ViewRootImpl.PROPERTY_EMULATOR_WIN_OUTSET_BOTTOM_PX, 0);
} else if (windowStyle.hasValue(R.styleable.Window_windowOutsetBottom)) {
TypedValue outsetBottom = new TypedValue();
windowStyle.getValue(R.styleable.Window_windowOutsetBottom, outsetBottom);
return (int) outsetBottom.getDimension(displayMetrics);
} else {
return resources.getInteger(com.android.internal.R.integer.config_windowOutsetBottom);
}
return 0;
}
/**
@@ -41,8 +35,7 @@ public class ScreenShapeHelper {
if (IS_EMULATOR) {
return SystemProperties.getBoolean(ViewRootImpl.PROPERTY_EMULATOR_CIRCULAR, false);
} else {
return resources.getBoolean(
com.android.internal.R.bool.config_windowIsRound);
return resources.getBoolean(com.android.internal.R.bool.config_windowIsRound);
}
}
}

View File

@@ -34,8 +34,8 @@ public class BaseIWindow extends IWindow.Stub {
}
@Override
public void resized(Rect frame, Rect overscanInsets, Rect contentInsets,
Rect visibleInsets, Rect stableInsets, boolean reportDraw, Configuration newConfig) {
public void resized(Rect frame, Rect overscanInsets, Rect contentInsets, Rect visibleInsets,
Rect stableInsets, Rect outsets, boolean reportDraw, Configuration newConfig) {
if (reportDraw) {
try {
mSession.finishDrawing(this);

View File

@@ -1826,6 +1826,11 @@
<!-- default window inset isRound property -->
<bool name="config_windowIsRound">false</bool>
<!-- Override this value if the device has a chin, i.e. area that is not actual part of the
screen but you would like to be treated as a real display. The value is the height of the
chin. -->
<integer name="config_windowOutsetBottom">0</integer>
<!-- Package name for default network scorer app; overridden by product overlays. -->
<string name="config_defaultNetworkScorerPackageName"></string>

View File

@@ -374,6 +374,7 @@
<java-symbol type="integer" name="config_wifi_supplicant_scan_interval" />
<java-symbol type="integer" name="config_wifi_disconnected_scan_interval" />
<java-symbol type="integer" name="config_wifi_scan_interval_p2p_connected" />
<java-symbol type="integer" name="config_windowOutsetBottom" />
<java-symbol type="integer" name="db_connection_pool_size" />
<java-symbol type="integer" name="db_journal_size_limit" />
<java-symbol type="integer" name="db_wal_autocheckpoint" />

View File

@@ -25,7 +25,6 @@ import static android.view.WindowManager.LayoutParams.*;
import android.app.SearchManager;
import android.os.UserHandle;
import com.android.internal.R;
import com.android.internal.util.ScreenShapeHelper;
import com.android.internal.view.RootViewSurfaceTaker;
import com.android.internal.view.StandaloneActionMode;
import com.android.internal.view.menu.ContextMenuBuilder;
@@ -62,7 +61,6 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.transition.Scene;
import android.transition.Transition;
import android.transition.TransitionInflater;
@@ -76,7 +74,6 @@ import android.util.SparseArray;
import android.util.TypedValue;
import android.view.ActionMode;
import android.view.ContextThemeWrapper;
import android.view.Display;
import android.view.Gravity;
import android.view.IRotationWatcher;
import android.view.IWindowManager;
@@ -280,6 +277,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
private Boolean mSharedElementsUseOverlay;
private Rect mTempRect;
private Rect mOutsets = new Rect();
static class WindowManagerHolder {
static final IWindowManager sWindowManager = IWindowManager.Stub.asInterface(
@@ -2379,19 +2377,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
return super.dispatchGenericMotionEvent(event);
}
@Override
public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
if (mOutsetBottomPx != 0) {
WindowInsets newInsets = insets.replaceSystemWindowInsets(
insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
insets.getSystemWindowInsetRight(), mOutsetBottomPx);
return super.dispatchApplyWindowInsets(newInsets);
} else {
return super.dispatchApplyWindowInsets(insets);
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return onInterceptTouchEvent(event);
@@ -2603,11 +2588,21 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
}
}
if (mOutsetBottomPx != 0) {
getOutsets(mOutsets);
if (mOutsets.top > 0 || mOutsets.bottom > 0) {
int mode = MeasureSpec.getMode(heightMeasureSpec);
if (mode != MeasureSpec.UNSPECIFIED) {
int height = MeasureSpec.getSize(heightMeasureSpec);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height + mOutsetBottomPx, mode);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(
height + mOutsets.top + mOutsets.bottom, mode);
}
}
if (mOutsets.left > 0 || mOutsets.right > 0) {
int mode = MeasureSpec.getMode(widthMeasureSpec);
if (mode != MeasureSpec.UNSPECIFIED) {
int width = MeasureSpec.getSize(widthMeasureSpec);
widthMeasureSpec = MeasureSpec.makeMeasureSpec(
width + mOutsets.left + mOutsets.right, mode);
}
}
@@ -2644,6 +2639,18 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
getOutsets(mOutsets);
if (mOutsets.left > 0) {
offsetLeftAndRight(-mOutsets.left);
}
if (mOutsets.top > 0) {
offsetTopAndBottom(-mOutsets.top);
}
}
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
@@ -3433,19 +3440,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
requestFeature(FEATURE_ACTIVITY_TRANSITIONS);
}
final WindowManager windowService = (WindowManager) getContext().getSystemService(
Context.WINDOW_SERVICE);
if (windowService != null) {
final Display display = windowService.getDefaultDisplay();
final boolean shouldUseBottomOutset =
display.getDisplayId() == Display.DEFAULT_DISPLAY
|| (getForcedWindowFlags() & FLAG_FULLSCREEN) != 0;
if (shouldUseBottomOutset) {
mOutsetBottomPx = ScreenShapeHelper.getWindowOutsetBottomPx(
getContext().getResources().getDisplayMetrics(), a);
}
}
final Context context = getContext();
final int targetSdk = context.getApplicationInfo().targetSdkVersion;
final boolean targetPreHoneycomb = targetSdk < android.os.Build.VERSION_CODES.HONEYCOMB;

View File

@@ -109,6 +109,7 @@ import com.android.internal.policy.PolicyManager;
import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate;
import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate.ShowListener;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.util.ScreenShapeHelper;
import com.android.internal.widget.PointerLocationView;
import com.android.server.LocalServices;
@@ -459,6 +460,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
static final Rect mTmpDecorFrame = new Rect();
static final Rect mTmpStableFrame = new Rect();
static final Rect mTmpNavigationFrame = new Rect();
static final Rect mTmpOutsetFrame = new Rect();
WindowState mTopFullscreenOpaqueWindowState;
HashSet<IApplicationToken> mAppsToBeHidden = new HashSet<IApplicationToken>();
@@ -3328,6 +3330,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
final Rect of = mTmpOverscanFrame;
final Rect vf = mTmpVisibleFrame;
final Rect dcf = mTmpDecorFrame;
final Rect osf = mTmpOutsetFrame;
pf.left = df.left = of.left = vf.left = mDockLeft;
pf.top = df.top = of.top = vf.top = mDockTop;
pf.right = df.right = of.right = vf.right = mDockRight;
@@ -3439,7 +3442,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// And compute the final frame.
mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame,
mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf,
mTmpNavigationFrame);
mTmpNavigationFrame, mTmpNavigationFrame);
if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame);
if (mNavigationBarController.checkHiddenLw()) {
updateSysUiVisibility = true;
@@ -3464,7 +3467,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mStatusBarLayer = mStatusBar.getSurfaceLayer();
// Let the status bar determine its size.
mStatusBar.computeFrameLw(pf, df, vf, vf, vf, dcf, vf);
mStatusBar.computeFrameLw(pf, df, vf, vf, vf, dcf, vf, osf);
// For layout, the status bar is always at the top with our fixed height.
mStableTop = mUnrestrictedScreenTop + mStatusBarHeight;
@@ -3638,6 +3641,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
final Rect vf = mTmpVisibleFrame;
final Rect dcf = mTmpDecorFrame;
final Rect sf = mTmpStableFrame;
final Rect osf = mTmpOutsetFrame;
dcf.setEmpty();
final boolean hasNavBar = (isDefaultDisplay && mHasNavigationBar
@@ -3650,6 +3654,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} else {
sf.set(mOverscanLeft, mOverscanTop, mOverscanRight, mOverscanBottom);
}
osf.set(mStableLeft, mStableTop, mStableRight, mStableBottom);
if (!isDefaultDisplay) {
if (attached != null) {
@@ -4022,6 +4027,30 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
// If the device has a chin (e.g. some watches), a dead area at the bottom of the screen we
// need to provide information to the clients that want to pretend that you can draw there.
if (isDefaultDisplay) {
int outset = ScreenShapeHelper.getWindowOutsetBottomPx(mContext.getResources());
if (outset > 0) {
int rotation = Surface.ROTATION_0;
try {
rotation = mWindowManager.getRotation();
} catch (RemoteException e) {
}
if (rotation == Surface.ROTATION_0) {
osf.bottom += outset;
} else if (rotation == Surface.ROTATION_90) {
osf.right += outset;
} else if (rotation == Surface.ROTATION_180) {
osf.top -= outset;
} else if (rotation == Surface.ROTATION_270) {
osf.left -= outset;
}
if (DEBUG_LAYOUT) Slog.v(TAG, "applying bottom outset of " + outset
+ " with rotation " + rotation + ", result: " + osf);
}
}
if (DEBUG_LAYOUT) Slog.v(TAG, "Compute frame " + attrs.getTitle()
+ ": sim=#" + Integer.toHexString(sim)
+ " attach=" + attached + " type=" + attrs.type
@@ -4030,9 +4059,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
+ " of=" + of.toShortString()
+ " cf=" + cf.toShortString() + " vf=" + vf.toShortString()
+ " dcf=" + dcf.toShortString()
+ " sf=" + sf.toShortString());
+ " sf=" + sf.toShortString()
+ " osf=" + osf.toShortString());
win.computeFrameLw(pf, df, of, cf, vf, dcf, sf);
win.computeFrameLw(pf, df, of, cf, vf, dcf, sf, osf);
// Dock windows carve out the bottom of the screen, so normal windows
// can't appear underneath them.

View File

@@ -190,14 +190,15 @@ final class Session extends IWindowSession.Stub
public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs,
int requestedWidth, int requestedHeight, int viewFlags,
int flags, Rect outFrame, Rect outOverscanInsets, Rect outContentInsets,
Rect outVisibleInsets, Rect outStableInsets, Configuration outConfig,
Rect outVisibleInsets, Rect outStableInsets, Rect outsets, Configuration
outConfig,
Surface outSurface) {
if (false) Slog.d(WindowManagerService.TAG, ">>>>>> ENTERED relayout from "
+ Binder.getCallingPid());
int res = mService.relayoutWindow(this, window, seq, attrs,
requestedWidth, requestedHeight, viewFlags, flags,
outFrame, outOverscanInsets, outContentInsets, outVisibleInsets,
outStableInsets, outConfig, outSurface);
outStableInsets, outsets, outConfig, outSurface);
if (false) Slog.d(WindowManagerService.TAG, "<<<<<< EXITING relayout to "
+ Binder.getCallingPid());
return res;
@@ -536,4 +537,4 @@ final class Session extends IWindowSession.Stub
public String toString() {
return mStringName;
}
}
}

View File

@@ -3025,7 +3025,7 @@ public class WindowManagerService extends IWindowManager.Stub
WindowManager.LayoutParams attrs, int requestedWidth,
int requestedHeight, int viewVisibility, int flags,
Rect outFrame, Rect outOverscanInsets, Rect outContentInsets,
Rect outVisibleInsets, Rect outStableInsets, Configuration outConfig,
Rect outVisibleInsets, Rect outStableInsets, Rect outOutsets, Configuration outConfig,
Surface outSurface) {
boolean toBeDisplayed = false;
boolean inTouchMode;
@@ -3310,6 +3310,7 @@ public class WindowManagerService extends IWindowManager.Stub
outContentInsets.set(win.mContentInsets);
outVisibleInsets.set(win.mVisibleInsets);
outStableInsets.set(win.mStableInsets);
outOutsets.set(win.mOutsets);
if (localLOGV) Slog.v(
TAG, "Relayout given client " + client.asBinder()
+ ", requestedWidth=" + requestedWidth
@@ -9577,6 +9578,7 @@ public class WindowManagerService extends IWindowManager.Stub
w.mLastContentInsets.set(w.mContentInsets);
w.mLastVisibleInsets.set(w.mVisibleInsets);
w.mLastStableInsets.set(w.mStableInsets);
w.mLastOutsets.set(w.mOutsets);
makeWindowFreezingScreenIfNeededLocked(w);
// If the orientation is changing, then we need to
// hold off on unfreezing the display until this

View File

@@ -178,6 +178,14 @@ final class WindowState implements WindowManagerPolicy.WindowState {
final Rect mLastStableInsets = new Rect();
boolean mStableInsetsChanged;
/**
* Outsets determine the area outside of the surface where we want to pretend that it's possible
* to draw anyway.
*/
final Rect mOutsets = new Rect();
final Rect mLastOutsets = new Rect();
boolean mOutsetsChanged = false;
/**
* Set to true if we are waiting for this window to receive its
* given internal insets before laying out other windows based on it.
@@ -259,6 +267,10 @@ final class WindowState implements WindowManagerPolicy.WindowState {
// displays hint text.
final Rect mVisibleFrame = new Rect();
// Frame that includes dead area outside of the surface but where we want to pretend that it's
// possible to draw.
final Rect mOutsetFrame = new Rect();
boolean mContentChanged;
// If a window showing a wallpaper: the requested offset for the
@@ -515,7 +527,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
}
@Override
public void computeFrameLw(Rect pf, Rect df, Rect of, Rect cf, Rect vf, Rect dcf, Rect sf) {
public void computeFrameLw(Rect pf, Rect df, Rect of, Rect cf, Rect vf, Rect dcf, Rect sf,
Rect osf) {
mHaveFrame = true;
TaskStack stack = mAppToken != null ? getStack() : null;
@@ -583,6 +596,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
mVisibleFrame.set(vf);
mDecorFrame.set(dcf);
mStableFrame.set(sf);
mOutsetFrame.set(osf);
final int fw = mFrame.width();
final int fh = mFrame.height();
@@ -645,6 +659,11 @@ final class WindowState implements WindowManagerPolicy.WindowState {
Math.max(mFrame.right - mStableFrame.right, 0),
Math.max(mFrame.bottom - mStableFrame.bottom, 0));
mOutsets.set(Math.max(mContentFrame.left - mOutsetFrame.left, 0),
Math.max(mContentFrame.top - mOutsetFrame.top, 0),
Math.max(mOutsetFrame.right - mContentFrame.right, 0),
Math.max(mOutsetFrame.bottom - mContentFrame.bottom, 0));
mCompatFrame.set(mFrame);
if (mEnforceSizeCompat) {
// If there is a size compatibility scale being applied to the
@@ -654,6 +673,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
mContentInsets.scale(mInvGlobalScale);
mVisibleInsets.scale(mInvGlobalScale);
mStableInsets.scale(mInvGlobalScale);
mOutsets.scale(mInvGlobalScale);
// Also the scaled frame that we report to the app needs to be
// adjusted to be in its coordinate space.
@@ -676,7 +696,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
+ "): frame=" + mFrame.toShortString()
+ " ci=" + mContentInsets.toShortString()
+ " vi=" + mVisibleInsets.toShortString()
+ " vi=" + mStableInsets.toShortString());
+ " vi=" + mStableInsets.toShortString()
+ " of=" + mOutsets.toShortString());
}
@Override
@@ -782,7 +803,9 @@ final class WindowState implements WindowManagerPolicy.WindowState {
mContentInsetsChanged |= !mLastContentInsets.equals(mContentInsets);
mVisibleInsetsChanged |= !mLastVisibleInsets.equals(mVisibleInsets);
mStableInsetsChanged |= !mLastStableInsets.equals(mStableInsets);
return mOverscanInsetsChanged || mContentInsetsChanged || mVisibleInsetsChanged;
mOutsetsChanged |= !mLastOutsets.equals(mOutsets);
return mOverscanInsetsChanged || mContentInsetsChanged || mVisibleInsetsChanged
|| mOutsetsChanged;
}
public DisplayContent getDisplayContent() {
@@ -1327,7 +1350,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
}
return displayContent.isDefaultDisplay;
}
public void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) {
mShowToOwnerOnly = showToOwnerOnly;
}
@@ -1437,6 +1460,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
final Rect contentInsets = mLastContentInsets;
final Rect visibleInsets = mLastVisibleInsets;
final Rect stableInsets = mLastStableInsets;
final Rect outsets = mLastOutsets;
final boolean reportDraw = mWinAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING;
final Configuration newConfig = configChanged ? mConfiguration : null;
if (mAttrs.type != WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
@@ -1447,7 +1471,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
public void run() {
try {
mClient.resized(frame, overscanInsets, contentInsets,
visibleInsets, stableInsets, reportDraw, newConfig);
visibleInsets, stableInsets, outsets, reportDraw, newConfig);
} catch (RemoteException e) {
// Not a remote call, RemoteException won't be raised.
}
@@ -1455,7 +1479,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
});
} else {
mClient.resized(frame, overscanInsets, contentInsets, visibleInsets, stableInsets,
reportDraw, newConfig);
outsets, reportDraw, newConfig);
}
//TODO (multidisplay): Accessibility supported only for the default display.
@@ -1468,6 +1492,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
mContentInsetsChanged = false;
mVisibleInsetsChanged = false;
mStableInsetsChanged = false;
mOutsetsChanged = false;
mWinAnimator.mSurfaceResized = false;
} catch (RemoteException e) {
mOrientationChanging = false;
@@ -1618,17 +1643,22 @@ final class WindowState implements WindowManagerPolicy.WindowState {
pw.println();
pw.print(prefix); pw.print(" decor="); mDecorFrame.printShortString(pw);
pw.println();
pw.print(prefix); pw.print(" outset="); mOutsetFrame.printShortString(pw);
pw.println();
pw.print(prefix); pw.print("Cur insets: overscan=");
mOverscanInsets.printShortString(pw);
pw.print(" content="); mContentInsets.printShortString(pw);
pw.print(" visible="); mVisibleInsets.printShortString(pw);
pw.print(" stable="); mStableInsets.printShortString(pw);
pw.print(" outsets="); mOutsets.printShortString(pw);
pw.println();
pw.print(prefix); pw.print("Lst insets: overscan=");
mLastOverscanInsets.printShortString(pw);
pw.print(" content="); mLastContentInsets.printShortString(pw);
pw.print(" visible="); mLastVisibleInsets.printShortString(pw);
pw.print(" stable="); mLastStableInsets.printShortString(pw);
pw.print(" physical="); mLastOutsets.printShortString(pw);
pw.print(" outset="); mLastOutsets.printShortString(pw);
pw.println();
}
pw.print(prefix); pw.print(mWinAnimator); pw.println(":");

View File

@@ -47,8 +47,8 @@ public final class BridgeWindow implements IWindow {
}
@Override
public void resized(Rect rect, Rect rect2, Rect rect3, Rect rect4, Rect rect5, boolean b,
Configuration configuration) throws RemoteException {
public void resized(Rect rect, Rect rect2, Rect rect3, Rect rect4, Rect rect5, Rect rect6,
boolean b, Configuration configuration) throws RemoteException {
// pass for now.
}