diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 01f54ade9accf1d95d042fe8feca421e2cb0dcd6..8c778ff2407b08794a6aafe8226368af62bb0113 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -652,6 +652,7 @@ package android.app { field public static final String OPSTR_CAPTURE_CONSENTLESS_BUGREPORT_ON_USERDEBUG_BUILD = "android:capture_consentless_bugreport_on_userdebug_build"; field public static final String OPSTR_CHANGE_WIFI_STATE = "android:change_wifi_state"; field @FlaggedApi("android.view.contentprotection.flags.create_accessibility_overlay_app_op_enabled") public static final String OPSTR_CREATE_ACCESSIBILITY_OVERLAY = "android:create_accessibility_overlay"; + field @FlaggedApi("android.location.flags.location_bypass") public static final String OPSTR_EMERGENCY_LOCATION = "android:emergency_location"; field @FlaggedApi("android.permission.flags.op_enable_mobile_data_by_user") public static final String OPSTR_ENABLE_MOBILE_DATA_BY_USER = "android:enable_mobile_data_by_user"; field public static final String OPSTR_ESTABLISH_VPN_MANAGER = "android:establish_vpn_manager"; field public static final String OPSTR_ESTABLISH_VPN_SERVICE = "android:establish_vpn_service"; diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 0dbce97c978b86d18b70f9023380f6417e158b2c..329d3dd58c5623be332ee5aa6b5cc5acd5b74361 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -16,6 +16,7 @@ package android.app; +import static android.location.flags.Flags.FLAG_LOCATION_BYPASS; import static android.permission.flags.Flags.FLAG_OP_ENABLE_MOBILE_DATA_BY_USER; import static android.view.contentprotection.flags.Flags.FLAG_CREATE_ACCESSIBILITY_OVERLAY_APP_OP_ENABLED; import static android.view.contentprotection.flags.Flags.FLAG_RAPID_CLEAR_NOTIFICATIONS_BY_LISTENER_APP_OP_ENABLED; @@ -1571,9 +1572,17 @@ public class AppOpsManager { public static final int OP_UNARCHIVAL_CONFIRMATION = AppProtoEnums.APP_OP_UNARCHIVAL_CONFIRMATION; + /** + * Allows an app to access location without the traditional location permissions and while the + * user location setting is off, but only during pre-defined emergency sessions. + * + * @hide + */ + public static final int OP_EMERGENCY_LOCATION = AppProtoEnums.APP_OP_EMERGENCY_LOCATION; + /** @hide */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - public static final int _NUM_OP = 147; + public static final int _NUM_OP = 148; /** * All app ops represented as strings. @@ -1726,6 +1735,7 @@ public class AppOpsManager { OPSTR_RUN_BACKUP_JOBS, OPSTR_ARCHIVE_ICON_OVERLAY, OPSTR_UNARCHIVAL_CONFIRMATION, + OPSTR_EMERGENCY_LOCATION, }) public @interface AppOpString {} @@ -2439,6 +2449,16 @@ public class AppOpsManager { */ public static final String OPSTR_RUN_BACKUP_JOBS = "android:run_backup_jobs"; + /** + * Allows an app to access location without the traditional location permissions and while the + * user location setting is off, but only during pre-defined emergency sessions. + * + * @hide + */ + @SystemApi + @FlaggedApi(FLAG_LOCATION_BYPASS) + public static final String OPSTR_EMERGENCY_LOCATION = "android:emergency_location"; + /** {@link #sAppOpsToNote} not initialized yet for this op */ private static final byte SHOULD_COLLECT_NOTE_OP_NOT_INITIALIZED = 0; /** Should not collect noting of this app-op in {@link #sAppOpsToNote} */ @@ -3019,6 +3039,9 @@ public class AppOpsManager { new AppOpInfo.Builder(OP_UNARCHIVAL_CONFIRMATION, OPSTR_UNARCHIVAL_CONFIRMATION, "UNARCHIVAL_CONFIRMATION") .setDefaultMode(MODE_ALLOWED).build(), + // TODO(b/301150056): STOPSHIP determine how this appop should work with the permission + new AppOpInfo.Builder(OP_EMERGENCY_LOCATION, OPSTR_EMERGENCY_LOCATION, "EMERGENCY_LOCATION") + .setPermission(Manifest.permission.LOCATION_BYPASS).build(), }; // The number of longs needed to form a full bitmask of app ops diff --git a/location/java/android/location/flags/location.aconfig b/location/java/android/location/flags/location.aconfig index a96fe47f2381562fc8e9490ffb6b8eaa2457a09a..0fa641b926a99f8133f9380e76eba21e6e5aead0 100644 --- a/location/java/android/location/flags/location.aconfig +++ b/location/java/android/location/flags/location.aconfig @@ -1,5 +1,12 @@ package: "android.location.flags" +flag { + name: "location_bypass" + namespace: "location" + description: "Enable location bypass appops behavior" + bug: "301150056" +} + flag { name: "fix_service_watcher" namespace: "location"