1 /* 2 * Copyright (C) 2023 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; 18 19 import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; 20 import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; 21 22 import android.app.Activity; 23 import android.os.Bundle; 24 import android.server.wm.app.AbstractLifecycleLogActivity; 25 26 public class HelperActivities { 27 public static class ResizeablePortraitActivity extends AbstractLifecycleLogActivity {} 28 29 public static class ResponsiveActivity extends AbstractLifecycleLogActivity {} 30 31 public static class NonResizeablePortraitActivity extends AbstractLifecycleLogActivity {} 32 33 public static class NonResizeableLandscapeActivity extends AbstractLifecycleLogActivity {} 34 35 public static class NonResizeableNonFixedOrientationActivity 36 extends AbstractLifecycleLogActivity {} 37 38 public static class NonResizeableAspectRatioActivity extends AbstractLifecycleLogActivity {} 39 40 public static class NonResizeableLargeAspectRatioActivity 41 extends AbstractLifecycleLogActivity {} 42 43 public static class SupportsSizeChangesPortraitActivity extends AbstractLifecycleLogActivity {} 44 45 public static class ResizeableLeftActivity extends AbstractLifecycleLogActivity {} 46 47 public static class ResizeableRightActivity extends AbstractLifecycleLogActivity {} 48 49 public static class StandardActivity extends Activity {} 50 51 // Test activity 52 public static class SecondStandardActivity extends Activity {} 53 54 public static class NoPropertyChangeOrientationWhileRelaunchingActivity 55 extends AbstractLifecycleLogActivity { 56 57 private static boolean sHasChangeOrientationInOnResume; 58 59 @Override onCreate(Bundle instance)60 protected void onCreate(Bundle instance) { 61 super.onCreate(instance); 62 // When OVERRIDE_ENABLE_COMPAT_IGNORE_REQUESTED_ORIENTATION is enabled this request 63 // should be ignored if sHasChangeOrientationInOnResume is true. 64 setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE); 65 } 66 67 @Override onResume()68 protected void onResume() { 69 super.onResume(); 70 if (!sHasChangeOrientationInOnResume) { 71 setRequestedOrientation(SCREEN_ORIENTATION_PORTRAIT); 72 sHasChangeOrientationInOnResume = true; 73 } 74 } 75 } 76 } 77