Loading core/java/android/net/ConnectivityManager.java +12 −26 Original line number Diff line number Diff line Loading @@ -35,15 +35,17 @@ import android.os.Messenger; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.telephony.TelephonyManager; import android.util.ArrayMap; import android.util.Log; import com.android.internal.telephony.ITelephony; import com.android.internal.util.Protocol; import java.net.InetAddress; import java.util.concurrent.atomic.AtomicInteger; import java.util.HashMap; import com.android.internal.util.Protocol; /** * Class that answers queries about the state of network connectivity. It also * notifies applications when network connectivity changes. Get an instance Loading Loading @@ -940,34 +942,18 @@ public class ConnectivityManager { } /** * Gets the value of the setting for enabling Mobile data. * * @return Whether mobile data is enabled. * * <p>This method requires the call to hold the permission * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. * @hide * @deprecated Talk to TelephonyManager directly */ public boolean getMobileDataEnabled() { IBinder b = ServiceManager.getService(Context.TELEPHONY_SERVICE); if (b != null) { try { return mService.getMobileDataEnabled(); } catch (RemoteException e) { return true; } } /** * Sets the persisted value for enabling/disabling Mobile data. * * @param enabled Whether the user wants the mobile data connection used * or not. * @hide */ public void setMobileDataEnabled(boolean enabled) { try { mService.setMobileDataEnabled(enabled); } catch (RemoteException e) { ITelephony it = ITelephony.Stub.asInterface(b); return it.getDataEnabled(); } catch (RemoteException e) { } } return false; } /** Loading core/java/android/net/IConnectivityManager.aidl +0 −3 Original line number Diff line number Diff line Loading @@ -74,9 +74,6 @@ interface IConnectivityManager boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress, String packageName); boolean getMobileDataEnabled(); void setMobileDataEnabled(boolean enabled); /** Policy control over specific {@link NetworkStateTracker}. */ void setPolicyDataEnable(int networkType, boolean enabled); Loading services/core/java/com/android/server/ConnectivityService.java +0 −41 Original line number Diff line number Diff line Loading @@ -342,12 +342,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { */ private static final int EVENT_INET_CONDITION_HOLD_END = 5; /** * used internally to set enable/disable cellular data * arg1 = ENBALED or DISABLED */ private static final int EVENT_SET_MOBILE_DATA = 7; /** * used internally to clear a wakelock when transitioning * from one net to another Loading Loading @@ -1822,20 +1816,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { return true; } /** * @see ConnectivityManager#getMobileDataEnabled() */ public boolean getMobileDataEnabled() { // TODO: This detail should probably be in DataConnectionTracker's // which is where we store the value and maybe make this // asynchronous. enforceAccessPermission(); boolean retVal = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.MOBILE_DATA, 1) == 1; if (VDBG) log("getMobileDataEnabled returning " + retVal); return retVal; } public void setDataDependency(int networkType, boolean met) { enforceConnectivityInternalPermission(); Loading Loading @@ -1908,22 +1888,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { } }; /** * @see ConnectivityManager#setMobileDataEnabled(boolean) */ public void setMobileDataEnabled(boolean enabled) { enforceChangePermission(); if (DBG) log("setMobileDataEnabled(" + enabled + ")"); mHandler.sendMessage(mHandler.obtainMessage(EVENT_SET_MOBILE_DATA, (enabled ? ENABLED : DISABLED), 0)); } private void handleSetMobileData(boolean enabled) { // TODO - handle this - probably generalize passing in a transport type and send to the // factories? } @Override public void setPolicyDataEnable(int networkType, boolean enabled) { // only someone like NPMS should only be calling us Loading Loading @@ -3315,11 +3279,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { handleInetConditionHoldEnd(netType, sequence); break; } case EVENT_SET_MOBILE_DATA: { boolean enabled = (msg.arg1 == ENABLED); handleSetMobileData(enabled); break; } case EVENT_APPLY_GLOBAL_HTTP_PROXY: { handleDeprecatedGlobalHttpProxy(); break; Loading telephony/java/android/telephony/TelephonyManager.java +21 −0 Original line number Diff line number Diff line Loading @@ -2249,4 +2249,25 @@ public class TelephonyManager { } return false; } /** @hide */ @PrivateApi public void setDataEnabled(boolean enable) { try { getITelephony().setDataEnabled(enable); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#setDataEnabled", e); } } /** @hide */ @PrivateApi public boolean getDataEnabled() { try { return getITelephony().getDataEnabled(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#getDataEnabled", e); } return false; } } telephony/java/com/android/internal/telephony/ITelephony.aidl +14 −0 Original line number Diff line number Diff line Loading @@ -436,4 +436,18 @@ interface ITelephony { * @return true on success; false on any failure. */ boolean setPreferredNetworkType(int networkType); /** * User enable/disable Mobile Data. * * @param enable true to turn on, else false */ void setDataEnabled(boolean enable); /** * Get the user enabled state of Mobile Data. * * @return true on enabled */ boolean getDataEnabled(); } Loading
core/java/android/net/ConnectivityManager.java +12 −26 Original line number Diff line number Diff line Loading @@ -35,15 +35,17 @@ import android.os.Messenger; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.telephony.TelephonyManager; import android.util.ArrayMap; import android.util.Log; import com.android.internal.telephony.ITelephony; import com.android.internal.util.Protocol; import java.net.InetAddress; import java.util.concurrent.atomic.AtomicInteger; import java.util.HashMap; import com.android.internal.util.Protocol; /** * Class that answers queries about the state of network connectivity. It also * notifies applications when network connectivity changes. Get an instance Loading Loading @@ -940,34 +942,18 @@ public class ConnectivityManager { } /** * Gets the value of the setting for enabling Mobile data. * * @return Whether mobile data is enabled. * * <p>This method requires the call to hold the permission * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. * @hide * @deprecated Talk to TelephonyManager directly */ public boolean getMobileDataEnabled() { IBinder b = ServiceManager.getService(Context.TELEPHONY_SERVICE); if (b != null) { try { return mService.getMobileDataEnabled(); } catch (RemoteException e) { return true; } } /** * Sets the persisted value for enabling/disabling Mobile data. * * @param enabled Whether the user wants the mobile data connection used * or not. * @hide */ public void setMobileDataEnabled(boolean enabled) { try { mService.setMobileDataEnabled(enabled); } catch (RemoteException e) { ITelephony it = ITelephony.Stub.asInterface(b); return it.getDataEnabled(); } catch (RemoteException e) { } } return false; } /** Loading
core/java/android/net/IConnectivityManager.aidl +0 −3 Original line number Diff line number Diff line Loading @@ -74,9 +74,6 @@ interface IConnectivityManager boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress, String packageName); boolean getMobileDataEnabled(); void setMobileDataEnabled(boolean enabled); /** Policy control over specific {@link NetworkStateTracker}. */ void setPolicyDataEnable(int networkType, boolean enabled); Loading
services/core/java/com/android/server/ConnectivityService.java +0 −41 Original line number Diff line number Diff line Loading @@ -342,12 +342,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { */ private static final int EVENT_INET_CONDITION_HOLD_END = 5; /** * used internally to set enable/disable cellular data * arg1 = ENBALED or DISABLED */ private static final int EVENT_SET_MOBILE_DATA = 7; /** * used internally to clear a wakelock when transitioning * from one net to another Loading Loading @@ -1822,20 +1816,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { return true; } /** * @see ConnectivityManager#getMobileDataEnabled() */ public boolean getMobileDataEnabled() { // TODO: This detail should probably be in DataConnectionTracker's // which is where we store the value and maybe make this // asynchronous. enforceAccessPermission(); boolean retVal = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.MOBILE_DATA, 1) == 1; if (VDBG) log("getMobileDataEnabled returning " + retVal); return retVal; } public void setDataDependency(int networkType, boolean met) { enforceConnectivityInternalPermission(); Loading Loading @@ -1908,22 +1888,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { } }; /** * @see ConnectivityManager#setMobileDataEnabled(boolean) */ public void setMobileDataEnabled(boolean enabled) { enforceChangePermission(); if (DBG) log("setMobileDataEnabled(" + enabled + ")"); mHandler.sendMessage(mHandler.obtainMessage(EVENT_SET_MOBILE_DATA, (enabled ? ENABLED : DISABLED), 0)); } private void handleSetMobileData(boolean enabled) { // TODO - handle this - probably generalize passing in a transport type and send to the // factories? } @Override public void setPolicyDataEnable(int networkType, boolean enabled) { // only someone like NPMS should only be calling us Loading Loading @@ -3315,11 +3279,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { handleInetConditionHoldEnd(netType, sequence); break; } case EVENT_SET_MOBILE_DATA: { boolean enabled = (msg.arg1 == ENABLED); handleSetMobileData(enabled); break; } case EVENT_APPLY_GLOBAL_HTTP_PROXY: { handleDeprecatedGlobalHttpProxy(); break; Loading
telephony/java/android/telephony/TelephonyManager.java +21 −0 Original line number Diff line number Diff line Loading @@ -2249,4 +2249,25 @@ public class TelephonyManager { } return false; } /** @hide */ @PrivateApi public void setDataEnabled(boolean enable) { try { getITelephony().setDataEnabled(enable); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#setDataEnabled", e); } } /** @hide */ @PrivateApi public boolean getDataEnabled() { try { return getITelephony().getDataEnabled(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#getDataEnabled", e); } return false; } }
telephony/java/com/android/internal/telephony/ITelephony.aidl +14 −0 Original line number Diff line number Diff line Loading @@ -436,4 +436,18 @@ interface ITelephony { * @return true on success; false on any failure. */ boolean setPreferredNetworkType(int networkType); /** * User enable/disable Mobile Data. * * @param enable true to turn on, else false */ void setDataEnabled(boolean enable); /** * Get the user enabled state of Mobile Data. * * @return true on enabled */ boolean getDataEnabled(); }