summaryrefslogtreecommitdiff
path: root/src/com/android/dialer/dialpad/DialpadFragment.java
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2015-09-18 12:54:59 -0700
committerYorke Lee <yorkelee@google.com>2015-09-22 09:47:04 -0700
commit762b357ec94aef3e7ee6f991c553aa950840a8bc (patch)
treeae5834a64f7f38fe8698c166156d92f9c9f0c06f /src/com/android/dialer/dialpad/DialpadFragment.java
parenta5dd7f93654181ebf927723d19e2f84a7e4c6ceb (diff)
Protect against more Telecom privileged operations
Make sure that all invocations of TelecomManager methods that could possibly require a permission are protected by a permission check. Some of these are overcautious - for example, the UI should never show the option to return to a call (READ_PHONE_STATE) if we didn't detect an active call (READ_PHONE_STATE) in the first place, so it is not strictly necessary to protect against the former. But not crashing is the most preferable of all options. Bug: 20266292 Change-Id: Id91dd16e34320a5e607f91dbce9a4296025eeaaf
Diffstat (limited to 'src/com/android/dialer/dialpad/DialpadFragment.java')
-rw-r--r--src/com/android/dialer/dialpad/DialpadFragment.java16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 54e4b8946..9c77f30c5 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -42,7 +42,6 @@ import android.provider.Contacts.PhonesColumns;
import android.provider.Settings;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
-import android.telecom.TelecomManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.text.Editable;
@@ -274,10 +273,6 @@ public class DialpadFragment extends Fragment
return (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
}
- private TelecomManager getTelecomManager() {
- return (TelecomManager) getActivity().getSystemService(Context.TELECOM_SERVICE);
- }
-
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
mWasEmptyBeforeTextChange = TextUtils.isEmpty(s);
@@ -980,7 +975,7 @@ public class DialpadFragment extends Fragment
List<PhoneAccountHandle> subscriptionAccountHandles =
PhoneAccountUtils.getSubscriptionPhoneAccounts(getActivity());
boolean hasUserSelectedDefault = subscriptionAccountHandles.contains(
- getTelecomManager().getDefaultOutgoingPhoneAccount(
+ TelecomUtil.getDefaultOutgoingPhoneAccount(getActivity(),
PhoneAccount.SCHEME_VOICEMAIL));
boolean needsAccountDisambiguation = subscriptionAccountHandles.size() > 1
&& !hasUserSelectedDefault;
@@ -1462,7 +1457,7 @@ public class DialpadFragment extends Fragment
* or "return to call" from the dialpad chooser.
*/
private void returnToInCallScreen(boolean showDialpad) {
- getTelecomManager().showInCallScreen(showDialpad);
+ TelecomUtil.showInCallScreen(getActivity(), showDialpad);
// Finally, finish() ourselves so that we don't stay on the
// activity stack.
@@ -1579,20 +1574,19 @@ public class DialpadFragment extends Fragment
*
* @return true if voicemail is enabled and accessible. Note that this can be false
* "temporarily" after the app boot.
- * @see TelecomManager#getVoiceMailNumber(PhoneAccountHandle)
*/
private boolean isVoicemailAvailable() {
try {
PhoneAccountHandle defaultUserSelectedAccount =
- getTelecomManager().getDefaultOutgoingPhoneAccount(
+ TelecomUtil.getDefaultOutgoingPhoneAccount(getActivity(),
PhoneAccount.SCHEME_VOICEMAIL);
if (defaultUserSelectedAccount == null) {
// In a single-SIM phone, there is no default outgoing phone account selected by
// the user, so just call TelephonyManager#getVoicemailNumber directly.
return !TextUtils.isEmpty(getTelephonyManager().getVoiceMailNumber());
} else {
- return !TextUtils.isEmpty(
- getTelecomManager().getVoiceMailNumber(defaultUserSelectedAccount));
+ return !TextUtils.isEmpty(TelecomUtil.getVoicemailNumber(getActivity(),
+ defaultUserSelectedAccount));
}
} catch (SecurityException se) {
// Possibly no READ_PHONE_STATE privilege.