am 4fff3d9b: Merge "Don\'t show background apps in Settings->Location (b/10806272)" into klp-dev

* commit '4fff3d9b9d3677383fe1eef9c067058a92fdc5b7':
  Don't show background apps in Settings->Location (b/10806272)
This commit is contained in:
David Christie
2013-09-23 19:00:49 -07:00
committed by Android Git Automerger

View File

@@ -16,6 +16,7 @@
package com.android.settings.location; package com.android.settings.location;
import android.app.ActivityManager;
import android.app.AppOpsManager; import android.app.AppOpsManager;
import android.content.Context; import android.content.Context;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
@@ -23,6 +24,7 @@ import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.Process; import android.os.Process;
import android.os.UserHandle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.util.Log; import android.util.Log;
@@ -168,9 +170,12 @@ public class RecentLocationApps {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
for (AppOpsManager.PackageOps ops : appOps) { for (AppOpsManager.PackageOps ops : appOps) {
// Don't show the Android System in the list - it's not actionable for the user. // Don't show the Android System in the list - it's not actionable for the user.
if (ops.getUid() != Process.SYSTEM_UID // Also don't show apps belonging to background users.
|| !ANDROID_SYSTEM_PACKAGE_NAME.equals(ops.getPackageName())) { int uid = ops.getUid();
BatterySipperWrapper wrapper = sipperMap.get(ops.getUid()); boolean isAndroidOs = (uid == Process.SYSTEM_UID)
&& ANDROID_SYSTEM_PACKAGE_NAME.equals(ops.getPackageName());
if (!isAndroidOs && ActivityManager.getCurrentUser() == UserHandle.getUserId(uid)) {
BatterySipperWrapper wrapper = sipperMap.get(uid);
Preference pref = getPreferenceFromOps(now, ops, wrapper); Preference pref = getPreferenceFromOps(now, ops, wrapper);
if (pref != null) { if (pref != null) {
prefs.add(pref); prefs.add(pref);
@@ -267,7 +272,7 @@ public class RecentLocationApps {
" belongs to another inactive account, ignored."); " belongs to another inactive account, ignored.");
} }
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
Log.wtf(TAG, "Package not found: " + packageName); Log.wtf(TAG, "Package not found: " + packageName, e);
} }
} }