Home | History | Annotate | Download | only in tapjacking
      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 com.android.cts.verifier.admin.tapjacking;
     18 
     19 import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
     20 import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
     21 import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
     22 import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
     23 
     24 import android.app.Activity;
     25 import android.content.pm.PackageManager;
     26 import android.os.Bundle;
     27 import android.view.WindowManager;
     28 
     29 import com.android.cts.verifier.R;
     30 
     31 
     32 public class OverlayingActivity extends Activity {
     33 
     34     private static final long ACTIVITY_TIMEOUT_ON_WATCH = 10_000;
     35 
     36     @Override
     37     protected void onCreate(Bundle savedInstanceState) {
     38         super.onCreate(savedInstanceState);
     39         setContentView(R.layout.da_tapjacking_overlay_activity);
     40         WindowManager.LayoutParams params = getWindow().getAttributes();
     41         params.flags = FLAG_LAYOUT_NO_LIMITS | FLAG_NOT_TOUCH_MODAL | FLAG_NOT_TOUCHABLE
     42                 | FLAG_KEEP_SCREEN_ON;
     43         if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
     44             getWindow().getDecorView().postDelayed(() -> OverlayingActivity.this.finish(),
     45                     ACTIVITY_TIMEOUT_ON_WATCH);
     46         }
     47     }
     48 }
     49