From 827a90fb309fd26f5b155c1ad612512011d58437 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Thu, 17 Sep 2015 18:10:58 -0700 Subject: Wrap some privileged Telecom operations with permission checks If the Dialer is not the default dialer and does not have the CALL_PHONE permission, don't call TelecomManager methods that will cause SecurityExceptions. Bug: 20266292 Change-Id: I229dd045269a262632c4a911e2321203443de684 --- src/com/android/dialer/util/DialerUtils.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/com/android/dialer/util/DialerUtils.java') diff --git a/src/com/android/dialer/util/DialerUtils.java b/src/com/android/dialer/util/DialerUtils.java index fbe14ba9e..8870f76e4 100644 --- a/src/com/android/dialer/util/DialerUtils.java +++ b/src/com/android/dialer/util/DialerUtils.java @@ -33,18 +33,12 @@ import android.text.TextDirectionHeuristics; import android.text.TextUtils; import android.view.View; import android.view.inputmethod.InputMethodManager; -import android.widget.ImageView; -import android.widget.TextView; import android.widget.Toast; import com.android.contacts.common.ContactsUtils; import com.android.contacts.common.interactions.TouchPointManager; import com.android.dialer.R; -import com.android.dialer.widget.EmptyContentView; -import com.android.incallui.CallCardFragment; -import com.android.incallui.Log; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -94,7 +88,14 @@ public class DialerUtils { } final TelecomManager tm = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); - tm.placeCall(intent.getData(), intent.getExtras()); + if (TelecomUtil.hasCallPhonePermission(context)) { + tm.placeCall(intent.getData(), intent.getExtras()); + } else { + // TODO: Make calling activity show request permission dialog and handle + // callback results appropriately. + Toast.makeText(context, "Cannot place call without Phone permission", + Toast.LENGTH_SHORT); + } } else { context.startActivity(intent); } -- cgit v1.2.3