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 android.os; 18 19 import android.app.Activity; 20 import android.service.vr.VrListenerService; 21 22 import java.util.concurrent.CountDownLatch; 23 import java.util.concurrent.TimeUnit; 24 25 /** 26 * An activity for enabling/disabling VrMode. 27 */ 28 public class TestVrActivity extends Activity { 29 private CountDownLatch mLatch; 30 31 @Override onCreate(Bundle savedInstanceState)32 protected void onCreate(Bundle savedInstanceState) { 33 super.onCreate(savedInstanceState); 34 mLatch = new CountDownLatch(1); 35 } 36 37 @Override onStart()38 protected void onStart() { 39 super.onStart(); 40 mLatch.countDown(); 41 } 42 43 public static class TestVrListenerService extends VrListenerService { 44 @Override onCreate()45 public void onCreate() { 46 super.onCreate(); 47 } 48 } 49 waitForActivityStart()50 public boolean waitForActivityStart() { 51 boolean result = false; 52 try { 53 result = mLatch.await(2L, TimeUnit.SECONDS); 54 } catch (InterruptedException e) { 55 } 56 return result; 57 } 58 } 59