Merge "Refactor dispatching the focus event from handleWindowFocusChanged" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
baa7f98f58
@@ -3799,44 +3799,7 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mAdded) {
|
if (mAdded) {
|
||||||
profileRendering(hasWindowFocus);
|
dispatchFocusEvent(hasWindowFocus);
|
||||||
if (hasWindowFocus) {
|
|
||||||
if (mAttachInfo.mThreadedRenderer != null && mSurface.isValid()) {
|
|
||||||
mFullRedrawNeeded = true;
|
|
||||||
try {
|
|
||||||
final Rect surfaceInsets = mWindowAttributes.surfaceInsets;
|
|
||||||
mAttachInfo.mThreadedRenderer.initializeIfNeeded(
|
|
||||||
mWidth, mHeight, mAttachInfo, mSurface, surfaceInsets);
|
|
||||||
} catch (OutOfResourcesException e) {
|
|
||||||
Log.e(mTag, "OutOfResourcesException locking surface", e);
|
|
||||||
try {
|
|
||||||
if (!mWindowSession.outOfMemory(mWindow)) {
|
|
||||||
Slog.w(mTag, "No processes killed for memory;"
|
|
||||||
+ " killing self");
|
|
||||||
Process.killProcess(Process.myPid());
|
|
||||||
}
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
}
|
|
||||||
// Retry in a bit.
|
|
||||||
mHandler.sendMessageDelayed(mHandler.obtainMessage(
|
|
||||||
MSG_WINDOW_FOCUS_CHANGED), 500);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mAttachInfo.mHasWindowFocus = hasWindowFocus;
|
|
||||||
mImeFocusController.updateImeFocusable(mWindowAttributes, true /* force */);
|
|
||||||
mImeFocusController.onPreWindowFocus(hasWindowFocus, mWindowAttributes);
|
|
||||||
|
|
||||||
if (mView != null) {
|
|
||||||
mAttachInfo.mKeyDispatchState.reset();
|
|
||||||
mView.dispatchWindowFocusChanged(hasWindowFocus);
|
|
||||||
mAttachInfo.mTreeObserver.dispatchOnWindowFocusChange(hasWindowFocus);
|
|
||||||
if (mAttachInfo.mTooltipHost != null) {
|
|
||||||
mAttachInfo.mTooltipHost.hideTooltip();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: must be done after the focus change callbacks,
|
// Note: must be done after the focus change callbacks,
|
||||||
// so all of the view state is set up correctly.
|
// so all of the view state is set up correctly.
|
||||||
@@ -3872,6 +3835,45 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dispatchFocusEvent(boolean hasWindowFocus) {
|
||||||
|
profileRendering(hasWindowFocus);
|
||||||
|
if (hasWindowFocus && mAttachInfo.mThreadedRenderer != null && mSurface.isValid()) {
|
||||||
|
mFullRedrawNeeded = true;
|
||||||
|
try {
|
||||||
|
final Rect surfaceInsets = mWindowAttributes.surfaceInsets;
|
||||||
|
mAttachInfo.mThreadedRenderer.initializeIfNeeded(
|
||||||
|
mWidth, mHeight, mAttachInfo, mSurface, surfaceInsets);
|
||||||
|
} catch (OutOfResourcesException e) {
|
||||||
|
Log.e(mTag, "OutOfResourcesException locking surface", e);
|
||||||
|
try {
|
||||||
|
if (!mWindowSession.outOfMemory(mWindow)) {
|
||||||
|
Slog.w(mTag, "No processes killed for memory;"
|
||||||
|
+ " killing self");
|
||||||
|
Process.killProcess(Process.myPid());
|
||||||
|
}
|
||||||
|
} catch (RemoteException ex) {
|
||||||
|
}
|
||||||
|
// Retry in a bit.
|
||||||
|
mHandler.sendMessageDelayed(mHandler.obtainMessage(
|
||||||
|
MSG_WINDOW_FOCUS_CHANGED), 500);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mAttachInfo.mHasWindowFocus = hasWindowFocus;
|
||||||
|
mImeFocusController.updateImeFocusable(mWindowAttributes, true /* force */);
|
||||||
|
mImeFocusController.onPreWindowFocus(hasWindowFocus, mWindowAttributes);
|
||||||
|
|
||||||
|
if (mView != null) {
|
||||||
|
mAttachInfo.mKeyDispatchState.reset();
|
||||||
|
mView.dispatchWindowFocusChanged(hasWindowFocus);
|
||||||
|
mAttachInfo.mTreeObserver.dispatchOnWindowFocusChange(hasWindowFocus);
|
||||||
|
if (mAttachInfo.mTooltipHost != null) {
|
||||||
|
mAttachInfo.mTooltipHost.hideTooltip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void handleWindowTouchModeChanged() {
|
private void handleWindowTouchModeChanged() {
|
||||||
final boolean inTouchMode;
|
final boolean inTouchMode;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
|||||||
Reference in New Issue
Block a user