[automerger skipped] DO NOT MERGE Fix sorting issue during emergency call attempt. am: af569ca6b9 am: 81376616b9 am: 3557d8dae0 -s ours am: 872563caf0 -s ours am: 226f14691d -s ours am: 539dcdbd8b -s ours am: 2275cc63c7 -s ours am: 020ab0b885 -s ours am: b4940b4e9f -s ours
am skip reason: subject contains skip directive
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telecomm/+/16460017
Change-Id: Ic141fbce78ca4796c3d2d64aad26a4a1b79d62ca
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index 86d5ebc..52c1590 100644
--- a/src/com/android/server/telecom/TelecomServiceImpl.java
+++ b/src/com/android/server/telecom/TelecomServiceImpl.java
@@ -1467,6 +1467,7 @@
enforceCallingPackage(callingPackage);
PhoneAccountHandle phoneAccountHandle = null;
+ boolean clearPhoneAccountHandleExtra = false;
if (extras != null) {
phoneAccountHandle = extras.getParcelable(
TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
@@ -1478,17 +1479,24 @@
boolean isSelfManaged = phoneAccountHandle != null &&
isSelfManagedConnectionService(phoneAccountHandle);
if (isSelfManaged) {
- mContext.enforceCallingOrSelfPermission(Manifest.permission.MANAGE_OWN_CALLS,
- "Self-managed ConnectionServices require MANAGE_OWN_CALLS permission.");
+ try {
+ mContext.enforceCallingOrSelfPermission(
+ Manifest.permission.MANAGE_OWN_CALLS,
+ "Self-managed ConnectionServices require "
+ + "MANAGE_OWN_CALLS permission.");
+ } catch (SecurityException e) {
+ // Fallback to use mobile network to avoid disclosing phone account handle
+ // package information
+ clearPhoneAccountHandleExtra = true;
+ }
- if (!callingPackage.equals(
+ if (!clearPhoneAccountHandleExtra && !callingPackage.equals(
phoneAccountHandle.getComponentName().getPackageName())
&& !canCallPhone(callingPackage, callingFeatureId,
"CALL_PHONE permission required to place calls.")) {
- // The caller is not allowed to place calls, so we want to ensure that it
- // can only place calls through itself.
- throw new SecurityException("Self-managed ConnectionServices can only "
- + "place calls through their own ConnectionService.");
+ // The caller is not allowed to place calls, so fallback to use mobile
+ // network.
+ clearPhoneAccountHandleExtra = true;
}
} else if (!canCallPhone(callingPackage, callingFeatureId, "placeCall")) {
throw new SecurityException("Package " + callingPackage
@@ -1523,6 +1531,9 @@
final Intent intent = new Intent(hasCallPrivilegedPermission ?
Intent.ACTION_CALL_PRIVILEGED : Intent.ACTION_CALL, handle);
if (extras != null) {
+ if (clearPhoneAccountHandleExtra) {
+ extras.remove(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
+ }
extras.setDefusable(true);
intent.putExtras(extras);
}