Debian Codegraph @

core/java/android/app/servertransaction/StopActivityItem.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.os.Trace.TRACE_TAG_ACTIVITY_MANAGER;
20
21 import android.annotation.NonNull;
22 import android.annotation.Nullable;
23 import android.app.ActivityThread.ActivityClientRecord;
24 import android.app.ClientTransactionHandler;
25 import android.os.IBinder;
26 import android.os.Parcel;
27 import android.os.Trace;
28
29 /**
30 * Request to move an activity to stopped state.
31 * @hide
32 */
33 public class StopActivityItem extends ActivityLifecycleItem {
34
35 private static final String TAG = "StopActivityItem";
36
37 private int mConfigChanges;
38
39 @Override
40 public void execute(ClientTransactionHandler client, ActivityClientRecord r,
41 PendingTransactionActions pendingActions) {
42 Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "activityStop");
43 client.handleStopActivity(r, mConfigChanges, pendingActions,
44 true /* finalStateRequest */, "STOP_ACTIVITY_ITEM");
45 Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER);
46 }
47
48 @Override
49 public void postExecute(ClientTransactionHandler client, IBinder token,
50 PendingTransactionActions pendingActions) {
51 client.reportStop(pendingActions);
52 }
53
54 @Override
55 public int getTargetState() {
56 return ON_STOP;
57 }
58
59
60 // ObjectPoolItem implementation
61
62 private StopActivityItem() {}
63
64 /**
65 * Obtain an instance initialized with provided params.
66 * @param configChanges Configuration pieces that changed.
67 */
68 public static StopActivityItem obtain(int configChanges) {
69 StopActivityItem instance = ObjectPool.obtain(StopActivityItem.class);
70 if (instance == null) {
71 instance = new StopActivityItem();
72 }
73 instance.mConfigChanges = configChanges;
74
75 return instance;
76 }
77
78 @Override
79 public void recycle() {
80 super.recycle();
81 mConfigChanges = 0;
82 ObjectPool.recycle(this);
83 }
84
85
86 // Parcelable implementation
87
88 /** Write to Parcel. */
89 @Override
90 public void writeToParcel(Parcel dest, int flags) {
91 dest.writeInt(mConfigChanges);
92 }
93
94 /** Read from Parcel. */
95 private StopActivityItem(Parcel in) {
96 mConfigChanges = in.readInt();
97 }
98
99 public static final @NonNull Creator<StopActivityItem> CREATOR =
100 new Creator<StopActivityItem>() {
101 public StopActivityItem createFromParcel(Parcel in) {
102 return new StopActivityItem(in);
103 }
104
105 public StopActivityItem[] newArray(int size) {
106 return new StopActivityItem[size];
107 }
108 };
109
110 @Override
111 public boolean equals(@Nullable Object o) {
112 if (this == o) {
113 return true;
114 }
115 if (o == null || getClass() != o.getClass()) {
116 return false;
117 }
118 final StopActivityItem other = (StopActivityItem) o;
119 return mConfigChanges == other.mConfigChanges;
120 }
121
122 @Override
123 public int hashCode() {
124 int result = 17;
125 result = 31 * result + mConfigChanges;
126 return result;
127 }
128
129 @Override
130 public String toString() {
131 return "StopActivityItem{configChanges=" + mConfigChanges + "}";
132 }
133 }