change recovery images to android with spinner

Also make writing the locale a bit more robust.

Change-Id: I803dd0aa0b9d6661fad74ea13fb085682402323c
diff --git a/recovery.cpp b/recovery.cpp
index e374c7d..70817d3 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -277,6 +277,18 @@
         }
     }
 
+    // Save the locale to cache, so if recovery is next started up
+    // without a --locale argument (eg, directly from the bootloader)
+    // it will use the last-known locale.
+    if (locale != NULL) {
+        LOGI("Saving locale \"%s\"\n", locale);
+        FILE* fp = fopen_path(LOCALE_FILE, "w");
+        fwrite(locale, 1, strlen(locale), fp);
+        fflush(fp);
+        fsync(fileno(fp));
+        check_and_fclose(fp, LOCALE_FILE);
+    }
+
     // Copy logs to cache so the system can find out what happened.
     copy_log_file(TEMPORARY_LOG_FILE, LOG_FILE, true);
     copy_log_file(TEMPORARY_LOG_FILE, LAST_LOG_FILE, false);
@@ -286,15 +298,6 @@
     chmod(LAST_LOG_FILE, 0640);
     chmod(LAST_INSTALL_FILE, 0644);
 
-    // Save the locale to cache, so if recovery is next started up
-    // without a --locale argument (eg, directly from the bootloader)
-    // it will use the last-known locale.
-    if (locale != NULL) {
-        FILE* fp = fopen(LOCALE_FILE, "w");
-        fwrite(locale, 1, strlen(locale), fp);
-        fclose(fp);
-    }
-
     // Reset to normal system boot so recovery won't cycle indefinitely.
     struct bootloader_message boot;
     memset(&boot, 0, sizeof(boot));