From b1dff5e869abe3fa558f639ca24c1a856d515306 Mon Sep 17 00:00:00 2001 From: Garik Badalyan Date: Tue, 24 Mar 2015 10:46:01 -0700 Subject: Fix the dial string to include the + sign added by user for VT call - The smart dial search normalizes the dial string and removes anything other than digits - Add a fix to add the + sign back to the normalized string if original typed number had a + sign - Add a check for prohibited numbers before making a call and display an error dialog Change-Id: Ib36462be573ce4fecc8821980226ae2920041cd2 --- src/com/android/dialer/list/SearchFragment.java | 40 ++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java index e50d0d89e..9abd7b048 100644 --- a/src/com/android/dialer/list/SearchFragment.java +++ b/src/com/android/dialer/list/SearchFragment.java @@ -16,10 +16,12 @@ package com.android.dialer.list; import android.app.Activity; +import android.app.DialogFragment; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.text.TextUtils; +import android.util.Log; import android.view.View; import android.view.animation.Interpolator; import android.widget.AbsListView; @@ -32,12 +34,14 @@ import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; import com.android.contacts.common.list.PhoneNumberPickerFragment; import com.android.contacts.common.util.ViewUtil; import com.android.contacts.commonbind.analytics.AnalyticsUtil; +import com.android.dialer.dialpad.DialpadFragment.ErrorDialogFragment; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.util.DialerUtils; import com.android.phone.common.animation.AnimUtils; public class SearchFragment extends PhoneNumberPickerFragment { + private static final String TAG = "SearchFragment"; private OnListFragmentScrolledListener mActivityScrollListener; @@ -137,6 +141,32 @@ public class SearchFragment extends PhoneNumberPickerFragment { mAddToContactNumber = addToContactNumber; } + /** + * Return true if phone number is prohibited by a value - + * (R.string.config_prohibited_phone_number_regexp) in the config files. False otherwise. + */ + public boolean checkForProhibitedPhoneNumber(String number) { + // Regular expression prohibiting manual phone call. Can be empty i.e. "no rule". + String prohibitedPhoneNumberRegexp = getResources().getString( + R.string.config_prohibited_phone_number_regexp); + + // "persist.radio.otaspdial" is a temporary hack needed for one carrier's automated + // test equipment. + if (number != null + && !TextUtils.isEmpty(prohibitedPhoneNumberRegexp) + && number.matches(prohibitedPhoneNumberRegexp)) { + Log.d(TAG, "The phone number is prohibited explicitly by a rule."); + if (getActivity() != null) { + DialogFragment dialogFragment = ErrorDialogFragment.newInstance( + R.string.dialog_phone_call_prohibited_message); + dialogFragment.show(getFragmentManager(), "phone_prohibited_dialog"); + } + + return true; + } + return false; + } + @Override protected ContactEntryListAdapter createListAdapter() { DialerPhoneNumberListAdapter adapter = new DialerPhoneNumberListAdapter(getActivity()); @@ -151,14 +181,16 @@ public class SearchFragment extends PhoneNumberPickerFragment { final int shortcutType = adapter.getShortcutTypeFromPosition(position); final OnPhoneNumberPickerActionListener listener; + boolean ret = checkForProhibitedPhoneNumber(mAddToContactNumber); + switch (shortcutType) { case DialerPhoneNumberListAdapter.SHORTCUT_INVALID: super.onItemClick(position, id); break; case DialerPhoneNumberListAdapter.SHORTCUT_DIRECT_CALL: listener = getOnPhoneNumberPickerListener(); - if (listener != null) { - listener.onCallNumberDirectly(getQueryString()); + if (listener != null && !ret) { + listener.onCallNumberDirectly(mAddToContactNumber); } break; case DialerPhoneNumberListAdapter.SHORTCUT_ADD_NUMBER_TO_CONTACTS: @@ -170,8 +202,8 @@ public class SearchFragment extends PhoneNumberPickerFragment { break; case DialerPhoneNumberListAdapter.SHORTCUT_MAKE_VIDEO_CALL: listener = getOnPhoneNumberPickerListener(); - if (listener != null) { - listener.onCallNumberDirectly(getQueryString(), true /* isVideoCall */); + if (listener != null && !ret) { + listener.onCallNumberDirectly(mAddToContactNumber, true /* isVideoCall */); } break; } -- cgit v1.2.3 From d3ffa4914baebe668d540fc966efddd0c89a92a2 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Fri, 3 Apr 2015 16:40:05 -0700 Subject: Cannot direct dial or video call from Dialer search results. - Change made in partner CL introduced a regression in dialing from the search results: https://partner-android-review.googlesource.com/#/c/206297/ The problem with that change is that it was intended to ensure that the + was not stripped off when dialing from the dial pad. It had the unintential impact of rendering direct dial from the search box inoperative. since mAddToContactNumber was null in this case. Bug: 20068746 Change-Id: Ic3a75ccf00164e7c865cc633a6a16d1699227ed2 --- src/com/android/dialer/list/SearchFragment.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java index 9abd7b048..1c88c4e81 100644 --- a/src/com/android/dialer/list/SearchFragment.java +++ b/src/com/android/dialer/list/SearchFragment.java @@ -180,9 +180,10 @@ public class SearchFragment extends PhoneNumberPickerFragment { final DialerPhoneNumberListAdapter adapter = (DialerPhoneNumberListAdapter) getAdapter(); final int shortcutType = adapter.getShortcutTypeFromPosition(position); final OnPhoneNumberPickerActionListener listener; + final String phoneNumber = TextUtils.isEmpty(mAddToContactNumber) ? + adapter.getQueryString() : mAddToContactNumber; - boolean ret = checkForProhibitedPhoneNumber(mAddToContactNumber); - + boolean ret = checkForProhibitedPhoneNumber(phoneNumber); switch (shortcutType) { case DialerPhoneNumberListAdapter.SHORTCUT_INVALID: super.onItemClick(position, id); @@ -190,7 +191,7 @@ public class SearchFragment extends PhoneNumberPickerFragment { case DialerPhoneNumberListAdapter.SHORTCUT_DIRECT_CALL: listener = getOnPhoneNumberPickerListener(); if (listener != null && !ret) { - listener.onCallNumberDirectly(mAddToContactNumber); + listener.onCallNumberDirectly(phoneNumber); } break; case DialerPhoneNumberListAdapter.SHORTCUT_ADD_NUMBER_TO_CONTACTS: @@ -203,7 +204,7 @@ public class SearchFragment extends PhoneNumberPickerFragment { case DialerPhoneNumberListAdapter.SHORTCUT_MAKE_VIDEO_CALL: listener = getOnPhoneNumberPickerListener(); if (listener != null && !ret) { - listener.onCallNumberDirectly(mAddToContactNumber, true /* isVideoCall */); + listener.onCallNumberDirectly(phoneNumber, true /* isVideoCall */); } break; } -- cgit v1.2.3