Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 440afbb9 authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "Remove the ActivityClientRecord reference once destroyed" into udc-dev

parents 31cf3ea3 b576a7b4
Loading
Loading
Loading
Loading
+15 −26
Original line number Original line Diff line number Diff line
@@ -360,9 +360,8 @@ public final class ActivityThread extends ClientTransactionHandler
    /** The activities to be truly destroyed (not include relaunch). */
    /** The activities to be truly destroyed (not include relaunch). */
    final Map<IBinder, ClientTransactionItem> mActivitiesToBeDestroyed =
    final Map<IBinder, ClientTransactionItem> mActivitiesToBeDestroyed =
            Collections.synchronizedMap(new ArrayMap<IBinder, ClientTransactionItem>());
            Collections.synchronizedMap(new ArrayMap<IBinder, ClientTransactionItem>());
    // List of new activities (via ActivityRecord.nextIdle) that should
    // List of new activities that should be reported when next we idle.
    // be reported when next we idle.
    final ArrayList<ActivityClientRecord> mNewActivities = new ArrayList<>();
    ActivityClientRecord mNewActivities = null;
    // Number of activities that are currently visible on-screen.
    // Number of activities that are currently visible on-screen.
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    int mNumVisibleActivities = 0;
    int mNumVisibleActivities = 0;
@@ -563,7 +562,6 @@ public final class ActivityThread extends ClientTransactionHandler
        private Configuration tmpConfig = new Configuration();
        private Configuration tmpConfig = new Configuration();
        // Callback used for updating activity override config and camera compat control state.
        // Callback used for updating activity override config and camera compat control state.
        ViewRootImpl.ActivityConfigCallback activityConfigCallback;
        ViewRootImpl.ActivityConfigCallback activityConfigCallback;
        ActivityClientRecord nextIdle;


        // Indicates whether this activity is currently the topmost resumed one in the system.
        // Indicates whether this activity is currently the topmost resumed one in the system.
        // This holds the last reported value from server.
        // This holds the last reported value from server.
@@ -657,7 +655,6 @@ public final class ActivityThread extends ClientTransactionHandler
            paused = false;
            paused = false;
            stopped = false;
            stopped = false;
            hideForNow = false;
            hideForNow = false;
            nextIdle = null;
            activityConfigCallback = new ViewRootImpl.ActivityConfigCallback() {
            activityConfigCallback = new ViewRootImpl.ActivityConfigCallback() {
                @Override
                @Override
                public void onConfigurationChanged(Configuration overrideConfig,
                public void onConfigurationChanged(Configuration overrideConfig,
@@ -2483,29 +2480,22 @@ public final class ActivityThread extends ClientTransactionHandler
    private class Idler implements MessageQueue.IdleHandler {
    private class Idler implements MessageQueue.IdleHandler {
        @Override
        @Override
        public final boolean queueIdle() {
        public final boolean queueIdle() {
            ActivityClientRecord a = mNewActivities;
            boolean stopProfiling = false;
            boolean stopProfiling = false;
            if (mBoundApplication != null && mProfiler.profileFd != null
            if (mBoundApplication != null && mProfiler.profileFd != null
                    && mProfiler.autoStopProfiler) {
                    && mProfiler.autoStopProfiler) {
                stopProfiling = true;
                stopProfiling = true;
            }
            }
            if (a != null) {
                mNewActivities = null;
            final ActivityClient ac = ActivityClient.getInstance();
            final ActivityClient ac = ActivityClient.getInstance();
                ActivityClientRecord prev;
            while (mNewActivities.size() > 0) {
                do {
                final ActivityClientRecord a = mNewActivities.remove(0);
                    if (localLOGV) Slog.v(
                if (localLOGV) {
                        TAG, "Reporting idle of " + a +
                    Slog.v(TAG, "Reporting idle of " + a + " finished="
                        " finished=" +
                            + (a.activity != null && a.activity.mFinished));
                        (a.activity != null && a.activity.mFinished));
                }
                if (a.activity != null && !a.activity.mFinished) {
                if (a.activity != null && !a.activity.mFinished) {
                    ac.activityIdle(a.token, a.createdConfig, stopProfiling);
                    ac.activityIdle(a.token, a.createdConfig, stopProfiling);
                    a.createdConfig = null;
                    a.createdConfig = null;
                }
                }
                    prev = a;
                    a = a.nextIdle;
                    prev.nextIdle = null;
                } while (a != null);
            }
            }
            if (stopProfiling) {
            if (stopProfiling) {
                mProfiler.stopProfiling();
                mProfiler.stopProfiling();
@@ -5107,8 +5097,7 @@ public final class ActivityThread extends ClientTransactionHandler
            }
            }
        }
        }


        r.nextIdle = mNewActivities;
        mNewActivities.add(r);
        mNewActivities = r;
        if (localLOGV) Slog.v(TAG, "Scheduling idle handler for " + r);
        if (localLOGV) Slog.v(TAG, "Scheduling idle handler for " + r);
        Looper.myQueue().addIdleHandler(new Idler());
        Looper.myQueue().addIdleHandler(new Idler());
    }
    }
@@ -5709,6 +5698,7 @@ public final class ActivityThread extends ClientTransactionHandler
        }
        }
        if (finishing) {
        if (finishing) {
            ActivityClient.getInstance().activityDestroyed(r.token);
            ActivityClient.getInstance().activityDestroyed(r.token);
            mNewActivities.remove(r);
        }
        }
        mSomeActivitiesChanged = true;
        mSomeActivitiesChanged = true;
    }
    }
@@ -5929,7 +5919,6 @@ public final class ActivityThread extends ClientTransactionHandler
        r.activity = null;
        r.activity = null;
        r.window = null;
        r.window = null;
        r.hideForNow = false;
        r.hideForNow = false;
        r.nextIdle = null;
        // Merge any pending results and pending intents; don't just replace them
        // Merge any pending results and pending intents; don't just replace them
        if (pendingResults != null) {
        if (pendingResults != null) {
            if (r.pendingResults == null) {
            if (r.pendingResults == null) {