Refactor AttachInfo.mGlobalSystemUiVisibility
Move it to ViewRootImpl and rename it: mDispatchedSystemUiVisibility with default value 0 in the new insets mode instead of -1. Because mCompatibleVisibilityInfo.globalVisibility will always be updated in the new insets mode, we don't need the -1 value to detect the change from non-zero value to zero dispatched from the server. Bug: 118118435 Test: atest LayoutTests Change-Id: I45064bdcdca37b9a2b30d82bb9d9c84e45732029
This commit is contained in:
@@ -28786,11 +28786,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
*/
|
||||
int mDisabledSystemUiVisibility;
|
||||
|
||||
/**
|
||||
* Last global system UI visibility reported by the window manager.
|
||||
*/
|
||||
int mGlobalSystemUiVisibility = -1;
|
||||
|
||||
/**
|
||||
* True if a view in this hierarchy has an OnSystemUiVisibilityChangeListener
|
||||
* attached.
|
||||
|
||||
@@ -436,6 +436,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
@UnsupportedAppUsage
|
||||
final View.AttachInfo mAttachInfo;
|
||||
final SystemUiVisibilityInfo mCompatibleVisibilityInfo;
|
||||
int mDispatchedSystemUiVisibility =
|
||||
ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL ? 0 : -1;
|
||||
InputQueue.Callback mInputQueueCallback;
|
||||
InputQueue mInputQueue;
|
||||
@UnsupportedAppUsage
|
||||
@@ -1945,11 +1947,33 @@ public final class ViewRootImpl implements ViewParent,
|
||||
} else {
|
||||
info.globalVisibility |= systemUiFlag;
|
||||
}
|
||||
if (mAttachInfo.mGlobalSystemUiVisibility != info.globalVisibility) {
|
||||
if (mDispatchedSystemUiVisibility != info.globalVisibility) {
|
||||
scheduleTraversals();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDispatchSystemUiVisibilityChanged(SystemUiVisibilityInfo args) {
|
||||
if (mSeq != args.seq && sNewInsetsMode != NEW_INSETS_MODE_FULL) {
|
||||
// The sequence has changed, so we need to update our value and make
|
||||
// sure to do a traversal afterward so the window manager is given our
|
||||
// most recent data.
|
||||
mSeq = args.seq;
|
||||
mAttachInfo.mForceReportNewAttributes = true;
|
||||
scheduleTraversals();
|
||||
}
|
||||
if (mView == null) return;
|
||||
if (args.localChanges != 0) {
|
||||
mView.updateLocalSystemUiVisibility(args.localValue, args.localChanges);
|
||||
args.localChanges = 0;
|
||||
}
|
||||
|
||||
final int visibility = args.globalVisibility & View.SYSTEM_UI_CLEARABLE_FLAGS;
|
||||
if (mDispatchedSystemUiVisibility != visibility) {
|
||||
mDispatchedSystemUiVisibility = visibility;
|
||||
mView.dispatchSystemUiVisibilityChanged(visibility);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static void adjustLayoutParamsForCompatibility(WindowManager.LayoutParams inOutParams) {
|
||||
if (sNewInsetsMode != NEW_INSETS_MODE_FULL) {
|
||||
@@ -7182,28 +7206,6 @@ public final class ViewRootImpl implements ViewParent,
|
||||
event.recycle();
|
||||
}
|
||||
|
||||
public void handleDispatchSystemUiVisibilityChanged(SystemUiVisibilityInfo args) {
|
||||
if (mSeq != args.seq && sNewInsetsMode != NEW_INSETS_MODE_FULL) {
|
||||
// The sequence has changed, so we need to update our value and make
|
||||
// sure to do a traversal afterward so the window manager is given our
|
||||
// most recent data.
|
||||
mSeq = args.seq;
|
||||
mAttachInfo.mForceReportNewAttributes = true;
|
||||
scheduleTraversals();
|
||||
}
|
||||
if (mView == null) return;
|
||||
if (args.localChanges != 0) {
|
||||
mView.updateLocalSystemUiVisibility(args.localValue, args.localChanges);
|
||||
args.localChanges = 0;
|
||||
}
|
||||
|
||||
int visibility = args.globalVisibility&View.SYSTEM_UI_CLEARABLE_FLAGS;
|
||||
if (visibility != mAttachInfo.mGlobalSystemUiVisibility) {
|
||||
mAttachInfo.mGlobalSystemUiVisibility = visibility;
|
||||
mView.dispatchSystemUiVisibilityChanged(visibility);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify that the window title changed
|
||||
*/
|
||||
@@ -8373,6 +8375,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
// TODO(118118435): Remove this after migration
|
||||
public void dispatchSystemUiVisibilityChanged(int seq, int globalVisibility,
|
||||
int localValue, int localChanges) {
|
||||
SystemUiVisibilityInfo args = new SystemUiVisibilityInfo();
|
||||
|
||||
Reference in New Issue
Block a user