commit | 9b772df2a5ae9db5cf67f2354a34f592953eab72 | [log] [tgz] |
---|---|---|
author | Shao Mengchuan <shao.mengchuan@zte.com.cn> | Thu Mar 28 19:42:24 2024 +0800 |
committer | Jia Jia <jia.jia@zte.com.cn> | Thu Mar 28 11:52:10 2024 +0000 |
tree | be7ae4ced48e7c390f0c8708c9a54f0f9c28409a | |
parent | f3ef502ad61c9ba576f8dadc2665b98f4f9a79bb [diff] |
Fix the memory leak caused by the accessibility menu in SystemUI When you turn on the "Accessibility Menu shortcut" switch in settings, it starts a service and creates a new A11yMenuOverlayLayout. However, the layout is not set to null at the right time, causing the A11yMenuOverlayLayout to be repeatedly created and leading to a memory leak. Change-Id: I2368a1bbbbe0159755859651ecf53831ac70db37 Signed-off-by: Jia Jia <jia.jia@zte.com.cn>
diff --git a/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/AccessibilityMenuService.java b/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/AccessibilityMenuService.java index 085fc29..b05d2ae 100644 --- a/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/AccessibilityMenuService.java +++ b/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/AccessibilityMenuService.java
@@ -387,6 +387,10 @@ unregisterReceiver(mToggleMenuReceiver); mPrefs.unregisterOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener); sInitialized = false; + if (mA11yMenuLayout != null) { + mA11yMenuLayout.clearLayout(); + mA11yMenuLayout = null; + } return super.onUnbind(intent); }
diff --git a/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/view/A11yMenuOverlayLayout.java b/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/view/A11yMenuOverlayLayout.java index edd6a48..1be04f8 100644 --- a/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/view/A11yMenuOverlayLayout.java +++ b/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/view/A11yMenuOverlayLayout.java
@@ -151,6 +151,14 @@ return mLayout; } + public void clearLayout() { + if (mLayout != null) { + mWindowManager.removeView(mLayout); + mLayout.setOnTouchListener(null); + mLayout = null; + } + } + /** Updates view layout with new layout parameters only. */ public void updateViewLayout() { if (mLayout == null || mLayoutParameter == null) {