From 24d034f92998a52868c10039e9c728f9ab5a44aa Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Wed, 1 Jul 2015 12:34:50 -0700 Subject: Fix dialer monkey NPEs Monkey tests exposed a bug in Dialer where certain call shortcuts could show up if contacts permissions were disabled and the UI was changing quickly. Don't enable shortcuts by default, and make sure to correctly disable all shortcuts in the case of missing permissions. Bug: 22225052 Change-Id: Icdd81412f695860eb322d7ccdc30555591c584d0 --- src/com/android/dialer/DialtactsActivity.java | 6 ++++++ src/com/android/dialer/list/DialerPhoneNumberListAdapter.java | 11 ++++++----- src/com/android/dialer/list/SearchFragment.java | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index b8a1d4dce..237073969 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -903,6 +903,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override public void onNewIntent(Intent newIntent) { setIntent(newIntent); + mStateSaved = false; displayFragment(newIntent); @@ -1215,6 +1216,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override public void onCallNumberDirectly(String phoneNumber, boolean isVideoCall) { + if (phoneNumber == null) { + // Invalid phone number, but let the call go through so that InCallUI can show + // an error message. + phoneNumber = ""; + } Intent intent = isVideoCall ? IntentUtil.getVideoCallIntent(phoneNumber, getCallOrigin()) : IntentUtil.getCallIntent(phoneNumber, getCallOrigin()); diff --git a/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java b/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java index 6c0ecf72b..401b0b641 100644 --- a/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java +++ b/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java @@ -44,11 +44,6 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { super(context); mCountryIso = GeoUtil.getCurrentCountryIso(context); - - // Enable all shortcuts by default - for (int i = 0; i < mShortcutEnabled.length; i++) { - mShortcutEnabled[i] = true; - } } @Override @@ -67,6 +62,12 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { return count; } + public void disableAllShortcuts() { + for (int i = 0; i < mShortcutEnabled.length; i++) { + mShortcutEnabled[i] = false; + } + } + @Override public int getItemViewType(int position) { final int shortcut = getShortcutTypeFromPosition(position); diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java index 1f33d5b75..106545eaf 100644 --- a/src/com/android/dialer/list/SearchFragment.java +++ b/src/com/android/dialer/list/SearchFragment.java @@ -345,7 +345,9 @@ public class SearchFragment extends PhoneNumberPickerFragment { super.startLoading(); } else if (TextUtils.isEmpty(getQueryString())) { // Clear out any existing call shortcuts. - getAdapter().setQueryString(null); + final DialerPhoneNumberListAdapter adapter = + (DialerPhoneNumberListAdapter) getAdapter(); + adapter.disableAllShortcuts(); } } -- cgit v1.2.3