Loading core/java/android/text/ClientFlags.java 0 → 100644 +58 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.text; import com.android.text.flags.Flags; /** * An aconfig feature flags that can be accessible from application process without * ContentProvider IPCs. * * When you add new flags, you have to add flag string to {@link TextFlags#TEXT_ACONFIGS_FLAGS}. * * @hide */ public class ClientFlags { /** * @see Flags#deprecateFontsXml() */ public static boolean deprecateFontsXml() { return TextFlags.isFeatureEnabled(Flags.FLAG_DEPRECATE_FONTS_XML); } /** * @see Flags#noBreakNoHyphenationSpan() */ public static boolean noBreakNoHyphenationSpan() { return TextFlags.isFeatureEnabled(Flags.FLAG_NO_BREAK_NO_HYPHENATION_SPAN); } /** * @see Flags#phraseStrictFallback() */ public static boolean phraseStrictFallback() { return TextFlags.isFeatureEnabled(Flags.FLAG_PHRASE_STRICT_FALLBACK); } /** * @see Flags#useBoundsForWidth() */ public static boolean useBoundsForWidth() { return TextFlags.isFeatureEnabled(Flags.FLAG_USE_BOUNDS_FOR_WIDTH); } } core/java/android/text/TextFlags.java +29 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,11 @@ package android.text; import android.annotation.NonNull; import android.app.AppGlobals; import com.android.text.flags.Flags; /** * Flags in the "text" namespace. * Loading Loading @@ -46,4 +51,28 @@ public final class TextFlags { */ public static final boolean ENABLE_NEW_CONTEXT_MENU_DEFAULT = true; /** * List of text flags to be transferred to the application process. */ public static final String[] TEXT_ACONFIGS_FLAGS = { Flags.FLAG_DEPRECATE_FONTS_XML, Flags.FLAG_NO_BREAK_NO_HYPHENATION_SPAN, Flags.FLAG_PHRASE_STRICT_FALLBACK, Flags.FLAG_USE_BOUNDS_FOR_WIDTH, }; /** * Get a key for the feature flag. */ public static String getKeyForFlag(@NonNull String flag) { return "text__" + flag; } /** * Return true if the feature flag is enabled. */ public static boolean isFeatureEnabled(@NonNull String flag) { return AppGlobals.getIntCoreSetting( getKeyForFlag(flag), 0 /* aconfig is false by default */) != 0; } } core/java/android/widget/TextView.java +2 −1 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.text.BoringLayout; import android.text.ClientFlags; import android.text.DynamicLayout; import android.text.Editable; import android.text.GetChars; Loading Loading @@ -1634,7 +1635,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } if (CompatChanges.isChangeEnabled(USE_BOUNDS_FOR_WIDTH)) { mUseBoundsForWidth = false; // TODO: Connect to the flag. mUseBoundsForWidth = ClientFlags.useBoundsForWidth(); } else { mUseBoundsForWidth = false; } Loading services/core/java/com/android/server/am/CoreSettingsObserver.java +10 −0 Original line number Diff line number Diff line Loading @@ -173,6 +173,16 @@ final class CoreSettingsObserver extends ContentObserver { TextFlags.NAMESPACE, TextFlags.ENABLE_NEW_CONTEXT_MENU, TextFlags.KEY_ENABLE_NEW_CONTEXT_MENU, boolean.class, TextFlags.ENABLE_NEW_CONTEXT_MENU_DEFAULT)); // Register all text aconfig flags. for (String flag : TextFlags.TEXT_ACONFIGS_FLAGS) { sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>( TextFlags.NAMESPACE, flag, TextFlags.getKeyForFlag(flag), boolean.class, false)); // All aconfig flags are false by default. } // add other device configs here... } private static volatile boolean sDeviceConfigContextEntriesLoaded = false; Loading Loading
core/java/android/text/ClientFlags.java 0 → 100644 +58 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.text; import com.android.text.flags.Flags; /** * An aconfig feature flags that can be accessible from application process without * ContentProvider IPCs. * * When you add new flags, you have to add flag string to {@link TextFlags#TEXT_ACONFIGS_FLAGS}. * * @hide */ public class ClientFlags { /** * @see Flags#deprecateFontsXml() */ public static boolean deprecateFontsXml() { return TextFlags.isFeatureEnabled(Flags.FLAG_DEPRECATE_FONTS_XML); } /** * @see Flags#noBreakNoHyphenationSpan() */ public static boolean noBreakNoHyphenationSpan() { return TextFlags.isFeatureEnabled(Flags.FLAG_NO_BREAK_NO_HYPHENATION_SPAN); } /** * @see Flags#phraseStrictFallback() */ public static boolean phraseStrictFallback() { return TextFlags.isFeatureEnabled(Flags.FLAG_PHRASE_STRICT_FALLBACK); } /** * @see Flags#useBoundsForWidth() */ public static boolean useBoundsForWidth() { return TextFlags.isFeatureEnabled(Flags.FLAG_USE_BOUNDS_FOR_WIDTH); } }
core/java/android/text/TextFlags.java +29 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,11 @@ package android.text; import android.annotation.NonNull; import android.app.AppGlobals; import com.android.text.flags.Flags; /** * Flags in the "text" namespace. * Loading Loading @@ -46,4 +51,28 @@ public final class TextFlags { */ public static final boolean ENABLE_NEW_CONTEXT_MENU_DEFAULT = true; /** * List of text flags to be transferred to the application process. */ public static final String[] TEXT_ACONFIGS_FLAGS = { Flags.FLAG_DEPRECATE_FONTS_XML, Flags.FLAG_NO_BREAK_NO_HYPHENATION_SPAN, Flags.FLAG_PHRASE_STRICT_FALLBACK, Flags.FLAG_USE_BOUNDS_FOR_WIDTH, }; /** * Get a key for the feature flag. */ public static String getKeyForFlag(@NonNull String flag) { return "text__" + flag; } /** * Return true if the feature flag is enabled. */ public static boolean isFeatureEnabled(@NonNull String flag) { return AppGlobals.getIntCoreSetting( getKeyForFlag(flag), 0 /* aconfig is false by default */) != 0; } }
core/java/android/widget/TextView.java +2 −1 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.text.BoringLayout; import android.text.ClientFlags; import android.text.DynamicLayout; import android.text.Editable; import android.text.GetChars; Loading Loading @@ -1634,7 +1635,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } if (CompatChanges.isChangeEnabled(USE_BOUNDS_FOR_WIDTH)) { mUseBoundsForWidth = false; // TODO: Connect to the flag. mUseBoundsForWidth = ClientFlags.useBoundsForWidth(); } else { mUseBoundsForWidth = false; } Loading
services/core/java/com/android/server/am/CoreSettingsObserver.java +10 −0 Original line number Diff line number Diff line Loading @@ -173,6 +173,16 @@ final class CoreSettingsObserver extends ContentObserver { TextFlags.NAMESPACE, TextFlags.ENABLE_NEW_CONTEXT_MENU, TextFlags.KEY_ENABLE_NEW_CONTEXT_MENU, boolean.class, TextFlags.ENABLE_NEW_CONTEXT_MENU_DEFAULT)); // Register all text aconfig flags. for (String flag : TextFlags.TEXT_ACONFIGS_FLAGS) { sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>( TextFlags.NAMESPACE, flag, TextFlags.getKeyForFlag(flag), boolean.class, false)); // All aconfig flags are false by default. } // add other device configs here... } private static volatile boolean sDeviceConfigContextEntriesLoaded = false; Loading