private INetworkManagementService mNetworkService;
private INetworkStatsService mStatsService;
private NetworkPolicyManager mPolicyManager;
- private ConnectivityManager mConnService;
+ private TelephonyManager mTelephonyManager;
+
private INetworkStatsSession mStatsSession;
mStatsService = INetworkStatsService.Stub.asInterface(
ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
mPolicyManager = NetworkPolicyManager.from(context);
- mConnService = ConnectivityManager.from(context);
+ mTelephonyManager = TelephonyManager.from(context);
mPrefs = getActivity().getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE);
// TODO: deprecate and remove this once enabled flag is on policy
return mMobileDataEnabled;
} else {
- return mConnService.getMobileDataEnabled();
+ return mTelephonyManager.getDataEnabled();
}
}
private void setMobileDataEnabled(boolean enabled) {
if (LOGD) Log.d(TAG, "setMobileDataEnabled()");
- mConnService.setMobileDataEnabled(enabled);
+ mTelephonyManager.setDataEnabled(enabled);
mMobileDataEnabled = enabled;
updatePolicy(false);
}
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
-import android.net.ConnectivityManager;
import android.net.TrafficStats;
import android.net.Uri;
import android.os.AsyncResult;
private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
- ConnectivityManager cm =
- (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
int state = mTelephonyManager.getDataState();
switch (state) {
case TelephonyManager.DATA_CONNECTED:
- cm.setMobileDataEnabled(false);
+ phone.setDataEnabled(false);
break;
case TelephonyManager.DATA_DISCONNECTED:
- cm.setMobileDataEnabled(true);
+ phone.setDataEnabled(true);
break;
default:
// do nothing