Merge "Do not use hidden APIs in UserHandle/UserManager"
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index bb1e293..475cc1f 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -379,7 +379,7 @@
for (int i = 0; i < users.size(); i++) {
final UserInfo user = users.get(i);
final UserHandle userHandle = user.getUserHandle();
- if (!mUserManager.hasUserRestriction(
+ if (!hasUserRestriction(
UserManager.DISALLOW_OUTGOING_CALLS, userHandle)
&& !user.isManagedProfile()) {
if (!maybeSendVoicemailNotificationUsingDefaultDialer(phone, vmCount, vmNumber,
@@ -397,7 +397,7 @@
for (int i = 0; i < users.size(); i++) {
final UserInfo user = users.get(i);
final UserHandle userHandle = user.getUserHandle();
- if (!mUserManager.hasUserRestriction(
+ if (!hasUserRestriction(
UserManager.DISALLOW_OUTGOING_CALLS, userHandle)
&& !user.isManagedProfile()) {
if (!maybeSendVoicemailNotificationUsingDefaultDialer(phone, 0, null, null,
@@ -412,6 +412,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
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 15818ec..571be34 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2927,18 +2927,19 @@
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
throw new IllegalArgumentException("Invalid Subscription ID: " + subId);
}
- Binder.withCleanCallingIdentity(() -> {
- try {
- // TODO: Refactor to remove ImsManager dependence and query through ImsPhone.
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
- .removeRegistrationCallbackForSubscription(c, subId);
- } catch (ImsException e) {
- Log.i(LOG_TAG, "unregisterImsRegistrationCallback: " + subId
- + "is inactive, ignoring unregister.");
- // If the subscription is no longer active, just return, since the callback
- // will already have been removed internally.
- }
- });
+ final long token = Binder.clearCallingIdentity();
+ try {
+ // TODO: Refactor to remove ImsManager dependence and query through ImsPhone.
+ ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
+ .removeRegistrationCallbackForSubscription(c, subId);
+ } catch (ImsException e) {
+ Log.i(LOG_TAG, "unregisterImsRegistrationCallback: " + subId
+ + "is inactive, ignoring unregister.");
+ // If the subscription is no longer active, just return, since the callback
+ // will already have been removed internally.
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
}
/**
@@ -3032,22 +3033,23 @@
@Override
public void unregisterMmTelCapabilityCallback(int subId, IImsCapabilityCallback c) {
enforceReadPrivilegedPermission("unregisterMmTelCapabilityCallback");
-
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
throw new IllegalArgumentException("Invalid Subscription ID: " + subId);
}
- Binder.withCleanCallingIdentity(() -> {
- try {
- // TODO: Refactor to remove ImsManager dependence and query through ImsPhone.
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
+
+ final long token = Binder.clearCallingIdentity();
+ try {
+ // TODO: Refactor to remove ImsManager dependence and query through ImsPhone.
+ ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
.removeCapabilitiesCallbackForSubscription(c, subId);
- } catch (ImsException e) {
- Log.i(LOG_TAG, "unregisterMmTelCapabilityCallback: " + subId
- + "is inactive, ignoring unregister.");
- // If the subscription is no longer active, just return, since the callback
- // will already have been removed internally.
- }
- });
+ } catch (ImsException e) {
+ Log.i(LOG_TAG, "unregisterMmTelCapabilityCallback: " + subId
+ + "is inactive, ignoring unregister.");
+ // If the subscription is no longer active, just return, since the callback
+ // will already have been removed internally.
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
}
@Override
diff --git a/src/com/android/services/telephony/EmergencyTonePlayer.java b/src/com/android/services/telephony/EmergencyTonePlayer.java
index 8e26349..431f8d7 100644
--- a/src/com/android/services/telephony/EmergencyTonePlayer.java
+++ b/src/com/android/services/telephony/EmergencyTonePlayer.java
@@ -23,7 +23,6 @@
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.ToneGenerator;
-import android.os.SystemVibrator;
import android.os.Vibrator;
import android.provider.Settings;
@@ -49,11 +48,9 @@
.setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
.build();
- // We don't rely on getSystemService(Context.VIBRATOR_SERVICE) to make sure that this vibrator
- // object will be isolated from others.
- private final Vibrator mVibrator = new SystemVibrator();
private final Context mContext;
private final AudioManager mAudioManager;
+ private final Vibrator mVibrator;
private ToneGenerator mToneGenerator;
private int mSavedInCallVolume;
@@ -62,6 +59,7 @@
EmergencyTonePlayer(Context context) {
mContext = context;
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+ mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
}
public void start() {