Start activity for the correct user in Settings > Data Usage
The 'app settings' button on the app details view now starts the app settings activity
for the correct user, i.e. the managed profile's app settings if the list item corresponds
to the managed profile's app. Formerly it always incorrectly started up the settings screen
for the primary user's app.
Bug:16727726
Change-Id: Ib31d45f4201fb26b5231e4e57c49858e7e41efc9
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index c8691e1..f7a0618 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -402,7 +402,6 @@
mAppSwitches = (LinearLayout) mAppDetail.findViewById(R.id.app_switches);
mAppSettings = (Button) mAppDetail.findViewById(R.id.app_settings);
- mAppSettings.setOnClickListener(mAppSettingsListener);
mAppRestrict = new Switch(inflater.getContext());
mAppRestrict.setClickable(false);
@@ -853,11 +852,24 @@
}
}
+ mAppSettings.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (!isAdded()) {
+ return;
+ }
+
+ // TODO: target towards entire UID instead of just first package
+ getActivity().startActivityAsUser(mAppSettingsIntent,
+ new UserHandle(UserHandle.getUserId(uid)));
+ }
+ });
mAppSettings.setEnabled(matchFound);
mAppSettings.setVisibility(View.VISIBLE);
} else {
mAppSettingsIntent = null;
+ mAppSettings.setOnClickListener(null);
mAppSettings.setVisibility(View.GONE);
}
@@ -1110,16 +1122,6 @@
}
};
- private OnClickListener mAppSettingsListener = new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (!isAdded()) return;
-
- // TODO: target torwards entire UID instead of just first package
- startActivity(mAppSettingsIntent);
- }
- };
-
private OnItemClickListener mListListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {