Merge "Rate limit calls from apps to reportKeepClearAreaChanged" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c11507f96c
@@ -321,6 +321,11 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
|
|
||||||
private static final int UNSET_SYNC_ID = -1;
|
private static final int UNSET_SYNC_ID = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum time to wait before reporting changes to keep clear areas.
|
||||||
|
*/
|
||||||
|
private static final int KEEP_CLEAR_AREA_REPORT_RATE_MILLIS = 100;
|
||||||
|
|
||||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
|
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
|
||||||
static final ThreadLocal<HandlerActionQueue> sRunQueues = new ThreadLocal<HandlerActionQueue>();
|
static final ThreadLocal<HandlerActionQueue> sRunQueues = new ThreadLocal<HandlerActionQueue>();
|
||||||
|
|
||||||
@@ -796,6 +801,8 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
new ViewRootRectTracker(v -> v.collectPreferKeepClearRects());
|
new ViewRootRectTracker(v -> v.collectPreferKeepClearRects());
|
||||||
private final ViewRootRectTracker mUnrestrictedKeepClearRectsTracker =
|
private final ViewRootRectTracker mUnrestrictedKeepClearRectsTracker =
|
||||||
new ViewRootRectTracker(v -> v.collectUnrestrictedPreferKeepClearRects());
|
new ViewRootRectTracker(v -> v.collectUnrestrictedPreferKeepClearRects());
|
||||||
|
private List<Rect> mPendingKeepClearAreas;
|
||||||
|
private List<Rect> mPendingUnrestrictedKeepClearAreas;
|
||||||
|
|
||||||
private IAccessibilityEmbeddedConnection mAccessibilityEmbeddedConnection;
|
private IAccessibilityEmbeddedConnection mAccessibilityEmbeddedConnection;
|
||||||
|
|
||||||
@@ -4824,15 +4831,42 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
unrestrictedKeepClearRects = Collections.emptyList();
|
unrestrictedKeepClearRects = Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (mHandler.hasMessages(MSG_REPORT_KEEP_CLEAR_RECTS)) {
|
||||||
mWindowSession.reportKeepClearAreasChanged(mWindow, restrictedKeepClearRects,
|
// Keep clear areas have been reported recently, wait before reporting new set
|
||||||
unrestrictedKeepClearRects);
|
// of keep clear areas
|
||||||
} catch (RemoteException e) {
|
mPendingKeepClearAreas = restrictedKeepClearRects;
|
||||||
throw e.rethrowFromSystemServer();
|
mPendingUnrestrictedKeepClearAreas = unrestrictedKeepClearRects;
|
||||||
|
} else {
|
||||||
|
mHandler.sendEmptyMessageDelayed(MSG_REPORT_KEEP_CLEAR_RECTS,
|
||||||
|
KEEP_CLEAR_AREA_REPORT_RATE_MILLIS);
|
||||||
|
try {
|
||||||
|
mWindowSession.reportKeepClearAreasChanged(mWindow, restrictedKeepClearRects,
|
||||||
|
unrestrictedKeepClearRects);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reportKeepClearAreasChanged() {
|
||||||
|
final List<Rect> restrictedKeepClearRects = mPendingKeepClearAreas;
|
||||||
|
final List<Rect> unrestrictedKeepClearRects = mPendingUnrestrictedKeepClearAreas;
|
||||||
|
if (restrictedKeepClearRects == null && unrestrictedKeepClearRects == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mPendingKeepClearAreas = null;
|
||||||
|
mPendingUnrestrictedKeepClearAreas = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
mWindowSession.reportKeepClearAreasChanged(mWindow, restrictedKeepClearRects,
|
||||||
|
unrestrictedKeepClearRects);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the root render node is invalidated next time we perform a draw, such that
|
* Requests that the root render node is invalidated next time we perform a draw, such that
|
||||||
* {@link WindowCallbacks#onPostDraw} gets called.
|
* {@link WindowCallbacks#onPostDraw} gets called.
|
||||||
@@ -5322,6 +5356,7 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
private static final int MSG_REQUEST_SCROLL_CAPTURE = 33;
|
private static final int MSG_REQUEST_SCROLL_CAPTURE = 33;
|
||||||
private static final int MSG_WINDOW_TOUCH_MODE_CHANGED = 34;
|
private static final int MSG_WINDOW_TOUCH_MODE_CHANGED = 34;
|
||||||
private static final int MSG_KEEP_CLEAR_RECTS_CHANGED = 35;
|
private static final int MSG_KEEP_CLEAR_RECTS_CHANGED = 35;
|
||||||
|
private static final int MSG_REPORT_KEEP_CLEAR_RECTS = 36;
|
||||||
|
|
||||||
|
|
||||||
final class ViewRootHandler extends Handler {
|
final class ViewRootHandler extends Handler {
|
||||||
@@ -5598,6 +5633,9 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
case MSG_KEEP_CLEAR_RECTS_CHANGED: {
|
case MSG_KEEP_CLEAR_RECTS_CHANGED: {
|
||||||
keepClearRectsChanged();
|
keepClearRectsChanged();
|
||||||
} break;
|
} break;
|
||||||
|
case MSG_REPORT_KEEP_CLEAR_RECTS: {
|
||||||
|
reportKeepClearAreasChanged();
|
||||||
|
} break;
|
||||||
case MSG_REQUEST_SCROLL_CAPTURE:
|
case MSG_REQUEST_SCROLL_CAPTURE:
|
||||||
handleScrollCaptureRequest((IScrollCaptureResponseListener) msg.obj);
|
handleScrollCaptureRequest((IScrollCaptureResponseListener) msg.obj);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user