Merge "Fix a race in local settings caches" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f4ddb7ce30
@ -1311,12 +1311,19 @@ public final class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide Key with the location in the {@link android.util.MemoryIntArray} where
|
* @hide Key with the location in the {@link android.util.MemoryIntArray} where
|
||||||
* to look up the generation id of the backing table.
|
* to look up the generation id of the backing table. The value is an integer.
|
||||||
*
|
*
|
||||||
* @see #CALL_METHOD_TRACK_GENERATION_KEY
|
* @see #CALL_METHOD_TRACK_GENERATION_KEY
|
||||||
*/
|
*/
|
||||||
public static final String CALL_METHOD_GENERATION_INDEX_KEY = "_generation_index";
|
public static final String CALL_METHOD_GENERATION_INDEX_KEY = "_generation_index";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide Key with the settings table generation. The value is an integer.
|
||||||
|
*
|
||||||
|
* @see #CALL_METHOD_TRACK_GENERATION_KEY
|
||||||
|
*/
|
||||||
|
public static final String CALL_METHOD_GENERATION_KEY = "_generation";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide - User handle argument extra to the fast-path call()-based requests
|
* @hide - User handle argument extra to the fast-path call()-based requests
|
||||||
*/
|
*/
|
||||||
@ -1467,11 +1474,11 @@ public final class Settings {
|
|||||||
private int mCurrentGeneration;
|
private int mCurrentGeneration;
|
||||||
|
|
||||||
public GenerationTracker(@NonNull MemoryIntArray array, int index,
|
public GenerationTracker(@NonNull MemoryIntArray array, int index,
|
||||||
Runnable errorHandler) {
|
int generation, Runnable errorHandler) {
|
||||||
mArray = array;
|
mArray = array;
|
||||||
mIndex = index;
|
mIndex = index;
|
||||||
mErrorHandler = errorHandler;
|
mErrorHandler = errorHandler;
|
||||||
mCurrentGeneration = readCurrentGeneration();
|
mCurrentGeneration = generation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGenerationChanged() {
|
public boolean isGenerationChanged() {
|
||||||
@ -1627,6 +1634,8 @@ public final class Settings {
|
|||||||
final int index = b.getInt(
|
final int index = b.getInt(
|
||||||
CALL_METHOD_GENERATION_INDEX_KEY, -1);
|
CALL_METHOD_GENERATION_INDEX_KEY, -1);
|
||||||
if (array != null && index >= 0) {
|
if (array != null && index >= 0) {
|
||||||
|
final int generation = b.getInt(
|
||||||
|
CALL_METHOD_GENERATION_KEY, 0);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.i(TAG, "Received generation tracker for type:"
|
Log.i(TAG, "Received generation tracker for type:"
|
||||||
+ mUri.getPath() + " in package:"
|
+ mUri.getPath() + " in package:"
|
||||||
@ -1634,7 +1643,7 @@ public final class Settings {
|
|||||||
+ userHandle + " with index:" + index);
|
+ userHandle + " with index:" + index);
|
||||||
}
|
}
|
||||||
mGenerationTracker = new GenerationTracker(array, index,
|
mGenerationTracker = new GenerationTracker(array, index,
|
||||||
() -> {
|
generation, () -> {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
Log.e(TAG, "Error accessing generation"
|
Log.e(TAG, "Error accessing generation"
|
||||||
+ " tracker - removing");
|
+ " tracker - removing");
|
||||||
|
@ -76,6 +76,8 @@ final class GenerationRegistry {
|
|||||||
bundle.putParcelable(Settings.CALL_METHOD_TRACK_GENERATION_KEY,
|
bundle.putParcelable(Settings.CALL_METHOD_TRACK_GENERATION_KEY,
|
||||||
backingStore);
|
backingStore);
|
||||||
bundle.putInt(Settings.CALL_METHOD_GENERATION_INDEX_KEY, index);
|
bundle.putInt(Settings.CALL_METHOD_GENERATION_INDEX_KEY, index);
|
||||||
|
bundle.putInt(Settings.CALL_METHOD_GENERATION_KEY,
|
||||||
|
backingStore.get(index));
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.i(LOG_TAG, "Exported index:" + index + " for key:"
|
Slog.i(LOG_TAG, "Exported index:" + index + " for key:"
|
||||||
+ SettingsProvider.keyToString(key));
|
+ SettingsProvider.keyToString(key));
|
||||||
|
Reference in New Issue
Block a user