Move the call to flush() to avoid a race condition
Bug: 221393932 Test: atest PersistentDataStoreTest Test: Manually change brightness, run 'adb shell dumpsys display | grep -A30 PersistentDataStore' and check that the brightness value has updated. Also reboot the device and check that the brightness value stays the same. Change-Id: I6f0b958a7db832a0ebe5e9f2ebc434ac92f47a8a
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user