Loading core/java/android/util/AtomicFile.java +9 −0 Original line number Diff line number Diff line Loading @@ -201,6 +201,15 @@ public class AtomicFile { return new FileInputStream(mBaseName); } /** * @hide * Checks if the original or backup file exists. * @return whether the original or backup file exists. */ public boolean exists() { return mBaseName.exists() || mBackupName.exists(); } /** * Gets the last modified time of the atomic file. * {@hide} Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +2 −2 Original line number Diff line number Diff line Loading @@ -2597,7 +2597,7 @@ public class SettingsProvider extends ContentProvider { synchronized (mLock) { final int key = makeKey(SETTINGS_TYPE_GLOBAL, UserHandle.USER_SYSTEM); File globalFile = getSettingsFile(key); if (globalFile.exists()) { if (SettingsState.stateFileExists(globalFile)) { return; } Loading Loading @@ -2634,7 +2634,7 @@ public class SettingsProvider extends ContentProvider { // Every user has secure settings and if no file we need to migrate. final int secureKey = makeKey(SETTINGS_TYPE_SECURE, userId); File secureFile = getSettingsFile(secureKey); if (secureFile.exists()) { if (SettingsState.stateFileExists(secureFile)) { return; } Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java +12 −8 Original line number Diff line number Diff line Loading @@ -689,17 +689,11 @@ final class SettingsState { private void readStateSyncLocked() { FileInputStream in; if (!mStatePersistFile.exists()) { Slog.i(LOG_TAG, "No settings state " + mStatePersistFile); addHistoricalOperationLocked(HISTORICAL_OPERATION_INITIALIZE, null); return; } try { in = new AtomicFile(mStatePersistFile).openRead(); } catch (FileNotFoundException fnfe) { String message = "No settings state " + mStatePersistFile; Slog.wtf(LOG_TAG, message); Slog.i(LOG_TAG, message); Slog.i(LOG_TAG, "No settings state " + mStatePersistFile); addHistoricalOperationLocked(HISTORICAL_OPERATION_INITIALIZE, null); return; } try { Loading @@ -715,6 +709,16 @@ final class SettingsState { } } /** * Uses AtomicFile to check if the file or its backup exists. * @param file The file to check for existence * @return whether the original or backup exist */ public static boolean stateFileExists(File file) { AtomicFile stateFile = new AtomicFile(file); return stateFile.exists(); } private void parseStateLocked(XmlPullParser parser) throws IOException, XmlPullParserException { final int outerDepth = parser.getDepth(); Loading Loading
core/java/android/util/AtomicFile.java +9 −0 Original line number Diff line number Diff line Loading @@ -201,6 +201,15 @@ public class AtomicFile { return new FileInputStream(mBaseName); } /** * @hide * Checks if the original or backup file exists. * @return whether the original or backup file exists. */ public boolean exists() { return mBaseName.exists() || mBackupName.exists(); } /** * Gets the last modified time of the atomic file. * {@hide} Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +2 −2 Original line number Diff line number Diff line Loading @@ -2597,7 +2597,7 @@ public class SettingsProvider extends ContentProvider { synchronized (mLock) { final int key = makeKey(SETTINGS_TYPE_GLOBAL, UserHandle.USER_SYSTEM); File globalFile = getSettingsFile(key); if (globalFile.exists()) { if (SettingsState.stateFileExists(globalFile)) { return; } Loading Loading @@ -2634,7 +2634,7 @@ public class SettingsProvider extends ContentProvider { // Every user has secure settings and if no file we need to migrate. final int secureKey = makeKey(SETTINGS_TYPE_SECURE, userId); File secureFile = getSettingsFile(secureKey); if (secureFile.exists()) { if (SettingsState.stateFileExists(secureFile)) { return; } Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java +12 −8 Original line number Diff line number Diff line Loading @@ -689,17 +689,11 @@ final class SettingsState { private void readStateSyncLocked() { FileInputStream in; if (!mStatePersistFile.exists()) { Slog.i(LOG_TAG, "No settings state " + mStatePersistFile); addHistoricalOperationLocked(HISTORICAL_OPERATION_INITIALIZE, null); return; } try { in = new AtomicFile(mStatePersistFile).openRead(); } catch (FileNotFoundException fnfe) { String message = "No settings state " + mStatePersistFile; Slog.wtf(LOG_TAG, message); Slog.i(LOG_TAG, message); Slog.i(LOG_TAG, "No settings state " + mStatePersistFile); addHistoricalOperationLocked(HISTORICAL_OPERATION_INITIALIZE, null); return; } try { Loading @@ -715,6 +709,16 @@ final class SettingsState { } } /** * Uses AtomicFile to check if the file or its backup exists. * @param file The file to check for existence * @return whether the original or backup exist */ public static boolean stateFileExists(File file) { AtomicFile stateFile = new AtomicFile(file); return stateFile.exists(); } private void parseStateLocked(XmlPullParser parser) throws IOException, XmlPullParserException { final int outerDepth = parser.getDepth(); Loading