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

Commit ac85f904 authored by Alan Viverette's avatar Alan Viverette
Browse files

Ensure all Java-side usages of config flags are using Java flags

Previously we were using native config flags in some places that expected
Java flags, and vice-versa. All usages of config flags are now annotated
to ensure we're using the right type.

Cleans up annotations on most methods that were touched.

Bug: 21161798
Change-Id: Ifd87dfb12199fc8258915d8a510e03ddb681ca89
parent 95b69f82
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.animation;

import android.content.pm.ActivityInfo.Config;
import android.content.res.ConstantState;

import java.util.ArrayList;
@@ -50,7 +51,7 @@ public abstract class Animator implements Cloneable {
     * A set of flags which identify the type of configuration changes that can affect this
     * Animator. Used by the Animator cache.
     */
    int mChangingConfigurations = 0;
    @Config int mChangingConfigurations = 0;

    /**
     * If this animator is inflated from a constant state, keep a reference to it so that
@@ -344,7 +345,7 @@ public abstract class Animator implements Cloneable {
     * @see android.content.pm.ActivityInfo
     * @hide
     */
    public int getChangingConfigurations() {
    public @Config int getChangingConfigurations() {
        return mChangingConfigurations;
    }

@@ -358,7 +359,7 @@ public abstract class Animator implements Cloneable {
     * @see android.content.pm.ActivityInfo
     * @hide
     */
    public void setChangingConfigurations(int configs) {
    public void setChangingConfigurations(@Config int configs) {
        mChangingConfigurations = configs;
    }

@@ -368,7 +369,7 @@ public abstract class Animator implements Cloneable {
     * This method is called while loading the animator.
     * @hide
     */
    public void appendChangingConfigurations(int configs) {
    public void appendChangingConfigurations(@Config int configs) {
        mChangingConfigurations |= configs;
    }

@@ -564,7 +565,7 @@ public abstract class Animator implements Cloneable {
    private static class AnimatorConstantState extends ConstantState<Animator> {

        final Animator mAnimator;
        int mChangingConf;
        @Config int mChangingConf;

        public AnimatorConstantState(Animator animator) {
            mAnimator = animator;
@@ -574,7 +575,7 @@ public abstract class Animator implements Cloneable {
        }

        @Override
        public int getChangingConfigurations() {
        public @Config int getChangingConfigurations() {
            return mChangingConf;
        }

+4 −1
Original line number Diff line number Diff line
@@ -16,7 +16,10 @@
package android.animation;

import android.annotation.AnimatorRes;
import android.annotation.AnyRes;
import android.annotation.NonNull;
import android.content.Context;
import android.content.pm.ActivityInfo.Config;
import android.content.res.ConfigurationBoundResourceCache;
import android.content.res.ConstantState;
import android.content.res.Resources;
@@ -1062,7 +1065,7 @@ public class AnimatorInflater {
        return anim;
    }

    private static int getChangingConfigs(Resources resources, int id) {
    private static @Config int getChangingConfigs(@NonNull Resources resources, @AnyRes int id) {
        synchronized (sTmpTypedValue) {
            resources.getValue(id, sTmpTypedValue, true);
            return sTmpTypedValue.changingConfigurations;
+7 −6
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.animation;

import android.content.pm.ActivityInfo.Config;
import android.content.res.ConstantState;
import android.util.StateSet;
import android.view.View;
@@ -53,7 +54,7 @@ public class StateListAnimator implements Cloneable {
    private WeakReference<View> mViewRef;
    private StateListAnimatorConstantState mConstantState;
    private AnimatorListenerAdapter mAnimatorListener;
    private int mChangingConfigurations;
    private @Config int mChangingConfigurations;

    public StateListAnimator() {
        initAnimatorListener();
@@ -223,7 +224,7 @@ public class StateListAnimator implements Cloneable {
     * @see android.content.pm.ActivityInfo
     * @hide
     */
    public int getChangingConfigurations() {
    public @Config int getChangingConfigurations() {
        return mChangingConfigurations;
    }

@@ -237,7 +238,7 @@ public class StateListAnimator implements Cloneable {
     * @see android.content.pm.ActivityInfo
     * @hide
     */
    public void setChangingConfigurations(int configs) {
    public void setChangingConfigurations(@Config int configs) {
        mChangingConfigurations = configs;
    }

@@ -247,7 +248,7 @@ public class StateListAnimator implements Cloneable {
     * This method is called while loading the animator.
     * @hide
     */
    public void appendChangingConfigurations(int configs) {
    public void appendChangingConfigurations(@Config int configs) {
        mChangingConfigurations |= configs;
    }

@@ -309,7 +310,7 @@ public class StateListAnimator implements Cloneable {

        final StateListAnimator mAnimator;

        int mChangingConf;
        @Config int mChangingConf;

        public StateListAnimatorConstantState(StateListAnimator animator) {
            mAnimator = animator;
@@ -318,7 +319,7 @@ public class StateListAnimator implements Cloneable {
        }

        @Override
        public int getChangingConfigurations() {
        public @Config int getChangingConfigurations() {
            return mChangingConf;
        }

+25 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.content.pm;

import android.annotation.IntDef;
import android.content.res.Configuration;
import android.content.res.Configuration.NativeConfig;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Printer;
@@ -495,6 +496,28 @@ public class ActivityInfo extends ComponentInfo
    @ScreenOrientation
    public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED;

    /** @hide */
    @IntDef(flag = true,
            value = {
                    CONFIG_MCC,
                    CONFIG_MNC,
                    CONFIG_LOCALE,
                    CONFIG_TOUCHSCREEN,
                    CONFIG_KEYBOARD,
                    CONFIG_KEYBOARD_HIDDEN,
                    CONFIG_NAVIGATION,
                    CONFIG_ORIENTATION,
                    CONFIG_SCREEN_LAYOUT,
                    CONFIG_UI_MODE,
                    CONFIG_SCREEN_SIZE,
                    CONFIG_SMALLEST_SCREEN_SIZE,
                    CONFIG_DENSITY,
                    CONFIG_LAYOUT_DIRECTION,
                    CONFIG_FONT_SCALE,
            })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Config {}

    /**
     * Bit in {@link #configChanges} that indicates that the activity
     * can itself handle changes to the IMSI MCC.  Set from the
@@ -629,7 +652,7 @@ public class ActivityInfo extends ComponentInfo
     *
     * @hide
     */
    public static int activityInfoConfigToNative(int input) {
    public static @NativeConfig int activityInfoConfigJavaToNative(@Config int input) {
        int output = 0;
        for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) {
            if ((input & (1 << i)) != 0) {
@@ -644,7 +667,7 @@ public class ActivityInfo extends ComponentInfo
     *
     * @hide
     */
    public static int activityInfoConfigNativeToJava(int input) {
    public static @Config int activityInfoConfigNativeToJava(@NativeConfig int input) {
        int output = 0;
        for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) {
            if ((input & CONFIG_NATIVE_BITS[i]) != 0) {
+6 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.ArrayRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringRes;
import android.content.res.Configuration.NativeConfig;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import android.util.SparseArray;
@@ -796,7 +797,10 @@ public final class AssetManager implements AutoCloseable {
    /*package*/ static final int STYLE_DATA = 1;
    /*package*/ static final int STYLE_ASSET_COOKIE = 2;
    /*package*/ static final int STYLE_RESOURCE_ID = 3;
    /*package*/ static final int STYLE_CHANGING_CONFIGURATIONS = 4;

    /* Offset within typed data array for native changingConfigurations. */
    static final int STYLE_CHANGING_CONFIGURATIONS = 4;

    /*package*/ static final int STYLE_DENSITY = 5;
    /*package*/ native static final boolean applyStyle(long theme,
            int defStyleAttr, int defStyleRes, long xmlParser,
@@ -845,7 +849,7 @@ public final class AssetManager implements AutoCloseable {
                                                                TypedValue outValue,
                                                                boolean resolve);
    /*package*/ native static final void dumpTheme(long theme, int priority, String tag, String prefix);
    /*package*/ native static final int getThemeChangingConfigurations(long theme);
    /*package*/ native static final @NativeConfig int getThemeChangingConfigurations(long theme);

    private native final long openXmlAssetNative(int cookie, String fileName);

Loading