summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.mk7
-rw-r--r--java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java7
-rw-r--r--java/com/android/dialer/assisteddialing/ConcreteCreator.java3
-rw-r--r--java/com/android/dialer/precall/impl/AssistedDialAction.java73
-rw-r--r--java/com/android/dialer/precall/impl/CallingAccountSelector.java114
-rw-r--r--java/com/android/dialer/precall/impl/PreCallImpl.java2
-rw-r--r--java/com/android/dialer/precall/impl/res/values/strings.xml22
7 files changed, 225 insertions, 3 deletions
diff --git a/Android.mk b/Android.mk
index 9defc7e45..e9841d9dc 100644
--- a/Android.mk
+++ b/Android.mk
@@ -81,6 +81,8 @@ EXCLUDE_EXTRA_PACKAGES := \
# We specify each package explicitly to glob resource files.
# find . -type f -name "AndroidManifest.xml" | uniq | sort | cut -c 8- | rev | cut -c 21- | rev | sed 's/\//./g' | sed 's/$/ \\/'
LOCAL_AAPT_FLAGS := \
+ com.android.assets.product \
+ com.android.assets.quantum \
com.android.bubble \
com.android.contacts.common \
com.android.dialer.about \
@@ -116,8 +118,11 @@ LOCAL_AAPT_FLAGS := \
com.android.dialer.main.impl \
com.android.dialer.notification \
com.android.dialer.oem \
+ com.android.dialer.phonelookup.database \
com.android.dialer.phonenumberutil \
com.android.dialer.postcall \
+ com.android.dialer.precall.impl \
+ com.android.dialer.preferredsim.impl \
com.android.dialer.searchfragment.common \
com.android.dialer.searchfragment.cp2 \
com.android.dialer.searchfragment.list \
@@ -129,7 +134,7 @@ LOCAL_AAPT_FLAGS := \
com.android.dialer.theme \
com.android.dialer.util \
com.android.dialer.voicemail.listui \
- com.android.dialer.voicemail.settings \
+ com.android.dialer.voicemail.settings \
com.android.dialer.voicemailstatus \
com.android.dialer.widget \
com.android.incallui \
diff --git a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
index 8156d97cf..6c6aebc0b 100644
--- a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
+++ b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
@@ -26,6 +26,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;
import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
@@ -116,6 +117,12 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
mListener = listener;
}
+ @Nullable
+ @VisibleForTesting
+ public SelectPhoneAccountListener getListener() {
+ return mListener;
+ }
+
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
diff --git a/java/com/android/dialer/assisteddialing/ConcreteCreator.java b/java/com/android/dialer/assisteddialing/ConcreteCreator.java
index c3721a7a8..806764567 100644
--- a/java/com/android/dialer/assisteddialing/ConcreteCreator.java
+++ b/java/com/android/dialer/assisteddialing/ConcreteCreator.java
@@ -22,6 +22,7 @@ import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
+import android.support.annotation.VisibleForTesting;
import android.support.v4.os.UserManagerCompat;
import android.telephony.TelephonyManager;
import com.android.dialer.assisteddialing.ui.R;
@@ -41,7 +42,7 @@ public final class ConcreteCreator {
// Floor set at N due to use of Optional.
protected static final int BUILD_CODE_FLOOR = Build.VERSION_CODES.N;
// Ceiling set at O because this feature will ship as part of the framework in P.
- protected static final int BUILD_CODE_CEILING = Build.VERSION_CODES.O;
+ @VisibleForTesting public static final int BUILD_CODE_CEILING = Build.VERSION_CODES.O;
/**
* Creates a new AssistedDialingMediator
diff --git a/java/com/android/dialer/precall/impl/AssistedDialAction.java b/java/com/android/dialer/precall/impl/AssistedDialAction.java
new file mode 100644
index 000000000..edf97cce3
--- /dev/null
+++ b/java/com/android/dialer/precall/impl/AssistedDialAction.java
@@ -0,0 +1,73 @@
+/*
+ * 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.impl;
+
+import android.annotation.TargetApi;
+import android.os.Build;
+import android.os.Bundle;
+import android.telecom.PhoneAccount;
+import android.telephony.TelephonyManager;
+import com.android.dialer.assisteddialing.AssistedDialingMediator;
+import com.android.dialer.assisteddialing.ConcreteCreator;
+import com.android.dialer.assisteddialing.TransformationInfo;
+import com.android.dialer.callintent.CallIntentBuilder;
+import com.android.dialer.common.Assert;
+import com.android.dialer.compat.telephony.TelephonyManagerCompat;
+import com.android.dialer.precall.PreCallAction;
+import com.android.dialer.precall.PreCallCoordinator;
+import com.android.dialer.util.CallUtil;
+import java.util.Optional;
+
+/** Rewrites the call URI with country code. TODO(erfanian): use phone account for multi SIM */
+public class AssistedDialAction implements PreCallAction {
+
+ @SuppressWarnings("AndroidApiChecker") // Use of optional
+ @TargetApi(Build.VERSION_CODES.N)
+ @Override
+ public void run(PreCallCoordinator coordinator) {
+ CallIntentBuilder builder = coordinator.getBuilder();
+ if (!builder.isAssistedDialAllowed()) {
+ return;
+ }
+ AssistedDialingMediator assistedDialingMediator =
+ ConcreteCreator.createNewAssistedDialingMediator(
+ coordinator.getActivity().getSystemService(TelephonyManager.class),
+ coordinator.getActivity());
+ if (!assistedDialingMediator.isPlatformEligible()) {
+ return;
+ }
+ builder.getOutgoingCallExtras().putBoolean(TelephonyManagerCompat.ALLOW_ASSISTED_DIAL, true);
+ String phoneNumber =
+ builder.getUri().getScheme().equals(PhoneAccount.SCHEME_TEL)
+ ? builder.getUri().getSchemeSpecificPart()
+ : "";
+ Optional<TransformationInfo> transformedNumber =
+ assistedDialingMediator.attemptAssistedDial(phoneNumber);
+ if (transformedNumber.isPresent()) {
+ Bundle assistedDialingExtras = transformedNumber.get().toBundle();
+ builder.getOutgoingCallExtras().putBoolean(TelephonyManagerCompat.IS_ASSISTED_DIALED, true);
+ builder
+ .getOutgoingCallExtras()
+ .putBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS, assistedDialingExtras);
+ builder.setUri(
+ CallUtil.getCallUri(Assert.isNotNull(transformedNumber.get().transformedNumber())));
+ }
+ }
+
+ @Override
+ public void onDiscard() {}
+}
diff --git a/java/com/android/dialer/precall/impl/CallingAccountSelector.java b/java/com/android/dialer/precall/impl/CallingAccountSelector.java
new file mode 100644
index 000000000..ca8798c5d
--- /dev/null
+++ b/java/com/android/dialer/precall/impl/CallingAccountSelector.java
@@ -0,0 +1,114 @@
+/*
+ * 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.impl;
+
+import android.app.Activity;
+import android.support.annotation.MainThread;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
+import android.telecom.PhoneAccount;
+import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment;
+import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener;
+import com.android.dialer.callintent.CallIntentBuilder;
+import com.android.dialer.common.Assert;
+import com.android.dialer.precall.PreCallAction;
+import com.android.dialer.precall.PreCallCoordinator;
+import java.util.List;
+
+/** PreCallAction to select which phone account to call with. Ignored if there's only one account */
+@SuppressWarnings("MissingPermission")
+public class CallingAccountSelector implements PreCallAction {
+
+ @VisibleForTesting static final String TAG_CALLING_ACCOUNT_SELECTOR = "CallingAccountSelector";
+
+ private SelectPhoneAccountDialogFragment selectPhoneAccountDialogFragment;
+
+ private boolean isDiscarding;
+
+ @Override
+ public void run(PreCallCoordinator coordinator) {
+ CallIntentBuilder builder = coordinator.getBuilder();
+ if (builder.getPhoneAccountHandle() != null) {
+ return;
+ }
+ Activity activity = coordinator.getActivity();
+ TelecomManager telecomManager = activity.getSystemService(TelecomManager.class);
+ List<PhoneAccountHandle> accounts = telecomManager.getCallCapablePhoneAccounts();
+ if (accounts.size() <= 1) {
+ return;
+ }
+ boolean isVoicemail = builder.getUri().getScheme().equals(PhoneAccount.SCHEME_VOICEMAIL);
+
+ if (!isVoicemail) {
+ PhoneAccountHandle defaultPhoneAccount =
+ telecomManager.getDefaultOutgoingPhoneAccount(builder.getUri().getScheme());
+ if (defaultPhoneAccount != null) {
+ builder.setPhoneAccountHandle(defaultPhoneAccount);
+ return;
+ }
+ }
+
+ selectPhoneAccountDialogFragment =
+ SelectPhoneAccountDialogFragment.newInstance(
+ R.string.pre_call_select_phone_account,
+ false /* canSetDefault */, // TODO(twyen): per contact defaults
+ accounts,
+ new SelectedListener(coordinator, coordinator.startPendingAction()),
+ null /* call ID */);
+ selectPhoneAccountDialogFragment.show(
+ activity.getFragmentManager(), TAG_CALLING_ACCOUNT_SELECTOR);
+ }
+
+ @Override
+ public void onDiscard() {
+ isDiscarding = true;
+ selectPhoneAccountDialogFragment.dismiss();
+ }
+
+ private class SelectedListener extends SelectPhoneAccountListener {
+
+ private final PreCallCoordinator coordinator;
+ private final PreCallCoordinator.PendingAction listener;
+
+ public SelectedListener(
+ @NonNull PreCallCoordinator builder, @NonNull PreCallCoordinator.PendingAction listener) {
+ this.coordinator = Assert.isNotNull(builder);
+ this.listener = Assert.isNotNull(listener);
+ }
+
+ @MainThread
+ @Override
+ public void onPhoneAccountSelected(
+ PhoneAccountHandle selectedAccountHandle, boolean setDefault, @Nullable String callId) {
+ coordinator.getBuilder().setPhoneAccountHandle(selectedAccountHandle);
+ listener.finish();
+ }
+
+ @MainThread
+ @Override
+ public void onDialogDismissed(@Nullable String callId) {
+ if (isDiscarding) {
+ return;
+ }
+ coordinator.abortCall();
+ listener.finish();
+ }
+ }
+}
diff --git a/java/com/android/dialer/precall/impl/PreCallImpl.java b/java/com/android/dialer/precall/impl/PreCallImpl.java
index ac9750ef2..fc2eff8b1 100644
--- a/java/com/android/dialer/precall/impl/PreCallImpl.java
+++ b/java/com/android/dialer/precall/impl/PreCallImpl.java
@@ -33,7 +33,7 @@ public class PreCallImpl implements PreCall {
@Override
public ImmutableList<PreCallAction> getActions() {
- return ImmutableList.of();
+ return ImmutableList.of(new CallingAccountSelector(), new AssistedDialAction());
}
@NonNull
diff --git a/java/com/android/dialer/precall/impl/res/values/strings.xml b/java/com/android/dialer/precall/impl/res/values/strings.xml
new file mode 100644
index 000000000..894394662
--- /dev/null
+++ b/java/com/android/dialer/precall/impl/res/values/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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
+ -->
+<resources>
+ <!-- Title of the dialog to select which SIM to call with before making a call, if the device has
+ multiple SIMs [CHAR LIMIT=40]-->
+ <string name="pre_call_select_phone_account">Call with</string>
+
+</resources> \ No newline at end of file