1 /* 2 * Copyright (C) 2014 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.print.test; 18 19 import android.app.Activity; 20 import android.app.KeyguardManager; 21 import android.content.res.Configuration; 22 import android.os.Bundle; 23 import android.util.Log; 24 import android.view.WindowManager; 25 26 public class PrintDocumentActivity extends Activity { 27 private static final String LOG_TAG = "PrintDocumentActivity"; 28 int mTestId; 29 30 @Override onCreate(Bundle savedInstanceState)31 protected void onCreate(Bundle savedInstanceState) { 32 super.onCreate(savedInstanceState); 33 34 mTestId = getIntent().getIntExtra(BasePrintTest.TEST_ID, -1); 35 Log.d(LOG_TAG, "onCreate() " + this + " for " + mTestId); 36 37 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON 38 | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); 39 40 KeyguardManager km = getSystemService(KeyguardManager.class); 41 if (km != null) { 42 km.requestDismissKeyguard(this, null); 43 } 44 45 BasePrintTest.onActivityCreateCalled(mTestId, this); 46 47 if (savedInstanceState != null) { 48 Log.d(LOG_TAG, 49 "We cannot deal with lifecycle. Hence finishing " + this + " for " + mTestId); 50 finish(); 51 } 52 } 53 54 @Override onConfigurationChanged(Configuration newConfig)55 public void onConfigurationChanged(Configuration newConfig) { 56 super.onConfigurationChanged(newConfig); 57 58 Log.d(LOG_TAG, "onConfigurationChanged(" + newConfig + ")"); 59 } 60 61 @Override onDestroy()62 protected void onDestroy() { 63 Log.d(LOG_TAG, "onDestroy() " + this); 64 BasePrintTest.onActivityDestroyCalled(mTestId); 65 super.onDestroy(); 66 } 67 } 68