Revert "Allow default and system dialers to make emergency calls via ACTION_CALL"

This reverts commit 31a94e394d4cddc873188b4138ab2c6f3324d533.

Change-Id: I29659ffbc507c415c9155fff98d57f336c46ebb0
diff --git a/src/com/android/telecomm/CallActivity.java b/src/com/android/telecomm/CallActivity.java
index 3479001..2868216 100644
--- a/src/com/android/telecomm/CallActivity.java
+++ b/src/com/android/telecomm/CallActivity.java
@@ -17,31 +17,18 @@
 package com.android.telecomm;
 
 import android.app.Activity;
-import android.content.ComponentName;
 import android.content.Intent;
 import android.content.res.Configuration;
 import android.os.Bundle;
 import android.telecomm.CallServiceDescriptor;
-import android.telecomm.PhoneApplication;
 import android.telecomm.TelecommConstants;
-import android.telecomm.TelecommManager;
-import android.text.TextUtils;
 
 /**
  * Activity that handles system CALL actions and forwards them to {@link CallsManager}.
  * Handles all three CALL action types: CALL, CALL_PRIVILEGED, and CALL_EMERGENCY.
- *
- * Pre-L, only the system dialer was allowed to make outgoing emergency calls via the
- * CALL_PRIVILEGED action (which requires the system only CALL_PRIVILEGED permission).
- *
- * In L, the system dialer can continue to make outgoing emergency calls via CALL_PRIVILEGED.
- * Also, the user-selected default dialer and the system dialer will be granted the ability to make
- * emergency outgoing calls using the CALL action. In order to do this, they must call
- * startActivityForResult on the CALL intent to allow their package name to be passed to
- * {@link CallActivity}. Calling startActivity will continue to work on all non-emergency numbers
- * just like it did pre-L.
  */
 public class CallActivity extends Activity {
+
     private CallsManager mCallsManager = CallsManager.getInstance();
 
     /**
@@ -105,10 +92,8 @@
     private void processOutgoingCallIntent(Intent intent) {
         ContactInfo contactInfo = null;
         NewOutgoingCallIntentBroadcaster broadcaster =
-                new NewOutgoingCallIntentBroadcaster(mCallsManager, contactInfo, intent,
-                        isDefaultOrSystemDialer());
-        final boolean success = broadcaster.processIntent();
-        setResult(success ? RESULT_OK : RESULT_CANCELED);
+                new NewOutgoingCallIntentBroadcaster(mCallsManager, contactInfo, intent);
+        broadcaster.processIntent();
     }
 
     /**
@@ -133,26 +118,4 @@
         Log.d(this, "Processing incoming call from call service [%s]", descriptor);
         mCallsManager.processIncomingCallIntent(descriptor, clientExtras);
     }
-
-    private boolean isDefaultOrSystemDialer() {
-        final String packageName = getCallingPackage();
-        if (TextUtils.isEmpty(packageName)) {
-            return false;
-        }
-
-        final ComponentName defaultPhoneApp = PhoneApplication.getDefaultPhoneApplication(this);
-        if (defaultPhoneApp != null) {
-            if (TextUtils.equals(defaultPhoneApp.getPackageName(), packageName)) {
-                return true;
-            }
-        }
-
-        TelecommManager telecommManager = (TelecommManager) getSystemService(TELECOMM_SERVICE);
-        final ComponentName systemPhoneApp = telecommManager.getSystemPhoneApplication();
-        if (systemPhoneApp != null) {
-            return TextUtils.equals(systemPhoneApp.getPackageName(), packageName);
-        } else {
-            return false;
-        }
-    }
 }
diff --git a/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java b/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
index 3ddeaf2..c40fde5 100644
--- a/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
+++ b/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
@@ -84,18 +84,12 @@
     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, boolean isDefaultPhoneApp) {
+            Intent intent) {
         mCallsManager = callsManager;
         mContactInfo = contactInfo;
         mIntent = intent;
-        mIsDefaultOrSystemPhoneApp = isDefaultPhoneApp;
     }
 
     /**
@@ -153,10 +147,8 @@
      * - 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.
      */
-    boolean processIntent() {
+    void processIntent() {
         Log.v(this, "Processing call intent in OutgoingCallIntentBroadcaster.");
 
         final Context context = TelecommApp.getInstance();
@@ -166,7 +158,7 @@
 
         if (TextUtils.isEmpty(handle)) {
             Log.w(this, "Empty handle obtained from the call intent.");
-            return false;
+            return;
         }
 
         boolean isUriNumber = PhoneNumberUtils.isUriNumber(handle);
@@ -187,25 +179,21 @@
         String action = intent.getAction();
         if (Intent.ACTION_CALL.equals(action)) {
             if (isPotentialEmergencyNumber) {
-                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;
-                }
+                Log.w(this, "Cannot call potential emergency number %s with CALL Intent %s.",
+                        handle, intent);
+                launchSystemDialer(context, intent.getData());
             }
+            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 false;
+                return;
             }
             callImmediately = true;
         } else {
             Log.w(this, "Unhandled Intent %s. Ignoring and not placing call.", intent);
-            return false;
+            return;
         }
 
         if (callImmediately) {
@@ -224,7 +212,6 @@
         }
 
         broadcastIntent(intent, handle, context, !callImmediately);
-        return true;
     }
 
     /**