From 7d20f8273886411ffc864231d59f780e450de3db Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Thu, 19 Jun 2014 17:09:33 -0700 Subject: Fix Dialer tests Fix Dialer tests and also wrap all startActivity calls that have the potential to fail with a catch block for ActivityNotFoundException Change-Id: I02ce4b985eeb0e3e607b8008a333e02168acd378 --- src/com/android/dialer/DialtactsActivity.java | 3 ++- src/com/android/dialer/PhoneCallDetailsHelper.java | 1 + src/com/android/dialer/calllog/CallLogAdapter.java | 3 ++- src/com/android/dialer/dialpad/DialpadFragment.java | 9 +++------ src/com/android/dialer/interactions/PhoneNumberInteraction.java | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index d48b28e72..cbb2fe865 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -84,6 +84,7 @@ import com.android.dialer.list.PhoneFavoriteSquareTileView; import com.android.dialer.list.RegularSearchFragment; import com.android.dialer.list.SearchFragment; import com.android.dialer.list.SmartDialSearchFragment; +import com.android.dialer.util.DialerUtils; import com.android.dialer.widget.ActionBarController; import com.android.dialer.widget.SearchEditTextLayout; import com.android.dialer.widget.SearchEditTextLayout.OnBackButtonClickedListener; @@ -1113,7 +1114,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override public void onCallNumberDirectly(String phoneNumber) { Intent intent = CallUtil.getCallIntent(phoneNumber, getCallOrigin()); - startActivity(intent); + DialerUtils.startActivityWithErrorToast(this, intent); mClearSearchOnPause = true; } diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java index bb74cba71..f1b6f7f3b 100644 --- a/src/com/android/dialer/PhoneCallDetailsHelper.java +++ b/src/com/android/dialer/PhoneCallDetailsHelper.java @@ -185,6 +185,7 @@ public class PhoneCallDetailsHelper { } /** Sets the text of the header view for the details page of a phone call. */ + @NeededForTesting public void setCallDetailsHeader(TextView nameView, PhoneCallDetails details) { final CharSequence nameText; final CharSequence displayNumber = diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 249c30c41..f19b924fe 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -43,6 +43,7 @@ import com.android.contacts.common.util.UriUtils; import com.android.dialer.PhoneCallDetails; import com.android.dialer.PhoneCallDetailsHelper; import com.android.dialer.R; +import com.android.dialer.util.DialerUtils; import com.android.dialer.util.ExpirableCache; import com.google.common.annotations.VisibleForTesting; @@ -304,7 +305,7 @@ public class CallLogAdapter extends GroupingListAdapter final Intent intent = intentProvider.getIntent(mContext); // See IntentProvider.getCallDetailIntentProvider() for why this may be null. if (intent != null) { - mContext.startActivity(intent); + DialerUtils.startActivityWithErrorToast(mContext, intent); } } } diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index bb5880295..cc4275518 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -279,10 +279,7 @@ public class DialpadFragment extends Fragment * Return an Intent for launching voicemail screen. */ private static Intent getVoicemailIntent() { - final Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED, - Uri.fromParts("voicemail", "", null)); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - return intent; + return CallUtil.getCallIntent(Uri.fromParts("voicemail", "", null)); } private TelephonyManager getTelephonyManager() { @@ -986,7 +983,7 @@ public class DialpadFragment extends Fragment } public void callVoicemail() { - startActivity(getVoicemailIntent()); + DialerUtils.startActivityWithErrorToast(getActivity(), getVoicemailIntent()); hideAndClearDialpad(false); } @@ -1085,7 +1082,7 @@ public class DialpadFragment extends Fragment final Intent intent = CallUtil.getCallIntent(number, (getActivity() instanceof DialtactsActivity ? ((DialtactsActivity) getActivity()).getCallOrigin() : null)); - startActivity(intent); + DialerUtils.startActivityWithErrorToast(getActivity(), intent); hideAndClearDialpad(false); } } diff --git a/src/com/android/dialer/interactions/PhoneNumberInteraction.java b/src/com/android/dialer/interactions/PhoneNumberInteraction.java index 722b9b33e..b494fffd5 100644 --- a/src/com/android/dialer/interactions/PhoneNumberInteraction.java +++ b/src/com/android/dialer/interactions/PhoneNumberInteraction.java @@ -20,7 +20,6 @@ import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.app.FragmentManager; -import android.content.ContentValues; import android.content.Context; import android.content.CursorLoader; import android.content.DialogInterface; @@ -37,7 +36,6 @@ import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.CommonDataKinds.SipAddress; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; -import android.provider.ContactsContract.PinnedPositions; import android.provider.ContactsContract.RawContacts; import android.view.LayoutInflater; import android.view.View; @@ -55,6 +53,8 @@ import com.android.contacts.common.activity.TransactionSafeActivity; import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.R; import com.android.dialer.contact.ContactUpdateService; +import com.android.dialer.util.DialerUtils; + import com.google.common.annotations.VisibleForTesting; import java.util.ArrayList; @@ -325,7 +325,7 @@ public class PhoneNumberInteraction implements OnLoadCompleteListener { intent = CallUtil.getCallIntent(phoneNumber, callOrigin); break; } - context.startActivity(intent); + DialerUtils.startActivityWithErrorToast(context, intent); } /** -- cgit v1.2.3