summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-03-25 11:36:11 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-03-25 11:36:11 +0000
commitb04ab6ceb1beee1c34538cccb36a20eaafcc063c (patch)
tree70a5828d6ecad4955fb166515ced3df61a3701c7
parent389580c7dac14797848090d39af3288bd1e93b70 (diff)
parentb3230a35945e58fdcb24d9586317509ce826c0a1 (diff)
Merge "Fix false positive of activity leak in NexusLauncherTests" into rvc-dev
-rw-r--r--core/java/android/app/ActivityThread.java27
1 files changed, 13 insertions, 14 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index bd3fee2d1fc7..21b56d3e337f 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -4974,10 +4974,8 @@ public final class ActivityThread extends ClientTransactionHandler {
ActivityClientRecord performDestroyActivity(IBinder token, boolean finishing,
int configChanges, boolean getNonConfigInstance, String reason) {
ActivityClientRecord r = mActivities.get(token);
- Class<? extends Activity> activityClass = null;
if (localLOGV) Slog.v(TAG, "Performing finish of " + r);
if (r != null) {
- activityClass = r.activity.getClass();
r.activity.mConfigChangeFlags |= configChanges;
if (finishing) {
r.activity.mFinished = true;
@@ -5030,7 +5028,6 @@ public final class ActivityThread extends ClientTransactionHandler {
synchronized (mResourcesManager) {
mActivities.remove(token);
}
- StrictMode.decrementExpectedActivityCount(activityClass);
return r;
}
@@ -5050,6 +5047,7 @@ public final class ActivityThread extends ClientTransactionHandler {
ActivityClientRecord r = performDestroyActivity(token, finishing,
configChanges, getNonConfigInstance, reason);
if (r != null) {
+ Class<? extends Activity> activityClass = r.activity.getClass();
cleanUpPendingRemoveWindows(r, finishing);
WindowManager wm = r.activity.getWindowManager();
View v = r.activity.mDecor;
@@ -5074,14 +5072,14 @@ public final class ActivityThread extends ClientTransactionHandler {
}
if (wtoken != null && r.mPendingRemoveWindow == null) {
WindowManagerGlobal.getInstance().closeAll(wtoken,
- r.activity.getClass().getName(), "Activity");
+ activityClass.getName(), "Activity");
} else if (r.mPendingRemoveWindow != null) {
// We're preserving only one window, others should be closed so app views
// will be detached before the final tear down. It should be done now because
// some components (e.g. WebView) rely on detach callbacks to perform receiver
// unregister and other cleanup.
WindowManagerGlobal.getInstance().closeAllExceptView(token, v,
- r.activity.getClass().getName(), "Activity");
+ activityClass.getName(), "Activity");
}
r.activity.mDecor = null;
}
@@ -5093,18 +5091,23 @@ public final class ActivityThread extends ClientTransactionHandler {
// about leaking windows, because that is a bug, so if they are
// using this recreate facility then they get to live with leaks.
WindowManagerGlobal.getInstance().closeAll(token,
- r.activity.getClass().getName(), "Activity");
+ activityClass.getName(), "Activity");
}
// Mocked out contexts won't be participating in the normal
// process lifecycle, but if we're running with a proper
// ApplicationContext we need to have it tear down things
// cleanly.
- Context c = r.activity.getBaseContext();
- if (c instanceof ContextImpl) {
- ((ContextImpl) c).scheduleFinalCleanup(
- r.activity.getClass().getName(), "Activity");
+ final ContextImpl impl = ContextImpl.getImpl(r.activity);
+ if (impl != null) {
+ impl.scheduleFinalCleanup(activityClass.getName(), "Activity");
}
+
+ r.activity = null;
+ r.window = null;
+ r.hideForNow = false;
+ r.nextIdle = null;
+ StrictMode.decrementExpectedActivityCount(activityClass);
}
if (finishing) {
try {
@@ -5334,10 +5337,6 @@ public final class ActivityThread extends ClientTransactionHandler {
handleDestroyActivity(r.token, false, configChanges, true, reason);
- r.activity = null;
- r.window = null;
- r.hideForNow = false;
- r.nextIdle = null;
// Merge any pending results and pending intents; don't just replace them
if (pendingResults != null) {
if (r.pendingResults == null) {