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.ServiceManager;
import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.ArrayMap;
import android.util.Log;
@@ -1295,9 +1296,15 @@ public class ConnectivityManager {
if (b != null) {
try {
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) { }
}
Log.d("ConnectivityManager", "getMobileDataEnabled()- remote exception retVal=false");
return false;
}

View File

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

View File

@@ -3509,8 +3509,15 @@ public class TelephonyManager {
/** @hide */
@SystemApi
public void setDataEnabled(boolean enable) {
setDataEnabled(SubscriptionManager.getDefaultDataSubId(), enable);
}
/** @hide */
@SystemApi
public void setDataEnabled(int subId, boolean enable) {
try {
getITelephony().setDataEnabled(enable);
Log.d(TAG, "setDataEnabled: enabled=" + enable);
getITelephony().setDataEnabled(subId, enable);
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#setDataEnabled", e);
}
@@ -3519,12 +3526,21 @@ public class TelephonyManager {
/** @hide */
@SystemApi
public boolean getDataEnabled() {
return getDataEnabled(SubscriptionManager.getDefaultDataSubId());
}
/** @hide */
@SystemApi
public boolean getDataEnabled(int subId) {
boolean retVal;
try {
return getITelephony().getDataEnabled();
retVal = getITelephony().getDataEnabled(subId);
} catch (RemoteException 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
*/
void setDataEnabled(boolean enable);
void setDataEnabled(int subId, boolean enable);
/**
* Get the user enabled state of Mobile Data.
*
* @return true on enabled
*/
boolean getDataEnabled();
boolean getDataEnabled(int subId);
/**
* Get P-CSCF address from PCO after data connection is established or modified.