From 941221c1577a34c922c03b30be7ef0a4afda4278 Mon Sep 17 00:00:00 2001 From: Laurent Tu Date: Thu, 4 Oct 2012 14:21:52 -0700 Subject: [PATCH] Handle other providers in isAllowedProviderSafe() Add a case for isAllowedProviderSafe() to handle providers that are not GPS/Passive/Network/Fused. For example, this is useful for mock providers. Bug: 7047435 Change-Id: If4799aa90a5338889c47582d45cbfc25772c9c53 --- .../server/LocationManagerService.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index 2197e3122269c..184c8d24c5766 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -639,7 +639,27 @@ public class LocationManagerService extends ILocationManager.Stub implements Run == PackageManager.PERMISSION_GRANTED) || (mContext.checkCallingOrSelfPermission(ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED); + } else { + // mock providers + LocationProviderInterface lp = mMockProviders.get(provider); + if (lp != null) { + ProviderProperties properties = lp.getProperties(); + if (properties != null) { + if (properties.mRequiresSatellite) { + // provider requiring satellites require FINE permission + return mContext.checkCallingOrSelfPermission(ACCESS_FINE_LOCATION) + == PackageManager.PERMISSION_GRANTED; + } else if (properties.mRequiresNetwork || properties.mRequiresCell) { + // provider requiring network and or cell require COARSE or FINE + return (mContext.checkCallingOrSelfPermission(ACCESS_FINE_LOCATION) + == PackageManager.PERMISSION_GRANTED) || + (mContext.checkCallingOrSelfPermission(ACCESS_COARSE_LOCATION) + == PackageManager.PERMISSION_GRANTED); + } + } + } } + return false; }