summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Davidson <jpd@google.com> 2016-11-23 03:55:26 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-11-23 03:55:27 +0000
commit99d6227782844e42d7060b14d320cfd66a536798 (patch)
treee06166ed718fbc9c8153721ee4b832ba6d470c03
parent9c69c41b957de2dabcb469447043ea3df1a8e692 (diff)
parent40db40878e9f7a25f63076d95d7c7859488290cb (diff)
Merge "Expose TelephonyManager#{set,get}DataEnabled."
-rw-r--r--api/current.txt2
-rw-r--r--api/test-current.txt2
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java31
3 files changed, 29 insertions, 6 deletions
diff --git a/api/current.txt b/api/current.txt
index 277c6f574daa..f736bc0cf098 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -37222,6 +37222,7 @@ package android.telephony {
method public int getCallState();
method public android.telephony.CellLocation getCellLocation();
method public int getDataActivity();
+ method public boolean getDataEnabled();
method public int getDataNetworkType();
method public int getDataState();
method public java.lang.String getDeviceId();
@@ -37266,6 +37267,7 @@ package android.telephony {
method public boolean isWorldPhone();
method public void listen(android.telephony.PhoneStateListener, int);
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
+ method public void setDataEnabled(boolean);
method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);
method public boolean setOperatorBrandOverride(java.lang.String);
method public boolean setPreferredNetworkTypeToGlobal();
diff --git a/api/test-current.txt b/api/test-current.txt
index f2202eb202c2..4af06152121d 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -37299,6 +37299,7 @@ package android.telephony {
method public int getCallState();
method public android.telephony.CellLocation getCellLocation();
method public int getDataActivity();
+ method public boolean getDataEnabled();
method public int getDataNetworkType();
method public int getDataState();
method public java.lang.String getDeviceId();
@@ -37343,6 +37344,7 @@ package android.telephony {
method public boolean isWorldPhone();
method public void listen(android.telephony.PhoneStateListener, int);
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
+ method public void setDataEnabled(boolean);
method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);
method public boolean setOperatorBrandOverride(java.lang.String);
method public boolean setPreferredNetworkTypeToGlobal();
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 4e4e75dd8159..ca17c066e3ef 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -4557,10 +4557,19 @@ public class TelephonyManager {
return false;
}
- /** @hide */
- @SystemApi
+ /**
+ * Turns mobile data on or off.
+ *
+ * <p>Requires Permission:
+ * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the
+ * calling app has carrier privileges.
+ *
+ * @param enable Whether to enable mobile data.
+ *
+ * @see #hasCarrierPrivileges
+ */
public void setDataEnabled(boolean enable) {
- setDataEnabled(SubscriptionManager.getDefaultDataSubscriptionId(), enable);
+ setDataEnabled(getSubId(), enable);
}
/** @hide */
@@ -4576,10 +4585,20 @@ public class TelephonyManager {
}
}
- /** @hide */
- @SystemApi
+ /**
+ * Returns whether mobile data is enabled or not.
+ *
+ * <p>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.
+ *
+ * @return true if mobile data is enabled.
+ *
+ * @see #hasCarrierPrivileges
+ */
public boolean getDataEnabled() {
- return getDataEnabled(SubscriptionManager.getDefaultDataSubscriptionId());
+ return getDataEnabled(getSubId());
}
/** @hide */