diff options
author | Amith Yamasani <yamasani@google.com> | 2012-04-11 15:32:07 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2012-04-11 15:32:07 -0700 |
commit | a23bb38628ac1f5dc4ebe6847faedc424dd5fce1 (patch) | |
tree | 704db9e58c30ad25a2a97d5291deefb65f7d5fe9 /core | |
parent | d3ce6f50c114f58a3f50e44764e9b315ac41f637 (diff) | |
download | frameworks_base-a23bb38628ac1f5dc4ebe6847faedc424dd5fce1.zip frameworks_base-a23bb38628ac1f5dc4ebe6847faedc424dd5fce1.tar.gz frameworks_base-a23bb38628ac1f5dc4ebe6847faedc424dd5fce1.tar.bz2 |
Don't migrate accounts.db if already migrated.
Some developers accidentally create a blank accounts.db and this
was causing accounts to vanish. This safeguards the case where both
old and new files exist.
Bug: 6168813
Change-Id: I79cf211acc5422ff1c17fe0c9af80c49227b60ac
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/accounts/AccountManagerService.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java index 197c1bd..3d5bbd4 100644 --- a/core/java/android/accounts/AccountManagerService.java +++ b/core/java/android/accounts/AccountManagerService.java @@ -1844,9 +1844,12 @@ public class AccountManagerService File systemDir = Environment.getSystemSecureDirectory(); File databaseFile = new File(systemDir, "users/" + userId + "/" + DATABASE_NAME); if (userId == 0) { - // Migrate old file, if it exists, to the new location + // Migrate old file, if it exists, to the new location. + // Make sure the new file doesn't already exist. A dummy file could have been + // accidentally created in the old location, causing the new one to become corrupted + // as well. File oldFile = new File(systemDir, DATABASE_NAME); - if (oldFile.exists()) { + if (oldFile.exists() && !databaseFile.exists()) { // Check for use directory; create if it doesn't exist, else renameTo will fail File userDir = new File(systemDir, "users/" + userId); if (!userDir.exists()) { |