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

Commit 33d3fede authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge changes from topic "wm-unify"

* changes:
  Renamed some members of AppWindowToken (49/n)
  Removed cancelRecentsAnimationSynchronously() call path (48/n)
  Reset some threads after test finishes.
  Adopt upstream Mockito's solution to mem leak.
  Unify WM test setup for system services (47/n)
parents df720692 83b8a6b8
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import static android.os.Process.THREAD_PRIORITY_DISPLAY;
import android.os.Handler;
import android.os.Trace;

import com.android.internal.annotations.VisibleForTesting;

/**
 * Thread for handling all legacy window animations, or anything that's directly impacting
 * animations like starting windows or traversals.
@@ -55,4 +57,20 @@ public final class AnimationThread extends ServiceThread {
            return sHandler;
        }
    }

    /**
     * Disposes current animation thread if it's initialized. Should only be used in tests to set up
     * a new environment.
     */
    @VisibleForTesting
    public static void dispose() {
        synchronized (DisplayThread.class) {
            if (sInstance == null) {
                return;
            }

            getHandler().runWithScissors(() -> sInstance.quit(), 0 /* timeout */);
            sInstance = null;
        }
    }
}
+18 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.os.Handler;
import android.os.Process;
import android.os.Trace;

import com.android.internal.annotations.VisibleForTesting;

/**
 * Shared singleton foreground thread for the system.  This is a thread for
 * operations that affect what's on the display, which needs to have a minimum
@@ -58,4 +60,20 @@ public final class DisplayThread extends ServiceThread {
            return sHandler;
        }
    }

    /**
     * Disposes current display thread if it's initialized. Should only be used in tests to set up a
     * new environment.
     */
    @VisibleForTesting
    public static void dispose() {
        synchronized (DisplayThread.class) {
            if (sInstance == null) {
                return;
            }

            getHandler().runWithScissors(() -> sInstance.quit(), 0 /* timeout */);
            sInstance = null;
        }
    }
}
+6 −2
Original line number Diff line number Diff line
@@ -1480,8 +1480,9 @@ public class ActivityManagerService extends IActivityManager.Stub
    public ActivityTaskManagerService mActivityTaskManager;
    @VisibleForTesting
    public ActivityTaskManagerInternal mAtmInternal;
    UriGrantsManagerInternal mUgmInternal;
    @VisibleForTesting
    public UriGrantsManagerInternal mUgmInternal;
    public final ActivityManagerInternal mInternal;
    final ActivityThread mSystemThread;
    private final class AppDeathRecipient implements IBinder.DeathRecipient {
@@ -2413,6 +2414,8 @@ public class ActivityManagerService extends IActivityManager.Stub
        mProcStartHandler = null;
        mHiddenApiBlacklist = null;
        mFactoryTest = FACTORY_TEST_OFF;
        mUgmInternal = LocalServices.getService(UriGrantsManagerInternal.class);
        mInternal = new LocalService();
    }
    // Note: This method is invoked on the main thread but may need to attach various
@@ -2566,6 +2569,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            Slog.w(TAG, "Setting background thread cpuset failed");
        }
        mInternal = new LocalService();
    }
    public void setSystemServiceManager(SystemServiceManager mgr) {
@@ -2583,7 +2587,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        mBatteryStatsService.publish();
        mAppOpsService.publish(mContext);
        Slog.d("AppOps", "AppOpsService published");
        LocalServices.addService(ActivityManagerInternal.class, new LocalService());
        LocalServices.addService(ActivityManagerInternal.class, mInternal);
        mActivityTaskManager.onActivityManagerInternalAdded();
        mUgmInternal.onActivityManagerInternalAdded();
        mPendingIntentController.onActivityManagerInternalAdded();
+17 −12
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import static com.android.server.am.ActivityDisplayProto.RESUMED_ACTIVITY;
import static com.android.server.am.ActivityDisplayProto.SINGLE_TASK_INSTANCE;
import static com.android.server.am.ActivityDisplayProto.STACKS;
import static com.android.server.wm.ActivityStack.ActivityState.RESUMED;
import static com.android.server.wm.ActivityStack.REMOVE_TASK_MODE_DESTROYING;
import static com.android.server.wm.ActivityStack.STACK_VISIBILITY_VISIBLE;
import static com.android.server.wm.ActivityStackSupervisor.TAG_TASKS;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_STACK;
@@ -173,18 +174,10 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
        mService = root.mService;
        mDisplayId = display.getDisplayId();
        mDisplay = display;
        mDisplayContent = createDisplayContent();
        mDisplayContent = mService.mWindowManager.mRoot.createDisplayContent(mDisplay, this);
        mDisplayContent.reconfigureDisplayLocked();
        updateBounds();
    }

    protected DisplayContent createDisplayContent() {
        return mService.mWindowManager.mRoot.createDisplayContent(mDisplay, this);
    }

    private void updateBounds() {
        mDisplay.getRealSize(mTmpDisplaySize);
        setBounds(0, 0, mTmpDisplaySize.x, mTmpDisplaySize.y);
        onRequestedOverrideConfigurationChanged(
                mDisplayContent.getRequestedOverrideConfiguration());
    }

    void onDisplayChanged() {
@@ -200,7 +193,8 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
            }
        }

        updateBounds();
        mDisplay.getRealSize(mTmpDisplaySize);
        setBounds(0, 0, mTmpDisplaySize.x, mTmpDisplaySize.y);
        if (mDisplayContent != null) {
            mDisplayContent.updateDisplayInfo();
            mService.mWindowManager.requestTraversal();
@@ -1541,6 +1535,17 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
        return mSingleTaskInstance;
    }

    @VisibleForTesting
    void removeAllTasks() {
        for (int i = getChildCount() - 1; i >= 0; --i) {
            final ActivityStack stack = getChildAt(i);
            final ArrayList<TaskRecord> tasks = stack.getAllTasks();
            for (int j = tasks.size() - 1; j >= 0; --j) {
                stack.removeTask(tasks.get(j), "removeAllTasks", REMOVE_TASK_MODE_DESTROYING);
            }
        }
    }

    public void dump(PrintWriter pw, String prefix) {
        pw.println(prefix + "displayId=" + mDisplayId + " stacks=" + mStacks.size()
                + (mSingleTaskInstance ? " mSingleTaskInstance" : ""));
+11 −9
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ import static com.android.server.wm.ActivityStack.PAUSE_TIMEOUT_MSG;
import static com.android.server.wm.ActivityStack.STACK_VISIBILITY_VISIBLE;
import static com.android.server.wm.ActivityStack.STOP_TIMEOUT_MSG;
import static com.android.server.wm.ActivityStackSupervisor.PAUSE_IMMEDIATELY;
import static com.android.server.wm.ActivityStackSupervisor.PRESERVE_WINDOWS;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_ALL;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_CONFIGURATION;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_CONTAINERS;
@@ -1372,16 +1373,17 @@ final class ActivityRecord extends ConfigurationContainer {
        return stack != null ? stack.getDisplay() : null;
    }

    boolean changeWindowTranslucency(boolean toOpaque) {
        if (fullscreen == toOpaque) {
            return false;
    boolean setOccludesParent(boolean occludesParent) {
        final boolean changed = mAppWindowToken.setOccludesParent(occludesParent);
        if (changed) {
            if (!occludesParent) {
                getActivityStack().convertActivityToTranslucent(this);
            }

            // Keep track of the number of fullscreen activities in this task.
        task.numFullscreen += toOpaque ? +1 : -1;

        fullscreen = toOpaque;
        return true;
            task.numFullscreen += occludesParent ? +1 : -1;
            mRootActivityContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
        }
        return changed;
    }

    void takeFromHistory() {
Loading