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

Commit 42c8338a authored by Varun Shah's avatar Varun Shah Committed by Android (Google) Code Review
Browse files

Merge "Introduce a new FGS type for media processing." into main

parents 3ac13642 257619ce
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ package android {
    field public static final String FOREGROUND_SERVICE_HEALTH = "android.permission.FOREGROUND_SERVICE_HEALTH";
    field public static final String FOREGROUND_SERVICE_LOCATION = "android.permission.FOREGROUND_SERVICE_LOCATION";
    field public static final String FOREGROUND_SERVICE_MEDIA_PLAYBACK = "android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK";
    field @FlaggedApi("android.content.pm.introduce_media_processing_type") public static final String FOREGROUND_SERVICE_MEDIA_PROCESSING = "android.permission.FOREGROUND_SERVICE_MEDIA_PROCESSING";
    field public static final String FOREGROUND_SERVICE_MEDIA_PROJECTION = "android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION";
    field public static final String FOREGROUND_SERVICE_MICROPHONE = "android.permission.FOREGROUND_SERVICE_MICROPHONE";
    field public static final String FOREGROUND_SERVICE_PHONE_CALL = "android.permission.FOREGROUND_SERVICE_PHONE_CALL";
@@ -13287,6 +13288,7 @@ package android.content.pm {
    field @RequiresPermission(allOf={android.Manifest.permission.FOREGROUND_SERVICE_LOCATION}, anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_LOCATION = 8; // 0x8
    field public static final int FOREGROUND_SERVICE_TYPE_MANIFEST = -1; // 0xffffffff
    field @RequiresPermission(value=android.Manifest.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK = 2; // 0x2
    field @FlaggedApi("android.content.pm.introduce_media_processing_type") @RequiresPermission(android.Manifest.permission.FOREGROUND_SERVICE_MEDIA_PROCESSING) public static final int FOREGROUND_SERVICE_TYPE_MEDIA_PROCESSING = 8192; // 0x2000
    field @RequiresPermission(value=android.Manifest.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION = 32; // 0x20
    field @RequiresPermission(allOf={android.Manifest.permission.FOREGROUND_SERVICE_MICROPHONE}, anyOf={android.Manifest.permission.CAPTURE_AUDIO_OUTPUT, android.Manifest.permission.RECORD_AUDIO}, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_MICROPHONE = 128; // 0x80
    field @Deprecated public static final int FOREGROUND_SERVICE_TYPE_NONE = 0; // 0x0
+23 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_HEALTH;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROCESSING;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE;
@@ -576,6 +577,26 @@ public abstract class ForegroundServiceTypePolicy {
            false /* foregroundOnlyPermission */
    );

    /**
     * The policy for the {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_MEDIA_PROCESSING}.
     *
     * @hide
     */
    public static final @NonNull ForegroundServiceTypePolicyInfo FGS_TYPE_POLICY_MEDIA_PROCESSING =
            new ForegroundServiceTypePolicyInfo(
                    FOREGROUND_SERVICE_TYPE_MEDIA_PROCESSING,
                    ForegroundServiceTypePolicyInfo.INVALID_CHANGE_ID,
                    ForegroundServiceTypePolicyInfo.INVALID_CHANGE_ID,
                    new ForegroundServiceTypePermissions(new ForegroundServiceTypePermission[] {
                            new RegularPermission(
                                    Manifest.permission.FOREGROUND_SERVICE_MEDIA_PROCESSING)
                    }, true),
                    null /* anyOfPermissions */,
                    null /* permissionEnforcementFlag */,
                    true /* permissionEnforcementFlagDefaultValue */,
                    false /* foregroundOnlyPermission */
            );

    /**
     * The policy for the {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SPECIAL_USE}.
     *
@@ -1331,6 +1352,8 @@ public abstract class ForegroundServiceTypePolicy {
                    FGS_TYPE_POLICY_SYSTEM_EXEMPTED);
            mForegroundServiceTypePolicies.put(FOREGROUND_SERVICE_TYPE_SHORT_SERVICE,
                    FGS_TYPE_POLICY_SHORT_SERVICE);
            mForegroundServiceTypePolicies.put(FOREGROUND_SERVICE_TYPE_MEDIA_PROCESSING,
                    FGS_TYPE_POLICY_MEDIA_PROCESSING);
            // TODO (b/271950506): revisit it in the next release.
            // Hide the file management type for now. If anyone uses it, will default to "none".
            mForegroundServiceTypePolicies.put(FOREGROUND_SERVICE_TYPE_SPECIAL_USE,
+15 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.content.pm;

import android.Manifest;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.RequiresPermission;
import android.os.Parcel;
@@ -470,6 +471,17 @@ public class ServiceInfo extends ComponentInfo
    )
    public static final int FOREGROUND_SERVICE_TYPE_FILE_MANAGEMENT = 1 << 12;

    /**
     * Constant corresponding to {@code mediaProcessing} in
     * the {@link android.R.attr#foregroundServiceType} attribute.
     * Media processing use cases such as video or photo editing and processing.
     */
    @RequiresPermission(
            value = Manifest.permission.FOREGROUND_SERVICE_MEDIA_PROCESSING
    )
    @FlaggedApi(Flags.FLAG_INTRODUCE_MEDIA_PROCESSING_TYPE)
    public static final int FOREGROUND_SERVICE_TYPE_MEDIA_PROCESSING = 1 << 13;

    /**
     * Constant corresponding to {@code specialUse} in
     * the {@link android.R.attr#foregroundServiceType} attribute.
@@ -554,6 +566,7 @@ public class ServiceInfo extends ComponentInfo
            FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED,
            FOREGROUND_SERVICE_TYPE_SHORT_SERVICE,
            FOREGROUND_SERVICE_TYPE_FILE_MANAGEMENT,
            FOREGROUND_SERVICE_TYPE_MEDIA_PROCESSING,
            FOREGROUND_SERVICE_TYPE_SPECIAL_USE,
    })
    @Retention(RetentionPolicy.SOURCE)
@@ -640,6 +653,8 @@ public class ServiceInfo extends ComponentInfo
                return "shortService";
            case FOREGROUND_SERVICE_TYPE_FILE_MANAGEMENT:
                return "fileManagement";
            case FOREGROUND_SERVICE_TYPE_MEDIA_PROCESSING:
                return "mediaProcessing";
            case FOREGROUND_SERVICE_TYPE_SPECIAL_USE:
                return "specialUse";
            default:
+7 −0
Original line number Diff line number Diff line
@@ -131,3 +131,10 @@ flag {
    bug: "310801107"
    is_fixed_read_only: true
}

flag {
    name: "introduce_media_processing_type"
    namespace: "backstage_power"
    description: "Add a new FGS type for media processing use cases."
    bug: "317788011"
}
+10 −0
Original line number Diff line number Diff line
@@ -7147,6 +7147,16 @@
        android:label="@string/permlab_foregroundServiceFileManagement"
        android:protectionLevel="normal|instant" />

    <!-- @FlaggedApi("android.content.pm.introduce_media_processing_type")
         Allows a regular application to use {@link android.app.Service#startForeground
         Service.startForeground} with the type "mediaProcessing".
         <p>Protection level: normal|instant
    -->
    <permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROCESSING"
                android:description="@string/permdesc_foregroundServiceMediaProcessing"
                android:label="@string/permlab_foregroundServiceMediaProcessing"
                android:protectionLevel="normal|instant" />

    <!-- Allows a regular application to use {@link android.app.Service#startForeground
         Service.startForeground} with the type "specialUse".
         <p>Protection level: normal|appop|instant
Loading