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
Change-Id: I8d6fd13e319ce165e25f2afd93bf9884fbf22667
This commit is contained in:
Sarah Chin
2021-12-20 17:49:05 -08:00
parent 8704be3652
commit 419e4ff03a
3 changed files with 31 additions and 2 deletions

View File

@@ -43505,8 +43505,10 @@ package android.telephony {
field public static final int DATA_DISCONNECTED = 0; // 0x0 field public static final int DATA_DISCONNECTED = 0; // 0x0
field public static final int DATA_DISCONNECTING = 4; // 0x4 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_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_POLICY = 1; // 0x1
field public static final int DATA_ENABLED_REASON_THERMAL = 3; // 0x3 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_ENABLED_REASON_USER = 0; // 0x0
field public static final int DATA_SUSPENDED = 3; // 0x3 field public static final int DATA_SUSPENDED = 3; // 0x3
field public static final int DATA_UNKNOWN = -1; // 0xffffffff field public static final int DATA_UNKNOWN = -1; // 0xffffffff

View File

@@ -1408,10 +1408,11 @@ public class TelephonyCallback {
* *
* @param enabled {@code true} if data is enabled, otherwise disabled. * @param enabled {@code true} if data is enabled, otherwise disabled.
* @param reason Reason for data enabled/disabled. * @param reason Reason for data enabled/disabled.
* See {@link TelephonyManager.DataEnabledReason}. * See {@link TelephonyManager.DataEnabledChangedReason}.
*/ */
@RequiresPermission(Manifest.permission.READ_PRECISE_PHONE_STATE) @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

@@ -13005,6 +13005,25 @@ public class TelephonyManager {
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface DataEnabledReason{} 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. * To indicate that user enabled or disabled data.
*/ */
@@ -13031,6 +13050,13 @@ public class TelephonyManager {
*/ */
public static final int DATA_ENABLED_REASON_THERMAL = 3; 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. * Control of data connection and provide the reason triggering the data connection control.
* This can be called for following reasons * This can be called for following reasons