Fix a bug in appwidget migration to multiuser directory.

Bug: 6393606

Migrate the old appwidgets.xml if the file doesn't exist,
not if the directory doesn't exist. It worked earlier because
this was the first service that I migrated to multi-user :(

Change-Id: I59bcbc31ff9d101e44dff5e5f44b3cab8f08dc06
This commit is contained in:
Amith Yamasani
2012-05-01 13:48:48 -07:00
parent 11dea29451
commit e0eb39b548

View File

@@ -1595,15 +1595,15 @@ class AppWidgetServiceImpl {
AtomicFile savedStateFile() {
File dir = new File("/data/system/users/" + mUserId);
File settingsFile = getSettingsFile(mUserId);
if (!dir.exists()) {
dir.mkdirs();
if (mUserId == 0) {
// Migrate old data
File oldFile = new File("/data/system/" + SETTINGS_FILENAME);
// Method doesn't throw an exception on failure. Ignore any errors
// in moving the file (like non-existence)
oldFile.renameTo(settingsFile);
if (!settingsFile.exists() && mUserId == 0) {
if (!dir.exists()) {
dir.mkdirs();
}
// Migrate old data
File oldFile = new File("/data/system/" + SETTINGS_FILENAME);
// Method doesn't throw an exception on failure. Ignore any errors
// in moving the file (like non-existence)
oldFile.renameTo(settingsFile);
}
return new AtomicFile(settingsFile);
}