summaryrefslogtreecommitdiffstats
path: root/location
diff options
context:
space:
mode:
authorSvet Ganov <svetoslavganov@google.com>2015-05-13 10:40:31 -0700
committerSvetoslav <svetoslavganov@google.com>2015-05-13 15:37:21 -0700
commitf7e9cf4fb48ea80cbc5088204ac3f898109623f7 (patch)
treeef7eca0fc42142de07c0304c150b5afca2045617 /location
parent90c66e3ded4a91613b0c1760ab2ef15e0d118a36 (diff)
downloadframeworks_base-f7e9cf4fb48ea80cbc5088204ac3f898109623f7.zip
frameworks_base-f7e9cf4fb48ea80cbc5088204ac3f898109623f7.tar.gz
frameworks_base-f7e9cf4fb48ea80cbc5088204ac3f898109623f7.tar.bz2
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
Diffstat (limited to 'location')
-rw-r--r--location/java/android/location/ILocationManager.aidl17
-rw-r--r--location/java/android/location/LocationManager.java74
2 files changed, 42 insertions, 49 deletions
diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl
index af76175..a3ea896 100644
--- a/location/java/android/location/ILocationManager.aidl
+++ b/location/java/android/location/ILocationManager.aidl
@@ -77,14 +77,15 @@ interface ILocationManager
ProviderProperties getProviderProperties(String provider);
boolean isProviderEnabled(String provider);
- void addTestProvider(String name, in ProviderProperties properties);
- void removeTestProvider(String provider);
- void setTestProviderLocation(String provider, in Location loc);
- void clearTestProviderLocation(String provider);
- void setTestProviderEnabled(String provider, boolean enabled);
- void clearTestProviderEnabled(String provider);
- void setTestProviderStatus(String provider, int status, in Bundle extras, long updateTime);
- void clearTestProviderStatus(String provider);
+ void addTestProvider(String name, in ProviderProperties properties, String opPackageName);
+ void removeTestProvider(String provider, String opPackageName);
+ void setTestProviderLocation(String provider, in Location loc, String opPackageName);
+ void clearTestProviderLocation(String provider, String opPackageName);
+ void setTestProviderEnabled(String provider, boolean enabled, String opPackageName);
+ void clearTestProviderEnabled(String provider, String opPackageName);
+ void setTestProviderStatus(String provider, int status, in Bundle extras, long updateTime,
+ String opPackageName);
+ void clearTestProviderStatus(String provider, String opPackageName);
boolean sendExtraCommand(String provider, String command, inout Bundle extras);
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index a3d04d9..b09f216 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -37,7 +37,6 @@ import java.util.List;
import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
-import static android.Manifest.permission.ACCESS_MOCK_LOCATION;
/**
* This class provides access to the system location services. These
@@ -1218,12 +1217,11 @@ public class LocationManager {
*
* @param name the provider name
*
- * @throws SecurityException if the ACCESS_MOCK_LOCATION permission is not present
- * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION
- * Settings.Secure.ALLOW_MOCK_LOCATION} system setting is not enabled
+ * @throws SecurityException if {@link android.app.AppOpsManager#OPSTR_MOCK_LOCATION
+ * mock location app op} is not set to {@link android.app.AppOpsManager#MODE_ALLOWED
+ * allowed} for your app.
* @throws IllegalArgumentException if a provider with the given name already exists
*/
- @RequiresPermission(value = ACCESS_MOCK_LOCATION, conditional = true)
public void addTestProvider(String name, boolean requiresNetwork, boolean requiresSatellite,
boolean requiresCell, boolean hasMonetaryCost, boolean supportsAltitude,
boolean supportsSpeed, boolean supportsBearing, int powerRequirement, int accuracy) {
@@ -1235,7 +1233,7 @@ public class LocationManager {
}
try {
- mService.addTestProvider(name, properties);
+ mService.addTestProvider(name, properties, mContext.getOpPackageName());
} catch (RemoteException e) {
Log.e(TAG, "RemoteException", e);
}
@@ -1246,15 +1244,14 @@ public class LocationManager {
*
* @param provider the provider name
*
- * @throws SecurityException if the ACCESS_MOCK_LOCATION permission is not present
- * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION
- * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled
+ * @throws SecurityException if {@link android.app.AppOpsManager#OPSTR_MOCK_LOCATION
+ * mock location app op} is not set to {@link android.app.AppOpsManager#MODE_ALLOWED
+ * allowed} for your app.
* @throws IllegalArgumentException if no provider with the given name exists
*/
- @RequiresPermission(value = ACCESS_MOCK_LOCATION, conditional = true)
public void removeTestProvider(String provider) {
try {
- mService.removeTestProvider(provider);
+ mService.removeTestProvider(provider, mContext.getOpPackageName());
} catch (RemoteException e) {
Log.e(TAG, "RemoteException", e);
}
@@ -1270,13 +1267,12 @@ public class LocationManager {
* @param provider the provider name
* @param loc the mock location
*
- * @throws SecurityException if the ACCESS_MOCK_LOCATION permission is not present
- * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION
- * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled
+ * @throws SecurityException if {@link android.app.AppOpsManager#OPSTR_MOCK_LOCATION
+ * mock location app op} is not set to {@link android.app.AppOpsManager#MODE_ALLOWED
+ * allowed} for your app.
* @throws IllegalArgumentException if no provider with the given name exists
* @throws IllegalArgumentException if the location is incomplete
*/
- @RequiresPermission(value = ACCESS_MOCK_LOCATION, conditional = true)
public void setTestProviderLocation(String provider, Location loc) {
if (!loc.isComplete()) {
IllegalArgumentException e = new IllegalArgumentException(
@@ -1292,7 +1288,7 @@ public class LocationManager {
}
try {
- mService.setTestProviderLocation(provider, loc);
+ mService.setTestProviderLocation(provider, loc, mContext.getOpPackageName());
} catch (RemoteException e) {
Log.e(TAG, "RemoteException", e);
}
@@ -1303,15 +1299,14 @@ public class LocationManager {
*
* @param provider the provider name
*
- * @throws SecurityException if the ACCESS_MOCK_LOCATION permission is not present
- * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION
- * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled
+ * @throws SecurityException if {@link android.app.AppOpsManager#OPSTR_MOCK_LOCATION
+ * mock location app op} is not set to {@link android.app.AppOpsManager#MODE_ALLOWED
+ * allowed} for your app.
* @throws IllegalArgumentException if no provider with the given name exists
*/
- @RequiresPermission(value = ACCESS_MOCK_LOCATION, conditional = true)
public void clearTestProviderLocation(String provider) {
try {
- mService.clearTestProviderLocation(provider);
+ mService.clearTestProviderLocation(provider, mContext.getOpPackageName());
} catch (RemoteException e) {
Log.e(TAG, "RemoteException", e);
}
@@ -1324,15 +1319,14 @@ public class LocationManager {
* @param provider the provider name
* @param enabled the mock enabled value
*
- * @throws SecurityException if the ACCESS_MOCK_LOCATION permission is not present
- * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION
- * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled
+ * @throws SecurityException if {@link android.app.AppOpsManager#OPSTR_MOCK_LOCATION
+ * mock location app op} is not set to {@link android.app.AppOpsManager#MODE_ALLOWED
+ * allowed} for your app.
* @throws IllegalArgumentException if no provider with the given name exists
*/
- @RequiresPermission(value = ACCESS_MOCK_LOCATION, conditional = true)
public void setTestProviderEnabled(String provider, boolean enabled) {
try {
- mService.setTestProviderEnabled(provider, enabled);
+ mService.setTestProviderEnabled(provider, enabled, mContext.getOpPackageName());
} catch (RemoteException e) {
Log.e(TAG, "RemoteException", e);
}
@@ -1343,15 +1337,14 @@ public class LocationManager {
*
* @param provider the provider name
*
- * @throws SecurityException if the ACCESS_MOCK_LOCATION permission is not present
- * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION
- * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled
+ * @throws SecurityException if {@link android.app.AppOpsManager#OPSTR_MOCK_LOCATION
+ * mock location app op} is not set to {@link android.app.AppOpsManager#MODE_ALLOWED
+ * allowed} for your app.
* @throws IllegalArgumentException if no provider with the given name exists
*/
- @RequiresPermission(value = ACCESS_MOCK_LOCATION, conditional = true)
public void clearTestProviderEnabled(String provider) {
try {
- mService.clearTestProviderEnabled(provider);
+ mService.clearTestProviderEnabled(provider, mContext.getOpPackageName());
} catch (RemoteException e) {
Log.e(TAG, "RemoteException", e);
}
@@ -1366,15 +1359,15 @@ public class LocationManager {
* @param extras a Bundle containing mock extras
* @param updateTime the mock update time
*
- * @throws SecurityException if the ACCESS_MOCK_LOCATION permission is not present
- * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION
- * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled
+ * @throws SecurityException if {@link android.app.AppOpsManager#OPSTR_MOCK_LOCATION
+ * mock location app op} is not set to {@link android.app.AppOpsManager#MODE_ALLOWED
+ * allowed} for your app.
* @throws IllegalArgumentException if no provider with the given name exists
*/
- @RequiresPermission(value = ACCESS_MOCK_LOCATION, conditional = true)
public void setTestProviderStatus(String provider, int status, Bundle extras, long updateTime) {
try {
- mService.setTestProviderStatus(provider, status, extras, updateTime);
+ mService.setTestProviderStatus(provider, status, extras, updateTime,
+ mContext.getOpPackageName());
} catch (RemoteException e) {
Log.e(TAG, "RemoteException", e);
}
@@ -1385,15 +1378,14 @@ public class LocationManager {
*
* @param provider the provider name
*
- * @throws SecurityException if the ACCESS_MOCK_LOCATION permission is not present
- * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION
- * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled
+ * @throws SecurityException if {@link android.app.AppOpsManager#OPSTR_MOCK_LOCATION
+ * mock location app op} is not set to {@link android.app.AppOpsManager#MODE_ALLOWED
+ * allowed} for your app.
* @throws IllegalArgumentException if no provider with the given name exists
*/
- @RequiresPermission(value = ACCESS_MOCK_LOCATION, conditional = true)
public void clearTestProviderStatus(String provider) {
try {
- mService.clearTestProviderStatus(provider);
+ mService.clearTestProviderStatus(provider, mContext.getOpPackageName());
} catch (RemoteException e) {
Log.e(TAG, "RemoteException", e);
}