Debian Codegraph @

core/java/android/app/servertransaction/StartActivityItem.java

raw symbols SCIP
1 /*
2 * Copyright 2019 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.os.Trace.TRACE_TAG_ACTIVITY_MANAGER;
20
21 import android.annotation.NonNull;
22 import android.annotation.Nullable;
23 import android.app.ActivityOptions;
24 import android.app.ActivityThread.ActivityClientRecord;
25 import android.app.ClientTransactionHandler;
26 import android.os.Parcel;
27 import android.os.Trace;
28
29 /**
30 * Request to move an activity to started and visible state.
31 * @hide
32 */
33 public class StartActivityItem extends ActivityLifecycleItem {
34
35 private static final String TAG = "StartActivityItem";
36
37 private ActivityOptions mActivityOptions;
38
39 @Override
40 public void execute(ClientTransactionHandler client, ActivityClientRecord r,
41 PendingTransactionActions pendingActions) {
42 Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "startActivityItem");
43 client.handleStartActivity(r, pendingActions, mActivityOptions);
44 Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER);
45 }
46
47 @Override
48 public int getTargetState() {
49 return ON_START;
50 }
51
52
53 // ObjectPoolItem implementation
54
55 private StartActivityItem() {}
56
57 /** Obtain an instance initialized with provided params. */
58 public static StartActivityItem obtain(ActivityOptions activityOptions) {
59 StartActivityItem instance = ObjectPool.obtain(StartActivityItem.class);
60 if (instance == null) {
61 instance = new StartActivityItem();
62 }
63 instance.mActivityOptions = activityOptions;
64
65 return instance;
66 }
67
68 @Override
69 public void recycle() {
70 super.recycle();
71 mActivityOptions = null;
72 ObjectPool.recycle(this);
73 }
74
75
76 // Parcelable implementation
77
78 /** Write to Parcel. */
79 @Override
80 public void writeToParcel(Parcel dest, int flags) {
81 dest.writeBundle(mActivityOptions != null ? mActivityOptions.toBundle() : null);
82 }
83
84 /** Read from Parcel. */
85 private StartActivityItem(Parcel in) {
86 mActivityOptions = ActivityOptions.fromBundle(in.readBundle());
87 }
88
89 public static final @NonNull Creator<StartActivityItem> CREATOR =
90 new Creator<StartActivityItem>() {
91 public StartActivityItem createFromParcel(Parcel in) {
92 return new StartActivityItem(in);
93 }
94
95 public StartActivityItem[] newArray(int size) {
96 return new StartActivityItem[size];
97 }
98 };
99
100 @Override
101 public boolean equals(@Nullable Object o) {
102 if (this == o) {
103 return true;
104 }
105 if (o == null || getClass() != o.getClass()) {
106 return false;
107 }
108 final StartActivityItem other = (StartActivityItem) o;
109 return (mActivityOptions == null) == (other.mActivityOptions == null);
110 }
111
112 @Override
113 public int hashCode() {
114 int result = 17;
115 result = 31 * result + (mActivityOptions != null ? 1 : 0);
116 return result;
117 }
118
119 @Override
120 public String toString() {
121 return "StartActivityItem{options=" + mActivityOptions + "}";
122 }
123 }
124