Debian Codegraph @

core/java/android/app/servertransaction/NewIntentItem.java

raw symbols SCIP
1 /*
2 * Copyright 2017 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.servertransaction;
18
19 import static android.app.servertransaction.ActivityLifecycleItem.ON_RESUME;
20 import static android.app.servertransaction.ActivityLifecycleItem.UNDEFINED;
21
22 import android.annotation.NonNull;
23 import android.annotation.Nullable;
24 import android.app.ActivityThread.ActivityClientRecord;
25 import android.app.ClientTransactionHandler;
26 import android.compat.annotation.UnsupportedAppUsage;
27 import android.os.Build;
28 import android.os.Parcel;
29 import android.os.Parcelable;
30 import android.os.Trace;
31
32 import com.android.internal.content.ReferrerIntent;
33
34 import java.util.List;
35 import java.util.Objects;
36
37 /**
38 * New intent message.
39 * @hide
40 */
41 public class NewIntentItem extends ActivityTransactionItem {
42
43 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
44 private List<ReferrerIntent> mIntents;
45 private boolean mResume;
46
47 @Override
48 public int getPostExecutionState() {
49 return mResume ? ON_RESUME : UNDEFINED;
50 }
51
52 @Override
53 public void execute(ClientTransactionHandler client, ActivityClientRecord r,
54 PendingTransactionActions pendingActions) {
55 Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityNewIntent");
56 client.handleNewIntent(r, mIntents);
57 Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
58 }
59
60
61 // ObjectPoolItem implementation
62
63 private NewIntentItem() {}
64
65 /** Obtain an instance initialized with provided params. */
66 public static NewIntentItem obtain(List<ReferrerIntent> intents, boolean resume) {
67 NewIntentItem instance = ObjectPool.obtain(NewIntentItem.class);
68 if (instance == null) {
69 instance = new NewIntentItem();
70 }
71 instance.mIntents = intents;
72 instance.mResume = resume;
73
74 return instance;
75 }
76
77 @Override
78 public void recycle() {
79 mIntents = null;
80 mResume = false;
81 ObjectPool.recycle(this);
82 }
83
84
85 // Parcelable implementation
86
87 /** Write to Parcel. */
88 @Override
89 public void writeToParcel(Parcel dest, int flags) {
90 dest.writeBoolean(mResume);
91 dest.writeTypedList(mIntents, flags);
92 }
93
94 /** Read from Parcel. */
95 private NewIntentItem(Parcel in) {
96 mResume = in.readBoolean();
97 mIntents = in.createTypedArrayList(ReferrerIntent.CREATOR);
98 }
99
100 public static final @NonNull Parcelable.Creator<NewIntentItem> CREATOR =
101 new Parcelable.Creator<NewIntentItem>() {
102 public NewIntentItem createFromParcel(Parcel in) {
103 return new NewIntentItem(in);
104 }
105
106 public NewIntentItem[] newArray(int size) {
107 return new NewIntentItem[size];
108 }
109 };
110
111 @Override
112 public boolean equals(@Nullable Object o) {
113 if (this == o) {
114 return true;
115 }
116 if (o == null || getClass() != o.getClass()) {
117 return false;
118 }
119 final NewIntentItem other = (NewIntentItem) o;
120 return mResume == other.mResume && Objects.equals(mIntents, other.mIntents);
121 }
122
123 @Override
124 public int hashCode() {
125 int result = 17;
126 result = 31 * result + (mResume ? 1 : 0);
127 result = 31 * result + mIntents.hashCode();
128 return result;
129 }
130
131 @Override
132 public String toString() {
133 return "NewIntentItem{intents=" + mIntents + ",resume=" + mResume + "}";
134 }
135 }