• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.SceneTransitionInfo;
24 import android.app.ActivityThread.ActivityClientRecord;
25 import android.app.ClientTransactionHandler;
26 import android.os.IBinder;
27 import android.os.Parcel;
28 import android.os.Trace;
29 
30 /**
31  * Request to move an activity to started and visible state.
32  *
33  * @hide
34  */
35 public class StartActivityItem extends ActivityLifecycleItem {
36 
37     @Nullable
38     private final SceneTransitionInfo mSceneTransitionInfo;
39 
StartActivityItem(@onNull IBinder activityToken, @Nullable SceneTransitionInfo sceneTransitionInfo)40     public StartActivityItem(@NonNull IBinder activityToken,
41             @Nullable SceneTransitionInfo sceneTransitionInfo) {
42         super(activityToken);
43         mSceneTransitionInfo = sceneTransitionInfo;
44     }
45 
46     @Override
execute(@onNull ClientTransactionHandler client, @NonNull ActivityClientRecord r, @NonNull PendingTransactionActions pendingActions)47     public void execute(@NonNull ClientTransactionHandler client, @NonNull ActivityClientRecord r,
48             @NonNull PendingTransactionActions pendingActions) {
49         Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "startActivityItem");
50         client.handleStartActivity(r, pendingActions, mSceneTransitionInfo);
51         Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER);
52     }
53 
54     @Override
getTargetState()55     public int getTargetState() {
56         return ON_START;
57     }
58 
59     // Parcelable implementation
60 
61     /** Writes to Parcel. */
62     @Override
writeToParcel(@onNull Parcel dest, int flags)63     public void writeToParcel(@NonNull Parcel dest, int flags) {
64         super.writeToParcel(dest, flags);
65         dest.writeTypedObject(mSceneTransitionInfo, flags);
66     }
67 
68     /** Reads from Parcel. */
StartActivityItem(@onNull Parcel in)69     private StartActivityItem(@NonNull Parcel in) {
70         super(in);
71         mSceneTransitionInfo = in.readTypedObject(SceneTransitionInfo.CREATOR);
72     }
73 
74     public static final @NonNull Creator<StartActivityItem> CREATOR = new Creator<>() {
75         public StartActivityItem createFromParcel(@NonNull Parcel in) {
76             return new StartActivityItem(in);
77         }
78 
79         public StartActivityItem[] newArray(int size) {
80             return new StartActivityItem[size];
81         }
82     };
83 
84     @Override
equals(@ullable Object o)85     public boolean equals(@Nullable Object o) {
86         if (this == o) {
87             return true;
88         }
89         if (!super.equals(o)) {
90             return false;
91         }
92         final StartActivityItem other = (StartActivityItem) o;
93         return (mSceneTransitionInfo == null) == (other.mSceneTransitionInfo == null);
94     }
95 
96     @Override
hashCode()97     public int hashCode() {
98         int result = 17;
99         result = 31 * result + super.hashCode();
100         result = 31 * result + (mSceneTransitionInfo != null ? 1 : 0);
101         return result;
102     }
103 
104     @Override
toString()105     public String toString() {
106         return "StartActivityItem{" + super.toString()
107                 + ",sceneTransitionInfo=" + mSceneTransitionInfo + "}";
108     }
109 }
110 
111