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 com.android.server.wm.overlay_app;
18 
19 import android.app.Activity;
20 import android.graphics.Color;
21 import android.os.Bundle;
22 import android.view.Gravity;
23 import android.view.WindowManager;
24 import android.widget.LinearLayout;
25 
26 /**
27  * Test app that is translucent not touchable modal.
28  * If launched with "disableInputSink" extra boolean value, this activity disables
29  * ActivityRecordInputSinkEnabled as long as the permission is granted.
30  */
31 public class OverlayApp extends Activity {
32     private static final String KEY_DISABLE_INPUT_SINK = "disableInputSink";
33 
34     @Override
onCreate(Bundle savedInstanceState)35     protected void onCreate(Bundle savedInstanceState) {
36         super.onCreate(savedInstanceState);
37 
38         LinearLayout tv = new LinearLayout(this);
39         tv.setBackgroundColor(Color.GREEN);
40         tv.setPadding(50, 50, 50, 50);
41         tv.setGravity(Gravity.CENTER);
42         setContentView(tv);
43 
44         getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
45         getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
46 
47         if (getIntent().getBooleanExtra(KEY_DISABLE_INPUT_SINK, false)) {
48             setActivityRecordInputSinkEnabled(false);
49         }
50     }
51 }
52