diff options
author | 2016-04-04 09:51:06 +0900 | |
---|---|---|
committer | 2016-04-04 10:34:36 +0900 | |
commit | 58927c2872496ab93a164b40a5b77fe00a6405f8 (patch) | |
tree | b47218d2059c25b2d9ff61719053e81f67ad1ff9 | |
parent | fa1832e469b544015e141d7be44e4d5b38708bb5 (diff) |
Fix perf tests for cold startup.
Kiling ia force-stopping was invalidating the entire roots cache.
Bug: 27743087
Change-Id: Ib788cfeaa6e60c40b7277ba7ca0f2371816eded1
-rw-r--r-- | app-perf-tests/AndroidManifest.xml | 2 | ||||
-rw-r--r-- | app-perf-tests/src/com/android/documentsui/FilesAppPerfTest.java | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/app-perf-tests/AndroidManifest.xml b/app-perf-tests/AndroidManifest.xml index 1c3ed80ad..0013b6b7b 100644 --- a/app-perf-tests/AndroidManifest.xml +++ b/app-perf-tests/AndroidManifest.xml @@ -2,6 +2,8 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.documentsui.appperftests"> + <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" /> + <application> <uses-library android:name="android.test.runner" /> diff --git a/app-perf-tests/src/com/android/documentsui/FilesAppPerfTest.java b/app-perf-tests/src/com/android/documentsui/FilesAppPerfTest.java index d6e8a96f3..ce2fc13bc 100644 --- a/app-perf-tests/src/com/android/documentsui/FilesAppPerfTest.java +++ b/app-perf-tests/src/com/android/documentsui/FilesAppPerfTest.java @@ -17,6 +17,8 @@ package com.android.documentsui; import android.app.Activity; +import android.app.ActivityManager; +import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; @@ -91,12 +93,15 @@ public class FilesAppPerfTest extends InstrumentationTestCase { } private void killProviders() throws Exception { - final PackageManager pm = getInstrumentation().getContext().getPackageManager(); + final Context context = getInstrumentation().getContext(); + final PackageManager pm = context.getPackageManager(); + final ActivityManager am = (ActivityManager) context.getSystemService( + Context.ACTIVITY_SERVICE); final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE); final List<ResolveInfo> providers = pm.queryIntentContentProviders(intent, 0); for (ResolveInfo info : providers) { final String packageName = info.providerInfo.packageName; - mDevice.executeShellCommand("am force-stop " + packageName); + am.killBackgroundProcesses(packageName); } } } |