setDataEnabled requires MODIFY_PHONE_STATE or carrier privileges.
getDataEnabled will work with any of the above or
ACCESS_NETWORK_STATE.
Merged-In: I2d5a9df2e55f3f7be1729abefe137c00ae1d6c4e
Test: Exercised APIs from test app, updated and executed CTS tests
Change-Id: I2d5a9df2e55f3f7be1729abefe137c00ae1d6c4e
Fixes:
32644451
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();
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();
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();
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();
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 */
}
}
- /** @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 */