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

Commit 01548639 authored by Garfield Tan's avatar Garfield Tan
Browse files

Add a test API to remove launch param records.

Some tests are broken because launch params are persisted between test
cases.

Bug: 120035844
Test: Manual test on the CTS.
Change-Id: Ia4f23778467f73dad471487eb94979bfccde16d9
parent 18b665d4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ package android.app {
  }

  public class ActivityTaskManager {
    method public void clearLaunchParamsForPackages(java.util.List<java.lang.String>);
    method public java.lang.String listAllStacks();
    method public void moveTaskToStack(int, int, boolean);
    method public boolean moveTopActivityToPinnedStack(int, android.graphics.Rect);
+14 −0
Original line number Diff line number Diff line
@@ -433,4 +433,18 @@ public class ActivityTaskManager {
        }
        return sb.toString();
    }

    /**
     * Clears launch params for the given package.
     * @param packageNames the names of the packages of which the launch params are to be cleared
     */
    @TestApi
    @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
    public void clearLaunchParamsForPackages(List<String> packageNames) {
        try {
            getService().clearLaunchParamsForPackages(packageNames);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -445,4 +445,9 @@ interface IActivityTaskManager {
    void setPackageScreenCompatMode(in String packageName, int mode);
    boolean getPackageAskScreenCompat(in String packageName);
    void setPackageAskScreenCompat(in String packageName, boolean ask);

    /**
     * Clears launch params for given packages.
     */
    void clearLaunchParamsForPackages(in List<String> packageNames);
}
+15 −0
Original line number Diff line number Diff line
@@ -4508,6 +4508,21 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        return mKeyguardController.isKeyguardLocked();
    }

    /**
     * Clears launch params for the given package.
     * @param packageNames the names of the packages of which the launch params are to be cleared
     */
    @Override
    public void clearLaunchParamsForPackages(List<String> packageNames) {
        mAmInternal.enforceCallingPermission(Manifest.permission.MANAGE_ACTIVITY_STACKS,
                "clearLaunchParamsForPackages");
        synchronized (mGlobalLock) {
            for (int i = 0; i < packageNames.size(); ++i) {
                mStackSupervisor.mLaunchParamsPersister.removeRecordForPackage(packageNames.get(i));
            }
        }
    }

    void dumpLastANRLocked(PrintWriter pw) {
        pw.println("ACTIVITY MANAGER LAST ANR (dumpsys activity lastanr)");
        if (mLastANRState == null) {
+2 −2
Original line number Diff line number Diff line
@@ -268,7 +268,7 @@ class LaunchParamsPersister {
        outParams.mBounds.set(persistableParams.mBounds);
    }

    private void onPackageRemoved(String packageName) {
    void removeRecordForPackage(String packageName) {
        final List<File> fileToDelete = new ArrayList<>();
        for (int i = 0; i < mMap.size(); ++i) {
            int userId = mMap.keyAt(i);
@@ -309,7 +309,7 @@ class LaunchParamsPersister {

        @Override
        public void onPackageRemoved(String packageName) {
            LaunchParamsPersister.this.onPackageRemoved(packageName);
            removeRecordForPackage(packageName);
        }
    }

Loading