The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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.app; |
| 18 | |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 19 | import android.annotation.UnsupportedAppUsage; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | import android.content.Intent; |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 21 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | import android.os.Parcel; |
| 23 | import android.os.Parcelable; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | |
Andrii Kulian | 6b9d3a1 | 2017-11-16 14:36:36 -0800 | [diff] [blame] | 25 | import java.util.Objects; |
| 26 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | /** |
| 28 | * {@hide} |
| 29 | */ |
| 30 | public class ResultInfo implements Parcelable { |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 31 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | public final String mResultWho; |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 33 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | public final int mRequestCode; |
| 35 | public final int mResultCode; |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 36 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | public final Intent mData; |
| 38 | |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 39 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | public ResultInfo(String resultWho, int requestCode, int resultCode, |
| 41 | Intent data) { |
| 42 | mResultWho = resultWho; |
| 43 | mRequestCode = requestCode; |
| 44 | mResultCode = resultCode; |
| 45 | mData = data; |
| 46 | } |
| 47 | |
| 48 | public String toString() { |
| 49 | return "ResultInfo{who=" + mResultWho + ", request=" + mRequestCode |
| 50 | + ", result=" + mResultCode + ", data=" + mData + "}"; |
| 51 | } |
| 52 | |
| 53 | public int describeContents() { |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | public void writeToParcel(Parcel out, int flags) { |
| 58 | out.writeString(mResultWho); |
| 59 | out.writeInt(mRequestCode); |
| 60 | out.writeInt(mResultCode); |
| 61 | if (mData != null) { |
| 62 | out.writeInt(1); |
| 63 | mData.writeToParcel(out, 0); |
| 64 | } else { |
| 65 | out.writeInt(0); |
| 66 | } |
| 67 | } |
| 68 | |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 69 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame^] | 70 | public static final @android.annotation.NonNull Parcelable.Creator<ResultInfo> CREATOR |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | = new Parcelable.Creator<ResultInfo>() { |
| 72 | public ResultInfo createFromParcel(Parcel in) { |
| 73 | return new ResultInfo(in); |
| 74 | } |
| 75 | |
| 76 | public ResultInfo[] newArray(int size) { |
| 77 | return new ResultInfo[size]; |
| 78 | } |
| 79 | }; |
| 80 | |
| 81 | public ResultInfo(Parcel in) { |
| 82 | mResultWho = in.readString(); |
| 83 | mRequestCode = in.readInt(); |
| 84 | mResultCode = in.readInt(); |
| 85 | if (in.readInt() != 0) { |
| 86 | mData = Intent.CREATOR.createFromParcel(in); |
| 87 | } else { |
| 88 | mData = null; |
| 89 | } |
| 90 | } |
Andrii Kulian | 6b9d3a1 | 2017-11-16 14:36:36 -0800 | [diff] [blame] | 91 | |
| 92 | @Override |
| 93 | public boolean equals(Object obj) { |
| 94 | if (obj == null || !(obj instanceof ResultInfo)) { |
| 95 | return false; |
| 96 | } |
| 97 | final ResultInfo other = (ResultInfo) obj; |
| 98 | final boolean intentsEqual = mData == null ? (other.mData == null) |
| 99 | : mData.filterEquals(other.mData); |
| 100 | return intentsEqual && Objects.equals(mResultWho, other.mResultWho) |
| 101 | && mResultCode == other.mResultCode |
| 102 | && mRequestCode == other.mRequestCode; |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public int hashCode() { |
| 107 | int result = 17; |
| 108 | result = 31 * result + mRequestCode; |
| 109 | result = 31 * result + mResultCode; |
| 110 | result = 31 * result + Objects.hashCode(mResultWho); |
| 111 | if (mData != null) { |
| 112 | result = 31 * result + mData.filterHashCode(); |
| 113 | } |
| 114 | return result; |
| 115 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | } |