From 67466de364b40fe5bad0a8d27ddbb8c7692fe1d2 Mon Sep 17 00:00:00 2001 From: Yurii Zubrytskyi Date: Thu, 25 Apr 2024 17:06:28 -0700 Subject: [PATCH] Don't overwrite the system global gender settings Developer setting shouldn't rewrite the proper user-selected value. This is best effort and will still overwrite it when the values used to be the same. Bug: 332955145 Test: manual Change-Id: I7c350ff84dfc7e216835ab3b45b7c1316ea78155 --- .../GrammaticalGenderPreferenceController.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/development/GrammaticalGenderPreferenceController.java b/src/com/android/settings/development/GrammaticalGenderPreferenceController.java index 054097487e0..347894d7ee6 100644 --- a/src/com/android/settings/development/GrammaticalGenderPreferenceController.java +++ b/src/com/android/settings/development/GrammaticalGenderPreferenceController.java @@ -69,12 +69,19 @@ public class GrammaticalGenderPreferenceController extends DeveloperOptionsPrefe @Override public boolean onPreferenceChange(Preference preference, Object newValue) { + final var oldValue = SystemProperties.getInt(GRAMMATICAL_GENDER_PROPERTY, + Configuration.GRAMMATICAL_GENDER_NOT_SPECIFIED); SystemProperties.set(GRAMMATICAL_GENDER_PROPERTY, newValue.toString()); updateState(mPreference); try { Configuration config = mActivityManager.getConfiguration(); - config.setGrammaticalGender(Integer.parseInt(newValue.toString())); - mActivityManager.updatePersistentConfiguration(config); + // Only apply the developer settings value if it is the one currently used, + // otherwise it means there's some kind of override that we don't want to + // touch here. + if (config.getGrammaticalGender() == oldValue) { + config.setGrammaticalGender(Integer.parseInt(newValue.toString())); + mActivityManager.updatePersistentConfiguration(config); + } } catch (RemoteException ex) { // intentional no-op }