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 
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.RetentionPolicy;
23 
24 /**
25  * Request for lifecycle state that an activity should reach.
26  * @hide
27  */
28 public abstract class ActivityLifecycleItem extends ClientTransactionItem {
29 
30     @IntDef(prefix = { "UNDEFINED", "PRE_", "ON_" }, value = {
31             UNDEFINED,
32             PRE_ON_CREATE,
33             ON_CREATE,
34             ON_START,
35             ON_RESUME,
36             ON_PAUSE,
37             ON_STOP,
38             ON_DESTROY,
39             ON_RESTART
40     })
41     @Retention(RetentionPolicy.SOURCE)
42     public @interface LifecycleState{}
43     public static final int UNDEFINED = -1;
44     public static final int PRE_ON_CREATE = 0;
45     public static final int ON_CREATE = 1;
46     public static final int ON_START = 2;
47     public static final int ON_RESUME = 3;
48     public static final int ON_PAUSE = 4;
49     public static final int ON_STOP = 5;
50     public static final int ON_DESTROY = 6;
51     public static final int ON_RESTART = 7;
52 
53     /** A final lifecycle state that an activity should reach. */
54     @LifecycleState
getTargetState()55     public abstract int getTargetState();
56 
57     /** Called by subclasses to make sure base implementation is cleaned up */
58     @Override
recycle()59     public void recycle() {
60     }
61 }
62