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

Commit 14162d30 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I9abb9065,Ifcbab049

* changes:
  Removed references to ActivityTaskManagerService.getRecentTasks() from AMS (32/n)
  Removed references to IActivityController from AMS (31/n)
parents 206d8d1e d7889f5b
Loading
Loading
Loading
Loading
+8 −14
Original line number Original line Diff line number Diff line
@@ -3552,7 +3552,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                if (appInfo != null) {
                if (appInfo != null) {
                    forceStopPackageLocked(packageName, appInfo.uid, "clear data");
                    forceStopPackageLocked(packageName, appInfo.uid, "clear data");
                    mActivityTaskManager.getRecentTasks().removeTasksByPackageName(packageName, resolvedUserId);
                    mAtmInternal.removeRecentTasksByPackageName(packageName, resolvedUserId);
                }
                }
            }
            }
@@ -13971,16 +13971,14 @@ public class ActivityManagerService extends IActivityManager.Stub
                                    forceStopPackageLocked(list[i], -1, false, true, true,
                                    forceStopPackageLocked(list[i], -1, false, true, true,
                                            false, false, userId, "storage unmount");
                                            false, false, userId, "storage unmount");
                                }
                                }
                                mActivityTaskManager.getRecentTasks().cleanupLocked(
                                mAtmInternal.cleanupRecentTasksForUser(UserHandle.USER_ALL);
                                        UserHandle.USER_ALL);
                                sendPackageBroadcastLocked(
                                sendPackageBroadcastLocked(
                                        ApplicationThreadConstants.EXTERNAL_STORAGE_UNAVAILABLE,
                                        ApplicationThreadConstants.EXTERNAL_STORAGE_UNAVAILABLE,
                                        list, userId);
                                        list, userId);
                            }
                            }
                            break;
                            break;
                        case Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE:
                        case Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE:
                            mActivityTaskManager.getRecentTasks().cleanupLocked(
                            mAtmInternal.cleanupRecentTasksForUser(UserHandle.USER_ALL);
                                    UserHandle.USER_ALL);
                            break;
                            break;
                        case Intent.ACTION_PACKAGE_REMOVED:
                        case Intent.ACTION_PACKAGE_REMOVED:
                        case Intent.ACTION_PACKAGE_CHANGED:
                        case Intent.ACTION_PACKAGE_CHANGED:
@@ -14013,7 +14011,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                                        mUgmInternal.removeUriPermissionsForPackage(ssp, userId,
                                        mUgmInternal.removeUriPermissionsForPackage(ssp, userId,
                                                true, false);
                                                true, false);
                                        mActivityTaskManager.getRecentTasks().removeTasksByPackageName(ssp, userId);
                                        mAtmInternal.removeRecentTasksByPackageName(ssp, userId);
                                        mServices.forceStopPackageLocked(ssp, userId);
                                        mServices.forceStopPackageLocked(ssp, userId);
                                        mAtmInternal.onPackageUninstalled(ssp);
                                        mAtmInternal.onPackageUninstalled(ssp);
@@ -14043,10 +14041,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                            final int userHandle = intent.getIntExtra(
                            final int userHandle = intent.getIntExtra(
                                    Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
                                    Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
                            synchronized(ActivityManagerService.this) {
                            mAtmInternal.onPackagesSuspendedChanged(packageNames, suspended,
                                mActivityTaskManager.getRecentTasks().onPackagesSuspendedChanged(
                                    userHandle);
                                        packageNames, suspended, userHandle);
                            }
                            break;
                            break;
                    }
                    }
                    break;
                    break;
@@ -16544,8 +16540,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    if (curSchedGroup == ProcessList.SCHED_GROUP_TOP_APP) {
                    if (curSchedGroup == ProcessList.SCHED_GROUP_TOP_APP) {
                        // do nothing if we already switched to RT
                        // do nothing if we already switched to RT
                        if (oldSchedGroup != ProcessList.SCHED_GROUP_TOP_APP) {
                        if (oldSchedGroup != ProcessList.SCHED_GROUP_TOP_APP) {
                            mActivityTaskManager.onTopProcChangedLocked(
                            app.getWindowProcessController().onTopProcChanged();
                                    app.getWindowProcessController());
                            if (mUseFifoUiScheduling) {
                            if (mUseFifoUiScheduling) {
                                // Switch UI pipeline for app to SCHED_FIFO
                                // Switch UI pipeline for app to SCHED_FIFO
                                app.savedPriority = Process.getThreadPriority(app.pid);
                                app.savedPriority = Process.getThreadPriority(app.pid);
@@ -16577,8 +16572,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                        }
                        }
                    } else if (oldSchedGroup == ProcessList.SCHED_GROUP_TOP_APP &&
                    } else if (oldSchedGroup == ProcessList.SCHED_GROUP_TOP_APP &&
                            curSchedGroup != ProcessList.SCHED_GROUP_TOP_APP) {
                            curSchedGroup != ProcessList.SCHED_GROUP_TOP_APP) {
                        mActivityTaskManager.onTopProcChangedLocked(
                        app.getWindowProcessController().onTopProcChanged();
                                app.getWindowProcessController());
                        if (mUseFifoUiScheduling) {
                        if (mUseFifoUiScheduling) {
                            try {
                            try {
                                // Reset UI pipeline to SCHED_OTHER
                                // Reset UI pipeline to SCHED_OTHER
+1 −1
Original line number Original line Diff line number Diff line
@@ -2736,7 +2736,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
    int runWrite(PrintWriter pw) {
    int runWrite(PrintWriter pw) {
        mInternal.enforceCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER,
        mInternal.enforceCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER,
                "registerUidObserver()");
                "registerUidObserver()");
        mInternal.mActivityTaskManager.getRecentTasks().flush();
        mInternal.mAtmInternal.flushRecentTasks();
        pw.println("All tasks persisted.");
        pw.println("All tasks persisted.");
        return 0;
        return 0;
    }
    }
+57 −5
Original line number Original line Diff line number Diff line
@@ -397,7 +397,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    // VoiceInteractionManagerService
    // VoiceInteractionManagerService
    ComponentName mActiveVoiceInteractionServiceComponent;
    ComponentName mActiveVoiceInteractionServiceComponent;


    private VrController mVrController;
    VrController mVrController;
    KeyguardController mKeyguardController;
    KeyguardController mKeyguardController;
    private final ClientLifecycleManager mLifecycleManager;
    private final ClientLifecycleManager mLifecycleManager;
    private TaskChangeNotificationController mTaskChangeNotificationController;
    private TaskChangeNotificationController mTaskChangeNotificationController;
@@ -4355,10 +4355,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        mRecentTasks.notifyTaskPersisterLocked(task, flush);
        mRecentTasks.notifyTaskPersisterLocked(task, flush);
    }
    }


    void onTopProcChangedLocked(WindowProcessController proc) {
        mVrController.onTopProcChangedLocked(proc);
    }

    boolean isKeyguardLocked() {
    boolean isKeyguardLocked() {
        return mKeyguardController.isKeyguardLocked();
        return mKeyguardController.isKeyguardLocked();
    }
    }
@@ -6689,5 +6685,61 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                mPendingTempWhitelist.remove(uid);
                mPendingTempWhitelist.remove(uid);
            }
            }
        }
        }

        @Override
        public boolean handleAppCrashInActivityController(String processName, int pid,
                String shortMsg, String longMsg, long timeMillis, String stackTrace,
                Runnable killCrashingAppCallback) {
            synchronized (mGlobalLock) {
                if (mController == null) {
                    return false;
                }

                try {
                    if (!mController.appCrashed(processName, pid, shortMsg, longMsg, timeMillis,
                            stackTrace)) {
                        killCrashingAppCallback.run();
                        return true;
                    }
                } catch (RemoteException e) {
                    mController = null;
                    Watchdog.getInstance().setActivityController(null);
                }
                return false;
            }
        }

        @Override
        public void removeRecentTasksByPackageName(String packageName, int userId) {
            synchronized (mGlobalLock) {
                mRecentTasks.removeTasksByPackageName(packageName, userId);
            }
        }

        @Override
        public void cleanupRecentTasksForUser(int userId) {
            synchronized (mGlobalLock) {
                mRecentTasks.cleanupLocked(userId);
            }
        }

        @Override
        public void loadRecentTasksForUser(int userId) {
            synchronized (mGlobalLock) {
                mRecentTasks.loadUserRecentsLocked(userId);
            }
        }

        @Override
        public void onPackagesSuspendedChanged(String[] packages, boolean suspended, int userId) {
            synchronized (mGlobalLock) {
                mRecentTasks.onPackagesSuspendedChanged(packages, suspended, userId);
            }
        }

        @Override
        public void flushRecentTasks() {
            mRecentTasks.flush();
        }
    }
    }
}
}
+20 −32
Original line number Original line Diff line number Diff line
@@ -526,26 +526,20 @@ class AppErrors {
                                                       String shortMsg, String longMsg,
                                                       String shortMsg, String longMsg,
                                                       String stackTrace, long timeMillis,
                                                       String stackTrace, long timeMillis,
                                                       int callingPid, int callingUid) {
                                                       int callingPid, int callingUid) {
        if (mService.mActivityTaskManager.mController == null) {
            return false;
        }

        try {
        String name = r != null ? r.processName : null;
        String name = r != null ? r.processName : null;
        int pid = r != null ? r.pid : callingPid;
        int pid = r != null ? r.pid : callingPid;
        int uid = r != null ? r.info.uid : callingUid;
        int uid = r != null ? r.info.uid : callingUid;
            if (!mService.mActivityTaskManager.mController.appCrashed(name, pid,

                    shortMsg, longMsg, timeMillis, crashInfo.stackTrace)) {
        return mService.mAtmInternal.handleAppCrashInActivityController(
                name, pid, shortMsg, longMsg, timeMillis, crashInfo.stackTrace, () -> {
            if ("1".equals(SystemProperties.get(SYSTEM_DEBUGGABLE, "0"))
            if ("1".equals(SystemProperties.get(SYSTEM_DEBUGGABLE, "0"))
                    && "Native crash".equals(crashInfo.exceptionClassName)) {
                    && "Native crash".equals(crashInfo.exceptionClassName)) {
                Slog.w(TAG, "Skip killing native crashed app " + name
                Slog.w(TAG, "Skip killing native crashed app " + name
                        + "(" + pid + ") during testing");
                        + "(" + pid + ") during testing");
            } else {
            } else {
                    Slog.w(TAG, "Force-killing crashed app " + name
                Slog.w(TAG, "Force-killing crashed app " + name + " at watcher's request");
                            + " at watcher's request");
                if (r != null) {
                if (r != null) {
                        if (!makeAppCrashingLocked(r, shortMsg, longMsg, stackTrace, null))
                    if (!makeAppCrashingLocked(r, shortMsg, longMsg, stackTrace, null)) {
                        {
                        r.kill("crash", true);
                        r.kill("crash", true);
                    }
                    }
                } else {
                } else {
@@ -554,13 +548,7 @@ class AppErrors {
                    ProcessList.killProcessGroup(uid, pid);
                    ProcessList.killProcessGroup(uid, pid);
                }
                }
            }
            }
                return true;
        });
            }
        } catch (RemoteException e) {
            mService.mActivityTaskManager.mController = null;
            Watchdog.getInstance().setActivityController(null);
        }
        return false;
    }
    }


    private boolean makeAppCrashingLocked(ProcessRecord app,
    private boolean makeAppCrashingLocked(ProcessRecord app,
+7 −31
Original line number Original line Diff line number Diff line
@@ -1244,19 +1244,7 @@ final class ProcessRecord implements WindowProcessListener {
        ArrayList<Integer> firstPids = new ArrayList<>(5);
        ArrayList<Integer> firstPids = new ArrayList<>(5);
        SparseArray<Boolean> lastPids = new SparseArray<>(20);
        SparseArray<Boolean> lastPids = new SparseArray<>(20);


        if (mService.mActivityTaskManager.mController != null) {
        mWindowProcessController.appEarlyNotResponding(annotation, () -> kill("anr", true));
            try {
                // 0 == continue, -1 = kill process immediately
                int res = mService.mActivityTaskManager.mController.appEarlyNotResponding(
                        processName, pid, annotation);
                if (res < 0 && pid != MY_PID) {
                    kill("anr", true);
                }
            } catch (RemoteException e) {
                mService.mActivityTaskManager.mController = null;
                Watchdog.getInstance().setActivityController(null);
            }
        }


        long anrTime = SystemClock.uptimeMillis();
        long anrTime = SystemClock.uptimeMillis();
        if (ActivityManagerService.MONITOR_CPU_USAGE) {
        if (ActivityManagerService.MONITOR_CPU_USAGE) {
@@ -1412,26 +1400,14 @@ final class ProcessRecord implements WindowProcessListener {
        mService.addErrorToDropBox("anr", this, processName, activityShortComponentName,
        mService.addErrorToDropBox("anr", this, processName, activityShortComponentName,
                parentShortComponentName, parentPr, annotation, cpuInfo, tracesFile, null);
                parentShortComponentName, parentPr, annotation, cpuInfo, tracesFile, null);


        if (mService.mActivityTaskManager.mController != null) {
        if (mWindowProcessController.appNotResponding(info.toString(), () -> kill("anr", true),
            try {
                () -> {
                // 0 == show dialog, 1 = keep waiting, -1 = kill process immediately
                int res = mService.mActivityTaskManager.mController.appNotResponding(
                        processName, pid, info.toString());
                if (res != 0) {
                    if (res < 0 && pid != MY_PID) {
                        kill("anr", true);
                    } else {
                    synchronized (mService) {
                    synchronized (mService) {
                        mService.mServices.scheduleServiceTimeoutLocked(this);
                        mService.mServices.scheduleServiceTimeoutLocked(this);
                    }
                    }
                    }
                })) {
            return;
            return;
        }
        }
            } catch (RemoteException e) {
                mService.mActivityTaskManager.mController = null;
                Watchdog.getInstance().setActivityController(null);
            }
        }


        synchronized (mService) {
        synchronized (mService) {
            mService.mBatteryStatsService.noteProcessAnr(processName, uid);
            mService.mBatteryStatsService.noteProcessAnr(processName, uid);
Loading