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

@ -2049,7 +2049,7 @@ class PackageManagerService extends IPackageManager.Stub {
scanMode |= SCAN_FORWARD_LOCKED;
}
File resFile = destResourceFile;
if ((scanMode & SCAN_FORWARD_LOCKED) != 0) {
if (ps != null && ((scanMode & SCAN_FORWARD_LOCKED) != 0)) {
resFile = getFwdLockedResource(ps.name);
}
// Note that we invoke the following method only if we are about to unpack an application
@ -6529,15 +6529,19 @@ class PackageManagerService extends IPackageManager.Stub {
|FileUtils.S_IRGRP|FileUtils.S_IWGRP
|FileUtils.S_IROTH,
-1, -1);
return;
} catch(XmlPullParserException e) {
Log.w(TAG, "Unable to write package manager settings, current changes will be lost at reboot", e);
} catch(java.io.IOException e) {
Log.w(TAG, "Unable to write package manager settings, current changes will be lost at reboot", e);
}
// Clean up partially written file
if (mSettingsFilename.exists()) {
if (!mSettingsFilename.delete()) {
Log.i(TAG, "Failed to clean up mangled file: " + mSettingsFilename);
}
}
//Debug.stopMethodTracing();
}