Move dis/enable of mobile data to Telephony
ConnectivityService doesn't do this anymore. bug:15077247 Change-Id: I3208c91b2c0369b594987f39ca29da7478435513
This commit is contained in:
@@ -35,15 +35,17 @@ 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.TelephonyManager;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.internal.telephony.ITelephony;
|
||||||
|
import com.android.internal.util.Protocol;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import com.android.internal.util.Protocol;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that answers queries about the state of network connectivity. It also
|
* Class that answers queries about the state of network connectivity. It also
|
||||||
* notifies applications when network connectivity changes. Get an instance
|
* notifies applications when network connectivity changes. Get an instance
|
||||||
@@ -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
|
* @hide
|
||||||
|
* @deprecated Talk to TelephonyManager directly
|
||||||
*/
|
*/
|
||||||
public boolean getMobileDataEnabled() {
|
public boolean getMobileDataEnabled() {
|
||||||
try {
|
IBinder b = ServiceManager.getService(Context.TELEPHONY_SERVICE);
|
||||||
return mService.getMobileDataEnabled();
|
if (b != null) {
|
||||||
} catch (RemoteException e) {
|
try {
|
||||||
return true;
|
ITelephony it = ITelephony.Stub.asInterface(b);
|
||||||
}
|
return it.getDataEnabled();
|
||||||
}
|
} catch (RemoteException e) { }
|
||||||
|
|
||||||
/**
|
|
||||||
* 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) {
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -74,9 +74,6 @@ interface IConnectivityManager
|
|||||||
|
|
||||||
boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress, String packageName);
|
boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress, String packageName);
|
||||||
|
|
||||||
boolean getMobileDataEnabled();
|
|
||||||
void setMobileDataEnabled(boolean enabled);
|
|
||||||
|
|
||||||
/** Policy control over specific {@link NetworkStateTracker}. */
|
/** Policy control over specific {@link NetworkStateTracker}. */
|
||||||
void setPolicyDataEnable(int networkType, boolean enabled);
|
void setPolicyDataEnable(int networkType, boolean enabled);
|
||||||
|
|
||||||
|
|||||||
@@ -342,12 +342,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
*/
|
*/
|
||||||
private static final int EVENT_INET_CONDITION_HOLD_END = 5;
|
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
|
* used internally to clear a wakelock when transitioning
|
||||||
* from one net to another
|
* from one net to another
|
||||||
@@ -1822,20 +1816,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
return true;
|
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) {
|
public void setDataDependency(int networkType, boolean met) {
|
||||||
enforceConnectivityInternalPermission();
|
enforceConnectivityInternalPermission();
|
||||||
|
|
||||||
@@ -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
|
@Override
|
||||||
public void setPolicyDataEnable(int networkType, boolean enabled) {
|
public void setPolicyDataEnable(int networkType, boolean enabled) {
|
||||||
// only someone like NPMS should only be calling us
|
// only someone like NPMS should only be calling us
|
||||||
@@ -3315,11 +3279,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
handleInetConditionHoldEnd(netType, sequence);
|
handleInetConditionHoldEnd(netType, sequence);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EVENT_SET_MOBILE_DATA: {
|
|
||||||
boolean enabled = (msg.arg1 == ENABLED);
|
|
||||||
handleSetMobileData(enabled);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EVENT_APPLY_GLOBAL_HTTP_PROXY: {
|
case EVENT_APPLY_GLOBAL_HTTP_PROXY: {
|
||||||
handleDeprecatedGlobalHttpProxy();
|
handleDeprecatedGlobalHttpProxy();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user