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.jetpack.utils;
18 
19 import android.app.Activity;
20 import android.os.Bundle;
21 import android.server.wm.jetpack.extensions.util.ExtensionsUtil;
22 
23 import androidx.window.extensions.area.WindowAreaComponent;
24 
25 /**
26  * Test {@link Activity} used to initiate and enable the rear display presentation feature, and
27  * explicitly crashes when the feature is enabled.
28  */
29 public class TestRearDisplayCrashingActivity extends Activity {
30 
31     private WindowAreaComponent mWindowAreaComponent;
32 
33     @Override
onCreate(Bundle bundle)34     public void onCreate(Bundle bundle) {
35         super.onCreate(bundle);
36         mWindowAreaComponent = ExtensionsUtil.getExtensionWindowAreaComponent();
37     }
38 
39     @Override
onPostResume()40     protected void onPostResume() {
41         super.onPostResume();
42         mWindowAreaComponent.startRearDisplayPresentationSession(this, integer -> {
43             if (integer == WindowAreaComponent.SESSION_STATE_ACTIVE) {
44                 throw new RuntimeException("TEST EXCEPTION");
45             }
46         });
47     }
48 }
49