auto import from //branches/cupcake/...@130745
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 65e3650..760988d 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -35,6 +35,7 @@
 import android.os.ServiceManager;
 import android.os.SystemProperties;
 import android.provider.Settings;
+import android.provider.Sync;
 import android.util.EventLog;
 import android.util.Log;
 
@@ -333,6 +334,32 @@
         }
     }
 
+    /**
+     * @see ConnectivityManager#getBackgroundDataSetting()
+     */
+    public boolean getBackgroundDataSetting() {
+        return Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.BACKGROUND_DATA, 1) == 1;
+    }
+    
+    /**
+     * @see ConnectivityManager#setBackgroundDataSetting(boolean)
+     */
+    public void setBackgroundDataSetting(boolean allowBackgroundDataUsage) {
+        mContext.enforceCallingOrSelfPermission(
+                android.Manifest.permission.CHANGE_BACKGROUND_DATA_SETTING,
+                "ConnectivityService");
+        
+        if (getBackgroundDataSetting() == allowBackgroundDataUsage) return;
+
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.BACKGROUND_DATA, allowBackgroundDataUsage ? 1 : 0);
+        
+        Intent broadcast = new Intent(
+                ConnectivityManager.ACTION_BACKGROUND_DATA_SETTING_CHANGED);
+        mContext.sendBroadcast(broadcast);
+    }    
+    
     private int getNumConnectedNetworks() {
         int numConnectedNets = 0;
 
@@ -632,7 +659,7 @@
 
     @Override
     protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DUMP)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                 != PackageManager.PERMISSION_GRANTED) {
             pw.println("Permission Denial: can't dump ConnectivityService from from pid="
                     + Binder.getCallingPid()