Merge "Refactor InkWindow lifetime" into udc-qpr-dev am: 1139a889d5

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24138936

Change-Id: I23b3d071ecd1cf5ecbbea64474486206ffec3993
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Taran Singh
2023-07-26 05:33:41 +00:00
committed by Automerger Merge Worker

View File

@@ -807,9 +807,11 @@ public class InputMethodService extends AbstractInputMethodService {
onUnbindInput();
mInputBinding = null;
mInputConnection = null;
// free-up cached InkWindow surface on detaching from current client.
if (mInkWindow != null) {
removeHandwritingInkWindow();
finishStylusHandwriting();
// free-up InkWindow surface after timeout.
scheduleStylusWindowIdleTimeout();
}
}
@@ -1020,6 +1022,7 @@ public class InputMethodService extends AbstractInputMethodService {
mOnPreparedStylusHwCalled = true;
}
if (onStartStylusHandwriting()) {
cancelStylusWindowIdleTimeout();
mPrivOps.onStylusHandwritingReady(requestId, Process.myPid());
} else {
Log.i(TAG, "IME is not ready. Can't start Stylus Handwriting");
@@ -1109,7 +1112,7 @@ public class InputMethodService extends AbstractInputMethodService {
*/
@Override
public void removeStylusHandwritingWindow() {
InputMethodService.this.removeStylusHandwritingWindow();
InputMethodService.this.finishAndRemoveStylusHandwritingWindow();
}
/**
@@ -2667,21 +2670,15 @@ public class InputMethodService extends AbstractInputMethodService {
* Typically, this is called when {@link InkWindow} should no longer be holding a surface in
* memory.
*/
private void removeStylusHandwritingWindow() {
private void finishAndRemoveStylusHandwritingWindow() {
cancelStylusWindowIdleTimeout();
mOnPreparedStylusHwCalled = false;
mStylusWindowIdleTimeoutRunnable = null;
if (mInkWindow != null) {
if (mHandwritingRequestId.isPresent()) {
// if handwriting session is still ongoing. This shouldn't happen.
finishStylusHandwriting();
}
removeHandwritingInkWindow();
}
}
private void removeHandwritingInkWindow() {
cancelStylusWindowIdleTimeout();
mOnPreparedStylusHwCalled = false;
mStylusWindowIdleTimeoutRunnable = null;
if (mInkWindow != null) {
mInkWindow.hide(true /* remove */);
mInkWindow.destroy();
mInkWindow = null;
@@ -2707,7 +2704,7 @@ public class InputMethodService extends AbstractInputMethodService {
private Runnable getStylusWindowIdleTimeoutRunnable() {
if (mStylusWindowIdleTimeoutRunnable == null) {
mStylusWindowIdleTimeoutRunnable = () -> {
removeHandwritingInkWindow();
finishAndRemoveStylusHandwritingWindow();
mStylusWindowIdleTimeoutRunnable = null;
};
}