Merge "Additional change to IS_SUPER_PRIMARY" into lmp-mr1-dev
diff --git a/src/com/android/providers/contacts/util/UserUtils.java b/src/com/android/providers/contacts/util/UserUtils.java
index 0df5a24..74fd2e7 100644
--- a/src/com/android/providers/contacts/util/UserUtils.java
+++ b/src/com/android/providers/contacts/util/UserUtils.java
@@ -61,16 +61,6 @@
             Log.v(TAG, "getCorpUserId: myUser=" + myUser);
         }
 
-        // TODO DevicePolicyManager is not mockable -- the constructor is private.
-        // Test it somehow.
-        if (getDevicePolicyManager(context)
-                .getCrossProfileCallerIdDisabled(new UserHandle(myUser))) {
-            if (VERBOSE_LOGGING) {
-                Log.v(TAG, "Enterprise caller-id disabled.");
-            }
-            return -1;
-        }
-
         // Check each user.
         for (UserInfo ui : um.getUsers()) {
             if (!ui.isManagedProfile()) {
@@ -82,10 +72,21 @@
             }
             // Check if it's linked to the current user.
             if (parent.id == myUser) {
-                if (VERBOSE_LOGGING) {
-                    Log.v(TAG, "Corp user=" + ui.id);
+                // Check if profile is blocking calling id.
+                // TODO DevicePolicyManager is not mockable -- the constructor is private.
+                // Test it somehow.
+                if (getDevicePolicyManager(context)
+                        .getCrossProfileCallerIdDisabled(ui.getUserHandle())) {
+                    if (VERBOSE_LOGGING) {
+                        Log.v(TAG, "Enterprise caller-id disabled for user " + ui.id);
+                    }
+                    return -1;
+                } else {
+                    if (VERBOSE_LOGGING) {
+                        Log.v(TAG, "Corp user=" + ui.id);
+                    }
+                    return ui.id;
                 }
-                return ui.id;
             }
         }
         if (VERBOSE_LOGGING) {