Merge "Defer dispatching insets to app if its window frame will be changed soon" into sc-dev
This commit is contained in:
@@ -65,13 +65,20 @@ oneway interface IWindow {
|
||||
|
||||
/**
|
||||
* Called when the window insets configuration has changed.
|
||||
*
|
||||
* @param willMove The window frame will be moved soon.
|
||||
* @param willResize The window frame will be resized soon.
|
||||
*/
|
||||
void insetsChanged(in InsetsState insetsState);
|
||||
void insetsChanged(in InsetsState insetsState, in boolean willMove, in boolean willResize);
|
||||
|
||||
/**
|
||||
* Called when this window retrieved control over a specified set of insets sources.
|
||||
*
|
||||
* @param willMove The window frame will be moved soon.
|
||||
* @param willResize The window frame will be resized soon.
|
||||
*/
|
||||
void insetsControlChanged(in InsetsState insetsState, in InsetsSourceControl[] activeControls);
|
||||
void insetsControlChanged(in InsetsState insetsState, in InsetsSourceControl[] activeControls,
|
||||
in boolean willMove, in boolean willResize);
|
||||
|
||||
/**
|
||||
* Called when a set of insets source window should be shown by policy.
|
||||
|
||||
@@ -585,6 +585,10 @@ public final class ViewRootImpl implements ViewParent,
|
||||
final Rect mWinFrame; // frame given by window manager.
|
||||
|
||||
final Rect mPendingBackDropFrame = new Rect();
|
||||
|
||||
private boolean mWillMove;
|
||||
private boolean mWillResize;
|
||||
|
||||
boolean mPendingAlwaysConsumeSystemBars;
|
||||
private final InsetsState mTempInsets = new InsetsState();
|
||||
private final InsetsSourceControl[] mTempControls = new InsetsSourceControl[SIZE];
|
||||
@@ -1708,6 +1712,10 @@ public final class ViewRootImpl implements ViewParent,
|
||||
|
||||
void notifyInsetsChanged() {
|
||||
mApplyInsetsRequested = true;
|
||||
if (mWillMove || mWillResize) {
|
||||
// The window frame will be changed soon. The following logic will be executed then.
|
||||
return;
|
||||
}
|
||||
requestLayout();
|
||||
|
||||
// See comment for View.sForceLayoutWhenInsetsChanged
|
||||
@@ -2665,7 +2673,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
}
|
||||
}
|
||||
|
||||
if (mApplyInsetsRequested) {
|
||||
if (mApplyInsetsRequested && !(mWillMove || mWillResize)) {
|
||||
dispatchApplyInsets(host);
|
||||
if (mLayoutRequested) {
|
||||
// Short-circuit catching a new layout request here, so
|
||||
@@ -5235,16 +5243,25 @@ public final class ViewRootImpl implements ViewParent,
|
||||
break;
|
||||
case MSG_RESIZED:
|
||||
case MSG_RESIZED_REPORT: {
|
||||
mWillMove = false;
|
||||
mWillResize = false;
|
||||
final SomeArgs args = (SomeArgs) msg.obj;
|
||||
handleResized(msg.what, args);
|
||||
args.recycle();
|
||||
break;
|
||||
}
|
||||
case MSG_INSETS_CHANGED:
|
||||
mInsetsController.onStateChanged((InsetsState) msg.obj);
|
||||
case MSG_INSETS_CHANGED: {
|
||||
SomeArgs args = (SomeArgs) msg.obj;
|
||||
mWillMove = args.argi1 == 1;
|
||||
mWillResize = args.argi2 == 1;
|
||||
mInsetsController.onStateChanged((InsetsState) args.arg1);
|
||||
args.recycle();
|
||||
break;
|
||||
}
|
||||
case MSG_INSETS_CONTROL_CHANGED: {
|
||||
SomeArgs args = (SomeArgs) msg.obj;
|
||||
mWillMove = args.argi1 == 1;
|
||||
mWillResize = args.argi2 == 1;
|
||||
|
||||
// Deliver state change before control change, such that:
|
||||
// a) When gaining control, controller can compare with server state to evaluate
|
||||
@@ -5253,6 +5270,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
// dispatched state as truth.
|
||||
mInsetsController.onStateChanged((InsetsState) args.arg1);
|
||||
mInsetsController.onControlsChanged((InsetsSourceControl[]) args.arg2);
|
||||
args.recycle();
|
||||
break;
|
||||
}
|
||||
case MSG_SHOW_INSETS: {
|
||||
@@ -5270,6 +5288,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
break;
|
||||
}
|
||||
case MSG_WINDOW_MOVED:
|
||||
mWillMove = false;
|
||||
if (mAdded) {
|
||||
final int w = mWinFrame.width();
|
||||
final int h = mWinFrame.height();
|
||||
@@ -7744,6 +7763,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
|
||||
}
|
||||
setFrame(mTmpFrames.frame);
|
||||
mWillMove = false;
|
||||
mWillResize = false;
|
||||
mInsetsController.onStateChanged(mTempInsets);
|
||||
mInsetsController.onControlsChanged(mTempControls);
|
||||
return relayoutResult;
|
||||
@@ -8179,7 +8200,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
private void dispatchInsetsChanged(InsetsState insetsState) {
|
||||
private void dispatchInsetsChanged(InsetsState insetsState, boolean willMove,
|
||||
boolean willResize) {
|
||||
if (Binder.getCallingPid() == android.os.Process.myPid()) {
|
||||
insetsState = new InsetsState(insetsState, true /* copySource */);
|
||||
}
|
||||
@@ -8190,11 +8212,15 @@ public final class ViewRootImpl implements ViewParent,
|
||||
ImeTracing.getInstance().triggerClientDump("ViewRootImpl#dispatchInsetsChanged",
|
||||
getInsetsController().getHost().getInputMethodManager(), null /* icProto */);
|
||||
}
|
||||
mHandler.obtainMessage(MSG_INSETS_CHANGED, insetsState).sendToTarget();
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = insetsState;
|
||||
args.argi1 = willMove ? 1 : 0;
|
||||
args.argi2 = willResize ? 1 : 0;
|
||||
mHandler.obtainMessage(MSG_INSETS_CHANGED, args).sendToTarget();
|
||||
}
|
||||
|
||||
private void dispatchInsetsControlChanged(InsetsState insetsState,
|
||||
InsetsSourceControl[] activeControls) {
|
||||
InsetsSourceControl[] activeControls, boolean willMove, boolean willResize) {
|
||||
if (Binder.getCallingPid() == android.os.Process.myPid()) {
|
||||
insetsState = new InsetsState(insetsState, true /* copySource */);
|
||||
if (activeControls != null) {
|
||||
@@ -8214,6 +8240,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = insetsState;
|
||||
args.arg2 = activeControls;
|
||||
args.argi1 = willMove ? 1 : 0;
|
||||
args.argi2 = willResize ? 1 : 0;
|
||||
mHandler.obtainMessage(MSG_INSETS_CONTROL_CHANGED, args).sendToTarget();
|
||||
}
|
||||
|
||||
@@ -9560,19 +9588,20 @@ public final class ViewRootImpl implements ViewParent,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insetsChanged(InsetsState insetsState) {
|
||||
public void insetsChanged(InsetsState insetsState, boolean willMove, boolean willResize) {
|
||||
final ViewRootImpl viewAncestor = mViewAncestor.get();
|
||||
if (viewAncestor != null) {
|
||||
viewAncestor.dispatchInsetsChanged(insetsState);
|
||||
viewAncestor.dispatchInsetsChanged(insetsState, willMove, willResize);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insetsControlChanged(InsetsState insetsState,
|
||||
InsetsSourceControl[] activeControls) {
|
||||
InsetsSourceControl[] activeControls, boolean willMove, boolean willResize) {
|
||||
final ViewRootImpl viewAncestor = mViewAncestor.get();
|
||||
if (viewAncestor != null) {
|
||||
viewAncestor.dispatchInsetsControlChanged(insetsState, activeControls);
|
||||
viewAncestor.dispatchInsetsControlChanged(
|
||||
insetsState, activeControls, willMove, willResize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,12 +66,12 @@ public class BaseIWindow extends IWindow.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insetsChanged(InsetsState insetsState) {
|
||||
public void insetsChanged(InsetsState insetsState, boolean willMove, boolean willResize) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insetsControlChanged(InsetsState insetsState,
|
||||
InsetsSourceControl[] activeControls) {
|
||||
InsetsSourceControl[] activeControls, boolean willMove, boolean willResize) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -317,11 +317,11 @@ public class SystemWindows {
|
||||
public void locationInParentDisplayChanged(Point offset) {}
|
||||
|
||||
@Override
|
||||
public void insetsChanged(InsetsState insetsState) {}
|
||||
public void insetsChanged(InsetsState insetsState, boolean willMove, boolean willResize) {}
|
||||
|
||||
@Override
|
||||
public void insetsControlChanged(InsetsState insetsState,
|
||||
InsetsSourceControl[] activeControls) {}
|
||||
InsetsSourceControl[] activeControls, boolean willMove, boolean willResize) {}
|
||||
|
||||
@Override
|
||||
public void showInsets(int types, boolean fromIme) {}
|
||||
|
||||
@@ -3928,7 +3928,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
void notifyInsetsChanged() {
|
||||
ProtoLog.d(WM_DEBUG_IME, "notifyInsetsChanged for %s ", this);
|
||||
try {
|
||||
mClient.insetsChanged(getCompatInsetsState());
|
||||
mClient.insetsChanged(getCompatInsetsState(),
|
||||
hasMoved(),
|
||||
mWindowFrames.isFrameSizeChangeReported());
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG, "Failed to deliver inset state change w=" + this, e);
|
||||
}
|
||||
@@ -3944,7 +3946,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
getDisplayContent().getInsetsStateController();
|
||||
try {
|
||||
mClient.insetsControlChanged(getCompatInsetsState(),
|
||||
stateController.getControlsForDispatch(this));
|
||||
stateController.getControlsForDispatch(this),
|
||||
hasMoved(),
|
||||
mWindowFrames.isFrameSizeChangeReported());
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG, "Failed to deliver inset state change to w=" + this, e);
|
||||
}
|
||||
|
||||
@@ -53,12 +53,12 @@ public class TestIWindow extends IWindow.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insetsChanged(InsetsState insetsState) throws RemoteException {
|
||||
public void insetsChanged(InsetsState insetsState, boolean willMove, boolean willResize) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insetsControlChanged(InsetsState insetsState, InsetsSourceControl[] activeControls)
|
||||
throws RemoteException {
|
||||
public void insetsControlChanged(InsetsState insetsState,
|
||||
InsetsSourceControl[] activeControls, boolean willMove, boolean willResize) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user