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:
Suchi Amalapurapu
2009-09-29 15:20:32 -07:00
parent a33e3f7925
commit 8550f25523
5 changed files with 31 additions and 9 deletions

View File

@@ -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();