Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04b12fda authored by Trung Lam's avatar Trung Lam Committed by Automerger Merge Worker
Browse files

Merge "Fix issue with saving protos to disk during shutdown." am: 68e0de02...

Merge "Fix issue with saving protos to disk during shutdown." am: 68e0de02 am: 26fcba8c am: 32d14293 am: 043ebe22

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1492076

Change-Id: Iab62af81ff2aafba850f93f40d2e29f358754591
parents 36b8f60f 043ebe22
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -185,23 +185,24 @@ abstract class AbstractProtoDiskReadWriter<T> {
     * is useful for when device is powering off.
     */
    @MainThread
    synchronized void saveImmediately(@NonNull String fileName, @NonNull T data) {
    void saveImmediately(@NonNull String fileName, @NonNull T data) {
        synchronized (this) {
            mScheduledFileDataMap.put(fileName, data);
        }
        triggerScheduledFlushEarly();
    }

    @MainThread
    private synchronized void triggerScheduledFlushEarly() {
    private void triggerScheduledFlushEarly() {
        synchronized (this) {
            if (mScheduledFileDataMap.isEmpty() || mScheduledExecutorService.isShutdown()) {
                return;
            }
            // Cancel existing future.
            if (mScheduledFuture != null) {

            // We shouldn't need to interrupt as this method and threaded task
            // #flushScheduledData are both synchronized.
                mScheduledFuture.cancel(true);
            }
        }

        // Submit flush and blocks until it completes. Blocking will prevent the device from
        // shutting down before flushing completes.