Several fixes to new EncryptionInterstitial dialog.

The code now observes whether accessibility is turned on when
deciding the default state.

Additionally, it fixes a bug where the user can back out of
EncryptionInterstitial and leave the setting in a bad state.
We now propagate the state until the place where it ultimately
gets stored.

Also fixes problem where Encryption was ignoring the state
where the device was already encrypted.

Fixes bug 17881324

Change-Id: Iec09e4464832a506bb2a78bb14a38b3531971fa0
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 3ca85ea..37fcc87 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -368,6 +368,8 @@
     private boolean mNeedToRevertToInitialFragment = false;
     private int mHomeActivitiesCount = 1;
 
+    private Intent mResultIntentData;
+
     public SwitchBar getSwitchBar() {
         return mSwitchBar;
     }
@@ -597,21 +599,21 @@
                 Button backButton = (Button)findViewById(R.id.back_button);
                 backButton.setOnClickListener(new OnClickListener() {
                     public void onClick(View v) {
-                        setResult(RESULT_CANCELED);
+                        setResult(RESULT_CANCELED, getResultIntentData());
                         finish();
                     }
                 });
                 Button skipButton = (Button)findViewById(R.id.skip_button);
                 skipButton.setOnClickListener(new OnClickListener() {
                     public void onClick(View v) {
-                        setResult(RESULT_OK);
+                        setResult(RESULT_OK, getResultIntentData());
                         finish();
                     }
                 });
                 mNextButton = (Button)findViewById(R.id.next_button);
                 mNextButton.setOnClickListener(new OnClickListener() {
                     public void onClick(View v) {
-                        setResult(RESULT_OK);
+                        setResult(RESULT_OK, getResultIntentData());
                         finish();
                     }
                 });
@@ -1345,4 +1347,12 @@
             mSearchMenuItem.collapseActionView();
         }
     }
+
+    public Intent getResultIntentData() {
+        return mResultIntentData;
+    }
+
+    public void setResultIntentData(Intent resultIntentData) {
+        mResultIntentData = resultIntentData;
+    }
 }