diff options
author | David Christie <dnchrist@google.com> | 2013-08-14 00:07:58 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-08-14 00:07:58 +0000 |
commit | b5eaf2662c174a7f5844bc62eba4f09dd64877f7 (patch) | |
tree | f52b9f0f9a3f73f68da27ec4c6afbdfd164a855c /services | |
parent | 5c7e64609c4de93cd70c2cbe238a5fc3ff3c6078 (diff) | |
parent | 15b3191f913091e686e9e1f3708b7f8240a07e8b (diff) | |
download | frameworks_base-b5eaf2662c174a7f5844bc62eba4f09dd64877f7.zip frameworks_base-b5eaf2662c174a7f5844bc62eba4f09dd64877f7.tar.gz frameworks_base-b5eaf2662c174a7f5844bc62eba4f09dd64877f7.tar.bz2 |
Merge "Update location AppOp monitoring to respect settings. If a provider is disabled, we don't mark an app as actively using location just because it's requested that provider. Also updates the concept of high power to support third party custom providers (doesn't hard code gps but looks at the provider's actual stated power requirement)." into klp-dev
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/LocationManagerService.java | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index d039a5e..9761441 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -548,30 +548,52 @@ public class LocationManagerService extends ILocationManager.Stub { return s.toString(); } + /** + * Update AppOp monitoring for this receiver. + * + * @param allow If true receiver is currently active, if false it's been removed. + */ public void updateMonitoring(boolean allow) { if (mHideFromAppOps) { return; } + boolean requestingLocation = false; + boolean requestingHighPowerLocation = false; + if (allow) { + // See if receiver has any enabled update records. Also note if any update records + // are high power (has a high power provider with an interval under a threshold). + for (UpdateRecord updateRecord : mUpdateRecords.values()) { + if (isAllowedByCurrentUserSettingsLocked(updateRecord.mProvider)) { + requestingLocation = true; + LocationProviderInterface locationProvider + = mProvidersByName.get(updateRecord.mProvider); + ProviderProperties properties = locationProvider != null + ? locationProvider.getProperties() : null; + if (properties != null + && properties.mPowerRequirement == Criteria.POWER_HIGH + && updateRecord.mRequest.getInterval() < HIGH_POWER_INTERVAL_MS) { + requestingHighPowerLocation = true; + break; + } + } + } + } + // First update monitoring of any location request (including high power). - mOpMonitoring = updateMonitoring(allow, mOpMonitoring, + mOpMonitoring = updateMonitoring( + requestingLocation, + mOpMonitoring, AppOpsManager.OP_MONITOR_LOCATION); // Now update monitoring of high power requests only. - // A high power request is any gps request with interval under a threshold. - boolean allowHighPower = allow; - if (allowHighPower) { - UpdateRecord gpsRecord = mUpdateRecords.get(LocationManager.GPS_PROVIDER); - if (gpsRecord == null - || gpsRecord.mRequest.getInterval() > HIGH_POWER_INTERVAL_MS) { - allowHighPower = false; - } - } boolean wasHighPowerMonitoring = mOpHighPowerMonitoring; - mOpHighPowerMonitoring = updateMonitoring(allowHighPower, mOpHighPowerMonitoring, + mOpHighPowerMonitoring = updateMonitoring( + requestingHighPowerLocation, + mOpHighPowerMonitoring, AppOpsManager.OP_MONITOR_HIGH_POWER_LOCATION); if (mOpHighPowerMonitoring != wasHighPowerMonitoring) { - // send an intent to notify that a high power request has been added/removed. + // Send an intent to notify that a high power request has been added/removed. Intent intent = new Intent(LocationManager.HIGH_POWER_REQUEST_CHANGE_ACTION); mContext.sendBroadcastAsUser(intent, UserHandle.ALL); } @@ -688,6 +710,10 @@ public class LocationManagerService extends ILocationManager.Stub { } public boolean callProviderEnabledLocked(String provider, boolean enabled) { + // First update AppOp monitoring. + // An app may get/lose location access as providers are enabled/disabled. + updateMonitoring(true); + if (mListener != null) { try { synchronized (this) { |