1 /* 2 * Copyright 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.credentials; 18 19 import static java.util.Objects.requireNonNull; 20 21 import android.annotation.NonNull; 22 import android.os.Bundle; 23 import android.os.Parcel; 24 import android.os.Parcelable; 25 26 import com.android.internal.util.AnnotationValidations; 27 28 /** 29 * A response object that encapsulates the result of a successful credential creation execution. 30 */ 31 public final class CreateCredentialResponse implements Parcelable { 32 33 /** 34 * The response data. 35 */ 36 @NonNull 37 private final Bundle mData; 38 39 /** 40 * Returns the response data. 41 */ 42 @NonNull getData()43 public Bundle getData() { 44 return mData; 45 } 46 47 @Override writeToParcel(@onNull Parcel dest, int flags)48 public void writeToParcel(@NonNull Parcel dest, int flags) { 49 dest.writeBundle(mData); 50 } 51 52 @Override describeContents()53 public int describeContents() { 54 return 0; 55 } 56 57 @Override toString()58 public String toString() { 59 return "CreateCredentialResponse {data=" + mData + "}"; 60 } 61 62 /** 63 * Constructs a {@link CreateCredentialResponse}. 64 * 65 * @param data the data associated with the credential created. 66 */ CreateCredentialResponse(@onNull Bundle data)67 public CreateCredentialResponse(@NonNull Bundle data) { 68 mData = requireNonNull(data, "data must not be null"); 69 } 70 CreateCredentialResponse(@onNull Parcel in)71 private CreateCredentialResponse(@NonNull Parcel in) { 72 Bundle data = in.readBundle(); 73 mData = data; 74 AnnotationValidations.validate(NonNull.class, null, mData); 75 } 76 77 public static final @NonNull Parcelable.Creator<CreateCredentialResponse> CREATOR = 78 new Parcelable.Creator<CreateCredentialResponse>() { 79 @Override 80 public CreateCredentialResponse[] newArray(int size) { 81 return new CreateCredentialResponse[size]; 82 } 83 84 @Override 85 public CreateCredentialResponse createFromParcel(@NonNull Parcel in) { 86 return new CreateCredentialResponse(in); 87 } 88 }; 89 } 90