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

Commit 987f9040 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Implement requestForegroundServiceExemption, without enabling it" into sc-dev

parents 3ee3029e 619c5a46
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -344,6 +344,9 @@ public class PowerExemptionManager {
     */
    public static final int REASON_MEDIA_SESSION_CALLBACK = 317;

    /** @hide The app requests out-out. */
    public static final int REASON_OPT_OUT_REQUESTED = 1000;

    /**
     * The list of BG-FGS-Launch and temp-allow-list reason code.
     * @hide
@@ -411,6 +414,7 @@ public class PowerExemptionManager {
            REASON_EVENT_MMS,
            REASON_SHELL,
            REASON_MEDIA_SESSION_CALLBACK,
            REASON_OPT_OUT_REQUESTED,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ReasonCode {}
@@ -709,6 +713,8 @@ public class PowerExemptionManager {
                return "SHELL";
            case REASON_MEDIA_SESSION_CALLBACK:
                return "MEDIA_SESSION_CALLBACK";
            case REASON_OPT_OUT_REQUESTED:
                return "REASON_OPT_OUT_REQUESTED";
            default:
                return "(unknown:" + reasonCode + ")";
        }
+5 −0
Original line number Diff line number Diff line
@@ -50,6 +50,10 @@ package android {
    field public static final String UNDEFINED = "android.permission-group.UNDEFINED";
  }

  public static final class R.attr {
    field public static final int requestForegroundServiceExemption;
  }

  public static final class R.bool {
    field public static final int config_assistantOnTopOfDream = 17891333; // 0x1110005
    field public static final int config_perDisplayFocusEnabled = 17891332; // 0x1110004
@@ -806,6 +810,7 @@ package android.content.pm {
  }

  public class ApplicationInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
    method public boolean hasRequestForegroundServiceExemption();
    method public boolean isPrivilegedApp();
    method public boolean isSystemApp();
    field public static final int PRIVATE_FLAG_PRIVILEGED = 8; // 0x8
+20 −0
Original line number Diff line number Diff line
@@ -778,9 +778,18 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public static final int PRIVATE_FLAG_EXT_PROFILEABLE = 1 << 0;

    /**
     * Value for {@link #privateFlagsExt}: whether this application has requested
     * exemption from the foreground service restriction introduced in S
     * (https://developer.android.com/about/versions/12/foreground-services).
     * @hide
     */
    public static final int PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION = 1 << 1;

    /** @hide */
    @IntDef(flag = true, prefix = { "PRIVATE_FLAG_EXT_" }, value = {
            PRIVATE_FLAG_EXT_PROFILEABLE,
            PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ApplicationInfoPrivateFlagsExt {}
@@ -2444,6 +2453,17 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_IS_RESOURCE_OVERLAY) != 0;
    }

    /**
     * @return whether the app has requested exemption from the foreground service restrictions.
     * This does not take any affect for now.
     * @hide
     */
    @TestApi
    public boolean hasRequestForegroundServiceExemption() {
        return (privateFlagsExt
                & ApplicationInfo.PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION) != 0;
    }

    /**
     * @hide
     */
+3 −1
Original line number Diff line number Diff line
@@ -806,7 +806,9 @@ public class PackageInfoWithoutStateUtils {
    public static int appInfoPrivateFlagsExt(ParsingPackageRead pkg) {
        // @formatter:off
        int privateFlagsExt =
                flag(pkg.isProfileable(), ApplicationInfo.PRIVATE_FLAG_EXT_PROFILEABLE);
                flag(pkg.isProfileable(), ApplicationInfo.PRIVATE_FLAG_EXT_PROFILEABLE)
                | flag(pkg.hasRequestForegroundServiceExemption(),
                        ApplicationInfo.PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION);
        // @formatter:on
        return privateFlagsExt;
    }
+2 −0
Original line number Diff line number Diff line
@@ -338,6 +338,8 @@ public interface ParsingPackage extends ParsingPackageRead {

    ParsingPackage setTheme(int theme);

    ParsingPackage setRequestForegroundServiceExemption(boolean requestForegroundServiceExemption);

    ParsingPackage setUpgradeKeySets(@NonNull Set<String> upgradeKeySets);

    ParsingPackage setUse32BitAbi(boolean use32BitAbi);
Loading