summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andrey Epin <ayepin@google.com> 2024-06-19 20:33:45 -0700
committer Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2024-07-11 04:23:52 +0000
commit7fe57d25c892ad206b58c99c587fb28289830b80 (patch)
tree14d89ef047461a35f2599fb69b33382a0c025931
parentf748a09a8d62bb0d4b75e9c28ac614b3dd18906a (diff)
Destroy all profile list adapters
Fix: 346671041 Test: launch media projection selection activity on a device with multiple profiles; check that the activity is leaking before the fid and is not leaking after the fix. Flag: android.service.chooser.fix_resolver_memory_leak (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:1f513aa2c90ec36d8b641251fcd5d11a23256876) Merged-In: I5055957464d905c2d8a638743658461d9680230c Change-Id: I5055957464d905c2d8a638743658461d9680230c
-rw-r--r--core/java/android/service/chooser/flags.aconfig11
-rw-r--r--core/java/com/android/internal/app/ResolverActivity.java16
2 files changed, 24 insertions, 3 deletions
diff --git a/core/java/android/service/chooser/flags.aconfig b/core/java/android/service/chooser/flags.aconfig
index d6425c397bbb..ed20207cfb0b 100644
--- a/core/java/android/service/chooser/flags.aconfig
+++ b/core/java/android/service/chooser/flags.aconfig
@@ -32,3 +32,14 @@ flag {
description: "Provides additional callbacks with information about user actions in ChooserResult"
bug: "263474465"
}
+
+flag {
+ name: "fix_resolver_memory_leak"
+ is_exported: true
+ namespace: "intentresolver"
+ description: "ResolverActivity memory leak (through the AppPredictor callback) fix"
+ bug: "346671041"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 920981e2b8fe..a1945352ae09 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -1209,9 +1209,19 @@ public class ResolverActivity extends Activity implements
if (!isChangingConfigurations() && mPickOptionRequest != null) {
mPickOptionRequest.cancel();
}
- if (mMultiProfilePagerAdapter != null
- && mMultiProfilePagerAdapter.getActiveListAdapter() != null) {
- mMultiProfilePagerAdapter.getActiveListAdapter().onDestroy();
+ if (mMultiProfilePagerAdapter != null) {
+ ResolverListAdapter activeAdapter =
+ mMultiProfilePagerAdapter.getActiveListAdapter();
+ if (activeAdapter != null) {
+ activeAdapter.onDestroy();
+ }
+ if (android.service.chooser.Flags.fixResolverMemoryLeak()) {
+ ResolverListAdapter inactiveAdapter =
+ mMultiProfilePagerAdapter.getInactiveListAdapter();
+ if (inactiveAdapter != null) {
+ inactiveAdapter.onDestroy();
+ }
+ }
}
}