summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Christie <dnchrist@google.com>2014-05-14 15:11:15 -0700
committerDavid Christie <dnchrist@google.com>2014-05-14 16:57:03 -0700
commit1f141c1cbc1925fec36edb8a34a229cf6209d13a (patch)
treed8a4a485fd302d25804186d17cb4b0be891ab74b
parent92ddeeab47c9c98454df725275764e708025615f (diff)
downloadframeworks_base-1f141c1cbc1925fec36edb8a34a229cf6209d13a.zip
frameworks_base-1f141c1cbc1925fec36edb8a34a229cf6209d13a.tar.gz
frameworks_base-1f141c1cbc1925fec36edb8a34a229cf6209d13a.tar.bz2
Fix bug where location provider fails on secondary users.
Bug: 12592045 Change-Id: I196b8621c7f61c3492ad29ae90b608304dc29d66
-rw-r--r--services/core/java/com/android/server/LocationManagerService.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index e54e5d0..11fc941 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -1847,10 +1847,10 @@ public class LocationManagerService extends ILocationManager.Stub {
return true;
}
if (mGeocodeProvider != null) {
- if (doesPackageHaveUid(uid, mGeocodeProvider.getConnectedPackageName())) return true;
+ if (doesUidHavePackage(uid, mGeocodeProvider.getConnectedPackageName())) return true;
}
for (LocationProviderProxy proxy : mProxyProviders) {
- if (doesPackageHaveUid(uid, proxy.getConnectedPackageName())) return true;
+ if (doesUidHavePackage(uid, proxy.getConnectedPackageName())) return true;
}
return false;
}
@@ -1876,19 +1876,23 @@ public class LocationManagerService extends ILocationManager.Stub {
"or UID of a currently bound location provider");
}
- private boolean doesPackageHaveUid(int uid, String packageName) {
+ /**
+ * Returns true if the given package belongs to the given uid.
+ */
+ private boolean doesUidHavePackage(int uid, String packageName) {
if (packageName == null) {
return false;
}
- try {
- ApplicationInfo appInfo = mPackageManager.getApplicationInfo(packageName, 0);
- if (appInfo.uid != uid) {
- return false;
- }
- } catch (NameNotFoundException e) {
+ String[] packageNames = mPackageManager.getPackagesForUid(uid);
+ if (packageNames == null) {
return false;
}
- return true;
+ for (String name : packageNames) {
+ if (packageName.equals(name)) {
+ return true;
+ }
+ }
+ return false;
}
@Override