Add CALL* intent handling to Telecomm.

Adds a new activity to handle CALL, CALL_PRIVILEGED and CALL_EMERGENCY
withing Telecomm. Shows a toast upon receipt of intent.

Change-Id: Ia9ea7b0abd47d0f423c04ddbaa04452c31ca2318
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4147677..0450a28 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -16,8 +16,7 @@
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
-        package="com.android.telecomm"
->
+        package="com.android.telecomm">
     <!-- Prevents the activity manager from delaying any activity-start
          requests by this package, including requests immediately after
          the user presses "home". -->
@@ -29,5 +28,120 @@
             android:label="@string/telecommAppLabel"
             android:icon="@mipmap/ic_launcher_phone"
             android:supportsRtl="true">
+
+        <!-- CALL vs CALL_PRIVILEGED vs CALL_EMERGENCY
+             We have three different intents through which a call can be initiated each with its
+             own behavior.
+             1) CALL - Expected from any third party app with CALL_PHONE permission. Through this
+             intent, an app can call any number except emergency numbers.
+             2) CALL_PRIVILEGED - Expected from the dialer app and requires CALL_PRIVILEGED
+             permission, which is only held by the system dialer and the emergency dialer at the
+             time of this writing. Through this intent, an app can call any number including
+             emergency numbers.
+             3) CALL_EMERGENCY - Expected from the emergency dialer app and requires CALL_PRIVILEGED
+             permission. Through this intent, an app can call *only* emergency numbers. -->
+
+        <!-- Activity that starts the outgoing call process by listening to CALL intent which
+             contain contact information in the intent's data. CallActivity handles any data
+             URL with the schemes "tel", "sip", and "voicemail". It also handles URLs linked to
+             contacts provider entries. Any data not fitting the schema described is ignored. -->
+        <activity android:name="CallActivity"
+                android:theme="@android:style/Theme.NoDisplay"
+                android:permission="android.permission.CALL_PHONE"
+                android:excludeFromRecents="true">
+            <!-- CALL action intent filters for the various ways of initiating an outgoing call. -->
+            <intent-filter>
+                <action android:name="android.intent.action.CALL" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="tel" />
+            </intent-filter>
+            <!-- Specify an icon for SIP calls so that quick contacts widget shows a special SIP
+                 icon for calls to SIP addresses. -->
+            <intent-filter android:icon="@drawable/ic_launcher_sip_call">
+                <action android:name="android.intent.action.CALL" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="sip" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.CALL" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="voicemail" />
+            </intent-filter>
+            <!-- Omit default category below so that all Intents sent to this filter must be
+                 explicit. -->
+            <intent-filter>
+                <action android:name="android.intent.action.CALL" />
+                <data android:mimeType="vnd.android.cursor.item/phone" />
+                <data android:mimeType="vnd.android.cursor.item/phone_v2" />
+                <data android:mimeType="vnd.android.cursor.item/person" />
+            </intent-filter>
+        </activity>
+
+        <!-- Works like CallActivity with CALL_PRIVILEGED instead of CALL intent.
+             CALL_PRIVILEGED allows calls to emergency numbers unlike CALL which disallows it.
+             Intent-sender must have the CALL_PRIVILEGED permission or the broadcast will not be
+             processed. High priority of 1000 is used in all intent filters to prevent anything but
+             the system from processing this intent (b/8871505). -->
+        <activity-alias android:name="PrivilegedCallActivity"
+                android:targetActivity="CallActivity"
+                android:permission="android.permission.CALL_PRIVILEGED">
+            <intent-filter android:priority="1000">
+                <action android:name="android.intent.action.CALL_PRIVILEGED" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="tel" />
+            </intent-filter>
+            <intent-filter android:priority="1000"
+                    android:icon="@drawable/ic_launcher_sip_call">
+                <action android:name="android.intent.action.CALL_PRIVILEGED" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="sip" />
+            </intent-filter>
+            <intent-filter android:priority="1000">
+                <action android:name="android.intent.action.CALL_PRIVILEGED" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="voicemail" />
+            </intent-filter>
+            <intent-filter android:priority="1000">
+                <action android:name="android.intent.action.CALL_PRIVILEGED" />
+                <data android:mimeType="vnd.android.cursor.item/phone" />
+                <data android:mimeType="vnd.android.cursor.item/phone_v2" />
+                <data android:mimeType="vnd.android.cursor.item/person" />
+            </intent-filter>
+        </activity-alias>
+
+        <!-- Works like CallActivity with CALL_EMERGENCY instead of CALL intent.
+             CALL_EMERGENCY allows calls *only* to emergency numbers. Intent-sender must have the
+             CALL_PRIVILEGED permission or the broadcast will not be processed. High priority of
+             1000 is used in all intent filters to prevent anything but the system from processing
+             this intent (b/8871505). -->
+        <!-- TODO(santoscordon): Is there really a notion of an emergency SIP number? If not, can
+             that scheme be removed from this activity? -->
+        <activity-alias android:name="EmergencyCallActivity"
+                android:targetActivity="CallActivity"
+                android:permission="android.permission.CALL_PRIVILEGED">
+            <intent-filter android:priority="1000">
+                <action android:name="android.intent.action.CALL_EMERGENCY" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="tel" />
+            </intent-filter>
+            <intent-filter android:priority="1000"
+                    android:icon="@drawable/ic_launcher_sip_call">
+                <action android:name="android.intent.action.CALL_EMERGENCY" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="sip" />
+            </intent-filter>
+            <intent-filter android:priority="1000">
+                <action android:name="android.intent.action.CALL_EMERGENCY" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="voicemail" />
+            </intent-filter>
+            <intent-filter android:priority="1000">
+                <action android:name="android.intent.action.CALL_EMERGENCY" />
+                <data android:mimeType="vnd.android.cursor.item/phone" />
+                <data android:mimeType="vnd.android.cursor.item/phone_v2" />
+                <data android:mimeType="vnd.android.cursor.item/person" />
+            </intent-filter>
+        </activity-alias>
+
     </application>
 </manifest>