From e6f11af6d326404ecd7f40649961ef880145538b Mon Sep 17 00:00:00 2001 From: Sally Date: Tue, 3 Nov 2020 19:34:16 +0000 Subject: [PATCH] Change forceBoldText to fontWeightAdjustment in ActivityTaskManagerService Convey the weight adjustment instead of a binary on/off Bug: b/170966021, b/110991537 Test: Manual with bold text toggle Change-Id: I06b5c2c7e6bd8a08c7350a0b40cbf2ca90a56008 --- .../server/wm/ActivityTaskManagerService.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 2cbc5148a4e1b..5f14956c18a0c 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -698,8 +698,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { private final class SettingObserver extends ContentObserver { private final Uri mFontScaleUri = Settings.System.getUriFor(FONT_SCALE); private final Uri mHideErrorDialogsUri = Settings.Global.getUriFor(HIDE_ERROR_DIALOGS); - private final Uri mForceBoldTextUri = Settings.Secure.getUriFor( - Settings.Secure.FORCE_BOLD_TEXT); + private final Uri mFontWeightAdjustmentUri = Settings.Secure.getUriFor( + Settings.Secure.FONT_WEIGHT_ADJUSTMENT); SettingObserver() { super(mH); @@ -707,7 +707,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { resolver.registerContentObserver(mFontScaleUri, false, this, UserHandle.USER_ALL); resolver.registerContentObserver(mHideErrorDialogsUri, false, this, UserHandle.USER_ALL); - resolver.registerContentObserver(mForceBoldTextUri, false, this, UserHandle.USER_ALL); + resolver.registerContentObserver( + mFontWeightAdjustmentUri, false, this, UserHandle.USER_ALL); } @Override @@ -720,8 +721,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { synchronized (mGlobalLock) { updateShouldShowDialogsLocked(getGlobalConfiguration()); } - } else if (mForceBoldTextUri.equals(uri)) { - updateForceBoldTextIfNeeded(userId); + } else if (mFontWeightAdjustmentUri.equals(uri)) { + updateFontWeightAdjustmentIfNeeded(userId); } } } @@ -5422,16 +5423,22 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } - private void updateForceBoldTextIfNeeded(@UserIdInt int userId) { - final int forceBoldTextConfig = Settings.Secure.getIntForUser(mContext.getContentResolver(), - Settings.Secure.FORCE_BOLD_TEXT, Configuration.FORCE_BOLD_TEXT_UNDEFINED, userId); + private void updateFontWeightAdjustmentIfNeeded(@UserIdInt int userId) { + final int fontWeightAdjustment = + Settings.Secure.getIntForUser( + mContext.getContentResolver(), + Settings.Secure.FONT_WEIGHT_ADJUSTMENT, + Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED, + userId); + synchronized (mGlobalLock) { - if (getGlobalConfiguration().forceBoldText == forceBoldTextConfig) { + if (getGlobalConfiguration().fontWeightAdjustment == fontWeightAdjustment) { return; } + final Configuration configuration = mWindowManager.computeNewConfiguration(DEFAULT_DISPLAY); - configuration.forceBoldText = forceBoldTextConfig; + configuration.fontWeightAdjustment = fontWeightAdjustment; updatePersistentConfiguration(configuration, userId); } }