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

Commit 89582fac authored by Hui Yu's avatar Hui Yu Committed by Android (Google) Code Review
Browse files

Merge "Add new foreground service type camera and microphone."

parents 2c12aac7 85679b4d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -12253,12 +12253,14 @@ package android.content.pm {
    field public static final int FLAG_SINGLE_USER = 1073741824; // 0x40000000
    field public static final int FLAG_STOP_WITH_TASK = 1; // 0x1
    field public static final int FLAG_USE_APP_ZYGOTE = 8; // 0x8
    field public static final int FOREGROUND_SERVICE_TYPE_CAMERA = 64; // 0x40
    field public static final int FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE = 16; // 0x10
    field public static final int FOREGROUND_SERVICE_TYPE_DATA_SYNC = 1; // 0x1
    field public static final int FOREGROUND_SERVICE_TYPE_LOCATION = 8; // 0x8
    field public static final int FOREGROUND_SERVICE_TYPE_MANIFEST = -1; // 0xffffffff
    field public static final int FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK = 2; // 0x2
    field public static final int FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION = 32; // 0x20
    field public static final int FOREGROUND_SERVICE_TYPE_MICROPHONE = 128; // 0x80
    field public static final int FOREGROUND_SERVICE_TYPE_NONE = 0; // 0x0
    field public static final int FOREGROUND_SERVICE_TYPE_PHONE_CALL = 4; // 0x4
    field public int flags;
+3 −1
Original line number Diff line number Diff line
@@ -75,8 +75,10 @@ package android.app {
    method public static void resumeAppSwitches() throws android.os.RemoteException;
    method @RequiresPermission(android.Manifest.permission.CHANGE_CONFIGURATION) public void scheduleApplicationInfoChanged(java.util.List<java.lang.String>, int);
    method @RequiresPermission("android.permission.MANAGE_USERS") public boolean switchUser(@NonNull android.os.UserHandle);
    field public static final int PROCESS_CAPABILITY_ALL = 1; // 0x1
    field public static final int PROCESS_CAPABILITY_ALL = 7; // 0x7
    field public static final int PROCESS_CAPABILITY_FOREGROUND_CAMERA = 2; // 0x2
    field public static final int PROCESS_CAPABILITY_FOREGROUND_LOCATION = 1; // 0x1
    field public static final int PROCESS_CAPABILITY_FOREGROUND_MICROPHONE = 4; // 0x4
    field public static final int PROCESS_CAPABILITY_NONE = 0; // 0x0
  }

+13 −1
Original line number Diff line number Diff line
@@ -573,6 +573,8 @@ public class ActivityManager {
    @IntDef(flag = true, prefix = { "PROCESS_CAPABILITY_" }, value = {
            PROCESS_CAPABILITY_NONE,
            PROCESS_CAPABILITY_FOREGROUND_LOCATION,
            PROCESS_CAPABILITY_FOREGROUND_CAMERA,
            PROCESS_CAPABILITY_FOREGROUND_MICROPHONE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ProcessCapability {}
@@ -585,9 +587,19 @@ public class ActivityManager {
    @TestApi
    public static final int PROCESS_CAPABILITY_FOREGROUND_LOCATION = 1 << 0;

    /** @hide Process can access camera while in foreground */
    @TestApi
    public static final int PROCESS_CAPABILITY_FOREGROUND_CAMERA = 1 << 1;

    /** @hide Process can access microphone while in foreground */
    @TestApi
    public static final int PROCESS_CAPABILITY_FOREGROUND_MICROPHONE = 1 << 2;

    /** @hide all capabilities, the ORing of all flags in {@link ProcessCapability}*/
    @TestApi
    public static final int PROCESS_CAPABILITY_ALL = PROCESS_CAPABILITY_FOREGROUND_LOCATION;
    public static final int PROCESS_CAPABILITY_ALL = PROCESS_CAPABILITY_FOREGROUND_LOCATION
            | PROCESS_CAPABILITY_FOREGROUND_CAMERA
            | PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;

    // NOTE: If PROCESS_STATEs are added, then new fields must be added
    // to frameworks/base/core/proto/android/app/enums.proto and the following method must
+24 −0
Original line number Diff line number Diff line
@@ -146,6 +146,28 @@ public class ServiceInfo extends ComponentInfo
     */
    public static final int FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION = 1 << 5;

    /**
     * Constant corresponding to {@code camera} in
     * the {@link android.R.attr#foregroundServiceType} attribute.
     * Use the camera device or record video.
     * For apps with <code>targetSdkVersion</code> {@link android.os.Build.VERSION_CODES#R} and
     * above, a foreground service will not be able to access the camera if this type is not
     * specified in the manifest and in
     * {@link android.app.Service#startForeground(int, android.app.Notification, int)}.
     */
    public static final int FOREGROUND_SERVICE_TYPE_CAMERA = 1 << 6;

    /**
     * Constant corresponding to {@code microphone} in
     * the {@link android.R.attr#foregroundServiceType} attribute.
     * Use the microphone device or record audio.
     * For apps with <code>targetSdkVersion</code> {@link android.os.Build.VERSION_CODES#R} and
     * above, a foreground service will not be able to access the microphone if this type is not
     * specified in the manifest and in
     * {@link android.app.Service#startForeground(int, android.app.Notification, int)}.
     */
    public static final int FOREGROUND_SERVICE_TYPE_MICROPHONE = 1 << 7;

    /**
     * A special value indicates to use all types set in manifest file.
     */
@@ -166,6 +188,8 @@ public class ServiceInfo extends ComponentInfo
            FOREGROUND_SERVICE_TYPE_LOCATION,
            FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE,
            FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION,
            FOREGROUND_SERVICE_TYPE_CAMERA,
            FOREGROUND_SERVICE_TYPE_MICROPHONE
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ForegroundServiceType {}
+16 −0
Original line number Diff line number Diff line
@@ -1520,6 +1520,22 @@
        <!-- Managing a media projection session, e.g, for screen recording or taking
             screenshots.-->
        <flag name="mediaProjection" value="0x20" />
        <!-- Use the camera device or record video.

            <p>For apps with <code>targetSdkVersion</code> {@link android.os.Build.VERSION_CODES#R}
            and above, a foreground service will not be able to access the camera if this type is
            not specified in the manifest and in
            {@link android.app.Service#startForeground(int, android.app.Notification, int)}.
            -->
        <flag name="camera" value="0x40" />
        <!--Use the microphone device or record audio.

            <p>For apps with <code>targetSdkVersion</code> {@link android.os.Build.VERSION_CODES#R}
            and above, a foreground service will not be able to access the microphone if this type
            is not specified in the manifest and in
            {@link android.app.Service#startForeground(int, android.app.Notification, int)}.
            -->
        <flag name="microphone" value="0x80" />
    </attr>


Loading