Data usage multi-user support.
Switch to storing policy per-user instead of per-app, meaning each user has control over their own set of apps. Summarize the usage of non-current users. Only allow owner to make changes to overall network policy. Hide auto-sync menu when viewing app details. Search for MANAGE_NETWORK_USAGE intent across all package names sharing a UID. Bug: 7121279, 5419594, 6978663 Change-Id: Ia70f04df70d27da27faccb947cd27021c628a41a
This commit is contained in:
@@ -21,20 +21,30 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.TrafficStats;
|
||||
import android.os.UserManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
/**
|
||||
* Return details about a specific UID, handling special cases like
|
||||
* {@link TrafficStats#UID_TETHERING} and {@link UserInfo}.
|
||||
*/
|
||||
public class UidDetailProvider {
|
||||
private final Context mContext;
|
||||
private final SparseArray<UidDetail> mUidDetailCache;
|
||||
|
||||
public static int buildKeyForUser(int userHandle) {
|
||||
return -(2000 + userHandle);
|
||||
}
|
||||
|
||||
public UidDetailProvider(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
mUidDetailCache = new SparseArray<UidDetail>();
|
||||
@@ -101,10 +111,21 @@ public class UidDetailProvider {
|
||||
return detail;
|
||||
}
|
||||
|
||||
// Handle keys that are actually user handles
|
||||
if (uid <= -2000) {
|
||||
final int userHandle = (-uid) - 2000;
|
||||
final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||
final UserInfo info = um.getUserInfo(userHandle);
|
||||
if (info != null) {
|
||||
detail.label = res.getString(R.string.running_process_item_user_label, info.name);
|
||||
detail.icon = Drawable.createFromPath(info.iconPath);
|
||||
return detail;
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise fall back to using packagemanager labels
|
||||
final String[] packageNames = pm.getPackagesForUid(uid);
|
||||
final int length = packageNames != null ? packageNames.length : 0;
|
||||
|
||||
try {
|
||||
if (length == 1) {
|
||||
final ApplicationInfo info = pm.getApplicationInfo(packageNames[0], 0);
|
||||
|
Reference in New Issue
Block a user