summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice/InputMethodService.java
diff options
context:
space:
mode:
authorTarandeep Singh <tarandeep@google.com>2020-02-03 14:55:30 -0800
committerTaran Singh <tarandeep@google.com>2020-02-26 18:58:33 +0000
commit94c9a8328e4dc9f8942ffc0d02784700ee77880b (patch)
tree2e7d5daf28d3c55cb88f28f5e699ccc74994c499 /core/java/android/inputmethodservice/InputMethodService.java
parentd506a78e94594be701b2a061cb48b5e2f5cf3908 (diff)
Remove IME surface when hidden
When IME is no longer shown, notify IMS to hide the window surface. This reclaims the memory allocated to IME window surface. Fix: 150163310 Test: atest CtsInputMethodTests Manually: 1. Open any app that has editor and run adb shell dumpsys SurfaceFlinger | grep Total 2. Note down total memory 3. Tap on editor and IME shows. Note down memory using command in #1. It should go up by ~27MB 4. Hide IME and note down memory again. It should revert to original value in #1. Change-Id: I6c2a13dd40b22d3fd62b4763ba369992e5ff1138
Diffstat (limited to 'core/java/android/inputmethodservice/InputMethodService.java')
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 20a4ab35defec..61adfbce30bff 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -814,6 +814,13 @@ public class InputMethodService extends AbstractInputMethodService {
onPreRenderedWindowVisibilityChanged(false /* setVisible */);
}
+ private void removeImeSurface() {
+ if (!mShowInputRequested && !mWindowVisible) {
+ // hiding a window removes its surface.
+ mWindow.hide();
+ }
+ }
+
private void setImeWindowStatus(int visibilityFlags, int backDisposition) {
mPrivOps.setImeWindowStatus(visibilityFlags, backDisposition);
}
@@ -932,6 +939,14 @@ public class InputMethodService extends AbstractInputMethodService {
public final void notifyImeHidden() {
InputMethodService.this.notifyImeHidden();
}
+
+ /**
+ * Notify IME that surface can be now removed.
+ * @hide
+ */
+ public final void removeImeSurface() {
+ InputMethodService.this.removeImeSurface();
+ }
}
/**