Remove usage of hidden UserManager api.
Test: basic sanity with secondary users allowing and disallowing
calls
Bug: 137202333
Change-Id: Iec05205bc85601e8ea09d859c57a2ed99933c95d
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index 8c6d23c..e9fd26d 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -378,7 +378,7 @@
List<UserInfo> users = mUserManager.getUsers(true);
for (UserInfo user : users) {
final UserHandle userHandle = user.getUserHandle();
- if (!mUserManager.hasUserRestriction(
+ if (!hasUserRestriction(
UserManager.DISALLOW_OUTGOING_CALLS, userHandle)
&& !mUserManager.isManagedProfile(userHandle.getIdentifier())) {
if (!maybeSendVoicemailNotificationUsingDefaultDialer(phone, vmCount, vmNumber,
@@ -395,7 +395,7 @@
List<UserInfo> users = mUserManager.getUsers(true /* excludeDying */);
for (UserInfo user : users) {
final UserHandle userHandle = user.getUserHandle();
- if (!mUserManager.hasUserRestriction(
+ if (!hasUserRestriction(
UserManager.DISALLOW_OUTGOING_CALLS, userHandle)
&& !mUserManager.isManagedProfile(userHandle.getIdentifier())) {
if (!maybeSendVoicemailNotificationUsingDefaultDialer(phone, 0, null, null,
@@ -410,6 +410,12 @@
}
}
+ private boolean hasUserRestriction(String restrictionKey, UserHandle userHandle) {
+ final List<UserManager.EnforcingUser> sources = mUserManager
+ .getUserRestrictionSources(restrictionKey, userHandle);
+ return (sources != null && !sources.isEmpty());
+ }
+
/**
* Sends a broadcast with the voicemail notification information to the default dialer. This
* method is also used to indicate to the default dialer when to clear the