1 /* 2 * Copyright (C) 2022 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.server.wm.activity.lifecycle; 18 19 import static android.server.wm.BuildUtils.HW_TIMEOUT_MULTIPLIER; 20 21 import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; 22 23 import android.app.Activity; 24 import android.content.ComponentName; 25 26 public final class LifecycleConstants { 27 28 public static final String ON_CREATE = "ON_CREATE"; 29 public static final String ON_START = "ON_START"; 30 public static final String ON_RESUME = "ON_RESUME"; 31 public static final String ON_PAUSE = "ON_PAUSE"; 32 public static final String ON_STOP = "ON_STOP"; 33 public static final String ON_RESTART = "ON_RESTART"; 34 public static final String ON_DESTROY = "ON_DESTROY"; 35 public static final String ON_ACTIVITY_RESULT = "ON_ACTIVITY_RESULT"; 36 public static final String ON_POST_CREATE = "ON_POST_CREATE"; 37 public static final String ON_NEW_INTENT = "ON_NEW_INTENT"; 38 public static final String ON_MULTI_WINDOW_MODE_CHANGED = "ON_MULTI_WINDOW_MODE_CHANGED"; 39 public static final String ON_TOP_POSITION_GAINED = "ON_TOP_POSITION_GAINED"; 40 public static final String ON_TOP_POSITION_LOST = "ON_TOP_POSITION_LOST"; 41 public static final String ON_USER_LEAVE_HINT = "ON_USER_LEAVE_HINT"; 42 43 /** 44 * Activity launch time is evaluated. It is expected to be less than 5 seconds. Otherwise, it's 45 * likely there is a timeout. 46 */ 47 static final long ACTIVITY_LAUNCH_TIMEOUT = 5 * 1000L * HW_TIMEOUT_MULTIPLIER; 48 static final String EXTRA_RECREATE = "recreate"; 49 static final String EXTRA_FINISH_IN_ON_CREATE = "finish_in_on_create"; 50 static final String EXTRA_FINISH_IN_ON_START = "finish_in_on_start"; 51 static final String EXTRA_FINISH_IN_ON_RESUME = "finish_in_on_resume"; 52 static final String EXTRA_FINISH_IN_ON_PAUSE = "finish_in_on_pause"; 53 static final String EXTRA_FINISH_IN_ON_STOP = "finish_in_on_stop"; 54 static final String EXTRA_START_ACTIVITY_IN_ON_CREATE = "start_activity_in_on_create"; 55 static final String EXTRA_START_ACTIVITY_WHEN_IDLE = "start_activity_when_idle"; 56 static final String EXTRA_ACTIVITY_ON_USER_LEAVE_HINT = "activity_on_user_leave_hint"; 57 /** 58 * Use this flag to skip recording top resumed state to avoid affecting verification. 59 * @see ActivityLifecycleClientTestBase.Launcher#setSkipTopResumedStateCheck() 60 */ 61 static final String EXTRA_SKIP_TOP_RESUMED_STATE = "skip_top_resumed_state"; 62 getComponentName(Class<? extends Activity> activity)63 static ComponentName getComponentName(Class<? extends Activity> activity) { 64 return new ComponentName(getInstrumentation().getContext(), activity); 65 } 66 } 67