Merge "Synchronize increment of resource cache generations" into udc-dev am: dd33731584
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23863712 Change-Id: Ibd38b15e4d216f0a2ae9ddc33f0a98bfd7b2b0b1 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -137,9 +137,11 @@ abstract class ThemedResourceCache<T> {
|
|||||||
*/
|
*/
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public void onConfigurationChange(@Config int configChanges) {
|
public void onConfigurationChange(@Config int configChanges) {
|
||||||
prune(configChanges);
|
synchronized (this) {
|
||||||
|
pruneLocked(configChanges);
|
||||||
mGeneration++;
|
mGeneration++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a cached entry has been invalidated by a configuration
|
* Returns whether a cached entry has been invalidated by a configuration
|
||||||
@@ -214,8 +216,7 @@ abstract class ThemedResourceCache<T> {
|
|||||||
* simply prune missing weak references
|
* simply prune missing weak references
|
||||||
* @return {@code true} if the cache is completely empty after pruning
|
* @return {@code true} if the cache is completely empty after pruning
|
||||||
*/
|
*/
|
||||||
private boolean prune(@Config int configChanges) {
|
private boolean pruneLocked(@Config int configChanges) {
|
||||||
synchronized (this) {
|
|
||||||
if (mThemedEntries != null) {
|
if (mThemedEntries != null) {
|
||||||
for (int i = mThemedEntries.size() - 1; i >= 0; i--) {
|
for (int i = mThemedEntries.size() - 1; i >= 0; i--) {
|
||||||
if (pruneEntriesLocked(mThemedEntries.valueAt(i), configChanges)) {
|
if (pruneEntriesLocked(mThemedEntries.valueAt(i), configChanges)) {
|
||||||
@@ -230,7 +231,6 @@ abstract class ThemedResourceCache<T> {
|
|||||||
return mThemedEntries == null && mNullThemedEntries == null
|
return mThemedEntries == null && mNullThemedEntries == null
|
||||||
&& mUnthemedEntries == null;
|
&& mUnthemedEntries == null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private boolean pruneEntriesLocked(@Nullable LongSparseArray<WeakReference<T>> entries,
|
private boolean pruneEntriesLocked(@Nullable LongSparseArray<WeakReference<T>> entries,
|
||||||
@Config int configChanges) {
|
@Config int configChanges) {
|
||||||
|
|||||||
Reference in New Issue
Block a user