Home | History | Annotate | Download | only in testapp
      1 /*
      2  * Copyright (C) 2015 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.assist.testapp;
     18 
     19 import android.app.Activity;
     20 import android.assist.common.Utils;
     21 import android.content.Intent;
     22 import android.os.Bundle;
     23 import android.util.Log;
     24 import android.view.View;
     25 import android.view.ViewTreeObserver;
     26 import android.view.ViewTreeObserver.OnGlobalLayoutListener;
     27 import android.view.WindowManager;
     28 
     29 public class SecureActivity extends Activity {
     30     static final String TAG = "SecureActivity";
     31     @Override
     32     public void onCreate(Bundle savedInstanceState) {
     33         super.onCreate(savedInstanceState);
     34         Log.i(TAG, "SecureActivity created");
     35         setContentView(R.layout.secure_app);
     36         getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
     37             WindowManager.LayoutParams.FLAG_SECURE);
     38     }
     39 
     40     @Override
     41     protected void onResume() {
     42         super.onResume();
     43         Log.i(TAG, "Activity has resumed");
     44         final View layout = findViewById(android.R.id.content);
     45         ViewTreeObserver vto = layout.getViewTreeObserver();
     46         vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
     47             @Override
     48             public void onGlobalLayout() {
     49                 layout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
     50                 sendBroadcast(new Intent(Utils.FLAG_SECURE_HASRESUMED));
     51             }
     52         });
     53     }
     54 }
     55