@@ -407,6 +407,9 @@ public void onInputEvent(InputEvent event) {
407407 // that area of the display from all other windows.
408408 int mRestrictedScreenLeft , mRestrictedScreenTop ;
409409 int mRestrictedScreenWidth , mRestrictedScreenHeight ;
410+ // During layout, the current screen borders accounting for any currently
411+ // visible system UI elements.
412+ int mSystemLeft , mSystemTop , mSystemRight , mSystemBottom ;
410413 // For applications requesting stable content insets, these are them.
411414 int mStableLeft , mStableTop , mStableRight , mStableBottom ;
412415 // During layout, the current screen borders with all outer decoration
@@ -423,6 +426,8 @@ public void onInputEvent(InputEvent event) {
423426 int mDockLeft , mDockTop , mDockRight , mDockBottom ;
424427 // During layout, the layer at which the doc window is placed.
425428 int mDockLayer ;
429+ // During layout, this is the layer of the status bar.
430+ int mStatusBarLayer ;
426431 int mLastSystemUiFlags ;
427432 // Bits that we are in the process of clearing, so we want to prevent
428433 // them from being set by applications until everything has been updated
@@ -438,6 +443,7 @@ public void onInputEvent(InputEvent event) {
438443
439444 static final Rect mTmpParentFrame = new Rect ();
440445 static final Rect mTmpDisplayFrame = new Rect ();
446+ static final Rect mTmpSystemFrame = new Rect ();
441447 static final Rect mTmpContentFrame = new Rect ();
442448 static final Rect mTmpVisibleFrame = new Rect ();
443449 static final Rect mTmpNavigationFrame = new Rect ();
@@ -2168,11 +2174,12 @@ public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotati
21682174 mRestrictedScreenLeft = mRestrictedScreenTop = 0 ;
21692175 mRestrictedScreenWidth = displayWidth ;
21702176 mRestrictedScreenHeight = displayHeight ;
2171- mDockLeft = mContentLeft = mStableLeft = mCurLeft = 0 ;
2172- mDockTop = mContentTop = mStableTop = mCurTop = 0 ;
2173- mDockRight = mContentRight = mStableRight = mCurRight = displayWidth ;
2174- mDockBottom = mContentBottom = mStableBottom = mCurBottom = displayHeight ;
2177+ mDockLeft = mContentLeft = mStableLeft = mSystemLeft = mCurLeft = 0 ;
2178+ mDockTop = mContentTop = mStableTop = mSystemTop = mCurTop = 0 ;
2179+ mDockRight = mContentRight = mStableRight = mSystemRight = mCurRight = displayWidth ;
2180+ mDockBottom = mContentBottom = mStableBottom = mSystemBottom = mCurBottom = displayHeight ;
21752181 mDockLayer = 0x10000000 ;
2182+ mStatusBarLayer = -1 ;
21762183
21772184 // start with the current dock rect, which will be (0,0,displayWidth,displayHeight)
21782185 final Rect pf = mTmpParentFrame ;
@@ -2232,6 +2239,12 @@ public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotati
22322239 // We currently want to hide the navigation UI.
22332240 mNavigationBar .hideLw (true );
22342241 }
2242+ if (navVisible && !mNavigationBar .isAnimatingLw ()) {
2243+ // If the nav bar is currently requested to be visible,
2244+ // and not in the process of animating on or off, then
2245+ // we can tell the app that it is covered by it.
2246+ mSystemBottom = mTmpNavigationFrame .top ;
2247+ }
22352248 } else {
22362249 // Landscape screen; nav bar goes to the right.
22372250 int left = displayWidth - mNavigationBarWidthForRotation [displayRotation ];
@@ -2250,16 +2263,23 @@ public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotati
22502263 // We currently want to hide the navigation UI.
22512264 mNavigationBar .hideLw (true );
22522265 }
2266+ if (navVisible && !mNavigationBar .isAnimatingLw ()) {
2267+ // If the nav bar is currently requested to be visible,
2268+ // and not in the process of animating on or off, then
2269+ // we can tell the app that it is covered by it.
2270+ mSystemRight = mTmpNavigationFrame .left ;
2271+ }
22532272 }
22542273 // Make sure the content and current rectangles are updated to
22552274 // account for the restrictions from the navigation bar.
22562275 mContentTop = mCurTop = mDockTop ;
22572276 mContentBottom = mCurBottom = mDockBottom ;
22582277 mContentLeft = mCurLeft = mDockLeft ;
22592278 mContentRight = mCurRight = mDockRight ;
2279+ mStatusBarLayer = mNavigationBar .getSurfaceLayer ();
22602280 // And compute the final frame.
22612281 mNavigationBar .computeFrameLw (mTmpNavigationFrame , mTmpNavigationFrame ,
2262- mTmpNavigationFrame , mTmpNavigationFrame );
2282+ mTmpNavigationFrame , mTmpNavigationFrame , mTmpNavigationFrame );
22632283 if (DEBUG_LAYOUT ) Log .i (TAG , "mNavigationBar frame: " + mTmpNavigationFrame );
22642284 }
22652285 if (DEBUG_LAYOUT ) Log .i (TAG , String .format ("mDock rect: (%d,%d - %d,%d)" ,
@@ -2277,8 +2297,10 @@ public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotati
22772297 vf .right = mStableRight ;
22782298 vf .bottom = mStableBottom ;
22792299
2300+ mStatusBarLayer = mStatusBar .getSurfaceLayer ();
2301+
22802302 // Let the status bar determine its size.
2281- mStatusBar .computeFrameLw (pf , df , vf , vf );
2303+ mStatusBar .computeFrameLw (pf , df , df , vf , vf );
22822304
22832305 // For layout, the status bar is always at the top with our fixed height.
22842306 mStableTop = mUnrestrictedScreenTop + mStatusBarHeight ;
@@ -2303,6 +2325,12 @@ public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotati
23032325 mContentLeft , mContentTop , mContentRight , mContentBottom ,
23042326 mCurLeft , mCurTop , mCurRight , mCurBottom ));
23052327 }
2328+ if (mStatusBar .isVisibleLw () && !mStatusBar .isAnimatingLw ()) {
2329+ // If the status bar is currently requested to be visible,
2330+ // and not in the process of animating on or off, then
2331+ // we can tell the app that it is covered by it.
2332+ mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight ;
2333+ }
23062334 }
23072335 }
23082336
@@ -2368,6 +2396,7 @@ public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs,
23682396
23692397 final Rect pf = mTmpParentFrame ;
23702398 final Rect df = mTmpDisplayFrame ;
2399+ final Rect sf = mTmpSystemFrame ;
23712400 final Rect cf = mTmpContentFrame ;
23722401 final Rect vf = mTmpVisibleFrame ;
23732402
@@ -2611,14 +2640,28 @@ public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs,
26112640 df .right = df .bottom = cf .right = cf .bottom = vf .right = vf .bottom = 10000 ;
26122641 }
26132642
2643+ // Compute the system frame. This is easy: for things behind the
2644+ // status bar, it is any application windows; otherwise it is not set.
2645+ int parentType = attached != null ? attached .getAttrs ().type : attrs .type ;
2646+ if (win .getSurfaceLayer () < mStatusBarLayer
2647+ && parentType < WindowManager .LayoutParams .FIRST_SYSTEM_WINDOW ) {
2648+ sf .left = mSystemLeft ;
2649+ sf .top = mSystemTop ;
2650+ sf .right = mSystemRight ;
2651+ sf .bottom = mSystemBottom ;
2652+ } else {
2653+ sf .left = sf .top = -10000 ;
2654+ sf .right = sf .bottom = 10000 ;
2655+ }
2656+
26142657 if (DEBUG_LAYOUT ) Log .v (TAG , "Compute frame " + attrs .getTitle ()
26152658 + ": sim=#" + Integer .toHexString (sim )
26162659 + " attach=" + attached + " type=" + attrs .type
26172660 + String .format (" flags=0x%08x" , fl )
26182661 + " pf=" + pf .toShortString () + " df=" + df .toShortString ()
26192662 + " cf=" + cf .toShortString () + " vf=" + vf .toShortString ());
26202663
2621- win .computeFrameLw (pf , df , cf , vf );
2664+ win .computeFrameLw (pf , df , sf , cf , vf );
26222665
26232666 // Dock windows carve out the bottom of the screen, so normal windows
26242667 // can't appear underneath them.
@@ -4193,6 +4236,10 @@ public void dump(String prefix, FileDescriptor fd, PrintWriter pw, String[] args
41934236 pw .print ("," ); pw .print (mStableTop );
41944237 pw .print (")-(" ); pw .print (mStableRight );
41954238 pw .print ("," ); pw .print (mStableBottom ); pw .println (")" );
4239+ pw .print (prefix ); pw .print ("mSystem=(" ); pw .print (mSystemLeft );
4240+ pw .print ("," ); pw .print (mSystemTop );
4241+ pw .print (")-(" ); pw .print (mSystemRight );
4242+ pw .print ("," ); pw .print (mSystemBottom ); pw .println (")" );
41964243 pw .print (prefix ); pw .print ("mCur=(" ); pw .print (mCurLeft );
41974244 pw .print ("," ); pw .print (mCurTop );
41984245 pw .print (")-(" ); pw .print (mCurRight );
@@ -4205,7 +4252,8 @@ public void dump(String prefix, FileDescriptor fd, PrintWriter pw, String[] args
42054252 pw .print ("," ); pw .print (mDockTop );
42064253 pw .print (")-(" ); pw .print (mDockRight );
42074254 pw .print ("," ); pw .print (mDockBottom ); pw .println (")" );
4208- pw .print (prefix ); pw .print ("mDockLayer=" ); pw .println (mDockLayer );
4255+ pw .print (prefix ); pw .print ("mDockLayer=" ); pw .print (mDockLayer );
4256+ pw .print (" mStatusBarLayer=" ); pw .println (mStatusBarLayer );
42094257 pw .print (prefix ); pw .print ("mTopFullscreenOpaqueWindowState=" );
42104258 pw .println (mTopFullscreenOpaqueWindowState );
42114259 pw .print (prefix ); pw .print ("mTopIsFullscreen=" ); pw .print (mTopIsFullscreen );
0 commit comments