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 android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.os.IBinder; 22 import android.os.Parcel; 23 24 import java.lang.annotation.Retention; 25 import java.lang.annotation.RetentionPolicy; 26 27 /** 28 * Request for lifecycle state that an activity should reach. 29 * 30 * @hide 31 */ 32 public abstract class ActivityLifecycleItem extends ActivityTransactionItem { 33 34 @IntDef(prefix = { "UNDEFINED", "PRE_", "ON_" }, value = { 35 UNDEFINED, 36 PRE_ON_CREATE, 37 ON_CREATE, 38 ON_START, 39 ON_RESUME, 40 ON_PAUSE, 41 ON_STOP, 42 ON_DESTROY, 43 ON_RESTART 44 }) 45 @Retention(RetentionPolicy.SOURCE) 46 public @interface LifecycleState{} 47 public static final int UNDEFINED = -1; 48 public static final int PRE_ON_CREATE = 0; 49 public static final int ON_CREATE = 1; 50 public static final int ON_START = 2; 51 public static final int ON_RESUME = 3; 52 public static final int ON_PAUSE = 4; 53 public static final int ON_STOP = 5; 54 public static final int ON_DESTROY = 6; 55 public static final int ON_RESTART = 7; 56 ActivityLifecycleItem(@onNull IBinder activityToken)57 ActivityLifecycleItem(@NonNull IBinder activityToken) { 58 super(activityToken); 59 } 60 61 // Parcelable implementation 62 63 /** Reads from Parcel. */ ActivityLifecycleItem(@onNull Parcel in)64 ActivityLifecycleItem(@NonNull Parcel in) { 65 super(in); 66 } 67 68 @Override isActivityLifecycleItem()69 public boolean isActivityLifecycleItem() { 70 return true; 71 } 72 73 /** A final lifecycle state that an activity should reach. */ 74 @LifecycleState getTargetState()75 public abstract int getTargetState(); 76 } 77