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.service.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 * A request class for clearing a user's credential state. 29 * Providers must clear the credential state when they receive this request. 30 */ 31 public final class ClearCredentialStateRequest implements Parcelable { 32 /** The request data. */ 33 @NonNull 34 private final CallingAppInfo mCallingAppInfo; 35 36 /** The request data. */ 37 @NonNull 38 private final Bundle mData; 39 40 /** Returns the request data. */ 41 @NonNull getData()42 public Bundle getData() { 43 return mData; 44 } 45 46 /** Returns the calling app info containing information pertaining to the calling app. */ 47 @NonNull getCallingAppInfo()48 public CallingAppInfo getCallingAppInfo() { 49 return mCallingAppInfo; 50 } 51 52 @Override writeToParcel(@onNull Parcel dest, int flags)53 public void writeToParcel(@NonNull Parcel dest, int flags) { 54 dest.writeTypedObject(mCallingAppInfo, flags); 55 dest.writeBundle(mData); 56 } 57 58 @Override describeContents()59 public int describeContents() { 60 return 0; 61 } 62 63 @Override toString()64 public String toString() { 65 return "ClearCredentialStateRequest {callingAppInfo=" 66 + mCallingAppInfo.toString() + " }, {data= " + mData + "}"; 67 } 68 69 /** 70 * Constructs a {@link ClearCredentialStateRequest}. 71 * 72 * @param data the request data 73 */ ClearCredentialStateRequest(@onNull CallingAppInfo callingAppInfo, @NonNull Bundle data)74 public ClearCredentialStateRequest(@NonNull CallingAppInfo callingAppInfo, 75 @NonNull Bundle data) { 76 mCallingAppInfo = requireNonNull( 77 callingAppInfo, "callingAppInfo must not be null"); 78 mData = requireNonNull(data, "data must not be null"); 79 } 80 ClearCredentialStateRequest(@onNull Parcel in)81 private ClearCredentialStateRequest(@NonNull Parcel in) { 82 mCallingAppInfo = in.readTypedObject(CallingAppInfo.CREATOR); 83 Bundle data = in.readBundle(); 84 mData = data; 85 AnnotationValidations.validate(NonNull.class, null, mData); 86 } 87 88 public static final @NonNull Creator<ClearCredentialStateRequest> CREATOR = 89 new Creator<ClearCredentialStateRequest>() { 90 @Override 91 public ClearCredentialStateRequest[] newArray(int size) { 92 return new ClearCredentialStateRequest[size]; 93 } 94 95 @Override 96 public ClearCredentialStateRequest createFromParcel(@NonNull Parcel in) { 97 return new ClearCredentialStateRequest(in); 98 } 99 }; 100 } 101