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

Commit db6bf66e authored by Suprabh Shukla's avatar Suprabh Shukla
Browse files

Adding user forced app standby to alarms

The app op RUN_ANY_IN_BACKGROUND can be set to ignored to indicate that
any alarms for the receiving app will be delayed until the app op is set
to allowed or the app comes into the foreground. Power whitelisted apps
are exempted.

Test: cts-tradefed run cts-dev -m AlarmManagerTestCases

Fixes: 64446607
Change-Id: Ic48b52383ad5ccd726c62769cdca25202d1e3814
parent 4a82f72e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -315,6 +315,7 @@ interface IActivityManager {
    int getLaunchedFromUid(in IBinder activityToken);
    void unstableProviderDied(in IBinder connection);
    boolean isIntentSenderAnActivity(in IIntentSender sender);
    boolean isIntentSenderAForegroundService(in IIntentSender sender);
    int startActivityAsUser(in IApplicationThread caller, in String callingPackage,
            in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
            int requestCode, int flags, in ProfilerInfo profilerInfo,
+16 −4
Original line number Diff line number Diff line
@@ -20,18 +20,17 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.content.Intent;
import android.content.IIntentReceiver;
import android.content.IIntentSender;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.os.Looper;
import android.os.RemoteException;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.AndroidException;

@@ -1010,6 +1009,19 @@ public final class PendingIntent implements Parcelable {
        }
    }

    /**
     * @hide
     * Check whether this PendingIntent will launch a foreground service
     */
    public boolean isForegroundService() {
        try {
            return ActivityManager.getService()
                    .isIntentSenderAForegroundService(mTarget);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @hide
     * Return the Intent of this PendingIntent.
+282 −11

File changed.

Preview size limit exceeded, changes collapsed.

+9 −0
Original line number Diff line number Diff line
@@ -7826,6 +7826,15 @@ public class ActivityManagerService extends IActivityManager.Stub
        return false;
    }
    @Override
    public boolean isIntentSenderAForegroundService(IIntentSender pendingResult) {
        if (pendingResult instanceof PendingIntentRecord) {
            final PendingIntentRecord res = (PendingIntentRecord) pendingResult;
            return res.key.type == ActivityManager.INTENT_SENDER_FOREGROUND_SERVICE;
        }
        return false;
    }
    @Override
    public Intent getIntentForIntentSender(IIntentSender pendingResult) {
        enforceCallingPermission(Manifest.permission.GET_INTENT_SENDER_INTENT,