xref: /aosp_15_r20/cts/tests/tests/systemui/src/android/systemui/cts/LightBarBaseActivity.java (revision b7c941bb3fa97aba169d73cee0bed2de8ac964bf)
1 /*
2  * Copyright (C) 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.systemui.cts;
18 
19 import android.annotation.MainThread;
20 import android.app.Activity;
21 import android.os.Bundle;
22 import android.view.View;
23 import android.view.ViewGroup.LayoutParams;
24 import android.view.WindowInsets;
25 import android.widget.FrameLayout;
26 
27 public class LightBarBaseActivity extends Activity {
28 
29     private View mContent;
30 
31     @Override
onCreate(Bundle bundle)32     protected void onCreate(Bundle bundle){
33         super.onCreate(bundle);
34         mContent = new View(this);
35         mContent.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
36                 LayoutParams.MATCH_PARENT));
37         final FrameLayout contentView = new FrameLayout(this);
38         contentView.setFitsSystemWindows(true);
39         contentView.addView(mContent);
40         setContentView(contentView);
41     }
42 
43     @MainThread
getRootWindowInsets()44     public WindowInsets getRootWindowInsets() {
45         return getWindow().getDecorView().getRootWindowInsets();
46     }
47 
getSystemUiVisibility()48     public int getSystemUiVisibility() {
49         return mContent.getWindowSystemUiVisibility();
50     }
51 
getLeft()52     public int getLeft() {
53         return mContent.getLocationOnScreen()[0];
54     }
55 
getTop()56     public int getTop() {
57         return mContent.getLocationOnScreen()[1];
58     }
59 
getBottom()60     public int getBottom() {
61         return mContent.getLocationOnScreen()[1] + mContent.getHeight();
62     }
63 
getRight()64     public int getRight() {
65         return mContent.getLocationOnScreen()[0] + mContent.getWidth();
66     }
67 
getWidth()68     public int getWidth() {
69         return mContent.getWidth();
70     }
71 }
72