Commit 9c0c0084 authored by Amos Lim's avatar Amos Lim Committed by Commit Bot

Fix parcelable implementations without CREATOR in code

Fix 'ParcelableCreator' and upgrade it to errorprone error
to prevent future regressions.

Bug: 834801
Change-Id: Ifef1abd12505779a23294cb4ba976685120d9b90
Reviewed-on: https://chromium-review.googlesource.com/1135110Reviewed-by: default avatarPeter Wen <wnwen@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Commit-Queue: Amos Lim <eui-sang.lim@samsung.com>
Cr-Commit-Position: refs/heads/master@{#575313}
parent 28bc65ff
...@@ -26,8 +26,6 @@ import colorama ...@@ -26,8 +26,6 @@ import colorama
ERRORPRONE_WARNINGS_TO_TURN_OFF = [ ERRORPRONE_WARNINGS_TO_TURN_OFF = [
# TODO(crbug.com/834807): Follow steps in bug # TODO(crbug.com/834807): Follow steps in bug
'DoubleBraceInitialization', 'DoubleBraceInitialization',
# TODO(crbug.com/834801): Follow steps in bug.
'ParcelableCreator',
# TODO(crbug.com/834790): Follow steps in bug. # TODO(crbug.com/834790): Follow steps in bug.
'CatchAndPrintStackTrace', 'CatchAndPrintStackTrace',
# TODO(crbug.com/801210): Follow steps in bug. # TODO(crbug.com/801210): Follow steps in bug.
...@@ -99,6 +97,7 @@ ERRORPRONE_WARNINGS_TO_ERROR = [ ...@@ -99,6 +97,7 @@ ERRORPRONE_WARNINGS_TO_ERROR = [
'MissingOverride', 'MissingOverride',
'NarrowingCompoundAssignment', 'NarrowingCompoundAssignment',
'ParameterName', 'ParameterName',
'ParcelableCreator',
'ReferenceEquality', 'ReferenceEquality',
'StaticGuardedByInstance', 'StaticGuardedByInstance',
'StaticQualifiedUsingExpression', 'StaticQualifiedUsingExpression',
......
...@@ -148,6 +148,7 @@ public class LauncherActivityTest { ...@@ -148,6 +148,7 @@ public class LauncherActivityTest {
* this will throw a BadParcelableException. * this will throw a BadParcelableException.
*/ */
@SuppressLint("ParcelCreator") @SuppressLint("ParcelCreator")
@SuppressWarnings("ParcelableCreator")
private static class InvalidParcelable implements Parcelable { private static class InvalidParcelable implements Parcelable {
@Override @Override
public void writeToParcel(Parcel parcel, int params) { public void writeToParcel(Parcel parcel, int params) {
......
...@@ -23,17 +23,18 @@ public enum PassphraseType implements Parcelable { ...@@ -23,17 +23,18 @@ public enum PassphraseType implements Parcelable {
FROZEN_IMPLICIT_PASSPHRASE(2), // Frozen GAIA passphrase. FROZEN_IMPLICIT_PASSPHRASE(2), // Frozen GAIA passphrase.
CUSTOM_PASSPHRASE(3); // User-provided passphrase. CUSTOM_PASSPHRASE(3); // User-provided passphrase.
public static Parcelable.Creator CREATOR = new Parcelable.Creator<PassphraseType>() { public static final Parcelable.Creator<PassphraseType> CREATOR =
@Override new Parcelable.Creator<PassphraseType>() {
public PassphraseType createFromParcel(Parcel parcel) { @Override
return fromInternalValue(parcel.readInt()); public PassphraseType createFromParcel(Parcel parcel) {
} return fromInternalValue(parcel.readInt());
}
@Override @Override
public PassphraseType[] newArray(int size) { public PassphraseType[] newArray(int size) {
return new PassphraseType[size]; return new PassphraseType[size];
} }
}; };
public static PassphraseType fromInternalValue(int value) { public static PassphraseType fromInternalValue(int value) {
for (PassphraseType type : values()) { for (PassphraseType type : values()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment