OSDN Git Service

Don't return self if not a profile
authorAmith Yamasani <yamasani@google.com>
Wed, 25 Jan 2017 19:35:44 +0000 (11:35 -0800)
committerAmith Yamasani <yamasani@google.com>
Wed, 25 Jan 2017 19:55:51 +0000 (11:55 -0800)
This fixes the inconsistency between no profile and a
removed profile.

Change-Id: I85d37ce42113bde8567be382372c5f4997601e85
Fixes: 34699518
Test: runtest -x
frameworks/base/services/tests/servicetests/src/com/android/server/pm/UserManagerTest.java

services/core/java/com/android/server/pm/UserManagerService.java
services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java

index 1eb8b94..58683d7 100644 (file)
@@ -718,7 +718,7 @@ public class UserManagerService extends IUserManager.Stub {
             return null;
         }
         int parentUserId = profile.profileGroupId;
-        if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
+        if (parentUserId == userHandle || parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
             return null;
         } else {
             return getUserInfoLU(parentUserId);
index 9b2c94e..1964cad 100644 (file)
@@ -177,10 +177,12 @@ public class UserManagerTest extends AndroidTestCase {
         UserInfo userInfo = createProfileForUser("Profile",
                 UserInfo.FLAG_MANAGED_PROFILE, primaryUserId);
         assertNotNull(userInfo);
-
+        assertNull(mUserManager.getProfileParent(primaryUserId));
         UserInfo parentProfileInfo = mUserManager.getProfileParent(userInfo.id);
         assertNotNull(parentProfileInfo);
         assertEquals(parentProfileInfo.id, primaryUserId);
+        removeUser(userInfo.id);
+        assertNull(mUserManager.getProfileParent(primaryUserId));
     }
 
     // Make sure only one managed profile can be created