1 /* 2 * Copyright (C) 2016 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 package com.android.cts.verifier.vr; 17 18 import android.app.Activity; 19 import android.content.ComponentName; 20 import android.content.pm.PackageManager; 21 import android.os.Bundle; 22 import android.os.Handler; 23 import android.util.Log; 24 25 public class MockVrActivity2 extends Activity { 26 private static final String TAG = "MockVrActivity2"; 27 private Handler mHandler; 28 29 @Override onCreate(Bundle savedInstanceState)30 protected void onCreate(Bundle savedInstanceState) { 31 Log.i(TAG, "onCreate called."); 32 super.onCreate(savedInstanceState); 33 try { 34 setVrModeEnabled(true, new ComponentName(this, MockVrListenerService.class)); 35 } catch (PackageManager.NameNotFoundException e) { 36 Log.e(TAG, "Could not set VR mode: " + e); 37 } 38 mHandler = new Handler(); 39 } 40 41 @Override onResume()42 protected void onResume() { 43 Log.i(TAG, "onResume called."); 44 45 super.onResume(); 46 mHandler.postDelayed(new Runnable() { 47 @Override 48 public void run() { 49 MockVrActivity2.this.finish(); 50 } 51 }, MockVrActivity.EVENT_DELAY_MS); 52 } 53 54 @Override onWindowFocusChanged(boolean hasFocus)55 public void onWindowFocusChanged(boolean hasFocus) { 56 Log.i(TAG, "onWindowFocusChanged called with " + hasFocus); 57 super.onWindowFocusChanged(hasFocus); 58 } 59 60 @Override onPause()61 protected void onPause() { 62 Log.i(TAG, "onPause called."); 63 super.onPause(); 64 } 65 66 } 67