1 /* 2 * Copyright (C) 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.ui; 18 19 import android.annotation.Nullable; 20 import android.content.Intent; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 24 import androidx.annotation.NonNull; 25 26 /** 27 * Response from a provider's pending intent 28 * 29 * @hide 30 */ 31 public final class ProviderPendingIntentResponse implements Parcelable { 32 private final int mResultCode; 33 @Nullable 34 private final Intent mResultData; 35 ProviderPendingIntentResponse(int resultCode, @Nullable Intent resultData)36 public ProviderPendingIntentResponse(int resultCode, @Nullable Intent resultData) { 37 mResultCode = resultCode; 38 mResultData = resultData; 39 } 40 ProviderPendingIntentResponse(Parcel in)41 protected ProviderPendingIntentResponse(Parcel in) { 42 mResultCode = in.readInt(); 43 mResultData = in.readTypedObject(Intent.CREATOR); 44 } 45 46 public static final Creator<ProviderPendingIntentResponse> CREATOR = 47 new Creator<ProviderPendingIntentResponse>() { 48 @Override 49 public ProviderPendingIntentResponse createFromParcel(Parcel in) { 50 return new ProviderPendingIntentResponse(in); 51 } 52 53 @Override 54 public ProviderPendingIntentResponse[] newArray(int size) { 55 return new ProviderPendingIntentResponse[size]; 56 } 57 }; 58 59 @Override describeContents()60 public int describeContents() { 61 return 0; 62 } 63 64 @Override writeToParcel(@onNull Parcel dest, int flags)65 public void writeToParcel(@NonNull Parcel dest, int flags) { 66 dest.writeInt(mResultCode); 67 dest.writeTypedObject(mResultData, flags); 68 } 69 70 /** Returns the result code associated with this pending intent activity result. */ getResultCode()71 public int getResultCode() { 72 return mResultCode; 73 } 74 75 /** Returns the result data associated with this pending intent activity result. */ getResultData()76 @NonNull public Intent getResultData() { 77 return mResultData; 78 } 79 } 80