Merge "Background data notification, API clean up."
This commit is contained in:
@@ -163,8 +163,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
private boolean mTestMode;
|
||||
private static ConnectivityService sServiceInstance;
|
||||
|
||||
private AtomicBoolean mBackgroundDataEnabled = new AtomicBoolean(true);
|
||||
|
||||
private INetworkManagementService mNetd;
|
||||
private INetworkPolicyManager mPolicyManager;
|
||||
|
||||
@@ -212,13 +210,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
private static final int EVENT_INET_CONDITION_HOLD_END =
|
||||
MAX_NETWORK_STATE_TRACKER_EVENT + 5;
|
||||
|
||||
/**
|
||||
* used internally to set the background data preference
|
||||
* arg1 = TRUE for enabled, FALSE for disabled
|
||||
*/
|
||||
private static final int EVENT_SET_BACKGROUND_DATA =
|
||||
MAX_NETWORK_STATE_TRACKER_EVENT + 6;
|
||||
|
||||
/**
|
||||
* used internally to set enable/disable cellular data
|
||||
* arg1 = ENBALED or DISABLED
|
||||
@@ -317,9 +308,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
handlerThread.start();
|
||||
mHandler = new MyHandler(handlerThread.getLooper());
|
||||
|
||||
mBackgroundDataEnabled.set(Settings.Secure.getInt(context.getContentResolver(),
|
||||
Settings.Secure.BACKGROUND_DATA, 1) == 1);
|
||||
|
||||
// setup our unique device name
|
||||
if (TextUtils.isEmpty(SystemProperties.get("net.hostname"))) {
|
||||
String id = Settings.Secure.getString(context.getContentResolver(),
|
||||
@@ -1208,35 +1196,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ConnectivityManager#getBackgroundDataSetting()
|
||||
*/
|
||||
public boolean getBackgroundDataSetting() {
|
||||
return mBackgroundDataEnabled.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ConnectivityManager#setBackgroundDataSetting(boolean)
|
||||
*/
|
||||
public void setBackgroundDataSetting(boolean allowBackgroundDataUsage) {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.CHANGE_BACKGROUND_DATA_SETTING,
|
||||
"ConnectivityService");
|
||||
|
||||
mBackgroundDataEnabled.set(allowBackgroundDataUsage);
|
||||
|
||||
mHandler.sendMessage(mHandler.obtainMessage(EVENT_SET_BACKGROUND_DATA,
|
||||
(allowBackgroundDataUsage ? ENABLED : DISABLED), 0));
|
||||
}
|
||||
|
||||
private void handleSetBackgroundData(boolean enabled) {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.BACKGROUND_DATA, enabled ? 1 : 0);
|
||||
Intent broadcast = new Intent(
|
||||
ConnectivityManager.ACTION_BACKGROUND_DATA_SETTING_CHANGED);
|
||||
mContext.sendBroadcast(broadcast);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ConnectivityManager#getMobileDataEnabled()
|
||||
*/
|
||||
@@ -2273,12 +2232,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
handleSetNetworkPreference(preference);
|
||||
break;
|
||||
}
|
||||
case EVENT_SET_BACKGROUND_DATA:
|
||||
{
|
||||
boolean enabled = (msg.arg1 == ENABLED);
|
||||
handleSetBackgroundData(enabled);
|
||||
break;
|
||||
}
|
||||
case EVENT_SET_MOBILE_DATA:
|
||||
{
|
||||
boolean enabled = (msg.arg1 == ENABLED);
|
||||
|
||||
Reference in New Issue
Block a user