OSDN Git Service

Start activity for the correct user in Settings > Data Usage
authorZoltan Szatmary-Ban <szatmz@google.com>
Thu, 7 Aug 2014 14:27:08 +0000 (15:27 +0100)
committerZoltan Szatmary-Ban <szatmz@google.com>
Thu, 7 Aug 2014 14:27:08 +0000 (15:27 +0100)
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

src/com/android/settings/DataUsageSummary.java

index c8691e1..f7a0618 100644 (file)
@@ -402,7 +402,6 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
             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 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
                 }
             }
 
+            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 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
         }
     };
 
-    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) {