From: Fyodor Kupolov Date: Thu, 7 Apr 2016 23:46:18 +0000 (-0700) Subject: Added getProfileIds method returning array of userIds X-Git-Tag: android-x86-7.1-r1~976^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4a4af5aec8e6367a022ca7da68564dce98a15841;p=android-x86%2Fpackages-apps-Settings.git Added getProfileIds method returning array of userIds Previously many usages of UserManager.getProfiles and getEnabledProfiles were only using ids of returned users. Given that the list of users needs to be parceled and unparceled for Binder calls, returning array of ids minimizes memory usage and serialization time. A new method getProfileIds was introduced which returns an array of userIds. Existing method calls were updated where appropriate. Bug: 27705805 Change-Id: Ib042f38d53d95d3b07cda7f824e5cb8c06cd10f5 --- diff --git a/src/com/android/settings/CredentialStorage.java b/src/com/android/settings/CredentialStorage.java index 9d001b4ca7..22e175bf80 100644 --- a/src/com/android/settings/CredentialStorage.java +++ b/src/com/android/settings/CredentialStorage.java @@ -344,13 +344,12 @@ public final class CredentialStorage extends Activity { // Clear all the users credentials could have been installed in for this user. final UserManager um = (UserManager) getSystemService(USER_SERVICE); - for (UserInfo pi : um.getProfiles(UserHandle.getUserId(Process.myUid()))) { + for (int userId : um.getProfileIdsWithDisabled(UserHandle.myUserId())) { for (int uid : SYSTEM_CREDENTIAL_UIDS) { - mKeyStore.clearUid(UserHandle.getUid(pi.id, uid)); + mKeyStore.clearUid(UserHandle.getUid(userId, uid)); } } - try { KeyChainConnection keyChainConnection = KeyChain.bind(CredentialStorage.this); try { diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 84bb2ddc4a..527194fb7b 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -615,12 +615,10 @@ public final class Utils extends com.android.settingslib.Utils { * @return the managed profile id or UserHandle.USER_NULL if there is none. */ public static int getManagedProfileId(UserManager um, int parentUserId) { - List profiles = um.getProfiles(parentUserId); - int numProfiles = profiles.size(); - for (int i = 0; i < numProfiles; ++i) { - UserInfo profile = profiles.get(i); - if (profile.id != parentUserId) { - return profile.id; + int[] profileIds = um.getProfileIdsWithDisabled(parentUserId); + for (int profileId : profileIds) { + if (profileId != parentUserId) { + return profileId; } } return UserHandle.USER_NULL;