diff --git a/services/core/java/com/android/server/display/PersistentDataStore.java b/services/core/java/com/android/server/display/PersistentDataStore.java index 4b93d8f42da39..59daee9ea2ff5 100644 --- a/services/core/java/com/android/server/display/PersistentDataStore.java +++ b/services/core/java/com/android/server/display/PersistentDataStore.java @@ -463,6 +463,7 @@ final class PersistentDataStore { TypedXmlSerializer serializer = Xml.resolveSerializer(os); saveToXml(serializer); + serializer.flush(); mHandler.removeCallbacksAndMessages(/* token */ null); mHandler.post(() -> { @@ -481,8 +482,6 @@ final class PersistentDataStore { } } }); - - serializer.flush(); } catch (IOException ex) { Slog.w(TAG, "Failed to process the XML serializer.", ex); }