Dynamically check for permission denials
Don't crash when performing certain operations that the
dialer might not have permissions to execute:
* Access voicemail provider
* Certain TelecomManager methods
Add a class TelecomUtil that checks for permissions/default
dialer status, and handles the privileged operations
appropriately.
Bug: 20266292
Change-Id: Ibe8a85440b9ca20169b5ce3be24d1a385caaebb6
diff --git a/src/com/android/dialer/SpecialCharSequenceMgr.java b/src/com/android/dialer/SpecialCharSequenceMgr.java
index 36145aa..a57e2ee 100644
--- a/src/com/android/dialer/SpecialCharSequenceMgr.java
+++ b/src/com/android/dialer/SpecialCharSequenceMgr.java
@@ -46,6 +46,7 @@
import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment;
import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener;
import com.android.dialer.calllog.PhoneAccountUtils;
+import com.android.dialer.util.TelecomUtil;
import java.util.Arrays;
import java.util.ArrayList;
@@ -272,7 +273,7 @@
sPreviousAdnQueryHandler = handler;
}
- static boolean handlePinEntry(Context context, final String input) {
+ static boolean handlePinEntry(final Context context, final String input) {
if ((input.startsWith("**04") || input.startsWith("**05")) && input.endsWith("#")) {
final TelecomManager telecomManager =
(TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
@@ -284,13 +285,14 @@
if (subscriptionAccountHandles.size() == 1 || hasUserSelectedDefault) {
// Don't bring up the dialog for single-SIM or if the default outgoing account is
// a subscription account.
- return telecomManager.handleMmi(input);
+ return TelecomUtil.handleMmi(context, input, null);
} else if (subscriptionAccountHandles.size() > 1){
SelectPhoneAccountListener listener = new SelectPhoneAccountListener() {
@Override
public void onPhoneAccountSelected(PhoneAccountHandle selectedAccountHandle,
boolean setDefault) {
- telecomManager.handleMmi(input, selectedAccountHandle);
+ TelecomUtil.handleMmi(context.getApplicationContext(),
+ input, selectedAccountHandle);
//TODO: show error dialog if result isn't valid
}
@Override