OSDN Git Service

Refresh in-memory SharedPreferences instances after restore
authorChristopher Tate <ctate@google.com>
Wed, 17 May 2017 22:42:35 +0000 (15:42 -0700)
committerChristopher Tate <ctate@google.com>
Tue, 30 May 2017 19:41:39 +0000 (12:41 -0700)
commitfe2368c38cc8ed57dbf7fb2614ca2d7939262818
tree2d0bdd7afcc6fc7b6a8b2cf646dbbf135d2ffb82
parent1bd58ef4b1563bf02e6051b6468ddc9bac10866c
Refresh in-memory SharedPreferences instances after restore

Existing instances don't know that the file has changed out from
under them, so they continue to return stale values from reads, and
risk overwriting restored data with stale content if writes are
performed.  We now tell the backing cache system to induce a
reload after restore (i.e. after we might have written a relevant
file out from under it).

Along the way we shook out an irregularity in the way we were
setting up the context topology of non-lifecycle instances of
the metadata-handling BackupAgent subclass, so that's fixed
now too.

Bug 12061817
Test: cts-tradefed run cts -m CtsBackupHostTestCases

Change-Id: I401fe9297235b55d8a8f041e430d122dc6e24129
core/java/android/app/ContextImpl.java
core/java/android/app/backup/BackupAgent.java
core/java/android/content/Context.java
core/java/android/content/ContextWrapper.java
services/backup/java/com/android/server/backup/BackupManagerService.java
test-runner/src/android/test/mock/MockContext.java