Revert "Revert "[SettingsProvider] skip caching in system server""

This reverts commit 0f69f74962.

Reason for revert: reland without DeviceConfig changes

BUG: 277448672
Test: atest android.accessibilityservice.cts.AccessibilityTextTraversalTest#testTextEditingAction
Change-Id: Ib02120028a3ea0a6e73041262096f0921d6f1cfc
This commit is contained in:
Song Chun Fan
2023-05-03 20:35:51 +00:00
committed by Songchun Fan
parent abbe7c5638
commit caeb19048d

View File

@@ -3036,9 +3036,7 @@ public final class Settings {
public void destroy() {
try {
// If this process is the system server process, mArray is the same object as
// the memory int array kept inside SettingsProvider, so skipping the close()
if (!Settings.isInSystemServer() && !mArray.isClosed()) {
if (!mArray.isClosed()) {
mArray.close();
}
} catch (IOException e) {
@@ -3218,8 +3216,9 @@ public final class Settings {
@UnsupportedAppUsage
public String getStringForUser(ContentResolver cr, String name, final int userHandle) {
final boolean isSelf = (userHandle == UserHandle.myUserId());
final boolean useCache = isSelf && !isInSystemServer();
boolean needsGenerationTracker = false;
if (isSelf) {
if (useCache) {
synchronized (NameValueCache.this) {
final GenerationTracker generationTracker = mGenerationTrackers.get(name);
if (generationTracker != null) {
@@ -3365,9 +3364,12 @@ public final class Settings {
}
}
} else {
if (LOCAL_LOGV) Log.i(TAG, "call-query of user " + userHandle
+ " by " + UserHandle.myUserId()
+ " so not updating cache");
if (DEBUG || LOCAL_LOGV) {
Log.i(TAG, "call-query of user " + userHandle
+ " by " + UserHandle.myUserId()
+ (isInSystemServer() ? " in system_server" : "")
+ " so not updating cache");
}
}
return value;
}