Merge "Refactor AttachInfo.mGlobalSystemUiVisibility"

This commit is contained in:
Tiger Huang
2020-02-17 12:24:44 +00:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 28 deletions

View File

@@ -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.

View File

@@ -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
@@ -1946,11 +1948,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) {
@@ -7183,28 +7207,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
*/
@@ -8374,6 +8376,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();