Skip to content

Commit

Permalink
Fix HiddenTypedefConstant Metalava error on PlaybackException
Browse files Browse the repository at this point in the history
This is done by removing the `@FieldNumber` IntDef completely. It's not
really adding much value anyway, because it's `open` so there's no real
enforcement to prevent passing 'incorrect' values.

#minor-release

PiperOrigin-RevId: 452108972
  • Loading branch information
icbaker authored and marcbaechinger committed Jun 7, 2022
1 parent 960422e commit 97210b5
Showing 1 changed file with 7 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,35 +397,14 @@ public boolean errorInfoEquals(@Nullable PlaybackException other) {

// Bundleable implementation.

/**
* Identifiers for fields in a {@link Bundle} which represents a playback exception. Subclasses
* may use {@link #FIELD_CUSTOM_ID_BASE} to generate more keys using {@link #keyForField(int)}.
*
* <p>Note: Changes to the Bundleable implementation must be backwards compatible, so as to avoid
* breaking communication across different Bundleable implementation versions.
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
@Target(TYPE_USE)
@IntDef(
open = true,
value = {
FIELD_INT_ERROR_CODE,
FIELD_LONG_TIMESTAMP_MS,
FIELD_STRING_MESSAGE,
FIELD_STRING_CAUSE_CLASS_NAME,
FIELD_STRING_CAUSE_MESSAGE,
})
protected @interface FieldNumber {}

private static final int FIELD_INT_ERROR_CODE = 0;
private static final int FIELD_LONG_TIMESTAMP_MS = 1;
private static final int FIELD_STRING_MESSAGE = 2;
private static final int FIELD_STRING_CAUSE_CLASS_NAME = 3;
private static final int FIELD_STRING_CAUSE_MESSAGE = 4;

/**
* Defines a minimum field id value for subclasses to use when implementing {@link #toBundle()}
* Defines a minimum field ID value for subclasses to use when implementing {@link #toBundle()}
* and {@link Bundleable.Creator}.
*
* <p>Subclasses should obtain their {@link Bundle Bundle's} field keys by applying a non-negative
Expand All @@ -452,10 +431,13 @@ public Bundle toBundle() {
}

/**
* Converts the given {@link FieldNumber} to a string which can be used as a field key when
* implementing {@link #toBundle()} and {@link Bundleable.Creator}.
* Converts the given field number to a string which can be used as a field key when implementing
* {@link #toBundle()} and {@link Bundleable.Creator}.
*
* <p>Subclasses should use {@code field} values greater than or equal to {@link
* #FIELD_CUSTOM_ID_BASE}.
*/
protected static String keyForField(@FieldNumber int field) {
protected static String keyForField(int field) {
return Integer.toString(field, Character.MAX_RADIX);
}

Expand Down

0 comments on commit 97210b5

Please sign in to comment.