Check System permissions for some TelephonyManager System apis.
The doc: https://docs.google.com/spreadsheets/d/1OJ6EXJ-Zys21mZ1BHgJeWkcfLq0pPxBR765r46ck80U/edit#gid=0
Test: Compile
Bug: 62346128
Change-Id: I470c0bb037359cf3145b6641257586560f213219
Merged-In: I470c0bb037359cf3145b6641257586560f213219
(cherry picked from commit 0fea376cbe1ca1396fff865582be5bf41e471ed8)
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index beae63a..62faa45 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -1611,6 +1611,7 @@
@Override
public boolean isDataConnectivityPossible(int subId) {
+ enforceReadPrivilegedPermission();
final Phone phone = getPhone(subId);
if (phone != null) {
return phone.isDataAllowed();
@@ -1905,12 +1906,18 @@
@Override
public int getActivePhoneTypeForSlot(int slotIndex) {
- final Phone phone = PhoneFactory.getPhone(slotIndex);
- if (phone == null) {
- return PhoneConstants.PHONE_TYPE_NONE;
- } else {
- return phone.getPhoneType();
+ enforceReadPrivilegedPermission();
+ return getPhoneTypeForSlot(slotIndex);
+ }
+
+ @Override
+ public int getVoiceCapableActivePhoneTypeForSlot(int slotIndex) {
+ // Check if the device is voice-capable
+ if (!mApp.getResources()
+ .getBoolean(com.android.internal.R.bool.config_voice_capable)) {
+ return TelephonyManager.PHONE_TYPE_NONE;
}
+ return getPhoneTypeForSlot(slotIndex);
}
/**
@@ -2015,6 +2022,7 @@
* Returns true if CDMA provisioning needs to run.
*/
public boolean needsOtaServiceProvisioning() {
+ enforceReadPrivilegedPermission();
return mPhone.needsOtaServiceProvisioning();
}
@@ -3046,6 +3054,7 @@
@Override
public List<String> getCarrierPackageNamesForIntentAndPhone(Intent intent, int phoneId) {
+ enforceReadPrivilegedPermission();
if (!SubscriptionManager.isValidPhoneId(phoneId)) {
loge("phoneId " + phoneId + " is not valid.");
return null;
@@ -3320,10 +3329,7 @@
@Override
public boolean isVideoCallingEnabled(String callingPackage) {
- if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, mPhone.getSubId(), callingPackage, "isVideoCallingEnabled")) {
- return false;
- }
+ enforceReadPrivilegedPermission();
// Check the user preference and the system-level IMS setting. Even if the user has
// enabled video calling, if IMS is disabled we aren't able to support video calling.
@@ -4179,4 +4185,17 @@
DEFAULT_NETWORK_MODE_PROPERTY_NAME,
String.valueOf(Phone.PREFERRED_NT_MODE)));
}
+
+ /**
+ * Util function that returns the phone type.
+ * @param slotIndex - slot to query.
+ */
+ private int getPhoneTypeForSlot(int slotIndex) {
+ final Phone phone = PhoneFactory.getPhone(slotIndex);
+ if (phone == null) {
+ return PhoneConstants.PHONE_TYPE_NONE;
+ } else {
+ return phone.getPhoneType();
+ }
+ }
}