Check if rename of backed up file fails before persisting new changes.
If not these system services will end up with inconsistent settings files when the device runs out of storage. Delete mangled settings file in PackageManager if the current write fails so that we don't end up overwriting the backed up version with the mangled version Include null check when retrieving fwd locked resource for an existing package
This commit is contained in:
@@ -381,7 +381,10 @@ public final class UsageStatsService extends IUsageStats.Stub {
|
||||
mFileLeaf = getCurrentDateStr(FILE_PREFIX);
|
||||
// Copy current file to back up
|
||||
File backupFile = new File(mFile.getPath() + ".bak");
|
||||
mFile.renameTo(backupFile);
|
||||
if (!mFile.renameTo(backupFile)) {
|
||||
Log.w(TAG, "Failed to persist new stats");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Write mStats to file
|
||||
writeStatsFLOCK();
|
||||
|
||||
Reference in New Issue
Block a user