[SettingsProvider] only increment generation of unset settings if new setting is non-predefined

This is a small optimization for the previous CL. The generation number
of all non-predefined, unset settings should only be incremented if the
newly inserted setting is also non-predefined. If it's a predefined
setting, it doesn't affect the non-predefined, unset settings.

BUG: 228619157
Test: atest android.widget.TextViewPrecomputedTextPerfTest#testOnMeasure_RandomText
Test: observed no regression
Change-Id: I33e2391e3e07fb5251cb497a0e87e9815d540e55
This commit is contained in:
Songchun Fan
2023-03-07 11:02:59 -08:00
parent 96c8a3b33f
commit c835bf549b

View File

@@ -3056,11 +3056,11 @@ public class SettingsProvider extends ContentProvider {
final int key = makeKey(type, userId);
boolean success = false;
boolean isNewSetting = false;
boolean wasUnsetNonPredefinedSetting = false;
SettingsState settingsState = peekSettingsStateLocked(key);
if (settingsState != null) {
if (!settingsState.hasSetting(name)) {
isNewSetting = true;
if (!isSettingPreDefined(name, type) && !settingsState.hasSetting(name)) {
wasUnsetNonPredefinedSetting = true;
}
success = settingsState.insertSettingLocked(name, value,
tag, makeDefault, forceNonSystemPackage, packageName,
@@ -3073,9 +3073,9 @@ public class SettingsProvider extends ContentProvider {
if (forceNotify || success) {
notifyForSettingsChange(key, name);
if (isNewSetting && !isSettingPreDefined(name, type)) {
// Increment the generation number for all null settings because a new
// non-predefined setting has been inserted
if (wasUnsetNonPredefinedSetting) {
// Increment the generation number for all non-predefined, unset settings,
// because a new non-predefined setting has been inserted
mGenerationRegistry.incrementGenerationForUnsetSettings(key);
}
}