diff options
author | David Christie <dnchrist@google.com> | 2014-05-19 18:09:50 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-19 18:09:50 +0000 |
commit | 3662ad4aece1a1ae4f16c9965f32eb3ba547a2ad (patch) | |
tree | 729e1ba20cfe4cad264e9e4acf7cc2dc83c47a04 | |
parent | 3257984e55434cea1a058e9829460d0db9808b0c (diff) | |
parent | 1f141c1cbc1925fec36edb8a34a229cf6209d13a (diff) | |
download | frameworks_base-3662ad4aece1a1ae4f16c9965f32eb3ba547a2ad.zip frameworks_base-3662ad4aece1a1ae4f16c9965f32eb3ba547a2ad.tar.gz frameworks_base-3662ad4aece1a1ae4f16c9965f32eb3ba547a2ad.tar.bz2 |
Merge "Fix bug where location provider fails on secondary users. Bug: 12592045"
-rw-r--r-- | services/core/java/com/android/server/LocationManagerService.java | 24 |
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 |