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.app.ActivityThread.ActivityClientRecord; 23 import android.app.ClientTransactionHandler; 24 import android.os.IBinder; 25 import android.os.Parcel; 26 import android.os.Trace; 27 28 /** 29 * Request to move an activity to stopped state. 30 * 31 * @hide 32 */ 33 public class StopActivityItem extends ActivityLifecycleItem { 34 StopActivityItem(@onNull IBinder activityToken)35 public StopActivityItem(@NonNull IBinder activityToken) { 36 super(activityToken); 37 } 38 39 @Override execute(@onNull ClientTransactionHandler client, @NonNull ActivityClientRecord r, @NonNull PendingTransactionActions pendingActions)40 public void execute(@NonNull ClientTransactionHandler client, @NonNull ActivityClientRecord r, 41 @NonNull PendingTransactionActions pendingActions) { 42 Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "activityStop"); 43 client.handleStopActivity(r, pendingActions, 44 true /* finalStateRequest */, "STOP_ACTIVITY_ITEM"); 45 Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER); 46 } 47 48 @Override postExecute(@onNull ClientTransactionHandler client, @NonNull PendingTransactionActions pendingActions)49 public void postExecute(@NonNull ClientTransactionHandler client, 50 @NonNull PendingTransactionActions pendingActions) { 51 client.reportStop(pendingActions); 52 } 53 54 @Override getTargetState()55 public int getTargetState() { 56 return ON_STOP; 57 } 58 59 // Parcelable implementation 60 61 /** Reads from Parcel. */ StopActivityItem(@onNull Parcel in)62 private StopActivityItem(@NonNull Parcel in) { 63 super(in); 64 } 65 66 public static final @NonNull Creator<StopActivityItem> CREATOR = new Creator<>() { 67 public StopActivityItem createFromParcel(@NonNull Parcel in) { 68 return new StopActivityItem(in); 69 } 70 71 public StopActivityItem[] newArray(int size) { 72 return new StopActivityItem[size]; 73 } 74 }; 75 76 @Override toString()77 public String toString() { 78 return "StopActivityItem{" + super.toString() + "}"; 79 } 80 } 81