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

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

Merge changes I84d43fdb,I726037d5

* changes:
  Removed references to ATMS.getLockTaskController() from AMS (34/n)
  Removed references to ATMS.mHomeProcess and mPreviousProcess from AMS (33/n)
parents 63578a07 27c48ae4
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -177,6 +177,7 @@ interface IActivityTaskManager {
    void cancelRecentsAnimation(boolean restoreHomeStackPosition);
    void cancelRecentsAnimation(boolean restoreHomeStackPosition);
    void startLockTaskModeByToken(in IBinder token);
    void startLockTaskModeByToken(in IBinder token);
    void stopLockTaskModeByToken(in IBinder token);
    void stopLockTaskModeByToken(in IBinder token);
    void updateLockTaskPackages(int userId, in String[] packages);
    boolean isInLockTaskMode();
    boolean isInLockTaskMode();
    int getLockTaskModeState();
    int getLockTaskModeState();
    void setTaskDescription(in IBinder token, in ActivityManager.TaskDescription values);
    void setTaskDescription(in IBinder token, in ActivityManager.TaskDescription values);
+10 −24
Original line number Original line Diff line number Diff line
@@ -5815,16 +5815,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    @Override
    @Override
    public void updateLockTaskPackages(int userId, String[] packages) {
    public void updateLockTaskPackages(int userId, String[] packages) {
        final int callingUid = Binder.getCallingUid();
        mActivityTaskManager.updateLockTaskPackages(userId, packages);
        if (callingUid != 0 && callingUid != SYSTEM_UID) {
            enforceCallingPermission(android.Manifest.permission.UPDATE_LOCK_TASK_PACKAGES,
                    "updateLockTaskPackages()");
        }
        synchronized (this) {
            if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "Whitelisting " + userId + ":" +
                    Arrays.toString(packages));
            mActivityTaskManager.getLockTaskController().updateLockTaskPackages(userId, packages);
        }
    }
    }
    @Override
    @Override
@@ -7284,7 +7275,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        mBatteryStatsService.shutdown();
        mBatteryStatsService.shutdown();
        synchronized (this) {
        synchronized (this) {
            mProcessStats.shutdownLocked();
            mProcessStats.shutdownLocked();
            mActivityTaskManager.notifyTaskPersisterLocked(null, true);
        }
        }
        return timedout;
        return timedout;
@@ -10384,11 +10374,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        dumpProcessesToGc(pw, needSep, null);
        dumpProcessesToGc(pw, needSep, null);
        pw.println();
        pw.println();
        pw.println("  mHomeProcess: " + mActivityTaskManager.mHomeProcess);
        mAtmInternal.dumpForOom(pw);
        pw.println("  mPreviousProcess: " + mActivityTaskManager.mPreviousProcess);
        if (mActivityTaskManager.mHeavyWeightProcess != null) {
            pw.println("  mHeavyWeightProcess: " + mActivityTaskManager.mHeavyWeightProcess);
        }
        return true;
        return true;
    }
    }
@@ -15442,7 +15428,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            }
        }
        }
        if (wpc == mActivityTaskManager.mHomeProcess) {
        if (wpc.isHomeProcess()) {
            if (adj > ProcessList.HOME_APP_ADJ) {
            if (adj > ProcessList.HOME_APP_ADJ) {
                // This process is hosting what we currently consider to be the
                // This process is hosting what we currently consider to be the
                // home app, so we don't want to let it go into the background.
                // home app, so we don't want to let it go into the background.
@@ -15463,7 +15449,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            }
        }
        }
        if (wpc == mActivityTaskManager.mPreviousProcess && app.hasActivities()) {
        if (wpc.isPreviousProcess() && app.hasActivities()) {
            if (adj > ProcessList.PREVIOUS_APP_ADJ) {
            if (adj > ProcessList.PREVIOUS_APP_ADJ) {
                // This was the previous process that showed UI to the user.
                // This was the previous process that showed UI to the user.
                // We want to try to keep it around more aggressively, to give
                // We want to try to keep it around more aggressively, to give
@@ -15540,7 +15526,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                                "Raise procstate to started service: " + app);
                                "Raise procstate to started service: " + app);
                    }
                    }
                }
                }
                if (app.hasShownUi && wpc != mActivityTaskManager.mHomeProcess) {
                if (app.hasShownUi && !wpc.isHomeProcess()) {
                    // If this process has shown some UI, let it immediately
                    // If this process has shown some UI, let it immediately
                    // go to the LRU list because it may be pretty heavy with
                    // go to the LRU list because it may be pretty heavy with
                    // UI stuff.  We'll tag it with a label just to help
                    // UI stuff.  We'll tag it with a label just to help
@@ -15619,7 +15605,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                        if ((cr.flags&Context.BIND_ALLOW_OOM_MANAGEMENT) != 0) {
                        if ((cr.flags&Context.BIND_ALLOW_OOM_MANAGEMENT) != 0) {
                            // Not doing bind OOM management, so treat
                            // Not doing bind OOM management, so treat
                            // this guy more like a started service.
                            // this guy more like a started service.
                            if (app.hasShownUi && wpc != mActivityTaskManager.mHomeProcess) {
                            if (app.hasShownUi && !wpc.isHomeProcess()) {
                                // If this process has shown some UI, let it immediately
                                // If this process has shown some UI, let it immediately
                                // go to the LRU list because it may be pretty heavy with
                                // go to the LRU list because it may be pretty heavy with
                                // UI stuff.  We'll tag it with a label just to help
                                // UI stuff.  We'll tag it with a label just to help
@@ -15652,7 +15638,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                            // about letting this process get into the LRU
                            // about letting this process get into the LRU
                            // list to be killed and restarted if needed for
                            // list to be killed and restarted if needed for
                            // memory.
                            // memory.
                            if (app.hasShownUi && wpc != mActivityTaskManager.mHomeProcess
                            if (app.hasShownUi && !wpc.isHomeProcess()
                                    && clientAdj > ProcessList.PERCEPTIBLE_APP_ADJ) {
                                    && clientAdj > ProcessList.PERCEPTIBLE_APP_ADJ) {
                                if (adj >= ProcessList.CACHED_APP_MIN_ADJ) {
                                if (adj >= ProcessList.CACHED_APP_MIN_ADJ) {
                                    adjType = "cch-bound-ui-services";
                                    adjType = "cch-bound-ui-services";
@@ -15858,7 +15844,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                }
                }
                String adjType = null;
                String adjType = null;
                if (adj > clientAdj) {
                if (adj > clientAdj) {
                    if (app.hasShownUi && wpc != mActivityTaskManager.mHomeProcess
                    if (app.hasShownUi && !wpc.isHomeProcess()
                            && clientAdj > ProcessList.PERCEPTIBLE_APP_ADJ) {
                            && clientAdj > ProcessList.PERCEPTIBLE_APP_ADJ) {
                        adjType = "cch-ui-provider";
                        adjType = "cch-ui-provider";
                    } else {
                    } else {
@@ -17349,8 +17335,8 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            }
            int factor = numTrimming/3;
            int factor = numTrimming/3;
            int minFactor = 2;
            int minFactor = 2;
            if (mActivityTaskManager.mHomeProcess != null) minFactor++;
            if (mAtmInternal.getHomeProcess() != null) minFactor++;
            if (mActivityTaskManager.mPreviousProcess != null) minFactor++;
            if (mAtmInternal.getPreviousProcess() != null) minFactor++;
            if (factor < minFactor) factor = minFactor;
            if (factor < minFactor) factor = minFactor;
            int curLevel = ComponentCallbacks2.TRIM_MEMORY_COMPLETE;
            int curLevel = ComponentCallbacks2.TRIM_MEMORY_COMPLETE;
            for (int i=N-1; i>=0; i--) {
            for (int i=N-1; i>=0; i--) {
+61 −11
Original line number Original line Diff line number Diff line
@@ -273,6 +273,7 @@ import java.io.StringWriter;
import java.lang.ref.WeakReference;
import java.lang.ref.WeakReference;
import java.text.DateFormat;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Date;
import java.util.HashSet;
import java.util.HashSet;
import java.util.List;
import java.util.List;
@@ -2511,6 +2512,20 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }
        }
    }
    }


    @Override
    public void updateLockTaskPackages(int userId, String[] packages) {
        final int callingUid = Binder.getCallingUid();
        if (callingUid != 0 && callingUid != SYSTEM_UID) {
            mAmInternal.enforceCallingPermission(Manifest.permission.UPDATE_LOCK_TASK_PACKAGES,
                    "updateLockTaskPackages()");
        }
        synchronized (this) {
            if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "Whitelisting " + userId + ":"
                    + Arrays.toString(packages));
            getLockTaskController().updateLockTaskPackages(userId, packages);
        }
    }

    @Override
    @Override
    public boolean isInLockTaskMode() {
    public boolean isInLockTaskMode() {
        return getLockTaskModeState() != LOCK_TASK_MODE_NONE;
        return getLockTaskModeState() != LOCK_TASK_MODE_NONE;
@@ -4613,17 +4628,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }
        }
    }
    }


    void updateUserConfiguration() {
        synchronized (mGlobalLock) {
            final Configuration configuration = new Configuration(getGlobalConfiguration());
            final int currentUserId = mAmInternal.getCurrentUserId();
            Settings.System.adjustConfigurationForUser(mContext.getContentResolver(), configuration,
                    currentUserId, Settings.System.canWrite(mContext));
            updateConfigurationLocked(configuration, null /* starting */, false /* initLocale */,
                    false /* persistent */, currentUserId, false /* deferResume */);
        }
    }

    private boolean updateConfigurationLocked(Configuration values, ActivityRecord starting,
    private boolean updateConfigurationLocked(Configuration values, ActivityRecord starting,
            boolean initLocale, boolean persistent, int userId, boolean deferResume) {
            boolean initLocale, boolean persistent, int userId, boolean deferResume) {
        return updateConfigurationLocked(values, starting, initLocale, persistent, userId,
        return updateConfigurationLocked(values, starting, initLocale, persistent, userId,
@@ -5904,6 +5908,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                mShuttingDown = true;
                mShuttingDown = true;
                mStackSupervisor.prepareForShutdownLocked();
                mStackSupervisor.prepareForShutdownLocked();
                updateEventDispatchingLocked(booted);
                updateEventDispatchingLocked(booted);
                notifyTaskPersisterLocked(null, true);
                return mStackSupervisor.shutdownLocked(timeout);
                return mStackSupervisor.shutdownLocked(timeout);
            }
            }
        }
        }
@@ -6583,6 +6588,17 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            }
            }
        }
        }


        @Override
        public void dumpForOom(PrintWriter pw) {
            synchronized (mGlobalLock) {
                pw.println("  mHomeProcess: " + mHomeProcess);
                pw.println("  mPreviousProcess: " + mPreviousProcess);
                if (mHeavyWeightProcess != null) {
                    pw.println("  mHeavyWeightProcess: " + mHeavyWeightProcess);
                }
            }
        }

        @Override
        @Override
        public boolean canGcNow() {
        public boolean canGcNow() {
            synchronized (mGlobalLock) {
            synchronized (mGlobalLock) {
@@ -6741,5 +6757,39 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        public void flushRecentTasks() {
        public void flushRecentTasks() {
            mRecentTasks.flush();
            mRecentTasks.flush();
        }
        }

        @Override
        public WindowProcessController getHomeProcess() {
            synchronized (mGlobalLock) {
                return mHomeProcess;
            }
        }

        @Override
        public WindowProcessController getPreviousProcess() {
            synchronized (mGlobalLock) {
                return mPreviousProcess;
            }
        }

        @Override
        public void clearLockedTasks(String reason) {
            synchronized (mGlobalLock) {
                getLockTaskController().clearLockedTasks(reason);
            }
        }

        @Override
        public void updateUserConfiguration() {
            synchronized (mGlobalLock) {
                final Configuration configuration = new Configuration(getGlobalConfiguration());
                final int currentUserId = mAmInternal.getCurrentUserId();
                Settings.System.adjustConfigurationForUser(mContext.getContentResolver(),
                        configuration, currentUserId, Settings.System.canWrite(mContext));
                updateConfigurationLocked(configuration, null /* starting */,
                        false /* initLocale */, false /* persistent */, currentUserId,
                        false /* deferResume */);
            }
        }
    }
    }
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -730,7 +730,7 @@ class AppErrors {
        // with a home activity running in the process to prevent a repeatedly crashing app
        // with a home activity running in the process to prevent a repeatedly crashing app
        // from blocking the user to manually clear the list.
        // from blocking the user to manually clear the list.
        final WindowProcessController proc = app.getWindowProcessController();
        final WindowProcessController proc = app.getWindowProcessController();
        final WindowProcessController homeProc = mService.mActivityTaskManager.mHomeProcess;
        final WindowProcessController homeProc = mService.mAtmInternal.getHomeProcess();
        if (proc == homeProc && proc.hasActivities()
        if (proc == homeProc && proc.hasActivities()
                && (homeProc.mInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
                && (homeProc.mInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
            proc.clearPackagePreferredForHomeActivities();
            proc.clearPackagePreferredForHomeActivities();
+2 −1
Original line number Original line Diff line number Diff line
@@ -78,7 +78,8 @@ import java.util.Arrays;
 * mode that can be launched via System UI as well as the fully locked mode that can be achieved
 * mode that can be launched via System UI as well as the fully locked mode that can be achieved
 * on fully managed devices.
 * on fully managed devices.
 *
 *
 * Note: All methods in this class should only be called with the ActivityManagerService lock held.
 * Note: All methods in this class should only be called with the ActivityTaskManagerService lock
 * held.
 *
 *
 * @see Activity#startLockTask()
 * @see Activity#startLockTask()
 * @see Activity#stopLockTask()
 * @see Activity#stopLockTask()
Loading