OSDN Git Service

Ignores AppOps entries belonging to other users
authorLifu Tang <lifu@google.com>
Fri, 30 Aug 2013 23:02:16 +0000 (16:02 -0700)
committerLifu Tang <lifu@google.com>
Tue, 3 Sep 2013 17:03:48 +0000 (10:03 -0700)
- Fix b/10567352

Change-Id: I6aac030a426e5a881578b518a9cf6bad8679d087

src/com/android/settings/location/RecentLocationApps.java

index 6e16151..1fa8aac 100644 (file)
@@ -243,11 +243,22 @@ public class RecentLocationApps {
             try {
                 ApplicationInfo appInfo = mPackageManager.getApplicationInfo(
                         packageName, PackageManager.GET_META_DATA);
-                pref = createRecentLocationEntry(
-                        mPackageManager.getApplicationIcon(appInfo),
-                        mPackageManager.getApplicationLabel(appInfo),
-                        highBattery,
-                        new PackageEntryClickedListener(packageName));
+                // Multiple users can install the same package. Each user gets a different Uid for
+                // the same package.
+                //
+                // Here we retrieve the Uid with package name, that will be the Uid for that package
+                // associated with the current active user. If the Uid differs from the Uid in ops,
+                // that means this entry belongs to another inactive user and we should ignore that.
+                if (appInfo.uid == ops.getUid()) {
+                    pref = createRecentLocationEntry(
+                            mPackageManager.getApplicationIcon(appInfo),
+                            mPackageManager.getApplicationLabel(appInfo),
+                            highBattery,
+                            new PackageEntryClickedListener(packageName));
+                } else if (Log.isLoggable(TAG, Log.VERBOSE)) {
+                    Log.v(TAG, "package " + packageName + " with Uid " + ops.getUid() +
+                            " belongs to another inactive account, ignored.");
+                }
             } catch (PackageManager.NameNotFoundException e) {
                 Log.wtf(TAG, "Package not found: " + packageName);
             }