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

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

Merge "Added an api to query ForcedAppStandby state"

parents d5a2e636 4d64c093
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3883,6 +3883,7 @@ package android.app {
    method public android.app.PendingIntent getRunningServiceControlPanel(android.content.ComponentName) throws java.lang.SecurityException;
    method public deprecated java.util.List<android.app.ActivityManager.RunningServiceInfo> getRunningServices(int) throws java.lang.SecurityException;
    method public deprecated java.util.List<android.app.ActivityManager.RunningTaskInfo> getRunningTasks(int) throws java.lang.SecurityException;
    method public boolean isBackgroundRestricted();
    method public deprecated boolean isInLockTaskMode();
    method public boolean isLowRamDevice();
    method public static boolean isRunningInTestHarness();
+22 −0
Original line number Diff line number Diff line
@@ -3334,6 +3334,28 @@ public class ActivityManager {
        }
    }

    /**
     * Query whether the user has enabled background restrictions for this app.
     *
     * <p> The user may chose to do this, if they see that an app is consuming an unreasonable
     * amount of battery while in the background. </p>
     *
     * <p> If true, any work that the app tries to do will be aggressively restricted while it is in
     * the background. At a minimum, jobs and alarms will not execute and foreground services
     * cannot be started unless an app activity is in the foreground. </p>
     *
     * <p><b> Note that these restrictions stay in effect even when the device is charging.</b></p>
     *
     * @return true if user has enforced background restrictions for this app, false otherwise.
     */
    public boolean isBackgroundRestricted() {
        try {
            return getService().isBackgroundRestricted(mContext.getOpPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Sets the memory trim mode for a process and schedules a memory trim operation.
     *
+1 −1
Original line number Diff line number Diff line
@@ -614,7 +614,7 @@ interface IActivityManager {
    int sendIntentSender(in IIntentSender target, in IBinder whitelistToken, int code,
            in Intent intent, in String resolvedType, in IIntentReceiver finishedReceiver,
            in String requiredPermission, in Bundle options);

    boolean isBackgroundRestricted(in String packageName);

    // Start of N MR1 transactions
    void setVrThread(int tid);
+19 −0
Original line number Diff line number Diff line
@@ -12878,6 +12878,25 @@ public class ActivityManagerService extends IActivityManager.Stub
        return false;
    }
    @Override
    public boolean isBackgroundRestricted(String packageName) {
        final int callingUid = Binder.getCallingUid();
        final IPackageManager pm = AppGlobals.getPackageManager();
        try {
            final int packageUid = pm.getPackageUid(packageName, MATCH_DEBUG_TRIAGED_MISSING,
                    UserHandle.getUserId(callingUid));
            if (packageUid != callingUid) {
                throw new IllegalArgumentException("Uid " + callingUid
                        + " cannot query restriction state for package " + packageName);
            }
        } catch (RemoteException exc) {
            // Ignore.
        }
        final int mode = mAppOpsService.checkOperation(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND,
                callingUid, packageName);
        return (mode != AppOpsManager.MODE_ALLOWED);
    }
    @Override
    public void backgroundWhitelistUid(final int uid) {
        if (Binder.getCallingUid() != Process.SYSTEM_UID) {