Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c835bf54 authored by Songchun Fan's avatar Songchun Fan
Browse files

[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
parent 96c8a3b3
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -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);
                }
            }