Merge "Add subId as parameter for get/setDataEnabled." into lmp-mr1-dev

This commit is contained in:
Wink Saville
2014-12-09 17:52:26 +00:00
committed by Android (Google) Code Review
4 changed files with 30 additions and 6 deletions

View File

@@ -37,6 +37,7 @@ import android.os.Messenger;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager; import android.os.ServiceManager;
import android.provider.Settings; import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.Log; import android.util.Log;
@@ -1295,9 +1296,15 @@ public class ConnectivityManager {
if (b != null) { if (b != null) {
try { try {
ITelephony it = ITelephony.Stub.asInterface(b); ITelephony it = ITelephony.Stub.asInterface(b);
return it.getDataEnabled(); int subId = SubscriptionManager.getDefaultDataSubId();
Log.d("ConnectivityManager", "getMobileDataEnabled()+ subId=" + subId);
boolean retVal = it.getDataEnabled(subId);
Log.d("ConnectivityManager", "getMobileDataEnabled()- subId=" + subId
+ " retVal=" + retVal);
return retVal;
} catch (RemoteException e) { } } catch (RemoteException e) { }
} }
Log.d("ConnectivityManager", "getMobileDataEnabled()- remote exception retVal=false");
return false; return false;
} }

View File

@@ -196,6 +196,7 @@ public class MobileDataControllerImpl implements NetworkController.MobileDataCon
} }
public void setMobileDataEnabled(boolean enabled) { public void setMobileDataEnabled(boolean enabled) {
Log.d(TAG, "setMobileDataEnabled: enabled=" + enabled);
mTelephonyManager.setDataEnabled(enabled); mTelephonyManager.setDataEnabled(enabled);
if (mCallback != null) { if (mCallback != null) {
mCallback.onMobileDataEnabled(enabled); mCallback.onMobileDataEnabled(enabled);

View File

@@ -3509,8 +3509,15 @@ public class TelephonyManager {
/** @hide */ /** @hide */
@SystemApi @SystemApi
public void setDataEnabled(boolean enable) { public void setDataEnabled(boolean enable) {
setDataEnabled(SubscriptionManager.getDefaultDataSubId(), enable);
}
/** @hide */
@SystemApi
public void setDataEnabled(int subId, boolean enable) {
try { try {
getITelephony().setDataEnabled(enable); Log.d(TAG, "setDataEnabled: enabled=" + enable);
getITelephony().setDataEnabled(subId, enable);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#setDataEnabled", e); Log.e(TAG, "Error calling ITelephony#setDataEnabled", e);
} }
@@ -3519,12 +3526,21 @@ public class TelephonyManager {
/** @hide */ /** @hide */
@SystemApi @SystemApi
public boolean getDataEnabled() { public boolean getDataEnabled() {
return getDataEnabled(SubscriptionManager.getDefaultDataSubId());
}
/** @hide */
@SystemApi
public boolean getDataEnabled(int subId) {
boolean retVal;
try { try {
return getITelephony().getDataEnabled(); retVal = getITelephony().getDataEnabled(subId);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#getDataEnabled", e); Log.e(TAG, "Error calling ITelephony#getDataEnabled", e);
retVal = false;
} }
return false; Log.d(TAG, "getDataEnabled: retVal=" + retVal);
return retVal;
} }
/** /**

View File

@@ -679,14 +679,14 @@ interface ITelephony {
* *
* @param enable true to turn on, else false * @param enable true to turn on, else false
*/ */
void setDataEnabled(boolean enable); void setDataEnabled(int subId, boolean enable);
/** /**
* Get the user enabled state of Mobile Data. * Get the user enabled state of Mobile Data.
* *
* @return true on enabled * @return true on enabled
*/ */
boolean getDataEnabled(); boolean getDataEnabled(int subId);
/** /**
* Get P-CSCF address from PCO after data connection is established or modified. * Get P-CSCF address from PCO after data connection is established or modified.