summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2014-11-04 00:51:26 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-11-04 00:51:27 +0000
commitac0b6dfffe08e027eac03973f99fdcf50edb001f (patch)
tree5e1ad7b0575e413aade61f477ee30ea45605ea0e
parentbd421b68ec17cd33ee3dd1d2613f5637299e57d9 (diff)
parent18c52ffec7896bbbb7f161994b4453d91fcc79ef (diff)
Merge "Adn queries for multi-SIM. (1/3)" into lmp-mr1-dev
-rw-r--r--src/com/android/dialer/SpecialCharSequenceMgr.java86
-rw-r--r--src/com/android/dialer/dialpad/DialpadFragment.java2
2 files changed, 64 insertions, 24 deletions
diff --git a/src/com/android/dialer/SpecialCharSequenceMgr.java b/src/com/android/dialer/SpecialCharSequenceMgr.java
index 2bf1afcf9..45c22fd55 100644
--- a/src/com/android/dialer/SpecialCharSequenceMgr.java
+++ b/src/com/android/dialer/SpecialCharSequenceMgr.java
@@ -43,10 +43,8 @@ import com.android.contacts.common.database.NoNullCursorAsyncQueryHandler;
import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment;
import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener;
import com.android.dialer.calllog.PhoneAccountUtils;
-import com.android.incallui.InCallPresenter;
import java.util.Arrays;
-import java.util.List;
import java.util.ArrayList;
import java.util.List;
@@ -151,7 +149,7 @@ public class SpecialCharSequenceMgr {
* This code works alongside the Asynchronous query handler {@link QueryHandler}
* and query cancel handler implemented in {@link SimContactQueryCookie}.
*/
- static boolean handleAdnEntry(Context context, String input, EditText textField) {
+ static boolean handleAdnEntry(final Context context, String input, EditText textField) {
/* ADN entries are of the form "N(N)(N)#" */
TelephonyManager telephonyManager =
@@ -175,7 +173,7 @@ public class SpecialCharSequenceMgr {
if ((len > 1) && (len < 5) && (input.endsWith("#"))) {
try {
// get the ordinal number of the sim contact
- int index = Integer.parseInt(input.substring(0, len-1));
+ final int index = Integer.parseInt(input.substring(0, len-1));
// The original code that navigated to a SIM Contacts list view did not
// highlight the requested contact correctly, a requirement for PTCRB
@@ -185,10 +183,10 @@ public class SpecialCharSequenceMgr {
// the dialer text field.
// create the async query handler
- QueryHandler handler = new QueryHandler (context.getContentResolver());
+ final QueryHandler handler = new QueryHandler (context.getContentResolver());
// create the cookie object
- SimContactQueryCookie sc = new SimContactQueryCookie(index - 1, handler,
+ final SimContactQueryCookie sc = new SimContactQueryCookie(index - 1, handler,
ADN_QUERY_TOKEN);
// setup the cookie fields
@@ -205,18 +203,38 @@ public class SpecialCharSequenceMgr {
sc.progressDialog.getWindow().addFlags(
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
- // display the progress dialog
- sc.progressDialog.show();
-
- // run the query.
- handler.startQuery(ADN_QUERY_TOKEN, sc, Uri.parse("content://icc/adn"),
- new String[]{ADN_PHONE_NUMBER_COLUMN_NAME}, null, null, null);
-
- if (sPreviousAdnQueryHandler != null) {
- // It is harmless to call cancel() even after the handler's gone.
- sPreviousAdnQueryHandler.cancel();
+ final TelecomManager telecomManager =
+ (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
+ List<PhoneAccountHandle> phoneAccountHandles =
+ PhoneAccountUtils.getSubscriptionPhoneAccounts(context);
+
+ boolean hasUserSelectedDefault = hasDefaultSubscriptionAccount(
+ telecomManager.getUserSelectedOutgoingPhoneAccount(), phoneAccountHandles);
+
+ if (phoneAccountHandles.size() == 1 || hasUserSelectedDefault) {
+ Uri uri = telecomManager.getAdnUriForPhoneAccount(null);
+ handleAdnQuery(handler, sc, uri);
+ } else if (phoneAccountHandles.size() > 1){
+ SelectPhoneAccountListener listener = new SelectPhoneAccountListener() {
+ @Override
+ public void onPhoneAccountSelected(PhoneAccountHandle selectedAccountHandle,
+ boolean setDefault) {
+ Uri uri =
+ telecomManager.getAdnUriForPhoneAccount(selectedAccountHandle);
+ handleAdnQuery(handler, sc, uri);
+ //TODO: show error dialog if result isn't valid
+ }
+ @Override
+ public void onDialogDismissed() {}
+ };
+
+ SelectPhoneAccountDialogFragment.showAccountDialog(
+ ((Activity) context).getFragmentManager(), false, phoneAccountHandles,
+ listener);
+ } else {
+ return false;
}
- sPreviousAdnQueryHandler = handler;
+
return true;
} catch (NumberFormatException ex) {
// Ignore
@@ -225,6 +243,27 @@ public class SpecialCharSequenceMgr {
return false;
}
+ private static void handleAdnQuery(QueryHandler handler, SimContactQueryCookie cookie,
+ Uri uri) {
+ if (handler == null || cookie == null || uri == null) {
+ Log.w(TAG, "queryAdn parameters incorrect");
+ return;
+ }
+
+ // display the progress dialog
+ cookie.progressDialog.show();
+
+ // run the query.
+ handler.startQuery(ADN_QUERY_TOKEN, cookie, uri, new String[]{ADN_PHONE_NUMBER_COLUMN_NAME},
+ null, null, null);
+
+ if (sPreviousAdnQueryHandler != null) {
+ // It is harmless to call cancel() even after the handler's gone.
+ sPreviousAdnQueryHandler.cancel();
+ }
+ sPreviousAdnQueryHandler = handler;
+ }
+
static boolean handlePinEntry(Context context, final String input) {
if ((input.startsWith("**04") || input.startsWith("**05")) && input.endsWith("#")) {
final TelecomManager telecomManager =
@@ -411,12 +450,13 @@ public class SpecialCharSequenceMgr {
// get the EditText to update or see if the request was cancelled.
EditText text = sc.getTextField();
- // if the textview is valid, and the cursor is valid and postionable
- // on the Nth number, then we update the text field and display a
- // toast indicating the caller name.
+ // if the TextView is valid, and the cursor is valid and positionable on the
+ // Nth number, then we update the text field and display a toast indicating the
+ // caller name.
if ((c != null) && (text != null) && (c.moveToPosition(sc.contactNum))) {
String name = c.getString(c.getColumnIndexOrThrow(ADN_NAME_COLUMN_NAME));
- String number = c.getString(c.getColumnIndexOrThrow(ADN_PHONE_NUMBER_COLUMN_NAME));
+ String number =
+ c.getString(c.getColumnIndexOrThrow(ADN_PHONE_NUMBER_COLUMN_NAME));
// fill the text in.
text.getText().replace(0, 0, number);
@@ -434,8 +474,8 @@ public class SpecialCharSequenceMgr {
public void cancel() {
mCanceled = true;
- // Ask AsyncQueryHandler to cancel the whole request. This will fails when the
- // query already started.
+ // Ask AsyncQueryHandler to cancel the whole request. This will fail when the query is
+ // already started.
cancelOperation(ADN_QUERY_TOKEN);
}
}
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index c6bbe25b5..5695f1c48 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -284,7 +284,7 @@ public class DialpadFragment extends Fragment
@Override
public void afterTextChanged(Editable input) {
- // When DTMF dialpad buttons are being pressed, we delay SpecialCharSequencMgr sequence,
+ // When DTMF dialpad buttons are being pressed, we delay SpecialCharSequenceMgr sequence,
// since some of SpecialCharSequenceMgr's behavior is too abrupt for the "touch-down"
// behavior.
if (!mDigitsFilledByIntent &&