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

Commit 60f1ee2d authored by Tor Norbye's avatar Tor Norbye Committed by Android (Google) Code Review
Browse files

Merge "Switch @IntDef from long to int, and add @LongDef"

parents 09695993 f740c7ea
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ public @interface IntDef {
    String[] prefix() default "";

    /** Defines the allowed constants for this element */
    long[] value() default {};
    int[] value() default {};

    /** Defines whether the constants can be used as a flag, or just as an enum (the default) */
    boolean flag() default false;
+62 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.annotation;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.RetentionPolicy.SOURCE;

/**
 * Denotes that the annotated long element represents
 * a logical type and that its value should be one of the explicitly
 * named constants. If the {@link #flag()} attribute is set to true,
 * multiple constants can be combined.
 * <p>
 * <pre><code>
 *  &#64;Retention(SOURCE)
 *  &#64;LongDef({NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS})
 *  public @interface NavigationMode {}
 *  public static final long NAVIGATION_MODE_STANDARD = 0;
 *  public static final long NAVIGATION_MODE_LIST = 1;
 *  public static final long NAVIGATION_MODE_TABS = 2;
 *  ...
 *  public abstract void setNavigationMode(@NavigationMode long mode);
 *  &#64;NavigationMode
 *  public abstract long getNavigationMode();
 * </code></pre>
 * For a flag, set the flag attribute:
 * <pre><code>
 *  &#64;LongDef(
 *      flag = true,
 *      value = {NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS})
 * </code></pre>
 *
 * @hide
 */
@Retention(SOURCE)
@Target({ANNOTATION_TYPE})
public @interface LongDef {
    /** Defines the constant prefix for this element */
    String[] prefix() default "";

    /** Defines the allowed constants for this element */
    long[] value() default {};

    /** Defines whether the constants can be used as a flag, or just as an enum (the default) */
    boolean flag() default false;
}
+2 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.hardware;

import android.annotation.IntDef;
import android.annotation.LongDef;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
@@ -70,7 +71,7 @@ public final class HardwareBuffer implements Parcelable, AutoCloseable {

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(flag = true, value = {USAGE_CPU_READ_RARELY, USAGE_CPU_READ_OFTEN,
    @LongDef(flag = true, value = {USAGE_CPU_READ_RARELY, USAGE_CPU_READ_OFTEN,
            USAGE_CPU_WRITE_RARELY, USAGE_CPU_WRITE_OFTEN, USAGE_GPU_SAMPLED_IMAGE,
            USAGE_GPU_COLOR_OUTPUT, USAGE_PROTECTED_CONTENT, USAGE_VIDEO_ENCODE,
            USAGE_GPU_DATA_BUFFER, USAGE_SENSOR_DIRECT_DATA})
+2 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package android.view;

import android.annotation.IntDef;
import android.annotation.LongDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -48,7 +48,7 @@ final class FrameInfo {
    // Is this the first-draw following a window layout?
    public static final long FLAG_WINDOW_LAYOUT_CHANGED = 1;

    @IntDef(flag = true, value = {
    @LongDef(flag = true, value = {
            FLAG_WINDOW_LAYOUT_CHANGED })
    @Retention(RetentionPolicy.SOURCE)
    public @interface FrameInfoFlags {}
+2 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.content.pm.ActivityInfo.COLOR_MODE_DEFAULT;

import android.Manifest.permission;
import android.annotation.IntDef;
import android.annotation.LongDef;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
@@ -1270,7 +1271,7 @@ public interface WindowManager extends ViewManager {

        /** @hide */
        @Retention(RetentionPolicy.SOURCE)
        @IntDef(
        @LongDef(
            flag = true,
            value = {
                    LayoutParams.FLAG2_LAYOUT_IN_DISPLAY_CUTOUT_AREA,
Loading