Rename setDataEnabledWithReason
1. Rename setDataEnabledWithReason to
setDataEnabledForReasn
2. Allow isDataConnectionAllowed to be accessed by
same apps as isDataEnabledForReason
3. Make these apis public
Bug: 156332911
Test: cts and build
Change-Id: I54825a2b6932daf64d5b8da6e32d301f03a04de9
Merged-In: I54825a2b6932daf64d5b8da6e32d301f03a04de9
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index e451a5d..a08893b 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -5892,7 +5892,18 @@
*/
@Override
public boolean isDataEnabled(int subId) {
- enforceReadPrivilegedPermission("isDataEnabled");
+ try {
+ try {
+ mApp.enforceCallingOrSelfPermission(
+ android.Manifest.permission.ACCESS_NETWORK_STATE,
+ null);
+ } catch (Exception e) {
+ mApp.enforceCallingOrSelfPermission(android.Manifest.permission.READ_PHONE_STATE,
+ "isDataEnabled");
+ }
+ } catch (Exception e) {
+ enforceReadPrivilegedPermission("isDataEnabled");
+ }
final long identity = Binder.clearCallingIdentity();
try {
@@ -5919,14 +5930,14 @@
* @return {@code true} if the overall data is enabled; {@code false} if not.
*/
@Override
- public boolean isDataEnabledWithReason(int subId,
+ public boolean isDataEnabledForReason(int subId,
@TelephonyManager.DataEnabledReason int reason) {
try {
mApp.enforceCallingOrSelfPermission(android.Manifest.permission.ACCESS_NETWORK_STATE,
null);
} catch (Exception e) {
mApp.enforceCallingOrSelfPermission(android.Manifest.permission.READ_PHONE_STATE,
- "isDataEnabledWithReason");
+ "isDataEnabledForReason");
}
@@ -5934,7 +5945,7 @@
try {
int phoneId = mSubscriptionController.getPhoneId(subId);
if (DBG) {
- log("isDataEnabledWithReason: subId=" + subId + " phoneId=" + phoneId
+ log("isDataEnabledForReason: subId=" + subId + " phoneId=" + phoneId
+ " reason=" + reason);
}
Phone phone = PhoneFactory.getPhone(phoneId);
@@ -5943,13 +5954,13 @@
if (reason == TelephonyManager.DATA_ENABLED_REASON_USER) {
retVal = phone.isUserDataEnabled();
} else {
- retVal = phone.getDataEnabledSettings().isDataEnabledWithReason(reason);
+ retVal = phone.getDataEnabledSettings().isDataEnabledForReason(reason);
}
- if (DBG) log("isDataEnabledWithReason: retVal=" + retVal);
+ if (DBG) log("isDataEnabledForReason: retVal=" + retVal);
return retVal;
} else {
if (DBG) {
- loge("isDataEnabledWithReason: no phone subId="
+ loge("isDataEnabledForReason: no phone subId="
+ subId + " retVal=false");
}
return false;
@@ -6787,7 +6798,7 @@
try {
if (SubscriptionManager.isUsableSubIdValue(subId) && !mUserManager.hasUserRestriction(
UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
- setDataEnabledWithReason(subId, TelephonyManager.DATA_ENABLED_REASON_USER,
+ setDataEnabledForReason(subId, TelephonyManager.DATA_ENABLED_REASON_USER,
getDefaultDataEnabled());
setNetworkSelectionModeAutomatic(subId);
setPreferredNetworkType(subId, getDefaultNetworkType(subId));
@@ -7415,13 +7426,13 @@
* @hide
*/
@Override
- public void setDataEnabledWithReason(int subId, @TelephonyManager.DataEnabledReason int reason,
+ public void setDataEnabledForReason(int subId, @TelephonyManager.DataEnabledReason int reason,
boolean enabled) {
if (reason == TelephonyManager.DATA_ENABLED_REASON_USER
|| reason == TelephonyManager.DATA_ENABLED_REASON_CARRIER) {
try {
TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege(
- mApp, subId, "setDataEnabledWithReason");
+ mApp, subId, "setDataEnabledForReason");
} catch (SecurityException se) {
enforceModifyPermission();
}