From abaa423fa15f00b07b9c92c16ee186c909cac145 Mon Sep 17 00:00:00 2001 From: Kenny Guy Date: Fri, 23 Jan 2015 20:17:09 +0000 Subject: Fix cross profile caller id to use manager profiles userid. Cross profile caller id was checking myUserId when deciding whether to allow caller id from manged profiles where it should have used the managed profiles userid. Bug: 19122752 Change-Id: I230fc933655cd9464d00b619a383ff0682660c12 --- .../android/providers/contacts/util/UserUtils.java | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) 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 @@ public final class UserUtils { 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 @@ public final class UserUtils { } // 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) { -- cgit v1.1