Don't reboot after default encrypting

Instead trigger normal default encryption mount

Requires matching change to system/core: https://googleplex-android-review.git.corp.google.com/#/c/527286/

Bug: 17041092

Change-Id: Ifcf023386e08325db7dce61395fbb056f7d9815b
diff --git a/cryptfs.c b/cryptfs.c
index 93680e5..57f24e7 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -2709,12 +2709,22 @@
 
         put_crypt_ftr_and_key(&crypt_ftr);
 
-        sleep(2); /* Give the UI a chance to show 100% progress */
-                  /* Partially encrypted - ensure writes are flushed to ssd */
-
         if (crypt_ftr.encrypted_upto == crypt_ftr.fs_size) {
+          char value[PROPERTY_VALUE_MAX];
+          property_get("ro.crypto.state", value, "");
+          if (!strcmp(value, "")) {
+            /* default encryption - continue first boot sequence */
+            property_set("ro.crypto.state", "encrypted");
+            release_wake_lock(lockid);
+            cryptfs_check_passwd(DEFAULT_PASSWORD);
+            cryptfs_restart_internal(1);
+            return 0;
+          } else {
+            sleep(2); /* Give the UI a chance to show 100% progress */
             cryptfs_reboot(reboot);
+          }
         } else {
+            sleep(2); /* Partially encrypted, ensure writes flushed to ssd */
             cryptfs_reboot(shutdown);
         }
     } else {