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

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

Merge "Don't schedule jobs in 'bad' apps"

parents bca8ddf9 8e737857
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -329,6 +329,9 @@ public abstract class ActivityManagerInternal {
    /** Returns true if the given uid is the app in the foreground. */
    public abstract boolean isAppForeground(int uid);

    /** Returns true if the given uid is currently marked 'bad' */
    public abstract boolean isAppBad(ApplicationInfo info);

    /** Remove pending backup for the given userId. */
    public abstract void clearPendingBackup(int userId);

+11 −0
Original line number Diff line number Diff line
@@ -5492,6 +5492,12 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
    }
    private boolean isAppBad(ApplicationInfo info) {
        synchronized (this) {
            return mAppErrors.isBadProcessLocked(info);
        }
    }
    // NOTE: this is an internal method used by the OnShellCommand implementation only and should
    // be guarded by permission checking.
    int getUidState(int uid) {
@@ -18077,6 +18083,11 @@ public class ActivityManagerService extends IActivityManager.Stub
            return ActivityManagerService.this.isAppForeground(uid);
        }
        @Override
        public boolean isAppBad(ApplicationInfo info) {
            return ActivityManagerService.this.isAppBad(info);
        }
        @Override
        public void clearPendingBackup(int userId) {
            ActivityManagerService.this.clearPendingBackup(userId);
+17 −8
Original line number Diff line number Diff line
@@ -2494,24 +2494,33 @@ public class JobSchedulerService extends com.android.server.SystemService
            }
        }

        // The expensive check last: validate that the defined package+service is
        // The expensive check: validate that the defined package+service is
        // still present & viable.
        final boolean componentPresent;
        final ServiceInfo service;
        try {
            componentPresent = (AppGlobals.getPackageManager().getServiceInfo(
            service = AppGlobals.getPackageManager().getServiceInfo(
                    job.getServiceComponent(), PackageManager.MATCH_DEBUG_TRIAGED_MISSING,
                    job.getUserId()) != null);
                    job.getUserId());
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }

        if (service == null) {
            if (DEBUG) {
                Slog.v(TAG, "isReadyToBeExecutedLocked: " + job.toShortString()
                    + " componentPresent=" + componentPresent);
                        + " component not present");
            }
            return false;
        }

        // Everything else checked out so far, so this is the final yes/no check
        return componentPresent;
        final boolean appIsBad = mActivityManagerInternal.isAppBad(service.applicationInfo);
        if (DEBUG) {
            if (appIsBad) {
                Slog.i(TAG, "App is bad for " + job.toShortString() + " so not runnable");
            }
        }
        return !appIsBad;
    }

    private void evaluateControllerStatesLocked(final JobStatus job) {