Merge "Hook up the automatic storage manager settings with the flag." into nyc-mr1-dev
am: 4c5e2bb526

* commit '4c5e2bb526d93e3e5a3958f44a4fe2d012a6ffe7':
  Hook up the automatic storage manager settings with the flag.

Change-Id: Ia3be5191adf3eee5fcf407ced923c94435e9da73
diff --git a/src/com/android/settings/deletionhelper/AutomaticStorageManagerSettings.java b/src/com/android/settings/deletionhelper/AutomaticStorageManagerSettings.java
index bb99725..abd0ec1 100644
--- a/src/com/android/settings/deletionhelper/AutomaticStorageManagerSettings.java
+++ b/src/com/android/settings/deletionhelper/AutomaticStorageManagerSettings.java
@@ -18,6 +18,7 @@
 
 import android.app.Activity;
 import android.os.Bundle;
+import android.provider.Settings;
 import android.util.Log;
 import android.view.View;
 import android.widget.Switch;
@@ -64,6 +65,10 @@
         mDeletionHelper.setOnPreferenceClickListener(this);
 
         mStorageManagerSwitch = (SwitchPreference) findPreference(KEY_STORAGE_MANAGER_SWITCH);
+        boolean isChecked =
+                Settings.Secure.getInt(getContentResolver(),
+                        Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, 0) != 0;
+        mStorageManagerSwitch.setChecked(isChecked);
         mStorageManagerSwitch.setOnPreferenceChangeListener(this);
     }
 
@@ -79,6 +84,8 @@
             case KEY_STORAGE_MANAGER_SWITCH:
                 boolean checked = (boolean) newValue;
                 mDaysToRetain.setEnabled(checked);
+                Settings.Secure.putInt(getContentResolver(),
+                        Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, checked ? 1 : 0);
                 break;
             case KEY_DAYS:
                 // TODO: Configure a setting which controls how many days of data the storage manager