OSDN Git Service

Make Settings->Apps can handle work apps even work profile not enabled yet
authorRicky Wai <rickywai@google.com>
Tue, 7 Jun 2016 14:25:42 +0000 (15:25 +0100)
committerRicky Wai <rickywai@google.com>
Tue, 7 Jun 2016 14:52:11 +0000 (14:52 +0000)
Bug: 29090660
Change-Id: I74f79a4939fac16a09c7991181dc25e1ba4e5edc

packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java

index 6d6a4b5..7392453 100644 (file)
@@ -46,6 +46,8 @@ import android.text.format.Formatter;
 import android.util.Log;
 import android.util.SparseArray;
 
+import com.android.internal.util.ArrayUtils;
+
 import java.io.File;
 import java.text.Collator;
 import java.text.Normalizer;
@@ -123,8 +125,8 @@ public class ApplicationsState {
         mPm = mContext.getPackageManager();
         mIpm = AppGlobals.getPackageManager();
         mUm = (UserManager) app.getSystemService(Context.USER_SERVICE);
-        for (UserHandle user : mUm.getUserProfiles()) {
-            mEntriesMap.put(user.getIdentifier(), new HashMap<String, AppEntry>());
+        for (int userId : mUm.getProfileIdsWithDisabled(UserHandle.myUserId())) {
+            mEntriesMap.put(userId, new HashMap<String, AppEntry>());
         }
         mThread = new HandlerThread("ApplicationsState.Loader",
                 Process.THREAD_PRIORITY_BACKGROUND);
@@ -426,7 +428,8 @@ public class ApplicationsState {
     }
 
     private void addUser(int userId) {
-        if (mUm.getUserProfiles().contains(new UserHandle(userId))) {
+        final int profileIds[] = mUm.getProfileIdsWithDisabled(UserHandle.myUserId());
+        if (ArrayUtils.contains(profileIds, userId)) {
             synchronized (mEntriesMap) {
                 mEntriesMap.put(userId, new HashMap<String, AppEntry>());
                 if (mResumed) {