SetDataEnabled indicate calling package
Test: atest TelephonyManagerTest
Bug: 226149142
Change-Id: I086d8e2fc777991934982a77e6db91e7d312f124
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index cd9dbad..5be501c 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2846,7 +2846,7 @@
// FIXME: subId version needed
@Override
- public boolean enableDataConnectivity() {
+ public boolean enableDataConnectivity(String callingPackage) {
enforceModifyPermission();
final long identity = Binder.clearCallingIdentity();
@@ -2856,7 +2856,7 @@
if (phone != null) {
if (phone.isUsingNewDataStack()) {
phone.getDataSettingsManager().setDataEnabled(
- TelephonyManager.DATA_ENABLED_REASON_USER, true);
+ TelephonyManager.DATA_ENABLED_REASON_USER, true, callingPackage);
} else {
phone.getDataEnabledSettings().setDataEnabled(
TelephonyManager.DATA_ENABLED_REASON_USER, true);
@@ -2872,7 +2872,7 @@
// FIXME: subId version needed
@Override
- public boolean disableDataConnectivity() {
+ public boolean disableDataConnectivity(String callingPackage) {
enforceModifyPermission();
final long identity = Binder.clearCallingIdentity();
@@ -2882,7 +2882,7 @@
if (phone != null) {
if (phone.isUsingNewDataStack()) {
phone.getDataSettingsManager().setDataEnabled(
- TelephonyManager.DATA_ENABLED_REASON_USER, false);
+ TelephonyManager.DATA_ENABLED_REASON_USER, false, callingPackage);
} else {
phone.getDataEnabledSettings().setDataEnabled(
TelephonyManager.DATA_ENABLED_REASON_USER, false);
@@ -7627,7 +7627,7 @@
}
@Override
- public void factoryReset(int subId) {
+ public void factoryReset(int subId, String callingPackage) {
enforceSettingsPermission();
if (mUserManager.hasUserRestriction(UserManager.DISALLOW_NETWORK_RESET)) {
return;
@@ -7643,7 +7643,7 @@
if (SubscriptionManager.isUsableSubIdValue(subId) && !mUserManager.hasUserRestriction(
UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
setDataEnabledForReason(subId, TelephonyManager.DATA_ENABLED_REASON_USER,
- getDefaultDataEnabled());
+ getDefaultDataEnabled(), callingPackage);
setNetworkSelectionModeAutomatic(subId);
Phone phone = getPhone(subId);
cleanUpAllowedNetworkTypes(phone, subId);
@@ -8444,13 +8444,14 @@
/**
* Policy control of data connection with reason {@@TelephonyManager.DataEnabledReason}
* @param subId Subscription index
- * @param reason the reason the data enable change is taking place
+ * @param reason The reason the data enable change is taking place.
* @param enabled True if enabling the data, otherwise disabling.
+ * @param callingPackage The package that changed the data enabled state.
* @hide
*/
@Override
public void setDataEnabledForReason(int subId, @TelephonyManager.DataEnabledReason int reason,
- boolean enabled) {
+ boolean enabled, String callingPackage) {
if (reason == TelephonyManager.DATA_ENABLED_REASON_USER
|| reason == TelephonyManager.DATA_ENABLED_REASON_CARRIER) {
try {
@@ -8471,7 +8472,8 @@
phone.carrierActionSetMeteredApnsEnabled(enabled);
} else {
if (phone.isUsingNewDataStack()) {
- phone.getDataSettingsManager().setDataEnabled(reason, enabled);
+ phone.getDataSettingsManager().setDataEnabled(
+ reason, enabled, callingPackage);
} else {
phone.getDataEnabledSettings().setDataEnabled(reason, enabled);
}
@@ -10179,7 +10181,7 @@
}
private int handleDataThrottlingRequest(int subId,
- DataThrottlingRequest dataThrottlingRequest) {
+ DataThrottlingRequest dataThrottlingRequest, String callingPackage) {
boolean isDataThrottlingSupported = isRadioInterfaceCapabilitySupported(
TelephonyManager.CAPABILITY_THERMAL_MITIGATION_DATA_THROTTLING);
if (!isDataThrottlingSupported && dataThrottlingRequest.getDataThrottlingAction()
@@ -10193,7 +10195,8 @@
return TelephonyManager.THERMAL_MITIGATION_RESULT_MODEM_NOT_AVAILABLE;
}
- setDataEnabledForReason(subId, TelephonyManager.DATA_ENABLED_REASON_THERMAL, true);
+ setDataEnabledForReason(
+ subId, TelephonyManager.DATA_ENABLED_REASON_THERMAL, true, callingPackage);
if (isDataThrottlingSupported) {
int thermalMitigationResult =
@@ -10295,7 +10298,8 @@
case ThermalMitigationRequest.THERMAL_MITIGATION_ACTION_DATA_THROTTLING:
thermalMitigationResult =
handleDataThrottlingRequest(subId,
- thermalMitigationRequest.getDataThrottlingRequest());
+ thermalMitigationRequest.getDataThrottlingRequest(),
+ callingPackage);
break;
case ThermalMitigationRequest.THERMAL_MITIGATION_ACTION_VOICE_ONLY:
if (thermalMitigationRequest.getDataThrottlingRequest() != null) {
@@ -10312,7 +10316,7 @@
}
setDataEnabledForReason(subId, TelephonyManager.DATA_ENABLED_REASON_THERMAL,
- false);
+ false, callingPackage);
thermalMitigationResult = TelephonyManager.THERMAL_MITIGATION_RESULT_SUCCESS;
break;
case ThermalMitigationRequest.THERMAL_MITIGATION_ACTION_RADIO_OFF: