@@ -165,6 +165,8 @@ public final class ViewRootImpl extends Handler implements ViewParent,
165165
166166 final int mTargetSdkVersion ;
167167
168+ int mSeq ;
169+
168170 View mView ;
169171 View mFocusedView ;
170172 View mRealFocusedView ; // this is not set to null in touch mode
@@ -308,6 +310,13 @@ public static IWindowSession getWindowSession(Looper mainLooper) {
308310 return sWindowSession ;
309311 }
310312 }
313+
314+ static final class SystemUiVisibilityInfo {
315+ int seq ;
316+ int globalVisibility ;
317+ int localValue ;
318+ int localChanges ;
319+ }
311320
312321 public ViewRootImpl (Context context ) {
313322 super ();
@@ -465,7 +474,7 @@ public void setView(View view, WindowManager.LayoutParams attrs, View panelParen
465474 }
466475 try {
467476 mOrigWindowType = mWindowAttributes .type ;
468- res = sWindowSession .add (mWindow , mWindowAttributes ,
477+ res = sWindowSession .add (mWindow , mSeq , mWindowAttributes ,
469478 getHostVisibility (), mAttachInfo .mContentInsets ,
470479 mInputChannel );
471480 } catch (RemoteException e ) {
@@ -1045,16 +1054,21 @@ private void performTraversals() {
10451054 attachInfo .mRecomputeGlobalAttributes = false ;
10461055 boolean oldScreenOn = attachInfo .mKeepScreenOn ;
10471056 int oldVis = attachInfo .mSystemUiVisibility ;
1057+ boolean oldHasSystemUiListeners = attachInfo .mHasSystemUiListeners ;
10481058 attachInfo .mKeepScreenOn = false ;
10491059 attachInfo .mSystemUiVisibility = 0 ;
10501060 attachInfo .mHasSystemUiListeners = false ;
10511061 host .dispatchCollectViewAttributes (0 );
10521062 if (attachInfo .mKeepScreenOn != oldScreenOn
10531063 || attachInfo .mSystemUiVisibility != oldVis
1054- || attachInfo .mHasSystemUiListeners ) {
1064+ || attachInfo .mHasSystemUiListeners != oldHasSystemUiListeners ) {
10551065 params = lp ;
10561066 }
10571067 }
1068+ if (attachInfo .mForceReportNewAttributes ) {
1069+ attachInfo .mForceReportNewAttributes = false ;
1070+ params = lp ;
1071+ }
10581072
10591073 if (mFirst || attachInfo .mViewVisibilityChanged ) {
10601074 attachInfo .mViewVisibilityChanged = false ;
@@ -1136,9 +1150,7 @@ private void performTraversals() {
11361150 params .flags |= WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON ;
11371151 }
11381152 params .subtreeSystemUiVisibility = attachInfo .mSystemUiVisibility ;
1139- params .hasSystemUiListeners = attachInfo .mHasSystemUiListeners
1140- || params .subtreeSystemUiVisibility != 0
1141- || params .systemUiVisibility != 0 ;
1153+ params .hasSystemUiListeners = attachInfo .mHasSystemUiListeners ;
11421154 }
11431155 if (DEBUG_LAYOUT ) {
11441156 Log .i (TAG , "host=w:" + host .getMeasuredWidth () + ", h:" +
@@ -2545,7 +2557,7 @@ public void handleMessage(Message msg) {
25452557 handleDragEvent (event );
25462558 } break ;
25472559 case DISPATCH_SYSTEM_UI_VISIBILITY : {
2548- handleDispatchSystemUiVisibilityChanged (msg .arg1 );
2560+ handleDispatchSystemUiVisibilityChanged (( SystemUiVisibilityInfo ) msg .obj );
25492561 } break ;
25502562 case UPDATE_CONFIGURATION : {
25512563 Configuration config = (Configuration )msg .obj ;
@@ -3429,12 +3441,27 @@ private void handleDragEvent(DragEvent event) {
34293441 event .recycle ();
34303442 }
34313443
3432- public void handleDispatchSystemUiVisibilityChanged (int visibility ) {
3444+ public void handleDispatchSystemUiVisibilityChanged (SystemUiVisibilityInfo args ) {
3445+ if (mSeq != args .seq ) {
3446+ // The sequence has changed, so we need to update our value and make
3447+ // sure to do a traversal afterward so the window manager is given our
3448+ // most recent data.
3449+ mSeq = args .seq ;
3450+ mAttachInfo .mForceReportNewAttributes = true ;
3451+ scheduleTraversals ();
3452+ }
34333453 if (mView == null ) return ;
3434- if (mAttachInfo != null ) {
3435- mAttachInfo .mSystemUiVisibility = visibility ;
3454+ if (args .localChanges != 0 ) {
3455+ if (mAttachInfo != null ) {
3456+ mAttachInfo .mSystemUiVisibility =
3457+ (mAttachInfo .mSystemUiVisibility &~args .localChanges )
3458+ | (args .localValue &args .localChanges );
3459+ }
3460+ mView .updateLocalSystemUiVisibility (args .localValue , args .localChanges );
3461+ mAttachInfo .mRecomputeGlobalAttributes = true ;
3462+ scheduleTraversals ();
34363463 }
3437- mView .dispatchSystemUiVisibilityChanged (visibility );
3464+ mView .dispatchSystemUiVisibilityChanged (args . globalVisibility );
34383465 }
34393466
34403467 public void getLastTouchPoint (Point outLocation ) {
@@ -3493,7 +3520,7 @@ private int relayoutWindow(WindowManager.LayoutParams params, int viewVisibility
34933520 }
34943521 }
34953522 int relayoutResult = sWindowSession .relayout (
3496- mWindow , params ,
3523+ mWindow , mSeq , params ,
34973524 (int ) (mView .getMeasuredWidth () * appScale + 0.5f ),
34983525 (int ) (mView .getMeasuredHeight () * appScale + 0.5f ),
34993526 viewVisibility , insetsPending , mWinFrame ,
@@ -3796,8 +3823,14 @@ public void dispatchDragEvent(DragEvent event) {
37963823 sendMessage (msg );
37973824 }
37983825
3799- public void dispatchSystemUiVisibilityChanged (int visibility ) {
3800- sendMessage (obtainMessage (DISPATCH_SYSTEM_UI_VISIBILITY , visibility , 0 ));
3826+ public void dispatchSystemUiVisibilityChanged (int seq , int globalVisibility ,
3827+ int localValue , int localChanges ) {
3828+ SystemUiVisibilityInfo args = new SystemUiVisibilityInfo ();
3829+ args .seq = seq ;
3830+ args .globalVisibility = globalVisibility ;
3831+ args .localValue = localValue ;
3832+ args .localChanges = localChanges ;
3833+ sendMessage (obtainMessage (DISPATCH_SYSTEM_UI_VISIBILITY , args ));
38013834 }
38023835
38033836 /**
@@ -4052,10 +4085,12 @@ public void dispatchDragEvent(DragEvent event) {
40524085 }
40534086 }
40544087
4055- public void dispatchSystemUiVisibilityChanged (int visibility ) {
4088+ public void dispatchSystemUiVisibilityChanged (int seq , int globalVisibility ,
4089+ int localValue , int localChanges ) {
40564090 final ViewRootImpl viewAncestor = mViewAncestor .get ();
40574091 if (viewAncestor != null ) {
4058- viewAncestor .dispatchSystemUiVisibilityChanged (visibility );
4092+ viewAncestor .dispatchSystemUiVisibilityChanged (seq , globalVisibility ,
4093+ localValue , localChanges );
40594094 }
40604095 }
40614096 }
0 commit comments