From 700c2062a0e6890540c068c7cbe02ef08a886a54 Mon Sep 17 00:00:00 2001 From: Darryl Johnson Date: Thu, 23 Apr 2020 18:14:40 +0000 Subject: Revert "Fix false positive of activity leak in NexusLauncherTests" This reverts commit b3230a35945e58fdcb24d9586317509ce826c0a1. Reason for revert: Possibly the cause of b/154581087 Bug: 154581087 Change-Id: I4a7ebeb33f68b8918d24b1e59638bbc5fa38bf72 --- core/java/android/app/ActivityThread.java | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'core/java/android/app/ActivityThread.java') diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 4e6f4bb7c06d..a62f0a6807bb 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -4973,8 +4973,10 @@ public final class ActivityThread extends ClientTransactionHandler { ActivityClientRecord performDestroyActivity(IBinder token, boolean finishing, int configChanges, boolean getNonConfigInstance, String reason) { ActivityClientRecord r = mActivities.get(token); + Class 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; @@ -5027,6 +5029,7 @@ public final class ActivityThread extends ClientTransactionHandler { synchronized (mResourcesManager) { mActivities.remove(token); } + StrictMode.decrementExpectedActivityCount(activityClass); return r; } @@ -5046,7 +5049,6 @@ public final class ActivityThread extends ClientTransactionHandler { ActivityClientRecord r = performDestroyActivity(token, finishing, configChanges, getNonConfigInstance, reason); if (r != null) { - Class activityClass = r.activity.getClass(); cleanUpPendingRemoveWindows(r, finishing); WindowManager wm = r.activity.getWindowManager(); View v = r.activity.mDecor; @@ -5071,14 +5073,14 @@ public final class ActivityThread extends ClientTransactionHandler { } if (wtoken != null && r.mPendingRemoveWindow == null) { WindowManagerGlobal.getInstance().closeAll(wtoken, - activityClass.getName(), "Activity"); + r.activity.getClass().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, - activityClass.getName(), "Activity"); + r.activity.getClass().getName(), "Activity"); } r.activity.mDecor = null; } @@ -5090,23 +5092,18 @@ 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, - activityClass.getName(), "Activity"); + r.activity.getClass().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. - final ContextImpl impl = ContextImpl.getImpl(r.activity); - if (impl != null) { - impl.scheduleFinalCleanup(activityClass.getName(), "Activity"); + Context c = r.activity.getBaseContext(); + if (c instanceof ContextImpl) { + ((ContextImpl) c).scheduleFinalCleanup( + r.activity.getClass().getName(), "Activity"); } - - r.activity = null; - r.window = null; - r.hideForNow = false; - r.nextIdle = null; - StrictMode.decrementExpectedActivityCount(activityClass); } if (finishing) { try { @@ -5336,6 +5333,10 @@ 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) { -- cgit v1.2.3