From 9a7d6bb4b91f003d61a7ad9a9817b196f29f99bf Mon Sep 17 00:00:00 2001 From: Jeff Davidson Date: Mon, 27 Feb 2017 10:41:21 -0800 Subject: [PATCH] Rename getDataEnabled() to isDataEnabled(). The old API is reverted back to @SystemApi and marked deprecated to avoid breaking any compilation. Also clean up the Javadoc by making the permissions requirements clearer and noting that this API does not take per-app data restrictions into account. Merged-In: I5baacc1fd7e75d54e1d6521c24f792f427d9e228 Change-Id: I5baacc1fd7e75d54e1d6521c24f792f427d9e228 Test: TreeHugger build/boot Fixes: 35766530 --- api/current.txt | 2 +- api/system-current.txt | 5 +-- api/test-current.txt | 2 +- .../android/telephony/TelephonyManager.java | 31 +++++++++++++++---- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/api/current.txt b/api/current.txt index 5d968be53c7aa..38c9879bacdc6 100644 --- a/api/current.txt +++ b/api/current.txt @@ -38180,7 +38180,6 @@ package android.telephony { method public android.os.PersistableBundle getCarrierConfig(); method public deprecated android.telephony.CellLocation getCellLocation(); method public int getDataActivity(); - method public boolean getDataEnabled(); method public int getDataNetworkType(); method public int getDataState(); method public deprecated java.lang.String getDeviceId(); @@ -38225,6 +38224,7 @@ package android.telephony { method public java.lang.String iccTransmitApduBasicChannel(int, int, int, int, int, java.lang.String); method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, java.lang.String); method public boolean isConcurrentVoiceAndDataAllowed(); + method public boolean isDataEnabled(); method public boolean isHearingAidCompatibilitySupported(); method public boolean isNetworkRoaming(); method public boolean isSmsCapable(); diff --git a/api/system-current.txt b/api/system-current.txt index f336cdb721338..cbe75074e20e5 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -41393,8 +41393,8 @@ package android.telephony { method public int getCurrentPhoneType(); method public int getCurrentPhoneType(int); method public int getDataActivity(); - method public boolean getDataEnabled(); - method public boolean getDataEnabled(int); + method public deprecated boolean getDataEnabled(); + method public deprecated boolean getDataEnabled(int); method public int getDataNetworkType(); method public int getDataState(); method public deprecated java.lang.String getDeviceId(); @@ -41443,6 +41443,7 @@ package android.telephony { method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, java.lang.String); method public boolean isConcurrentVoiceAndDataAllowed(); method public boolean isDataConnectivityPossible(); + method public boolean isDataEnabled(); method public boolean isHearingAidCompatibilitySupported(); method public boolean isIdle(); method public boolean isNetworkRoaming(); diff --git a/api/test-current.txt b/api/test-current.txt index 65cfd8477cec7..dbed400e049c3 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -38279,7 +38279,6 @@ package android.telephony { method public android.os.PersistableBundle getCarrierConfig(); method public deprecated android.telephony.CellLocation getCellLocation(); method public int getDataActivity(); - method public boolean getDataEnabled(); method public int getDataNetworkType(); method public int getDataState(); method public deprecated java.lang.String getDeviceId(); @@ -38324,6 +38323,7 @@ package android.telephony { method public java.lang.String iccTransmitApduBasicChannel(int, int, int, int, int, java.lang.String); method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, java.lang.String); method public boolean isConcurrentVoiceAndDataAllowed(); + method public boolean isDataEnabled(); method public boolean isHearingAidCompatibilitySupported(); method public boolean isNetworkRoaming(); method public boolean isSmsCapable(); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 5a848d956f5df..d751fcb8e00cf 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -5257,23 +5257,42 @@ public class TelephonyManager { } } + + /** + * @deprecated use {@link #isDataEnabled()} instead. + * @hide + */ + @SystemApi + @Deprecated + public boolean getDataEnabled() { + return isDataEnabled(); + } + /** * Returns whether mobile data is enabled or not. * - *

Requires Permission: - * {@link android.Manifest.permission#ACCESS_NETWORK_STATE ACCESS_NETWORK_STATE}, - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}, or that the - * calling app has carrier privileges. + *

Requires one of the following permissions: + * {@link android.Manifest.permission#ACCESS_NETWORK_STATE ACCESS_NETWORK_STATE}, + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}, or that the + * calling app has carrier privileges. + * + *

Note that this does not take into account any data restrictions that may be present on the + * calling app. Such restrictions may be inspected with + * {@link ConnectivityManager#getRestrictBackgroundStatus}. * * @return true if mobile data is enabled. * * @see #hasCarrierPrivileges */ - public boolean getDataEnabled() { + @SuppressWarnings("deprecation") + public boolean isDataEnabled() { return getDataEnabled(getSubId()); } - /** @hide */ + /** + * @deprecated use {@link #isDataEnabled(int)} instead. + * @hide + */ @SystemApi public boolean getDataEnabled(int subId) { boolean retVal = false;