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 17 package com.android.documentsui; 18 19 import static com.android.documentsui.Shared.EXTRA_BENCHMARK; 20 21 import android.app.Activity; 22 import android.content.Intent; 23 import android.content.pm.PackageManager; 24 import android.os.Bundle; 25 import android.os.Handler; 26 import android.util.Log; 27 28 import java.util.concurrent.CountDownLatch; 29 30 public class LauncherActivity extends Activity { 31 private static final String TARGET_PACKAGE = "com.android.documentsui"; 32 private static final int BENCHMARK_REQUEST_CODE = 1986; 33 34 public static CountDownLatch testCaseLatch = null; 35 public static long measurement = -1; 36 37 private long mStartTime = -1; 38 39 @Override 40 protected void onCreate(Bundle savedInstanceState) { 41 super.onCreate(savedInstanceState); 42 43 new Handler().post(new Runnable() { 44 @Override public void run() { 45 final Intent intent = new Intent("android.intent.action.OPEN_DOCUMENT"); 46 intent.addCategory(Intent.CATEGORY_OPENABLE); 47 intent.putExtra(EXTRA_BENCHMARK, true); 48 intent.setType("*/*"); 49 50 mStartTime = System.currentTimeMillis(); 51 startActivityForResult(intent, BENCHMARK_REQUEST_CODE); 52 } 53 }); 54 } 55 56 @Override 57 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 58 if (requestCode == BENCHMARK_REQUEST_CODE) { 59 measurement = System.currentTimeMillis() - mStartTime; 60 testCaseLatch.countDown(); 61 finish(); 62 } 63 } 64 } 65