summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/precall
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2017-11-13 14:51:51 -0800
committerzachh <zachh@google.com>2017-11-18 04:21:36 +0000
commitbee76bf00cfa677fc85c643b53af0cfebee3e2e1 (patch)
tree3e7906e8bc0ae69e8ed8003b19dd5fcce20edeba /java/com/android/dialer/precall
parent1ecb3e2751218d377cfd75d9623c6715174c8dc5 (diff)
Allow external apps to start pre-call flow
This CL adds an activity that will forward parameters to PreCall so external apps like contact can utilize SIM selection or assisted dialing features. The caller needs to have CALL_PHONE permission. Bug: 64213352 Test: LaunchPreCallActivityTest PiperOrigin-RevId: 175591732 Change-Id: I096ea022d5ed87c29ffb191cd1bdb04e3a17c945
Diffstat (limited to 'java/com/android/dialer/precall')
-rw-r--r--java/com/android/dialer/precall/externalreceiver/AndroidManifest.xml40
-rw-r--r--java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java60
2 files changed, 100 insertions, 0 deletions
diff --git a/java/com/android/dialer/precall/externalreceiver/AndroidManifest.xml b/java/com/android/dialer/precall/externalreceiver/AndroidManifest.xml
new file mode 100644
index 000000000..b1c625a0f
--- /dev/null
+++ b/java/com/android/dialer/precall/externalreceiver/AndroidManifest.xml
@@ -0,0 +1,40 @@
+<!--
+ ~ Copyright (C) 2017 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
+ -->
+<manifest
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.dialer.precall.externalreceiver">
+
+ <application>
+ <activity
+ android:excludeFromRecents="true"
+ android:exported="true"
+ android:name="com.android.dialer.precall.externalreceiver.LaunchPreCallActivity"
+ android:noHistory="true"
+ android:permission="android.permission.CALL_PHONE"
+ android:theme="@style/Theme.PreCall.DialogHolder">
+ <intent-filter>
+ <action android:name="com.android.dialer.LAUNCH_PRE_CALL"/>
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="tel" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="com.android.dialer.LAUNCH_PRE_CALL"/>
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="voicemail" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java b/java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java
new file mode 100644
index 000000000..121e6a6c9
--- /dev/null
+++ b/java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2017 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.dialer.precall.externalreceiver;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import com.android.dialer.callintent.CallInitiationType.Type;
+import com.android.dialer.callintent.CallIntentBuilder;
+import com.android.dialer.precall.PreCall;
+
+/**
+ * Activity that forwards to {@link PreCall#start(Context, CallIntentBuilder)} so the pre-call flow
+ * can be initiated by external apps. This activity is exported but can only be started by apps with
+ * {@link android.Manifest.permission#CALL_PHONE}. Keyguard will be triggered if phone is locked.
+ *
+ * @see CallIntentBuilder
+ */
+public class LaunchPreCallActivity extends Activity {
+
+ public static final String ACTION_LAUNCH_PRE_CALL = "com.android.dialer.LAUNCH_PRE_CALL";
+
+ public static final String EXTRA_PHONE_ACCOUNT_HANDLE = "phone_account_handle";
+
+ public static final String EXTRA_IS_VIDEO_CALL = "is_video_call";
+
+ public static final String EXTRA_CALL_SUBJECT = "call_subject";
+
+ public static final String EXTRA_ALLOW_ASSISTED_DIAL = "allow_assisted_dial";
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Intent intent = getIntent();
+ CallIntentBuilder builder = new CallIntentBuilder(intent.getData(), Type.EXTERNAL_INITIATION);
+ builder
+ .setPhoneAccountHandle(intent.getParcelableExtra(EXTRA_PHONE_ACCOUNT_HANDLE))
+ .setIsVideoCall(intent.getBooleanExtra(EXTRA_IS_VIDEO_CALL, false))
+ .setCallSubject(intent.getStringExtra(EXTRA_CALL_SUBJECT))
+ .setAllowAssistedDial(intent.getBooleanExtra(EXTRA_ALLOW_ASSISTED_DIAL, false));
+ PreCall.start(this, builder);
+ finish();
+ }
+}