Merge "Use dataclass codegen on a few initial framework classes"
diff --git a/Android.bp b/Android.bp
index 7687270..51cbba7 100644
--- a/Android.bp
+++ b/Android.bp
@@ -798,7 +798,10 @@
         "--multi-dex",
     ],
 
-    plugins: ["view-inspector-annotation-processor"],
+    plugins: [
+        "view-inspector-annotation-processor",
+        "staledataclass-annotation-processor",
+    ],
 }
 
 filegroup {
diff --git a/core/java/android/service/autofill/FillContext.java b/core/java/android/service/autofill/FillContext.java
index 70f434c..8331550 100644
--- a/core/java/android/service/autofill/FillContext.java
+++ b/core/java/android/service/autofill/FillContext.java
@@ -30,6 +30,8 @@
 import android.util.SparseIntArray;
 import android.view.autofill.AutofillId;
 
+import com.android.internal.util.DataClass;
+
 import java.util.LinkedList;
 
 /**
@@ -46,58 +48,36 @@
  * to {@link FillResponse.Builder#setClientState(Bundle)} to avoid interpreting
  * the UI state again while saving.
  */
+@DataClass(
+        genHiddenConstructor = true,
+        genAidl = false)
 public final class FillContext implements Parcelable {
+
+    /**
+     * The id of the {@link FillRequest fill request} this context
+     * corresponds to. This is useful to associate your custom client
+     * state with every request to avoid reinterpreting the UI when saving
+     * user data.
+     */
     private final int mRequestId;
+
+    /**
+     * The screen content.
+     */
     private final @NonNull AssistStructure mStructure;
+
+    /**
+     * The AutofillId of the view that triggered autofill.
+     */
     private final @NonNull AutofillId mFocusedId;
 
     /**
      * Lookup table AutofillId->ViewNode to speed up {@link #findViewNodesByAutofillIds}
      * This is purely a cache and can be deleted at any time
      */
-    @Nullable private ArrayMap<AutofillId, AssistStructure.ViewNode> mViewNodeLookupTable;
+    private transient @Nullable ArrayMap<AutofillId, AssistStructure.ViewNode> mViewNodeLookupTable;
 
 
-    /** @hide */
-    public FillContext(int requestId, @NonNull AssistStructure structure,
-            @NonNull AutofillId autofillId) {
-        mRequestId = requestId;
-        mStructure = structure;
-        mFocusedId = autofillId;
-    }
-
-    private FillContext(Parcel parcel) {
-        this(parcel.readInt(), parcel.readParcelable(null), parcel.readParcelable(null));
-    }
-
-    /**
-     * Gets the id of the {@link FillRequest fill request} this context
-     * corresponds to. This is useful to associate your custom client
-     * state with every request to avoid reinterpreting the UI when saving
-     * user data.
-     *
-     * @return The request id.
-     */
-    public int getRequestId() {
-        return mRequestId;
-    }
-
-    /**
-     * @return The screen content.
-     */
-    @NonNull
-    public AssistStructure getStructure() {
-        return mStructure;
-    }
-
-    /**
-     * @return the AutofillId of the view that triggered autofill.
-     */
-    @NonNull
-    public AutofillId getFocusedId() {
-        return mFocusedId;
-    }
-
     @Override
     public String toString() {
         if (!sDebug)  return super.toString();
@@ -105,18 +85,6 @@
         return "FillContext [reqId=" + mRequestId + ", focusedId=" + mFocusedId + "]";
     }
 
-    @Override
-    public int describeContents() {
-        return 0;
-    }
-
-    @Override
-    public void writeToParcel(Parcel parcel, int flags) {
-        parcel.writeInt(mRequestId);
-        parcel.writeParcelable(mStructure, flags);
-        parcel.writeParcelable(mFocusedId, flags);
-    }
-
     /**
      * Finds {@link ViewNode ViewNodes} that have the requested ids.
      *
@@ -190,18 +158,119 @@
         return foundNodes;
     }
 
-    public static final @android.annotation.NonNull Parcelable.Creator<FillContext> CREATOR =
-            new Parcelable.Creator<FillContext>() {
-        @Override
-        @NonNull
-        public FillContext createFromParcel(Parcel parcel) {
-            return new FillContext(parcel);
-        }
 
+
+    // Code below generated by codegen v1.0.0.
+    //
+    // DO NOT MODIFY!
+    //
+    // To regenerate run:
+    // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/autofill/FillContext.java
+    //
+    // CHECKSTYLE:OFF Generated code
+
+    /**
+     * Creates a new FillContext.
+     *
+     * @param requestId
+     *   The id of the {@link FillRequest fill request} this context
+     *   corresponds to. This is useful to associate your custom client
+     *   state with every request to avoid reinterpreting the UI when saving
+     *   user data.
+     * @param structure
+     *   The screen content.
+     * @param focusedId
+     *   The AutofillId of the view that triggered autofill.
+     * @hide
+     */
+    @DataClass.Generated.Member
+    public FillContext(
+            int requestId,
+            @NonNull AssistStructure structure,
+            @NonNull AutofillId focusedId) {
+        this.mRequestId = requestId;
+        this.mStructure = structure;
+        com.android.internal.util.AnnotationValidations.validate(
+                NonNull.class, null, mStructure);
+        this.mFocusedId = focusedId;
+        com.android.internal.util.AnnotationValidations.validate(
+                NonNull.class, null, mFocusedId);
+
+        // onConstructed(); // You can define this method to get a callback
+    }
+
+    /**
+     * The id of the {@link FillRequest fill request} this context
+     * corresponds to. This is useful to associate your custom client
+     * state with every request to avoid reinterpreting the UI when saving
+     * user data.
+     */
+    @DataClass.Generated.Member
+    public int getRequestId() {
+        return mRequestId;
+    }
+
+    /**
+     * The screen content.
+     */
+    @DataClass.Generated.Member
+    public @NonNull AssistStructure getStructure() {
+        return mStructure;
+    }
+
+    /**
+     * The AutofillId of the view that triggered autofill.
+     */
+    @DataClass.Generated.Member
+    public @NonNull AutofillId getFocusedId() {
+        return mFocusedId;
+    }
+
+    @Override
+    @DataClass.Generated.Member
+    public void writeToParcel(Parcel dest, int flags) {
+        // You can override field parcelling by defining methods like:
+        // void parcelFieldName(Parcel dest, int flags) { ... }
+
+        dest.writeInt(mRequestId);
+        dest.writeTypedObject(mStructure, flags);
+        dest.writeTypedObject(mFocusedId, flags);
+    }
+
+    @Override
+    @DataClass.Generated.Member
+    public int describeContents() { return 0; }
+
+    @DataClass.Generated.Member
+    public static final @NonNull Parcelable.Creator<FillContext> CREATOR
+            = new Parcelable.Creator<FillContext>() {
         @Override
-        @NonNull
         public FillContext[] newArray(int size) {
             return new FillContext[size];
         }
+
+        @Override
+        @SuppressWarnings({"unchecked", "RedundantCast"})
+        public FillContext createFromParcel(Parcel in) {
+            // You can override field unparcelling by defining methods like:
+            // static FieldType unparcelFieldName(Parcel in) { ... }
+
+            int requestId = in.readInt();
+            AssistStructure structure = (AssistStructure) in.readTypedObject(AssistStructure.CREATOR);
+            AutofillId focusedId = (AutofillId) in.readTypedObject(AutofillId.CREATOR);
+            return new FillContext(
+                    requestId,
+                    structure,
+                    focusedId);
+        }
     };
+
+    @DataClass.Generated(
+            time = 1565152135263L,
+            codegenVersion = "1.0.0",
+            sourceFile = "frameworks/base/core/java/android/service/autofill/FillContext.java",
+            inputSignatures = "private final  int mRequestId\nprivate final @android.annotation.NonNull android.app.assist.AssistStructure mStructure\nprivate final @android.annotation.NonNull android.view.autofill.AutofillId mFocusedId\nprivate transient @android.annotation.Nullable android.util.ArrayMap<android.view.autofill.AutofillId,android.app.assist.AssistStructure.ViewNode> mViewNodeLookupTable\npublic @java.lang.Override java.lang.String toString()\npublic @android.annotation.NonNull android.app.assist.AssistStructure.ViewNode[] findViewNodesByAutofillIds(android.view.autofill.AutofillId[])\nclass FillContext extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true, genAidl=false)")
+    @Deprecated
+    private void __metadata() {}
+
 }
diff --git a/core/java/android/service/autofill/FillRequest.java b/core/java/android/service/autofill/FillRequest.java
index 91f77ea..e53ebad 100644
--- a/core/java/android/service/autofill/FillRequest.java
+++ b/core/java/android/service/autofill/FillRequest.java
@@ -24,6 +24,7 @@
 import android.os.Parcelable;
 import android.view.View;
 
+import com.android.internal.util.DataClass;
 import com.android.internal.util.Preconditions;
 
 import java.lang.annotation.Retention;
@@ -39,6 +40,10 @@
  *
  * @see AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback)
  */
+@DataClass(
+        genToString = true,
+        genHiddenConstructor = true,
+        genHiddenConstDefs = true)
 public final class FillRequest implements Parcelable {
 
     /**
@@ -63,54 +68,45 @@
      * is called. For example, standard {@link android.widget.TextView} views show an
      * {@code AUTOFILL} option in the overflow menu that triggers such request.
      */
-    public static final int FLAG_MANUAL_REQUEST = 0x1;
+    public static final @RequestFlags int FLAG_MANUAL_REQUEST = 0x1;
 
     /**
      * Indicates this request was made using
      * <a href="AutofillService.html#CompatibilityMode">compatibility mode</a>.
      */
-    public static final int FLAG_COMPATIBILITY_MODE_REQUEST = 0x2;
+    public static final @RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST = 0x2;
 
     /** @hide */
     public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE;
 
-    /** @hide */
-    @IntDef(flag = true, prefix = { "FLAG_" }, value = {
-            FLAG_MANUAL_REQUEST, FLAG_COMPATIBILITY_MODE_REQUEST
-    })
-    @Retention(RetentionPolicy.SOURCE)
-    @interface RequestFlags{}
-
-    private final int mId;
-    private final @RequestFlags int mFlags;
-    private final @NonNull ArrayList<FillContext> mContexts;
-    private final @Nullable Bundle mClientState;
-
-    private FillRequest(@NonNull Parcel parcel) {
-        mId = parcel.readInt();
-        mContexts = new ArrayList<>();
-        parcel.readParcelableList(mContexts, null);
-
-        mClientState = parcel.readBundle();
-        mFlags = parcel.readInt();
-    }
-
-    /** @hide */
-    public FillRequest(int id, @NonNull ArrayList<FillContext> contexts,
-            @Nullable Bundle clientState, @RequestFlags int flags) {
-        mId = id;
-        mFlags = Preconditions.checkFlagsArgument(flags,
-                FLAG_MANUAL_REQUEST | FLAG_COMPATIBILITY_MODE_REQUEST);
-        mContexts = Preconditions.checkCollectionElementsNotNull(contexts, "contexts");
-        mClientState = clientState;
-    }
-
     /**
      * Gets the unique id of this request.
      */
-    public int getId() {
-        return mId;
-    }
+    private final int mId;
+
+    /**
+     * Gets the contexts associated with each previous fill request.
+     *
+     * <p><b>Note:</b> Starting on Android {@link android.os.Build.VERSION_CODES#Q}, it could also
+     * include contexts from requests whose {@link SaveInfo} had the
+     * {@link SaveInfo#FLAG_DELAY_SAVE} flag.
+     */
+    private final @NonNull List<FillContext> mFillContexts;
+
+    /**
+     * Gets the latest client state bundle set by the service in a
+     * {@link FillResponse.Builder#setClientState(Bundle) fill response}.
+     *
+     * <p><b>Note:</b> Prior to Android {@link android.os.Build.VERSION_CODES#P}, only client state
+     * bundles set by {@link FillResponse.Builder#setClientState(Bundle)} were considered. On
+     * Android {@link android.os.Build.VERSION_CODES#P} and higher, bundles set in the result of
+     * an authenticated request through the
+     * {@link android.view.autofill.AutofillManager#EXTRA_CLIENT_STATE} extra are
+     * also considered (and take precedence when set).
+     *
+     * @return The client state.
+     */
+    private final @Nullable Bundle mClientState;
 
     /**
      * Gets the flags associated with this request.
@@ -118,8 +114,105 @@
      * @return any combination of {@link #FLAG_MANUAL_REQUEST} and
      *         {@link #FLAG_COMPATIBILITY_MODE_REQUEST}.
      */
-    public @RequestFlags int getFlags() {
-        return mFlags;
+    private final @RequestFlags int mFlags;
+
+    private void onConstructed() {
+        Preconditions.checkCollectionElementsNotNull(mFillContexts, "contexts");
+    }
+
+
+
+    // Code below generated by codegen v1.0.0.
+    //
+    // DO NOT MODIFY!
+    //
+    // To regenerate run:
+    // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/autofill/FillRequest.java
+    //
+    // CHECKSTYLE:OFF Generated code
+
+    /** @hide */
+    @IntDef(flag = true, prefix = "FLAG_", value = {
+        FLAG_MANUAL_REQUEST,
+        FLAG_COMPATIBILITY_MODE_REQUEST
+    })
+    @Retention(RetentionPolicy.SOURCE)
+    @DataClass.Generated.Member
+    public @interface RequestFlags {}
+
+    /** @hide */
+    @DataClass.Generated.Member
+    public static String requestFlagsToString(@RequestFlags int value) {
+        return com.android.internal.util.BitUtils.flagsToString(
+                value, FillRequest::singleRequestFlagsToString);
+    }
+
+    @DataClass.Generated.Member
+    static String singleRequestFlagsToString(@RequestFlags int value) {
+        switch (value) {
+            case FLAG_MANUAL_REQUEST:
+                    return "FLAG_MANUAL_REQUEST";
+            case FLAG_COMPATIBILITY_MODE_REQUEST:
+                    return "FLAG_COMPATIBILITY_MODE_REQUEST";
+            default: return Integer.toHexString(value);
+        }
+    }
+
+    /**
+     * Creates a new FillRequest.
+     *
+     * @param id
+     *   Gets the unique id of this request.
+     * @param fillContexts
+     *   Gets the contexts associated with each previous fill request.
+     *
+     *   <p><b>Note:</b> Starting on Android {@link android.os.Build.VERSION_CODES#Q}, it could also
+     *   include contexts from requests whose {@link SaveInfo} had the
+     *   {@link SaveInfo#FLAG_DELAY_SAVE} flag.
+     * @param clientState
+     *   Gets the latest client state bundle set by the service in a
+     *   {@link FillResponse.Builder#setClientState(Bundle) fill response}.
+     *
+     *   <p><b>Note:</b> Prior to Android {@link android.os.Build.VERSION_CODES#P}, only client state
+     *   bundles set by {@link FillResponse.Builder#setClientState(Bundle)} were considered. On
+     *   Android {@link android.os.Build.VERSION_CODES#P} and higher, bundles set in the result of
+     *   an authenticated request through the
+     *   {@link android.view.autofill.AutofillManager#EXTRA_CLIENT_STATE} extra are
+     *   also considered (and take precedence when set).
+     * @param flags
+     *   Gets the flags associated with this request.
+     *
+     *   @return any combination of {@link #FLAG_MANUAL_REQUEST} and
+     *           {@link #FLAG_COMPATIBILITY_MODE_REQUEST}.
+     * @hide
+     */
+    @DataClass.Generated.Member
+    public FillRequest(
+            int id,
+            @NonNull List<FillContext> fillContexts,
+            @Nullable Bundle clientState,
+            @RequestFlags int flags) {
+        this.mId = id;
+        this.mFillContexts = fillContexts;
+        com.android.internal.util.AnnotationValidations.validate(
+                NonNull.class, null, mFillContexts);
+        this.mClientState = clientState;
+        this.mFlags = flags;
+
+        Preconditions.checkFlagsArgument(
+                mFlags,
+                FLAG_MANUAL_REQUEST
+                        | FLAG_COMPATIBILITY_MODE_REQUEST);
+
+        onConstructed();
+    }
+
+    /**
+     * Gets the unique id of this request.
+     */
+    @DataClass.Generated.Member
+    public int getId() {
+        return mId;
     }
 
     /**
@@ -129,13 +222,9 @@
      * include contexts from requests whose {@link SaveInfo} had the
      * {@link SaveInfo#FLAG_DELAY_SAVE} flag.
      */
+    @DataClass.Generated.Member
     public @NonNull List<FillContext> getFillContexts() {
-        return mContexts;
-    }
-
-    @Override
-    public String toString() {
-        return "FillRequest: [id=" + mId + ", flags=" + mFlags + ", ctxts= " + mContexts + "]";
+        return mFillContexts;
     }
 
     /**
@@ -151,33 +240,89 @@
      *
      * @return The client state.
      */
+    @DataClass.Generated.Member
     public @Nullable Bundle getClientState() {
         return mClientState;
     }
 
-    @Override
-    public int describeContents() {
-        return 0;
+    /**
+     * Gets the flags associated with this request.
+     *
+     * @return any combination of {@link #FLAG_MANUAL_REQUEST} and
+     *         {@link #FLAG_COMPATIBILITY_MODE_REQUEST}.
+     */
+    @DataClass.Generated.Member
+    public @RequestFlags int getFlags() {
+        return mFlags;
     }
 
     @Override
-    public void writeToParcel(Parcel parcel, int flags) {
-        parcel.writeInt(mId);
-        parcel.writeParcelableList(mContexts, flags);
-        parcel.writeBundle(mClientState);
-        parcel.writeInt(mFlags);
+    @DataClass.Generated.Member
+    public String toString() {
+        // You can override field toString logic by defining methods like:
+        // String fieldNameToString() { ... }
+
+        return "FillRequest { " +
+                "id = " + mId + ", " +
+                "fillContexts = " + mFillContexts + ", " +
+                "clientState = " + mClientState + ", " +
+                "flags = " + requestFlagsToString(mFlags) +
+        " }";
     }
 
-    public static final @android.annotation.NonNull Parcelable.Creator<FillRequest> CREATOR =
-            new Parcelable.Creator<FillRequest>() {
-        @Override
-        public FillRequest createFromParcel(Parcel parcel) {
-            return new FillRequest(parcel);
-        }
+    @Override
+    @DataClass.Generated.Member
+    public void writeToParcel(Parcel dest, int flags) {
+        // You can override field parcelling by defining methods like:
+        // void parcelFieldName(Parcel dest, int flags) { ... }
 
+        byte flg = 0;
+        if (mClientState != null) flg |= 0x4;
+        dest.writeByte(flg);
+        dest.writeInt(mId);
+        dest.writeParcelableList(mFillContexts, flags);
+        if (mClientState != null) dest.writeBundle(mClientState);
+        dest.writeInt(mFlags);
+    }
+
+    @Override
+    @DataClass.Generated.Member
+    public int describeContents() { return 0; }
+
+    @DataClass.Generated.Member
+    public static final @NonNull Parcelable.Creator<FillRequest> CREATOR
+            = new Parcelable.Creator<FillRequest>() {
         @Override
         public FillRequest[] newArray(int size) {
             return new FillRequest[size];
         }
+
+        @Override
+        @SuppressWarnings({"unchecked", "RedundantCast"})
+        public FillRequest createFromParcel(Parcel in) {
+            // You can override field unparcelling by defining methods like:
+            // static FieldType unparcelFieldName(Parcel in) { ... }
+
+            byte flg = in.readByte();
+            int id = in.readInt();
+            List<FillContext> fillContexts = new ArrayList<>();
+            in.readParcelableList(fillContexts, FillContext.class.getClassLoader());
+            Bundle clientState = (flg & 0x4) == 0 ? null : in.readBundle();
+            int flags = in.readInt();
+            return new FillRequest(
+                    id,
+                    fillContexts,
+                    clientState,
+                    flags);
+        }
     };
+
+    @DataClass.Generated(
+            time = 1565152134349L,
+            codegenVersion = "1.0.0",
+            sourceFile = "frameworks/base/core/java/android/service/autofill/FillRequest.java",
+            inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final  int INVALID_REQUEST_ID\nprivate final  int mId\nprivate final @android.annotation.NonNull java.util.List<android.service.autofill.FillContext> mFillContexts\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate  void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)")
+    @Deprecated
+    private void __metadata() {}
+
 }
diff --git a/core/java/com/android/internal/util/DataClass.java b/core/java/com/android/internal/util/DataClass.java
index da33f99..43539c7 100644
--- a/core/java/com/android/internal/util/DataClass.java
+++ b/core/java/com/android/internal/util/DataClass.java
@@ -65,11 +65,21 @@
     boolean genGetters() default true;
 
     /**
+     * {@link #genGetters} with @hide
+     */
+    boolean genHiddenGetters() default false;
+
+    /**
      * Generates setters for each field.
      */
     boolean genSetters() default false;
 
     /**
+     * {@link #genSetters} with @hide
+     */
+    boolean genHiddenSetters() default false;
+
+    /**
      * Generates a public constructor with each field initialized from a parameter and optionally
      * some user-defined state validation at the end.
      *
@@ -85,6 +95,11 @@
     boolean genConstructor() default true;
 
     /**
+     * {@link #genConstructor} with @hide
+     */
+    boolean genHiddenConstructor() default false;
+
+    /**
      * Generates a Builder for your class.
      *
      * Uses a package-private constructor under the hood, so same rules hold as for
@@ -93,6 +108,11 @@
     boolean genBuilder() default false;
 
     /**
+     * {@link #genBuilder} with @hide
+     */
+    boolean genHiddenBuilder() default false;
+
+    /**
      * Generates a structural {@link Object#equals} + {@link Object#hashCode}.
      *
      * You can customize individual fields' logic by declaring methods like:
@@ -126,6 +146,11 @@
     boolean genCopyConstructor() default false;
 
     /**
+     * {@link #genCopyConstructor} with @hide
+     */
+    boolean genHiddenCopyConstructor() default false;
+
+    /**
      * Generates constant annotations({@link IntDef}/{@link StringDef}) for any constant groups
      * with common prefix.
      * The annotation names are based on the common prefix.
@@ -146,6 +171,11 @@
      */
     boolean genConstDefs() default true;
 
+    /**
+     * {@link #genConstDefs} with @hide
+     */
+    boolean genHiddenConstDefs() default false;
+
 
     /**
      * Allows specifying custom parcelling logic based on reusable
diff --git a/tools/codegen/src/com/android/codegen/ClassPrinter.kt b/tools/codegen/src/com/android/codegen/ClassPrinter.kt
index 22b5d88..1f0d4b8 100644
--- a/tools/codegen/src/com/android/codegen/ClassPrinter.kt
+++ b/tools/codegen/src/com/android/codegen/ClassPrinter.kt
@@ -122,9 +122,13 @@
         if (cliArgs.contains("--$kebabCase")) return true
 
         val annotationKey = "gen$upperCamelCase"
+        val annotationHiddenKey = "genHidden$upperCamelCase"
         if (dataClassAnnotationFeatures.containsKey(annotationKey)) {
             return dataClassAnnotationFeatures[annotationKey]!!
         }
+        if (dataClassAnnotationFeatures.containsKey(annotationHiddenKey)) {
+            return dataClassAnnotationFeatures[annotationHiddenKey]!!
+        }
 
         if (cliArgs.contains("--all")) return true
         if (hidden) return true
@@ -144,11 +148,17 @@
         }
     }
 
-    val FeatureFlag.hidden
-        get(): Boolean = when {
-            cliArgs.contains("--hidden-$kebabCase") -> true
-            this == FeatureFlag.BUILD_UPON -> FeatureFlag.BUILDER.hidden
-            else -> false
+    val FeatureFlag.hidden: Boolean
+        get(): Boolean {
+            val annotationHiddenKey = "genHidden$upperCamelCase"
+            if (dataClassAnnotationFeatures.containsKey(annotationHiddenKey)) {
+                return dataClassAnnotationFeatures[annotationHiddenKey]!!
+            }
+            return when {
+                cliArgs.contains("--hidden-$kebabCase") -> true
+                this == FeatureFlag.BUILD_UPON -> FeatureFlag.BUILDER.hidden
+                else -> false
+            }
         }
 
     var currentIndent = INDENT_SINGLE
diff --git a/tools/codegen/src/com/android/codegen/FieldInfo.kt b/tools/codegen/src/com/android/codegen/FieldInfo.kt
index 6b0009c..ba00264 100644
--- a/tools/codegen/src/com/android/codegen/FieldInfo.kt
+++ b/tools/codegen/src/com/android/codegen/FieldInfo.kt
@@ -84,7 +84,6 @@
             classInfo.classAst.methods.find {
                 it.nameAsString == "default$NameUpperCamel" && it.parameters.isEmpty()
             }?.run { return "$nameAsString()" }
-            if (FieldClass == "List") return "${classPrinter.memberRef("java.util.Collections.emptyList")}()"
             return null
         }
     val hasDefault get() = defaultExpr != null
diff --git a/tools/codegen/src/com/android/codegen/Generators.kt b/tools/codegen/src/com/android/codegen/Generators.kt
index c6e0a06..914e475 100644
--- a/tools/codegen/src/com/android/codegen/Generators.kt
+++ b/tools/codegen/src/com/android/codegen/Generators.kt
@@ -68,12 +68,15 @@
         }
     }
 
-    val visibility = if (consts[0].second.isPublic) "public" else "/* package-*/"
+    val visibility = if (consts[0].second.isPublic) "public" else "/* package-private */"
 
     val Retention = classRef("java.lang.annotation.Retention")
     val RetentionPolicySource = memberRef("java.lang.annotation.RetentionPolicy.SOURCE")
     val ConstDef = classRef("android.annotation.${type.capitalize()}Def")
 
+    if (FeatureFlag.CONST_DEFS.hidden) {
+        +"/** @hide */"
+    }
     "@$ConstDef(${if_(flag, "flag = true, ")}prefix = \"${prefix}_\", value = {" {
         names.forEachLastAware { name, isLast ->
             +"$name${if_(!isLast, ",")}"
@@ -85,6 +88,9 @@
     +""
 
     if (type == "int") {
+        if (FeatureFlag.CONST_DEFS.hidden) {
+            +"/** @hide */"
+        }
         +GENERATED_MEMBER_HEADER
         val methodDefLine = "$visibility static String ${AnnotationName.decapitalize()}ToString(" +
                 "@$AnnotationName int value)"
diff --git a/tools/codegen/src/com/android/codegen/InputSignaturesComputation.kt b/tools/codegen/src/com/android/codegen/InputSignaturesComputation.kt
index 1b514d7..24cf469 100644
--- a/tools/codegen/src/com/android/codegen/InputSignaturesComputation.kt
+++ b/tools/codegen/src/com/android/codegen/InputSignaturesComputation.kt
@@ -97,7 +97,7 @@
         getFullClassName(buildString {
             type.scope.ifPresent { append(it).append(".") }
             append(type.nameAsString)
-        }) + (type.typeArguments.orElse(null)?.let { args -> args.joinToString(", ") {getFullClassName(it)}}?.let { "<$it>" } ?: "")
+        }) + (type.typeArguments.orElse(null)?.let { args -> args.joinToString(",") {getFullClassName(it)}}?.let { "<$it>" } ?: "")
     } else getFullClassName(type.asString())
 }
 
diff --git a/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt b/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt
index 26b15ae..d00def6 100644
--- a/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt
+++ b/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt
@@ -66,10 +66,14 @@
         if (dataClassAnnotation == null) {
             dataClassAnnotation = annotations.find {
                 it.qualifiedName.toString() == DATACLASS_ANNOTATION_NAME
-            }
+            } ?: return true
         }
 
-        val generatedAnnotatedElements = roundEnv.getElementsAnnotatedWith(generatedAnnotation)
+        val generatedAnnotatedElements = if (generatedAnnotation != null) {
+            roundEnv.getElementsAnnotatedWith(generatedAnnotation)
+        } else {
+            emptySet()
+        }
         generatedAnnotatedElements.forEach {
             processSingleFile(it)
         }