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

Commit f7e9cf4f authored by Svet Ganov's avatar Svet Ganov Committed by Svetoslav
Browse files

Access mock location is no longer a runtime permission - framework

The access mock location is no longer a runtime permission. It is a
signature protected one that apps cannot get but the fact they request
it means they want to inject location into the system. Now the user
gets to choose the current mock location app in developer options from
the apps that request the mock location permission. The access to mock
location is no longer guarded by the permisson but from a new app op
which is off by default and the settiings UI sets it to enabled only
for the currently selected mock location app.

bug:21078873

Change-Id: I19e3f9dc7c7de82eab46b30fec1abfbca54a0e59
parent 90c66e3d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3883,6 +3883,7 @@ package android.app {
    field public static final java.lang.String OPSTR_COARSE_LOCATION = "android:coarse_location";
    field public static final java.lang.String OPSTR_FINE_LOCATION = "android:fine_location";
    field public static final java.lang.String OPSTR_GET_USAGE_STATS = "android:get_usage_stats";
    field public static final java.lang.String OPSTR_MOCK_LOCATION = "android:mock_location";
    field public static final java.lang.String OPSTR_MONITOR_HIGH_POWER_LOCATION = "android:monitor_location_high_power";
    field public static final java.lang.String OPSTR_MONITOR_LOCATION = "android:monitor_location";
  }
@@ -26602,7 +26603,7 @@ package android.provider {
    field public static final java.lang.String ACCESSIBILITY_SPEAK_PASSWORD = "speak_password";
    field public static final deprecated java.lang.String ADB_ENABLED = "adb_enabled";
    field public static final java.lang.String ALLOWED_GEOLOCATION_ORIGINS = "allowed_geolocation_origins";
    field public static final java.lang.String ALLOW_MOCK_LOCATION = "mock_location";
    field public static final deprecated java.lang.String ALLOW_MOCK_LOCATION = "mock_location";
    field public static final java.lang.String ANDROID_ID = "android_id";
    field public static final deprecated java.lang.String BACKGROUND_DATA = "background_data";
    field public static final deprecated java.lang.String BLUETOOTH_ON = "bluetooth_on";
+2 −1
Original line number Diff line number Diff line
@@ -3975,6 +3975,7 @@ package android.app {
    field public static final java.lang.String OPSTR_COARSE_LOCATION = "android:coarse_location";
    field public static final java.lang.String OPSTR_FINE_LOCATION = "android:fine_location";
    field public static final java.lang.String OPSTR_GET_USAGE_STATS = "android:get_usage_stats";
    field public static final java.lang.String OPSTR_MOCK_LOCATION = "android:mock_location";
    field public static final java.lang.String OPSTR_MONITOR_HIGH_POWER_LOCATION = "android:monitor_location_high_power";
    field public static final java.lang.String OPSTR_MONITOR_LOCATION = "android:monitor_location";
  }
@@ -28627,7 +28628,7 @@ package android.provider {
    field public static final java.lang.String ACCESSIBILITY_SPEAK_PASSWORD = "speak_password";
    field public static final deprecated java.lang.String ADB_ENABLED = "adb_enabled";
    field public static final java.lang.String ALLOWED_GEOLOCATION_ORIGINS = "allowed_geolocation_origins";
    field public static final java.lang.String ALLOW_MOCK_LOCATION = "mock_location";
    field public static final deprecated java.lang.String ALLOW_MOCK_LOCATION = "mock_location";
    field public static final java.lang.String ANDROID_ID = "android_id";
    field public static final deprecated java.lang.String BACKGROUND_DATA = "background_data";
    field public static final deprecated java.lang.String BLUETOOTH_ON = "bluetooth_on";
+21 −8
Original line number Diff line number Diff line
@@ -227,8 +227,10 @@ public class AppOpsManager {
    public static final int OP_BODY_SENSORS = 56;
    /** @hide Read previously received cell broadcast messages. */
    public static final int OP_READ_CELL_BROADCASTS = 57;
    /** @hide Inject mock location into the system. */
    public static final int OP_MOCK_LOCATION = 58;
    /** @hide */
    public static final int _NUM_OP = 58;
    public static final int _NUM_OP = 59;

    /** Access to coarse location information. */
    public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -308,6 +310,9 @@ public class AppOpsManager {
    /** @hide Read previously received cell broadcast messages. */
    public static final String OPSTR_READ_CELL_BROADCASTS
            = "android:read_cell_broadcasts";
    /** Inject mock location into the system. */
    public static final String OPSTR_MOCK_LOCATION
            = "android:mock_location";

    /**
     * This maps each operation to the operation that serves as the
@@ -375,7 +380,8 @@ public class AppOpsManager {
            OP_PROCESS_OUTGOING_CALLS,
            OP_USE_FINGERPRINT,
            OP_BODY_SENSORS,
            OP_READ_CELL_BROADCASTS
            OP_READ_CELL_BROADCASTS,
            OP_MOCK_LOCATION
    };

    /**
@@ -440,7 +446,8 @@ public class AppOpsManager {
            null,
            OPSTR_USE_FINGERPRINT,
            OPSTR_BODY_SENSORS,
            OPSTR_READ_CELL_BROADCASTS
            OPSTR_READ_CELL_BROADCASTS,
            OPSTR_MOCK_LOCATION
    };

    /**
@@ -505,7 +512,8 @@ public class AppOpsManager {
            "PROCESS_OUTGOING_CALLS",
            "USE_FINGERPRINT",
            "BODY_SENSORS",
            "READ_CELL_BROADCASTS"
            "READ_CELL_BROADCASTS",
            "MOCK_LOCATION"
    };

    /**
@@ -570,7 +578,8 @@ public class AppOpsManager {
            Manifest.permission.PROCESS_OUTGOING_CALLS,
            Manifest.permission.USE_FINGERPRINT,
            Manifest.permission.BODY_SENSORS,
            Manifest.permission.READ_CELL_BROADCASTS
            Manifest.permission.READ_CELL_BROADCASTS,
            null
    };

    /**
@@ -636,7 +645,8 @@ public class AppOpsManager {
            null, // PROCESS_OUTGOING_CALLS
            null, // USE_FINGERPRINT
            null, // BODY_SENSORS
            null  // READ_CELL_BROADCASTS
            null, // READ_CELL_BROADCASTS
            null  // MOCK_LOCATION
    };

    /**
@@ -701,7 +711,8 @@ public class AppOpsManager {
            false, // PROCESS_OUTGOING_CALLS
            false, // USE_FINGERPRINT
            false, // BODY_SENSORS
            false  // READ_CELL_BROADCASTS
            false, // READ_CELL_BROADCASTS
            false  // MOCK_LOCATION
    };

    /**
@@ -765,7 +776,8 @@ public class AppOpsManager {
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_ALLOWED
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_ERRORED  // OP_MOCK_LOCATION
    };

    /**
@@ -833,6 +845,7 @@ public class AppOpsManager {
            false,
            false,
            false,
            false,
            false
    };

+3 −0
Original line number Diff line number Diff line
@@ -4133,7 +4133,10 @@ public final class Settings {
         * LocationManager service for testing purposes during application development.  These
         * locations and status values  override actual location and status information generated
         * by network, gps, or other location providers.
         *
         * @deprecated This settings is not used anymore.
         */
        @Deprecated
        public static final String ALLOW_MOCK_LOCATION = "mock_location";

        /**
+1 −3
Original line number Diff line number Diff line
@@ -836,9 +836,7 @@

    <!-- Allows an application to create mock location providers for testing. -->
    <permission android:name="android.permission.ACCESS_MOCK_LOCATION"
        android:label="@string/permlab_accessMockLocation"
        android:description="@string/permdesc_accessMockLocation"
        android:protectionLevel="normal" />
        android:protectionLevel="signature" />

    <!-- ======================================= -->
    <!-- Permissions for accessing networks -->
Loading