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>
diff --git a/res/drawable-hdpi/ic_launcher_sip_call.png b/res/drawable-hdpi/ic_launcher_sip_call.png
new file mode 100644
index 0000000..f1aa979
--- /dev/null
+++ b/res/drawable-hdpi/ic_launcher_sip_call.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_launcher_sip_call.png b/res/drawable-mdpi/ic_launcher_sip_call.png
new file mode 100644
index 0000000..d10b6bf
--- /dev/null
+++ b/res/drawable-mdpi/ic_launcher_sip_call.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_launcher_sip_call.png b/res/drawable-xhdpi/ic_launcher_sip_call.png
new file mode 100644
index 0000000..e9f655b
--- /dev/null
+++ b/res/drawable-xhdpi/ic_launcher_sip_call.png
Binary files differ
diff --git a/src/com/android/telecomm/CallActivity.java b/src/com/android/telecomm/CallActivity.java
new file mode 100644
index 0000000..1d48962
--- /dev/null
+++ b/src/com/android/telecomm/CallActivity.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.telecomm;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.Toast;
+
+/**
+ * Activity that handles system CALL actions and forwards them to {@link CallsManager}.
+ * Handles all three CALL action types: CALL, CALL_PRIVILEGED, and CALL_EMERGENCY.
+ * TODO(santoscordon): Connect with CallsManager.
+ */
+public class CallActivity extends Activity {
+ private static final String TAG = CallActivity.class.getSimpleName();
+ private static boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+
+ /**
+ * {@inheritDoc}
+ *
+ * This method is the single point of entry for the CALL intent, which is used by built-in apps
+ * like Contacts & Dialer, as well as 3rd party apps to initiate outgoing calls.
+ */
+ @Override
+ protected void onCreate(Bundle bundle) {
+ super.onCreate(bundle);
+
+ // TODO(santoscordon): This activity will be displayed until the next screen which could be
+ // the in-call UI and error dialog or potentially a call-type selection dialog.
+ // Traditionally, this has been a black screen with a spinner. We need to reevaluate if this
+ // is still desired and add back if necessary. Currently, the activity is set to NoDisplay
+ // theme which means it shows no UI.
+
+ Intent intent = getIntent();
+ Configuration configuration = getResources().getConfiguration();
+
+ if (DEBUG) {
+ Log.d(TAG, "onCreate: this = " + this + ", bundle= " + bundle);
+ Log.d(TAG, " - intent = " + intent);
+ Log.d(TAG, " - configuration = " + configuration);
+ }
+
+ // TODO(santoscordon): Figure out if there is something to restore from bundle.
+ // See OutgoingCallBroadcaster in services/Telephony for more.
+
+ processIntent(intent);
+
+ // TODO(santoscordon): Remove this finish() once this app does more than just show a toast.
+ finish();
+
+ if (DEBUG) {
+ Log.d(TAG, "onCreate: end");
+ }
+ }
+
+ /**
+ * Processes CALL, CALL_PRIVILEGED, and CALL_EMERGENCY intents.
+ *
+ * @param intent Call intent containing data about the handle to call.
+ */
+ private void processIntent(Intent intent) {
+ // TODO(santoscordon): Pass intent data through to CallsManager. At the moment, we just
+ // display a toast of the data.
+ String toastContent = "[" + intent.getAction() + "] " + intent.getDataString();
+ Toast.makeText(this, toastContent, Toast.LENGTH_LONG).show();
+ }
+}