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

Commit fe473986 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Avoid cross lock acquisition leading to deadlocks"

parents 35035f60 e83df489
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -553,13 +553,7 @@ final class SettingsState {
    }

    private void doWriteState() {
        synchronized (mWriteLock) {
            if (DEBUG_PERSISTENCE) {
                Slog.i(LOG_TAG, "[PERSIST START]");
            }

            AtomicFile destination = new AtomicFile(mStatePersistFile);

        boolean wroteState = false;
        final int version;
        final ArrayMap<String, Setting> settings;

@@ -570,6 +564,12 @@ final class SettingsState {
            mWriteScheduled = false;
        }

        synchronized (mWriteLock) {
            if (DEBUG_PERSISTENCE) {
                Slog.i(LOG_TAG, "[PERSIST START]");
            }

            AtomicFile destination = new AtomicFile(mStatePersistFile);
            FileOutputStream out = null;
            try {
                out = destination.startWrite();
@@ -600,9 +600,7 @@ final class SettingsState {
                serializer.endDocument();
                destination.finishWrite(out);

                synchronized (mLock) {
                    addHistoricalOperationLocked(HISTORICAL_OPERATION_PERSIST, null);
                }
                wroteState = true;

                if (DEBUG_PERSISTENCE) {
                    Slog.i(LOG_TAG, "[PERSIST END]");
@@ -614,6 +612,12 @@ final class SettingsState {
                IoUtils.closeQuietly(out);
            }
        }

        if (wroteState) {
            synchronized (mLock) {
                addHistoricalOperationLocked(HISTORICAL_OPERATION_PERSIST, null);
            }
        }
    }

    static void writeSingleSetting(int version, XmlSerializer serializer, String id,