Create new DataEnabledReasons for for DataSettingsManager

DataEnabledSettings used an internal DataEnabledChangedReason when
notifying data enabled was changed. For DataSettingsManager, sync the
reasons with TelephonyManager#DataEnabledReasons and remove the internal
reaons.

Test: atest FrameworksTelephonyTests
Bug: 204309297
Merged-In: I8d6fd13e319ce165e25f2afd93bf9884fbf22667
Change-Id: I8d6fd13e319ce165e25f2afd93bf9884fbf22667
This commit is contained in:
Sarah Chin
2021-12-20 17:49:05 -08:00
committed by Jack Yu
parent 7c8bca867d
commit 9d7925e60c
3 changed files with 31 additions and 2 deletions

View File

@@ -41759,8 +41759,10 @@ package android.telephony {
field public static final int DATA_DISCONNECTED = 0; // 0x0
field public static final int DATA_DISCONNECTING = 4; // 0x4
field public static final int DATA_ENABLED_REASON_CARRIER = 2; // 0x2
field public static final int DATA_ENABLED_REASON_OVERRIDE = 4; // 0x4
field public static final int DATA_ENABLED_REASON_POLICY = 1; // 0x1
field public static final int DATA_ENABLED_REASON_THERMAL = 3; // 0x3
field public static final int DATA_ENABLED_REASON_UNKNOWN = -1; // 0xffffffff
field public static final int DATA_ENABLED_REASON_USER = 0; // 0x0
field public static final int DATA_HANDOVER_IN_PROGRESS = 5; // 0x5
field public static final int DATA_SUSPENDED = 3; // 0x3

View File

@@ -1409,10 +1409,11 @@ public class TelephonyCallback {
*
* @param enabled {@code true} if data is enabled, otherwise disabled.
* @param reason Reason for data enabled/disabled.
* See {@link TelephonyManager.DataEnabledReason}.
* See {@link TelephonyManager.DataEnabledChangedReason}.
*/
@RequiresPermission(Manifest.permission.READ_PRECISE_PHONE_STATE)
void onDataEnabledChanged(boolean enabled, @TelephonyManager.DataEnabledReason int reason);
void onDataEnabledChanged(boolean enabled,
@TelephonyManager.DataEnabledChangedReason int reason);
}
/**

View File

@@ -12542,6 +12542,25 @@ public class TelephonyManager {
@Retention(RetentionPolicy.SOURCE)
public @interface DataEnabledReason{}
/** @hide */
@IntDef({
DATA_ENABLED_REASON_UNKNOWN,
DATA_ENABLED_REASON_USER,
DATA_ENABLED_REASON_POLICY,
DATA_ENABLED_REASON_CARRIER,
DATA_ENABLED_REASON_THERMAL,
DATA_ENABLED_REASON_OVERRIDE
})
@Retention(RetentionPolicy.SOURCE)
public @interface DataEnabledChangedReason{}
/**
* To indicate that data was enabled or disabled due to an unknown reason.
* Note that this is not a valid reason for {@link #setDataEnabledForReason(int, boolean)} and
* is only used to indicate that data enabled was changed.
*/
public static final int DATA_ENABLED_REASON_UNKNOWN = -1;
/**
* To indicate that user enabled or disabled data.
*/
@@ -12568,6 +12587,13 @@ public class TelephonyManager {
*/
public static final int DATA_ENABLED_REASON_THERMAL = 3;
/**
* To indicate data was enabled or disabled due to {@link MobileDataPolicy} overrides.
* Note that this is not a valid reason for {@link #setDataEnabledForReason(int, boolean)} and
* is only used to indicate that data enabled was changed due to an override.
*/
public static final int DATA_ENABLED_REASON_OVERRIDE = 4;
/**
* Control of data connection and provide the reason triggering the data connection control.
* This can be called for following reasons