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

Commit 02d89196 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi
Browse files

[res] Add the grammatical gender qualifier

Bug: 237579711
Test: UTs + build + boot

Change-Id: Id0919799a8a364f109ff351974f02e4f151f23cd
parent dac535a7
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -12984,9 +12984,9 @@ package android.content.res {
    field @NonNull public static final android.os.Parcelable.Creator<android.content.res.Configuration> CREATOR;
    field public static final int DENSITY_DPI_UNDEFINED = 0; // 0x0
    field public static final int FONT_WEIGHT_ADJUSTMENT_UNDEFINED = 2147483647; // 0x7fffffff
    field public static final int GRAMMATICAL_GENDER_FEMININE = 3; // 0x3
    field public static final int GRAMMATICAL_GENDER_MASCULINE = 4; // 0x4
    field public static final int GRAMMATICAL_GENDER_NEUTRAL = 2; // 0x2
    field public static final int GRAMMATICAL_GENDER_FEMININE = 2; // 0x2
    field public static final int GRAMMATICAL_GENDER_MASCULINE = 3; // 0x3
    field public static final int GRAMMATICAL_GENDER_NEUTRAL = 1; // 0x1
    field public static final int GRAMMATICAL_GENDER_NOT_SPECIFIED = 0; // 0x0
    field public static final int HARDKEYBOARDHIDDEN_NO = 1; // 0x1
    field public static final int HARDKEYBOARDHIDDEN_UNDEFINED = 0; // 0x0
+3 −2
Original line number Diff line number Diff line
@@ -998,6 +998,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        Configuration.NATIVE_CONFIG_DENSITY,                // DENSITY
        Configuration.NATIVE_CONFIG_LAYOUTDIR,              // LAYOUT DIRECTION
        Configuration.NATIVE_CONFIG_COLOR_MODE,             // COLOR_MODE
        Configuration.NATIVE_CONFIG_GRAMMATICAL_GENDER,
    };

    /**
@@ -1267,8 +1268,8 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
     * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN},
     * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION},
     * {@link #CONFIG_ORIENTATION}, {@link #CONFIG_SCREEN_LAYOUT},
     * {@link #CONFIG_DENSITY}, {@link #CONFIG_LAYOUT_DIRECTION} and
     * {@link #CONFIG_COLOR_MODE}.
     * {@link #CONFIG_DENSITY}, {@link #CONFIG_LAYOUT_DIRECTION},
     * {@link #CONFIG_COLOR_MODE}, and {link #CONFIG_GRAMMATICAL_GENDER}.
     * Set from the {@link android.R.attr#configChanges} attribute.
     */
    public int configChanges;
+3 −3
Original line number Diff line number Diff line
@@ -1456,7 +1456,7 @@ public class PackageParser {

    private static AssetManager newConfiguredAssetManager() {
        AssetManager assetManager = new AssetManager();
        assetManager.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        assetManager.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                Build.VERSION.RESOURCES_SDK_INT);
        return assetManager;
    }
@@ -9011,7 +9011,7 @@ public class PackageParser {
            }

            AssetManager assets = new AssetManager();
            assets.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            assets.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    Build.VERSION.RESOURCES_SDK_INT);
            assets.setApkAssets(apkAssets, false /*invalidateCaches*/);

@@ -9086,7 +9086,7 @@ public class PackageParser {

        private static AssetManager createAssetManagerWithAssets(ApkAssets[] apkAssets) {
            final AssetManager assets = new AssetManager();
            assets.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            assets.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    Build.VERSION.RESOURCES_SDK_INT);
            assets.setApkAssets(apkAssets, false /*invalidateCaches*/);
            return assets;
+4 −3
Original line number Diff line number Diff line
@@ -1461,13 +1461,14 @@ public final class AssetManager implements AutoCloseable {
    public void setConfiguration(int mcc, int mnc, @Nullable String locale, int orientation,
            int touchscreen, int density, int keyboard, int keyboardHidden, int navigation,
            int screenWidth, int screenHeight, int smallestScreenWidthDp, int screenWidthDp,
            int screenHeightDp, int screenLayout, int uiMode, int colorMode, int majorVersion) {
            int screenHeightDp, int screenLayout, int uiMode, int colorMode, int grammaticalGender,
            int majorVersion) {
        synchronized (this) {
            ensureValidLocked();
            nativeSetConfiguration(mObject, mcc, mnc, locale, orientation, touchscreen, density,
                    keyboard, keyboardHidden, navigation, screenWidth, screenHeight,
                    smallestScreenWidthDp, screenWidthDp, screenHeightDp, screenLayout, uiMode,
                    colorMode, majorVersion);
                    colorMode, grammaticalGender, majorVersion);
        }
    }

@@ -1557,7 +1558,7 @@ public final class AssetManager implements AutoCloseable {
            @Nullable String locale, int orientation, int touchscreen, int density, int keyboard,
            int keyboardHidden, int navigation, int screenWidth, int screenHeight,
            int smallestScreenWidthDp, int screenWidthDp, int screenHeightDp, int screenLayout,
            int uiMode, int colorMode, int majorVersion);
            int uiMode, int colorMode, int grammaticalGender, int majorVersion);
    private static native @NonNull SparseArray<String> nativeGetAssignedPackageIdentifiers(
            long ptr, boolean includeOverlays, boolean includeLoaders);

+50 −17
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.content.ConfigurationProto.COLOR_MODE;
import static android.content.ConfigurationProto.DENSITY_DPI;
import static android.content.ConfigurationProto.FONT_SCALE;
import static android.content.ConfigurationProto.FONT_WEIGHT_ADJUSTMENT;
import static android.content.ConfigurationProto.GRAMMATICAL_GENDER;
import static android.content.ConfigurationProto.HARD_KEYBOARD_HIDDEN;
import static android.content.ConfigurationProto.KEYBOARD;
import static android.content.ConfigurationProto.KEYBOARD_HIDDEN;
@@ -167,19 +168,19 @@ public final class Configuration implements Parcelable, Comparable<Configuration
     * Constant for grammatical gender: to indicate the terms of address the user
     * preferred in an application is neuter.
     */
    public static final int GRAMMATICAL_GENDER_NEUTRAL = 2;
    public static final int GRAMMATICAL_GENDER_NEUTRAL = 1;

    /**
     * Constant for grammatical gender: to indicate the terms of address the user
         * preferred in an application is feminine.
     */
    public static final int GRAMMATICAL_GENDER_FEMININE = 3;
    public static final int GRAMMATICAL_GENDER_FEMININE = 2;

    /**
     * Constant for grammatical gender: to indicate the terms of address the user
     * preferred in an application is masculine.
     */
    public static final int GRAMMATICAL_GENDER_MASCULINE = 4;
    public static final int GRAMMATICAL_GENDER_MASCULINE = 3;

    /** Constant for {@link #colorMode}: bits that encode whether the screen is wide gamut. */
    public static final int COLOR_MODE_WIDE_COLOR_GAMUT_MASK = 0x3;
@@ -529,15 +530,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        if ((diff & ActivityInfo.CONFIG_FONT_WEIGHT_ADJUSTMENT) != 0) {
            list.add("CONFIG_AUTO_BOLD_TEXT");
        }
        StringBuilder builder = new StringBuilder("{");
        for (int i = 0, n = list.size(); i < n; i++) {
            builder.append(list.get(i));
            if (i != n - 1) {
                builder.append(", ");
        if ((diff & ActivityInfo.CONFIG_GRAMMATICAL_GENDER) != 0) {
            list.add("CONFIG_GRAMMATICAL_GENDER");
        }
        }
        builder.append("}");
        return builder.toString();
        return "{" + TextUtils.join(", ", list) + "}";
    }

    /**
@@ -970,6 +966,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
            NATIVE_CONFIG_SMALLEST_SCREEN_SIZE,
            NATIVE_CONFIG_LAYOUTDIR,
            NATIVE_CONFIG_COLOR_MODE,
            NATIVE_CONFIG_GRAMMATICAL_GENDER,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface NativeConfig {}
@@ -1008,6 +1005,9 @@ public final class Configuration implements Parcelable, Comparable<Configuration
    public static final int NATIVE_CONFIG_LAYOUTDIR = 0x4000;
    /** @hide Native-specific bit mask for COLOR_MODE config ; DO NOT USE UNLESS YOU ARE SURE.*/
    public static final int NATIVE_CONFIG_COLOR_MODE = 0x10000;
    /** @hide Native-specific bit mask for GRAMMATICAL_GENDER config; DO NOT USE UNLESS YOU
     * ARE SURE.*/
    public static final int NATIVE_CONFIG_GRAMMATICAL_GENDER = 0x20000;

    /**
     * <p>Construct an invalid Configuration. This state is only suitable for constructing a
@@ -1112,6 +1112,14 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        } else {
            sb.append(" ?localeList");
        }
        if (mGrammaticalGender != 0) {
            switch (mGrammaticalGender) {
                case GRAMMATICAL_GENDER_NEUTRAL: sb.append(" neuter"); break;
                case GRAMMATICAL_GENDER_FEMININE: sb.append(" feminine"); break;
                case GRAMMATICAL_GENDER_MASCULINE: sb.append(" masculine"); break;
                case GRAMMATICAL_GENDER_NOT_SPECIFIED: sb.append(" ?grgend"); break;
            }
        }
        int layoutDir = (screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK);
        switch (layoutDir) {
            case SCREENLAYOUT_LAYOUTDIR_UNDEFINED: sb.append(" ?layoutDir"); break;
@@ -1292,6 +1300,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        protoOutputStream.write(ORIENTATION, orientation);
        protoOutputStream.write(SCREEN_WIDTH_DP, screenWidthDp);
        protoOutputStream.write(SCREEN_HEIGHT_DP, screenHeightDp);
        protoOutputStream.write(GRAMMATICAL_GENDER, mGrammaticalGender);
        protoOutputStream.end(token);
    }

@@ -1454,6 +1463,9 @@ public final class Configuration implements Parcelable, Comparable<Configuration
                    case (int) FONT_WEIGHT_ADJUSTMENT:
                        fontWeightAdjustment = protoInputStream.readInt(FONT_WEIGHT_ADJUSTMENT);
                        break;
                    case (int) GRAMMATICAL_GENDER:
                        mGrammaticalGender = protoInputStream.readInt(GRAMMATICAL_GENDER);
                        break;
                }
            }
        } finally {
@@ -1839,6 +1851,9 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        if ((mask & ActivityInfo.CONFIG_FONT_WEIGHT_ADJUSTMENT) != 0) {
            fontWeightAdjustment = delta.fontWeightAdjustment;
        }
        if ((mask & ActivityInfo.CONFIG_GRAMMATICAL_GENDER) != 0) {
            mGrammaticalGender = delta.mGrammaticalGender;
        }
    }

    /**
@@ -2172,6 +2187,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
            if (n != 0) return n;
        }

        n = this.mGrammaticalGender - that.mGrammaticalGender;
        if (n != 0) return n;
        n = this.touchscreen - that.touchscreen;
        if (n != 0) return n;
        n = this.keyboard - that.keyboard;
@@ -2205,11 +2222,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        n = windowConfiguration.compareTo(that.windowConfiguration);
        if (n != 0) return n;
        n = this.fontWeightAdjustment - that.fontWeightAdjustment;
        if (n != 0) return n;
        n = this.mGrammaticalGender - that.mGrammaticalGender;
        if (n != 0) return n;

        // if (n != 0) return n;
        return n;
    }

@@ -2482,6 +2494,20 @@ public final class Configuration implements Parcelable, Comparable<Configuration
            }
        }

        switch (config.mGrammaticalGender) {
            case Configuration.GRAMMATICAL_GENDER_NEUTRAL:
                parts.add("neuter");
                break;
            case Configuration.GRAMMATICAL_GENDER_FEMININE:
                parts.add("feminine");
                break;
            case Configuration.GRAMMATICAL_GENDER_MASCULINE:
                parts.add("masculine");
                break;
            default:
                break;
        }

        switch (config.screenLayout & Configuration.SCREENLAYOUT_LAYOUTDIR_MASK) {
            case Configuration.SCREENLAYOUT_LAYOUTDIR_LTR:
                parts.add("ldltr");
@@ -2768,6 +2794,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration
            delta.locale = change.locale;
        }

        if (base.mGrammaticalGender != change.mGrammaticalGender) {
            delta.mGrammaticalGender = change.mGrammaticalGender;
        }

        if (base.touchscreen != change.touchscreen) {
            delta.touchscreen = change.touchscreen;
        }
@@ -2881,6 +2911,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
    private static final String XML_ATTR_DENSITY = "density";
    private static final String XML_ATTR_APP_BOUNDS = "app_bounds";
    private static final String XML_ATTR_FONT_WEIGHT_ADJUSTMENT = "fontWeightAdjustment";
    private static final String XML_ATTR_GRAMMATICAL_GENDER = "grammaticalGender";

    /**
     * Reads the attributes corresponding to Configuration member fields from the Xml parser.
@@ -2932,6 +2963,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
                DENSITY_DPI_UNDEFINED);
        configOut.fontWeightAdjustment = XmlUtils.readIntAttribute(parser,
                XML_ATTR_FONT_WEIGHT_ADJUSTMENT, FONT_WEIGHT_ADJUSTMENT_UNDEFINED);
        configOut.mGrammaticalGender = XmlUtils.readIntAttribute(parser,
                XML_ATTR_GRAMMATICAL_GENDER, GRAMMATICAL_GENDER_NOT_SPECIFIED);

        // For persistence, we don't care about assetsSeq and WindowConfiguration, so do not read it
        // out.
Loading