Allow default and system dialers to make emergency calls via ACTION_CALL
Change-Id: I877b58e8f02f8e578e5f61456a99f24f5396714b
diff --git a/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java b/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
index c40fde5..3ddeaf2 100644
--- a/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
+++ b/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
@@ -84,12 +84,18 @@
private final CallsManager mCallsManager;
private final ContactInfo mContactInfo;
private final Intent mIntent;
+ /*
+ * Whether or not the outgoing call intent originated from the default phone application. If
+ * so, it will be allowed to make emergency calls, even with the ACTION_CALL intent.
+ */
+ private final boolean mIsDefaultOrSystemPhoneApp;
NewOutgoingCallIntentBroadcaster(CallsManager callsManager, ContactInfo contactInfo,
- Intent intent) {
+ Intent intent, boolean isDefaultPhoneApp) {
mCallsManager = callsManager;
mContactInfo = contactInfo;
mIntent = intent;
+ mIsDefaultOrSystemPhoneApp = isDefaultPhoneApp;
}
/**
@@ -147,8 +153,10 @@
* - CALL (intent launched by all third party dialers)
* - CALL_PRIVILEGED (intent launched by system apps e.g. system Dialer, voice Dialer)
* - CALL_EMERGENCY (intent launched by lock screen emergency dialer)
+ *
+ * @return whether or not the caller was allowed to start the outgoing call.
*/
- void processIntent() {
+ boolean processIntent() {
Log.v(this, "Processing call intent in OutgoingCallIntentBroadcaster.");
final Context context = TelecommApp.getInstance();
@@ -158,7 +166,7 @@
if (TextUtils.isEmpty(handle)) {
Log.w(this, "Empty handle obtained from the call intent.");
- return;
+ return false;
}
boolean isUriNumber = PhoneNumberUtils.isUriNumber(handle);
@@ -179,21 +187,25 @@
String action = intent.getAction();
if (Intent.ACTION_CALL.equals(action)) {
if (isPotentialEmergencyNumber) {
- Log.w(this, "Cannot call potential emergency number %s with CALL Intent %s.",
- handle, intent);
- launchSystemDialer(context, intent.getData());
+ if (!mIsDefaultOrSystemPhoneApp) {
+ Log.w(this, "Cannot call potential emergency number %s with CALL Intent %s "
+ + "unless caller is system or default dialer.", handle, intent);
+ launchSystemDialer(context, intent.getData());
+ return false;
+ } else {
+ callImmediately = true;
+ }
}
- callImmediately = false;
} else if (Intent.ACTION_CALL_EMERGENCY.equals(action)) {
if (!isPotentialEmergencyNumber) {
Log.w(this, "Cannot call non-potential-emergency number %s with EMERGENCY_CALL "
+ "Intent %s.", handle, intent);
- return;
+ return false;
}
callImmediately = true;
} else {
Log.w(this, "Unhandled Intent %s. Ignoring and not placing call.", intent);
- return;
+ return false;
}
if (callImmediately) {
@@ -212,6 +224,7 @@
}
broadcastIntent(intent, handle, context, !callImmediately);
+ return true;
}
/**