Hook up the automatic storage manager settings with the flag.

This allows the settings menu to actually toggle the feature on
and off.

Bug: 28905328
Change-Id: I132c0930970b70a0f88b8fc21e85b6829aaef8c8
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