summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2010-12-29 16:15:02 -0800
committerRobert Greenwalt <rgreenwalt@google.com>2010-12-29 16:15:02 -0800
commitd825ea4ff055eb9302dcb5c8e59fe65bf31f0a41 (patch)
tree932fb27ec5be7822c8d78ff072926426e54f6b4d /services
parent303f38c4d36d9e51ce5c471b65fbd176ff05508f (diff)
downloadframeworks_base-d825ea4ff055eb9302dcb5c8e59fe65bf31f0a41.zip
frameworks_base-d825ea4ff055eb9302dcb5c8e59fe65bf31f0a41.tar.gz
frameworks_base-d825ea4ff055eb9302dcb5c8e59fe65bf31f0a41.tar.bz2
Cache the current value of background-data.
The writing of the persistent setting is async, but we should still remember it so if somebody asks before the write completes we give the right answer. Makes the read faster too. bug:3312848 Change-Id: I864cb5f8d496d5bf9cbf0af9a71ca84da078f7c6
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/ConnectivityService.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index a84ba78..5eb42e7 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -59,6 +59,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.GregorianCalendar;
import java.util.List;
@@ -113,6 +114,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
private boolean mTestMode;
private static ConnectivityService sServiceInstance;
+ private AtomicBoolean mBackgroundDataEnabled = new AtomicBoolean(true);
+
private static final int ENABLED = 1;
private static final int DISABLED = 0;
@@ -261,6 +264,9 @@ 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(),
@@ -954,8 +960,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
* @see ConnectivityManager#getBackgroundDataSetting()
*/
public boolean getBackgroundDataSetting() {
- return Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.BACKGROUND_DATA, 1) == 1;
+ return mBackgroundDataEnabled.get();
}
/**
@@ -966,6 +971,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
android.Manifest.permission.CHANGE_BACKGROUND_DATA_SETTING,
"ConnectivityService");
+ mBackgroundDataEnabled.set(allowBackgroundDataUsage);
+
mHandler.sendMessage(mHandler.obtainMessage(EVENT_SET_BACKGROUND_DATA,
(allowBackgroundDataUsage ? ENABLED : DISABLED), 0));
}