@@ -410,6 +410,10 @@ public void onInputEvent(InputEvent event) {
410410 int mSystemLeft , mSystemTop , mSystemRight , mSystemBottom ;
411411 // For applications requesting stable content insets, these are them.
412412 int mStableLeft , mStableTop , mStableRight , mStableBottom ;
413+ // For applications requesting stable content insets but have also set the
414+ // fullscreen window flag, these are the stable dimensions without the status bar.
415+ int mStableFullscreenLeft , mStableFullscreenTop ;
416+ int mStableFullscreenRight , mStableFullscreenBottom ;
413417 // During layout, the current screen borders with all outer decoration
414418 // (status bar, input method dock) accounted for.
415419 int mCurLeft , mCurTop , mCurRight , mCurBottom ;
@@ -2153,22 +2157,31 @@ public int adjustSystemUiVisibilityLw(int visibility) {
21532157
21542158 public void getContentInsetHintLw (WindowManager .LayoutParams attrs , Rect contentInset ) {
21552159 final int fl = attrs .flags ;
2160+ final int systemUiVisibility = (attrs .systemUiVisibility |attrs .subtreeSystemUiVisibility );
21562161
2157- if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_FULLSCREEN | FLAG_LAYOUT_INSET_DECOR ))
2162+ if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR ))
21582163 == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR )) {
21592164 int availRight , availBottom ;
21602165 if (mCanHideNavigationBar &&
2161- (attrs . systemUiVisibility & View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION ) != 0 ) {
2166+ (systemUiVisibility & View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION ) != 0 ) {
21622167 availRight = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth ;
21632168 availBottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight ;
21642169 } else {
21652170 availRight = mRestrictedScreenLeft + mRestrictedScreenWidth ;
21662171 availBottom = mRestrictedScreenTop + mRestrictedScreenHeight ;
21672172 }
2168- if ((attrs .systemUiVisibility & View .SYSTEM_UI_FLAG_LAYOUT_STABLE ) != 0 ) {
2169- contentInset .set (mStableLeft , mStableTop ,
2170- availRight - mStableRight , availBottom - mStableBottom );
2171- } else if ((attrs .systemUiVisibility & (View .SYSTEM_UI_FLAG_FULLSCREEN
2173+ if ((systemUiVisibility & View .SYSTEM_UI_FLAG_LAYOUT_STABLE ) != 0 ) {
2174+ if ((fl & FLAG_FULLSCREEN ) != 0 ) {
2175+ contentInset .set (mStableFullscreenLeft , mStableFullscreenTop ,
2176+ availRight - mStableFullscreenRight ,
2177+ availBottom - mStableFullscreenBottom );
2178+ } else {
2179+ contentInset .set (mStableLeft , mStableTop ,
2180+ availRight - mStableRight , availBottom - mStableBottom );
2181+ }
2182+ } else if ((fl & FLAG_FULLSCREEN ) != 0 ) {
2183+ contentInset .setEmpty ();
2184+ } else if ((systemUiVisibility & (View .SYSTEM_UI_FLAG_FULLSCREEN
21722185 | View .SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN )) == 0 ) {
21732186 contentInset .set (mCurLeft , mCurTop ,
21742187 availRight - mCurRight , availBottom - mCurBottom );
@@ -2189,10 +2202,14 @@ public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotati
21892202 mRestrictedScreenLeft = mRestrictedScreenTop = 0 ;
21902203 mRestrictedScreenWidth = displayWidth ;
21912204 mRestrictedScreenHeight = displayHeight ;
2192- mDockLeft = mContentLeft = mStableLeft = mSystemLeft = mCurLeft = 0 ;
2193- mDockTop = mContentTop = mStableTop = mSystemTop = mCurTop = 0 ;
2194- mDockRight = mContentRight = mStableRight = mSystemRight = mCurRight = displayWidth ;
2195- mDockBottom = mContentBottom = mStableBottom = mSystemBottom = mCurBottom = displayHeight ;
2205+ mDockLeft = mContentLeft = mStableLeft = mStableFullscreenLeft
2206+ = mSystemLeft = mCurLeft = 0 ;
2207+ mDockTop = mContentTop = mStableTop = mStableFullscreenTop
2208+ = mSystemTop = mCurTop = 0 ;
2209+ mDockRight = mContentRight = mStableRight = mStableFullscreenRight
2210+ = mSystemRight = mCurRight = displayWidth ;
2211+ mDockBottom = mContentBottom = mStableBottom = mStableFullscreenBottom
2212+ = mSystemBottom = mCurBottom = displayHeight ;
21962213 mDockLayer = 0x10000000 ;
21972214 mStatusBarLayer = -1 ;
21982215
@@ -2245,7 +2262,7 @@ public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotati
22452262 }
22462263 }
22472264 mTmpNavigationFrame .set (0 , top , displayWidth , displayHeight );
2248- mStableBottom = mTmpNavigationFrame .top ;
2265+ mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame .top ;
22492266 if (navVisible ) {
22502267 mNavigationBar .showLw (true );
22512268 mDockBottom = mTmpNavigationFrame .top ;
@@ -2269,7 +2286,7 @@ public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotati
22692286 }
22702287 }
22712288 mTmpNavigationFrame .set (left , 0 , displayWidth , displayHeight );
2272- mStableRight = mTmpNavigationFrame .left ;
2289+ mStableRight = mStableFullscreenRight = mTmpNavigationFrame .left ;
22732290 if (navVisible ) {
22742291 mNavigationBar .showLw (true );
22752292 mDockRight = mTmpNavigationFrame .left ;
@@ -2407,7 +2424,25 @@ void setAttachedWindowFrames(WindowState win, int fl, int adjust,
24072424 pf .set ((fl & FLAG_LAYOUT_IN_SCREEN ) == 0
24082425 ? attached .getFrameLw () : df );
24092426 }
2410-
2427+
2428+ private void applyStableConstraints (int sysui , int fl , Rect r ) {
2429+ if ((sysui & View .SYSTEM_UI_FLAG_LAYOUT_STABLE ) != 0 ) {
2430+ // If app is requesting a stable layout, don't let the
2431+ // content insets go below the stable values.
2432+ if ((fl & FLAG_FULLSCREEN ) != 0 ) {
2433+ if (r .left < mStableFullscreenLeft ) r .left = mStableFullscreenLeft ;
2434+ if (r .top < mStableFullscreenTop ) r .top = mStableFullscreenTop ;
2435+ if (r .right > mStableFullscreenRight ) r .right = mStableFullscreenRight ;
2436+ if (r .bottom > mStableFullscreenBottom ) r .bottom = mStableFullscreenBottom ;
2437+ } else {
2438+ if (r .left < mStableLeft ) r .left = mStableLeft ;
2439+ if (r .top < mStableTop ) r .top = mStableTop ;
2440+ if (r .right > mStableRight ) r .right = mStableRight ;
2441+ if (r .bottom > mStableBottom ) r .bottom = mStableBottom ;
2442+ }
2443+ }
2444+ }
2445+
24112446 /** {@inheritDoc} */
24122447 public void layoutWindowLw (WindowState win , WindowManager .LayoutParams attrs ,
24132448 WindowState attached ) {
@@ -2514,14 +2549,7 @@ public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs,
25142549 cf .right = mContentRight ;
25152550 cf .bottom = mContentBottom ;
25162551 }
2517- if ((sysUiFl & View .SYSTEM_UI_FLAG_LAYOUT_STABLE ) != 0 ) {
2518- // If app is requesting a stable layout, don't let the
2519- // content insets go below the stable values.
2520- if (cf .left < mStableLeft ) cf .left = mStableLeft ;
2521- if (cf .top < mStableTop ) cf .top = mStableTop ;
2522- if (cf .right > mStableRight ) cf .right = mStableRight ;
2523- if (cf .bottom > mStableBottom ) cf .bottom = mStableBottom ;
2524- }
2552+ applyStableConstraints (sysUiFl , fl , cf );
25252553 if (adjust != SOFT_INPUT_ADJUST_NOTHING ) {
25262554 vf .left = mCurLeft ;
25272555 vf .top = mCurTop ;
@@ -2603,14 +2631,7 @@ public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs,
26032631 pf .bottom = df .bottom = cf .bottom
26042632 = mRestrictedScreenTop +mRestrictedScreenHeight ;
26052633 }
2606- if ((sysUiFl & View .SYSTEM_UI_FLAG_LAYOUT_STABLE ) != 0 ) {
2607- // If app is requesting a stable layout, don't let the
2608- // content insets go below the stable values.
2609- if (cf .left < mStableLeft ) cf .left = mStableLeft ;
2610- if (cf .top < mStableTop ) cf .top = mStableTop ;
2611- if (cf .right > mStableRight ) cf .right = mStableRight ;
2612- if (cf .bottom > mStableBottom ) cf .bottom = mStableBottom ;
2613- }
2634+ applyStableConstraints (sysUiFl , fl , cf );
26142635 if (adjust != SOFT_INPUT_ADJUST_NOTHING ) {
26152636 vf .left = mCurLeft ;
26162637 vf .top = mCurTop ;
@@ -4258,6 +4279,10 @@ public void dump(String prefix, FileDescriptor fd, PrintWriter pw, String[] args
42584279 pw .print ("," ); pw .print (mRestrictedScreenTop );
42594280 pw .print (") " ); pw .print (mRestrictedScreenWidth );
42604281 pw .print ("x" ); pw .println (mRestrictedScreenHeight );
4282+ pw .print (prefix ); pw .print ("mStableFullscreen=(" ); pw .print (mStableFullscreenLeft );
4283+ pw .print ("," ); pw .print (mStableFullscreenTop );
4284+ pw .print (")-(" ); pw .print (mStableFullscreenRight );
4285+ pw .print ("," ); pw .print (mStableFullscreenBottom ); pw .println (")" );
42614286 pw .print (prefix ); pw .print ("mStable=(" ); pw .print (mStableLeft );
42624287 pw .print ("," ); pw .print (mStableTop );
42634288 pw .print (")-(" ); pw .print (mStableRight );
0 commit comments