1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.sync.internal_api.pub;
7 import android.os.Parcel;
8 import android.os.Parcelable;
11 * This enum describes the type of passphrase required, if any, to decrypt synced data.
13 * It implements the Android {@link Parcelable} interface so it is easy to pass around in intents.
15 * It maps the native enum syncer::PassphraseType, but has the additional values INVALID and NONE.
17 public enum SyncDecryptionPassphraseType implements Parcelable {
18 INVALID(-2), // Used as default value and is not a valid decryption type.
19 NONE(-1), // No encryption (deprecated).
20 IMPLICIT_PASSPHRASE(0), // GAIA-based passphrase (deprecated).
21 KEYSTORE_PASSPHRASE(1), // Keystore passphrase.
22 FROZEN_IMPLICIT_PASSPHRASE(2), // Frozen GAIA passphrase.
23 CUSTOM_PASSPHRASE(3); // User-provided passphrase.
25 public static Parcelable.Creator CREATOR =
26 new Parcelable.Creator<SyncDecryptionPassphraseType>() {
28 public SyncDecryptionPassphraseType createFromParcel(Parcel parcel) {
29 return fromInternalValue(parcel.readInt());
33 public SyncDecryptionPassphraseType[] newArray(int size) {
34 return new SyncDecryptionPassphraseType[size];
38 public static SyncDecryptionPassphraseType fromInternalValue(int value) {
39 for (SyncDecryptionPassphraseType type : values()) {
40 if (type.internalValue() == value) {
44 // Falling back to INVALID. Should not happen if |value| was retrieved from native.
48 private final int mNativeValue;
50 private SyncDecryptionPassphraseType(int nativeValue) {
51 mNativeValue = nativeValue;
54 public int internalValue() {
55 // Since the values in this enums are constant and very small, this cast is safe.
60 public int describeContents() {
65 public void writeToParcel(Parcel dest, int flags) {
66 dest.writeInt(mNativeValue);