summaryrefslogtreecommitdiff
path: root/apct-tests
diff options
context:
space:
mode:
Diffstat (limited to 'apct-tests')
-rw-r--r--apct-tests/perftests/blobstore/Android.bp28
-rw-r--r--apct-tests/perftests/blobstore/AndroidManifest.xml27
-rw-r--r--apct-tests/perftests/blobstore/AndroidTest.xml28
-rw-r--r--apct-tests/perftests/blobstore/src/com/android/perftests/blob/AtraceUtils.java120
-rw-r--r--apct-tests/perftests/blobstore/src/com/android/perftests/blob/BlobStorePerfTests.java148
-rw-r--r--apct-tests/perftests/core/src/android/app/ResourcesManagerPerfTest.java2
-rw-r--r--apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java2
-rw-r--r--apct-tests/perftests/core/src/android/os/PackageManagerPerfTest.java111
-rw-r--r--apct-tests/perftests/core/src/android/view/CutoutSpecificationBenchmark.java240
-rw-r--r--apct-tests/perftests/core/src/android/wm/RelayoutPerfTest.java5
-rw-r--r--apct-tests/perftests/core/src/android/wm/WindowManagerPerfTestBase.java26
-rw-r--r--apct-tests/perftests/packagemanager/Android.bp21
-rw-r--r--apct-tests/perftests/packagemanager/AndroidManifest.xml89
-rw-r--r--apct-tests/perftests/packagemanager/AndroidTest.xml88
-rw-r--r--apct-tests/perftests/packagemanager/apps/query-all/Android.bp314
-rw-r--r--apct-tests/perftests/packagemanager/apps/query-all/AndroidManifest.xml81
-rw-r--r--apct-tests/perftests/packagemanager/src/android/os/PackageManagerPerfTest.java189
-rw-r--r--apct-tests/perftests/textclassifier/src/android/view/textclassifier/TextClassificationManagerPerfTest.java51
18 files changed, 1442 insertions, 128 deletions
diff --git a/apct-tests/perftests/blobstore/Android.bp b/apct-tests/perftests/blobstore/Android.bp
new file mode 100644
index 000000000000..be5072ce3d9d
--- /dev/null
+++ b/apct-tests/perftests/blobstore/Android.bp
@@ -0,0 +1,28 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test {
+ name: "BlobStorePerfTests",
+ srcs: ["src/**/*.java"],
+ static_libs: [
+ "BlobStoreTestUtils",
+ "androidx.test.rules",
+ "androidx.annotation_annotation",
+ "apct-perftests-utils",
+ "ub-uiautomator",
+ ],
+ platform_apis: true,
+ test_suites: ["device-tests"],
+ certificate: "platform",
+} \ No newline at end of file
diff --git a/apct-tests/perftests/blobstore/AndroidManifest.xml b/apct-tests/perftests/blobstore/AndroidManifest.xml
new file mode 100644
index 000000000000..21d0726927af
--- /dev/null
+++ b/apct-tests/perftests/blobstore/AndroidManifest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.perftests.blob">
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.perftests.blob"/>
+
+</manifest> \ No newline at end of file
diff --git a/apct-tests/perftests/blobstore/AndroidTest.xml b/apct-tests/perftests/blobstore/AndroidTest.xml
new file mode 100644
index 000000000000..19456c6d81d7
--- /dev/null
+++ b/apct-tests/perftests/blobstore/AndroidTest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration description="Runs BlobStorePerfTests metric instrumentation.">
+ <option name="test-suite-tag" value="apct" />
+ <option name="test-suite-tag" value="apct-metric-instrumentation" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="BlobStorePerfTests.apk" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="com.android.perftests.blob" />
+ <option name="hidden-api-checks" value="false"/>
+ </test>
+</configuration> \ No newline at end of file
diff --git a/apct-tests/perftests/blobstore/src/com/android/perftests/blob/AtraceUtils.java b/apct-tests/perftests/blobstore/src/com/android/perftests/blob/AtraceUtils.java
new file mode 100644
index 000000000000..0208dab33746
--- /dev/null
+++ b/apct-tests/perftests/blobstore/src/com/android/perftests/blob/AtraceUtils.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.perftests.blob;
+
+import android.app.Instrumentation;
+import android.app.UiAutomation;
+import android.os.ParcelFileDescriptor;
+import android.perftests.utils.TraceMarkParser;
+import android.perftests.utils.TraceMarkParser.TraceMarkSlice;
+import android.support.test.uiautomator.UiDevice;
+import android.util.Log;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.function.BiConsumer;
+
+// Copy of com.android.frameworks.perftests.am.util.AtraceUtils. TODO: avoid this duplication.
+public class AtraceUtils {
+ private static final String TAG = "AtraceUtils";
+ private static final boolean VERBOSE = true;
+
+ private static final String ATRACE_START = "atrace --async_start -b %d -c %s";
+ private static final String ATRACE_DUMP = "atrace --async_dump";
+ private static final String ATRACE_STOP = "atrace --async_stop";
+ private static final int DEFAULT_ATRACE_BUF_SIZE = 1024;
+
+ private UiAutomation mAutomation;
+ private static AtraceUtils sUtils = null;
+ private boolean mStarted = false;
+
+ private AtraceUtils(Instrumentation instrumentation) {
+ mAutomation = instrumentation.getUiAutomation();
+ }
+
+ public static AtraceUtils getInstance(Instrumentation instrumentation) {
+ if (sUtils == null) {
+ sUtils = new AtraceUtils(instrumentation);
+ }
+ return sUtils;
+ }
+
+ /**
+ * @param categories The list of the categories to trace, separated with space.
+ */
+ public void startTrace(String categories) {
+ synchronized (this) {
+ if (mStarted) {
+ throw new IllegalStateException("atrace already started");
+ }
+ runShellCommand(String.format(
+ ATRACE_START, DEFAULT_ATRACE_BUF_SIZE, categories));
+ mStarted = true;
+ }
+ }
+
+ public void stopTrace() {
+ synchronized (this) {
+ mStarted = false;
+ runShellCommand(ATRACE_STOP);
+ }
+ }
+
+ private String runShellCommand(String cmd) {
+ try {
+ return UiDevice.getInstance(
+ InstrumentationRegistry.getInstrumentation()).executeShellCommand(cmd);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * @param parser The function that can accept the buffer of atrace dump and parse it.
+ * @param handler The parse result handler
+ */
+ public void performDump(TraceMarkParser parser,
+ BiConsumer<String, List<TraceMarkSlice>> handler) {
+ parser.reset();
+ try {
+ if (VERBOSE) {
+ Log.i(TAG, "Collecting atrace dump...");
+ }
+ writeDataToBuf(mAutomation.executeShellCommand(ATRACE_DUMP), parser);
+ } catch (IOException e) {
+ Log.e(TAG, "Error in reading dump", e);
+ }
+ parser.forAllSlices(handler);
+ }
+
+ // The given file descriptor here will be closed by this function
+ private void writeDataToBuf(ParcelFileDescriptor pfDescriptor,
+ TraceMarkParser parser) throws IOException {
+ InputStream inputStream = new ParcelFileDescriptor.AutoCloseInputStream(pfDescriptor);
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ parser.visit(line);
+ }
+ }
+ }
+}
diff --git a/apct-tests/perftests/blobstore/src/com/android/perftests/blob/BlobStorePerfTests.java b/apct-tests/perftests/blobstore/src/com/android/perftests/blob/BlobStorePerfTests.java
new file mode 100644
index 000000000000..f6af09c853ca
--- /dev/null
+++ b/apct-tests/perftests/blobstore/src/com/android/perftests/blob/BlobStorePerfTests.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.perftests.blob;
+
+import android.app.blob.BlobStoreManager;
+import android.content.Context;
+import android.perftests.utils.ManualBenchmarkState;
+import android.perftests.utils.PerfManualStatusReporter;
+import android.perftests.utils.TraceMarkParser;
+import android.perftests.utils.TraceMarkParser.TraceMarkSlice;
+import android.support.test.uiautomator.UiDevice;
+
+import androidx.test.filters.LargeTest;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import com.android.utils.blob.DummyBlobData;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+
+@LargeTest
+@RunWith(Parameterized.class)
+public class BlobStorePerfTests {
+ // From frameworks/native/cmds/atrace/atrace.cpp
+ private static final String ATRACE_CATEGORY_SYSTEM_SERVER = "ss";
+ // From f/b/apex/blobstore/service/java/com/android/server/blob/BlobStoreSession.java
+ private static final String ATRACE_COMPUTE_DIGEST_PREFIX = "computeBlobDigest-";
+
+ private Context mContext;
+ private BlobStoreManager mBlobStoreManager;
+ private AtraceUtils mAtraceUtils;
+ private ManualBenchmarkState mState;
+
+ @Rule
+ public PerfManualStatusReporter mPerfManualStatusReporter = new PerfManualStatusReporter();
+
+ @Parameterized.Parameter(0)
+ public int fileSizeInMb;
+
+ @Parameterized.Parameters(name = "{0}MB")
+ public static Collection<Object[]> getParameters() {
+ return Arrays.asList(new Object[][] {
+ { 25 },
+ { 50 },
+ { 100 },
+ { 200 },
+ });
+ }
+
+ @Before
+ public void setUp() {
+ mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ mBlobStoreManager = (BlobStoreManager) mContext.getSystemService(
+ Context.BLOB_STORE_SERVICE);
+ mAtraceUtils = AtraceUtils.getInstance(InstrumentationRegistry.getInstrumentation());
+ mState = mPerfManualStatusReporter.getBenchmarkState();
+ }
+
+ @After
+ public void tearDown() {
+ // TODO: Add a blob_store shell command to trigger idle maintenance to avoid hardcoding
+ // job id like this.
+ // From BlobStoreConfig.IDLE_JOB_ID = 191934935.
+ runShellCommand("cmd jobscheduler run -f android 191934935");
+ }
+
+ @Ignore
+ @Test
+ public void testComputeDigest() throws Exception {
+ mAtraceUtils.startTrace(ATRACE_CATEGORY_SYSTEM_SERVER);
+ try {
+ final List<Long> durations = new ArrayList<>();
+ final DummyBlobData blobData = prepareDataBlob(fileSizeInMb);
+ final TraceMarkParser parser = new TraceMarkParser(
+ line -> line.name.startsWith(ATRACE_COMPUTE_DIGEST_PREFIX));
+ while (mState.keepRunning(durations)) {
+ commitBlob(blobData);
+
+ durations.clear();
+ collectDigestDurationsFromTrace(parser, durations);
+ // TODO: get and delete blobId before next iteration.
+ }
+ } finally {
+ mAtraceUtils.stopTrace();
+ }
+ }
+
+ private void collectDigestDurationsFromTrace(TraceMarkParser parser, List<Long> durations) {
+ mAtraceUtils.performDump(parser, (key, slices) -> {
+ for (TraceMarkSlice slice : slices) {
+ durations.add(TimeUnit.MICROSECONDS.toNanos(slice.getDurationInMicroseconds()));
+ }
+ });
+ }
+
+ private DummyBlobData prepareDataBlob(int fileSizeInMb) throws Exception {
+ final DummyBlobData blobData = new DummyBlobData(mContext,
+ fileSizeInMb * 1024 * 1024 /* bytes */);
+ blobData.prepare();
+ return blobData;
+ }
+
+ private void commitBlob(DummyBlobData blobData) throws Exception {
+ final long sessionId = mBlobStoreManager.createSession(blobData.getBlobHandle());
+ try (BlobStoreManager.Session session = mBlobStoreManager.openSession(sessionId)) {
+ blobData.writeToSession(session);
+ final CompletableFuture<Integer> callback = new CompletableFuture<>();
+ session.commit(mContext.getMainExecutor(), callback::complete);
+ // Ignore commit callback result.
+ callback.get();
+ }
+ }
+
+ private String runShellCommand(String cmd) {
+ try {
+ return UiDevice.getInstance(
+ InstrumentationRegistry.getInstrumentation()).executeShellCommand(cmd);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/apct-tests/perftests/core/src/android/app/ResourcesManagerPerfTest.java b/apct-tests/perftests/core/src/android/app/ResourcesManagerPerfTest.java
index 2955d2ca7d0e..050fecde8213 100644
--- a/apct-tests/perftests/core/src/android/app/ResourcesManagerPerfTest.java
+++ b/apct-tests/perftests/core/src/android/app/ResourcesManagerPerfTest.java
@@ -80,7 +80,7 @@ public class ResourcesManagerPerfTest {
private void getResourcesForPath(String path) {
ResourcesManager.getInstance().getResources(null, path, null, null, null,
Display.DEFAULT_DISPLAY, null, sContext.getResources().getCompatibilityInfo(),
- null);
+ null, null);
}
@Test
diff --git a/apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java b/apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java
index 6123e69b584e..f4c0a172710b 100644
--- a/apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java
+++ b/apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java
@@ -96,7 +96,7 @@ public class ResourcesThemePerfTest {
Resources destResources = resourcesManager.getResources(null, ai.sourceDir,
ai.splitSourceDirs, ai.resourceDirs, ai.sharedLibraryFiles, Display.DEFAULT_DISPLAY,
- c, mContext.getResources().getCompatibilityInfo(), null);
+ c, mContext.getResources().getCompatibilityInfo(), null, null);
Assert.assertNotEquals(destResources.getAssets(), mContext.getAssets());
Resources.Theme destTheme = destResources.newTheme();
diff --git a/apct-tests/perftests/core/src/android/os/PackageManagerPerfTest.java b/apct-tests/perftests/core/src/android/os/PackageManagerPerfTest.java
deleted file mode 100644
index 236f548cf6dd..000000000000
--- a/apct-tests/perftests/core/src/android/os/PackageManagerPerfTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package android.os;
-
-import android.content.ComponentName;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.perftests.utils.BenchmarkState;
-import android.perftests.utils.PerfStatusReporter;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.filters.LargeTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class PackageManagerPerfTest {
- private static final String PERMISSION_NAME_EXISTS =
- "com.android.perftests.core.TestPermission";
- private static final String PERMISSION_NAME_DOESNT_EXIST =
- "com.android.perftests.core.TestBadPermission";
- private static final ComponentName TEST_ACTIVITY =
- new ComponentName("com.android.perftests.core",
- "android.perftests.utils.PerfTestActivity");
-
- @Rule
- public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
-
- @Test
- public void testCheckPermissionExists() {
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
- final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager();
- final String packageName = TEST_ACTIVITY.getPackageName();
-
- while (state.keepRunning()) {
- int ret = pm.checkPermission(PERMISSION_NAME_EXISTS, packageName);
- }
- }
-
- @Test
- public void testCheckPermissionDoesntExist() {
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
- final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager();
- final String packageName = TEST_ACTIVITY.getPackageName();
-
- while (state.keepRunning()) {
- int ret = pm.checkPermission(PERMISSION_NAME_DOESNT_EXIST, packageName);
- }
- }
-
- @Test
- public void testQueryIntentActivities() {
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
- final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager();
- final Intent intent = new Intent("com.android.perftests.core.PERFTEST");
-
- while (state.keepRunning()) {
- pm.queryIntentActivities(intent, 0);
- }
- }
-
- @Test
- public void testGetPackageInfo() throws Exception {
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
- final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager();
- final String packageName = TEST_ACTIVITY.getPackageName();
-
- while (state.keepRunning()) {
- pm.getPackageInfo(packageName, 0);
- }
- }
-
- @Test
- public void testGetApplicationInfo() throws Exception {
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
- final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager();
- final String packageName = TEST_ACTIVITY.getPackageName();
-
- while (state.keepRunning()) {
- pm.getApplicationInfo(packageName, 0);
- }
- }
-
- @Test
- public void testGetActivityInfo() throws Exception {
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
- final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager();
-
- while (state.keepRunning()) {
- pm.getActivityInfo(TEST_ACTIVITY, 0);
- }
- }
-}
diff --git a/apct-tests/perftests/core/src/android/view/CutoutSpecificationBenchmark.java b/apct-tests/perftests/core/src/android/view/CutoutSpecificationBenchmark.java
new file mode 100644
index 000000000000..14282bfbd24e
--- /dev/null
+++ b/apct-tests/perftests/core/src/android/view/CutoutSpecificationBenchmark.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view;
+
+import android.content.Context;
+import android.graphics.Matrix;
+import android.graphics.Path;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.graphics.Region;
+import android.perftests.utils.BenchmarkState;
+import android.perftests.utils.PerfStatusReporter;
+import android.text.TextUtils;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.util.PathParser;
+
+import androidx.test.filters.LargeTest;
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+@LargeTest
+public class CutoutSpecificationBenchmark {
+ private static final String TAG = "CutoutSpecificationBenchmark";
+
+ private static final String BOTTOM_MARKER = "@bottom";
+ private static final String DP_MARKER = "@dp";
+ private static final String RIGHT_MARKER = "@right";
+ private static final String LEFT_MARKER = "@left";
+
+ private static final String DOUBLE_CUTOUT_SPEC = "M 0,0\n"
+ + "L -72, 0\n"
+ + "L -69.9940446283, 20.0595537175\n"
+ + "C -69.1582133885, 28.4178661152 -65.2, 32.0 -56.8, 32.0\n"
+ + "L 56.8, 32.0\n"
+ + "C 65.2, 32.0 69.1582133885, 28.4178661152 69.9940446283, 20.0595537175\n"
+ + "L 72, 0\n"
+ + "Z\n"
+ + "@bottom\n"
+ + "M 0,0\n"
+ + "L -72, 0\n"
+ + "L -69.9940446283, -20.0595537175\n"
+ + "C -69.1582133885, -28.4178661152 -65.2, -32.0 -56.8, -32.0\n"
+ + "L 56.8, -32.0\n"
+ + "C 65.2, -32.0 69.1582133885, -28.4178661152 69.9940446283, -20.0595537175\n"
+ + "L 72, 0\n"
+ + "Z\n"
+ + "@dp";
+ @Rule
+ public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
+
+ private Context mContext;
+ private DisplayMetrics mDisplayMetrics;
+
+ /**
+ * Setup the necessary member field used by test methods.
+ */
+ @Before
+ public void setUp() {
+ mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+
+ mDisplayMetrics = new DisplayMetrics();
+ mContext.getDisplay().getRealMetrics(mDisplayMetrics);
+ }
+
+
+ private static void toRectAndAddToRegion(Path p, Region inoutRegion, Rect inoutRect) {
+ final RectF rectF = new RectF();
+ p.computeBounds(rectF, false /* unused */);
+ rectF.round(inoutRect);
+ inoutRegion.op(inoutRect, Region.Op.UNION);
+ }
+
+ private static void oldMethodParsingSpec(String spec, int displayWidth, int displayHeight,
+ float density) {
+ Path p = null;
+ Rect boundTop = null;
+ Rect boundBottom = null;
+ Rect safeInset = new Rect();
+ String bottomSpec = null;
+ if (!TextUtils.isEmpty(spec)) {
+ spec = spec.trim();
+ final float offsetX;
+ if (spec.endsWith(RIGHT_MARKER)) {
+ offsetX = displayWidth;
+ spec = spec.substring(0, spec.length() - RIGHT_MARKER.length()).trim();
+ } else if (spec.endsWith(LEFT_MARKER)) {
+ offsetX = 0;
+ spec = spec.substring(0, spec.length() - LEFT_MARKER.length()).trim();
+ } else {
+ offsetX = displayWidth / 2f;
+ }
+ final boolean inDp = spec.endsWith(DP_MARKER);
+ if (inDp) {
+ spec = spec.substring(0, spec.length() - DP_MARKER.length());
+ }
+
+ if (spec.contains(BOTTOM_MARKER)) {
+ String[] splits = spec.split(BOTTOM_MARKER, 2);
+ spec = splits[0].trim();
+ bottomSpec = splits[1].trim();
+ }
+
+ final Matrix m = new Matrix();
+ final Region r = Region.obtain();
+ if (!spec.isEmpty()) {
+ try {
+ p = PathParser.createPathFromPathData(spec);
+ } catch (Throwable e) {
+ Log.wtf(TAG, "Could not inflate cutout: ", e);
+ }
+
+ if (p != null) {
+ if (inDp) {
+ m.postScale(density, density);
+ }
+ m.postTranslate(offsetX, 0);
+ p.transform(m);
+
+ boundTop = new Rect();
+ toRectAndAddToRegion(p, r, boundTop);
+ safeInset.top = boundTop.bottom;
+ }
+ }
+
+ if (bottomSpec != null) {
+ int bottomInset = 0;
+ Path bottomPath = null;
+ try {
+ bottomPath = PathParser.createPathFromPathData(bottomSpec);
+ } catch (Throwable e) {
+ Log.wtf(TAG, "Could not inflate bottom cutout: ", e);
+ }
+
+ if (bottomPath != null) {
+ // Keep top transform
+ m.postTranslate(0, displayHeight);
+ bottomPath.transform(m);
+ p.addPath(bottomPath);
+ boundBottom = new Rect();
+ toRectAndAddToRegion(bottomPath, r, boundBottom);
+ bottomInset = displayHeight - boundBottom.top;
+ }
+ safeInset.bottom = bottomInset;
+ }
+ }
+ }
+
+ @Test
+ public void parseByOldMethodForDoubleCutout() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ oldMethodParsingSpec(DOUBLE_CUTOUT_SPEC, mDisplayMetrics.widthPixels,
+ mDisplayMetrics.heightPixels, mDisplayMetrics.density);
+ }
+ }
+
+ @Test
+ public void parseByNewMethodForDoubleCutout() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ new CutoutSpecification.Parser(mDisplayMetrics.density,
+ mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels)
+ .parse(DOUBLE_CUTOUT_SPEC);
+ }
+ }
+
+ @Test
+ public void parseLongEdgeCutout() {
+ final String spec = "M 0,0\n"
+ + "H 48\n"
+ + "V 48\n"
+ + "H -48\n"
+ + "Z\n"
+ + "@left\n"
+ + "@center_vertical\n"
+ + "M 0,0\n"
+ + "H 48\n"
+ + "V 48\n"
+ + "H -48\n"
+ + "Z\n"
+ + "@left\n"
+ + "@center_vertical\n"
+ + "M 0,0\n"
+ + "H -48\n"
+ + "V 48\n"
+ + "H 48\n"
+ + "Z\n"
+ + "@right\n"
+ + "@dp";
+
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ new CutoutSpecification.Parser(mDisplayMetrics.density,
+ mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels).parse(spec);
+ }
+ }
+
+ @Test
+ public void parseShortEdgeCutout() {
+ final String spec = "M 0,0\n"
+ + "H 48\n"
+ + "V 48\n"
+ + "H -48\n"
+ + "Z\n"
+ + "@bottom\n"
+ + "M 0,0\n"
+ + "H 48\n"
+ + "V -48\n"
+ + "H -48\n"
+ + "Z\n"
+ + "@dp";
+
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ new CutoutSpecification.Parser(mDisplayMetrics.density,
+ mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels).parse(spec);
+ }
+ }
+}
diff --git a/apct-tests/perftests/core/src/android/wm/RelayoutPerfTest.java b/apct-tests/perftests/core/src/android/wm/RelayoutPerfTest.java
index b6e39e14602a..8633c9613138 100644
--- a/apct-tests/perftests/core/src/android/wm/RelayoutPerfTest.java
+++ b/apct-tests/perftests/core/src/android/wm/RelayoutPerfTest.java
@@ -125,7 +125,9 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase {
final WindowManager.LayoutParams mParams;
final int mWidth;
final int mHeight;
+ final Point mOutSurfaceSize = new Point();
final SurfaceControl mOutSurfaceControl;
+ final SurfaceControl mOutBlastSurfaceControl = new SurfaceControl();
final IntSupplier mViewVisibility;
@@ -150,7 +152,8 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase {
mViewVisibility.getAsInt(), mFlags, mFrameNumber, mOutFrame,
mOutContentInsets, mOutVisibleInsets, mOutStableInsets,
mOutBackDropFrame, mOutDisplayCutout, mOutMergedConfiguration,
- mOutSurfaceControl, mOutInsetsState, new Point(), new SurfaceControl());
+ mOutSurfaceControl, mOutInsetsState, mOutSurfaceSize,
+ mOutBlastSurfaceControl);
}
}
}
diff --git a/apct-tests/perftests/core/src/android/wm/WindowManagerPerfTestBase.java b/apct-tests/perftests/core/src/android/wm/WindowManagerPerfTestBase.java
index 62e9ba84530c..9e17e940a06b 100644
--- a/apct-tests/perftests/core/src/android/wm/WindowManagerPerfTestBase.java
+++ b/apct-tests/perftests/core/src/android/wm/WindowManagerPerfTestBase.java
@@ -20,15 +20,19 @@ import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentat
import android.app.Activity;
import android.app.UiAutomation;
+import android.content.Context;
import android.content.Intent;
+import android.os.BatteryManager;
import android.os.ParcelFileDescriptor;
import android.perftests.utils.PerfTestActivity;
+import android.provider.Settings;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.lifecycle.ActivityLifecycleCallback;
import androidx.test.runner.lifecycle.ActivityLifecycleMonitorRegistry;
import androidx.test.runner.lifecycle.Stage;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@@ -52,18 +56,36 @@ public class WindowManagerPerfTestBase {
*/
static final File BASE_OUT_PATH = new File("/data/local/CorePerfTests");
+ private static int sOriginalStayOnWhilePluggedIn;
+
@BeforeClass
public static void setUpOnce() {
+ final Context context = getInstrumentation().getContext();
+ sOriginalStayOnWhilePluggedIn = Settings.Global.getInt(context.getContentResolver(),
+ Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);
+ // Keep the device awake during testing.
+ setStayOnWhilePluggedIn(BatteryManager.BATTERY_PLUGGED_USB);
+
if (!BASE_OUT_PATH.exists()) {
executeShellCommand("mkdir -p " + BASE_OUT_PATH);
}
// In order to be closer to the real use case.
executeShellCommand("input keyevent KEYCODE_WAKEUP");
executeShellCommand("wm dismiss-keyguard");
- getInstrumentation().getContext().startActivity(new Intent(Intent.ACTION_MAIN)
+ context.startActivity(new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
+ @AfterClass
+ public static void tearDownOnce() {
+ setStayOnWhilePluggedIn(sOriginalStayOnWhilePluggedIn);
+ }
+
+ private static void setStayOnWhilePluggedIn(int value) {
+ executeShellCommand(String.format("settings put global %s %d",
+ Settings.Global.STAY_ON_WHILE_PLUGGED_IN, value));
+ }
+
/**
* Executes shell command with reading the output. It may also used to block until the current
* command is completed.
@@ -97,7 +119,7 @@ public class WindowManagerPerfTestBase {
*/
static class PerfTestActivityRule extends ActivityTestRule<PerfTestActivity> {
private final Intent mStartIntent =
- new Intent().putExtra(PerfTestActivity.INTENT_EXTRA_KEEP_SCREEN_ON, true);
+ new Intent(getInstrumentation().getTargetContext(), PerfTestActivity.class);
private final LifecycleListener mLifecycleListener = new LifecycleListener();
PerfTestActivityRule() {
diff --git a/apct-tests/perftests/packagemanager/Android.bp b/apct-tests/perftests/packagemanager/Android.bp
new file mode 100644
index 000000000000..17033e048c7d
--- /dev/null
+++ b/apct-tests/perftests/packagemanager/Android.bp
@@ -0,0 +1,21 @@
+android_test {
+ name: "PackageManagerPerfTests",
+
+ srcs: ["src/**/*.java"],
+
+ static_libs: [
+ "platform-compat-test-rules",
+ "androidx.appcompat_appcompat",
+ "androidx.test.rules",
+ "androidx.test.ext.junit",
+ "androidx.annotation_annotation",
+ "apct-perftests-utils",
+ ],
+
+ libs: ["android.test.base"],
+
+ platform_apis: true,
+
+ test_suites: ["device-tests"],
+
+}
diff --git a/apct-tests/perftests/packagemanager/AndroidManifest.xml b/apct-tests/perftests/packagemanager/AndroidManifest.xml
new file mode 100644
index 000000000000..520f4b55d931
--- /dev/null
+++ b/apct-tests/perftests/packagemanager/AndroidManifest.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.perftests.packagemanager">
+
+ <permission android:name="com.android.perftests.packagemanager.TestPermission" />
+ <uses-permission android:name="com.android.perftests.packagemanager.TestPermission" />
+
+ <queries>
+ <package android:name="com.android.perftests.appenumeration0" />
+ <package android:name="com.android.perftests.appenumeration1" />
+ <package android:name="com.android.perftests.appenumeration2" />
+ <package android:name="com.android.perftests.appenumeration3" />
+ <package android:name="com.android.perftests.appenumeration4" />
+ <package android:name="com.android.perftests.appenumeration5" />
+ <package android:name="com.android.perftests.appenumeration6" />
+ <package android:name="com.android.perftests.appenumeration7" />
+ <package android:name="com.android.perftests.appenumeration8" />
+ <package android:name="com.android.perftests.appenumeration9" />
+ <package android:name="com.android.perftests.appenumeration10" />
+ <package android:name="com.android.perftests.appenumeration11" />
+ <package android:name="com.android.perftests.appenumeration12" />
+ <package android:name="com.android.perftests.appenumeration13" />
+ <package android:name="com.android.perftests.appenumeration14" />
+ <package android:name="com.android.perftests.appenumeration15" />
+ <package android:name="com.android.perftests.appenumeration16" />
+ <package android:name="com.android.perftests.appenumeration17" />
+ <package android:name="com.android.perftests.appenumeration18" />
+ <package android:name="com.android.perftests.appenumeration19" />
+ <package android:name="com.android.perftests.appenumeration20" />
+ <package android:name="com.android.perftests.appenumeration21" />
+ <package android:name="com.android.perftests.appenumeration22" />
+ <package android:name="com.android.perftests.appenumeration23" />
+ <package android:name="com.android.perftests.appenumeration24" />
+ <package android:name="com.android.perftests.appenumeration25" />
+ <package android:name="com.android.perftests.appenumeration26" />
+ <package android:name="com.android.perftests.appenumeration27" />
+ <package android:name="com.android.perftests.appenumeration28" />
+ <package android:name="com.android.perftests.appenumeration29" />
+ <package android:name="com.android.perftests.appenumeration30" />
+ <package android:name="com.android.perftests.appenumeration31" />
+ <package android:name="com.android.perftests.appenumeration32" />
+ <package android:name="com.android.perftests.appenumeration33" />
+ <package android:name="com.android.perftests.appenumeration34" />
+ <package android:name="com.android.perftests.appenumeration35" />
+ <package android:name="com.android.perftests.appenumeration36" />
+ <package android:name="com.android.perftests.appenumeration37" />
+ <package android:name="com.android.perftests.appenumeration38" />
+ <package android:name="com.android.perftests.appenumeration39" />
+ <package android:name="com.android.perftests.appenumeration40" />
+ <package android:name="com.android.perftests.appenumeration41" />
+ <package android:name="com.android.perftests.appenumeration42" />
+ <package android:name="com.android.perftests.appenumeration43" />
+ <package android:name="com.android.perftests.appenumeration44" />
+ <package android:name="com.android.perftests.appenumeration45" />
+ <package android:name="com.android.perftests.appenumeration46" />
+ <package android:name="com.android.perftests.appenumeration47" />
+ <package android:name="com.android.perftests.appenumeration48" />
+ <package android:name="com.android.perftests.appenumeration49" />
+ </queries>
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ <activity android:name="android.perftests.utils.PerfTestActivity">
+ <intent-filter>
+ <action android:name="com.android.perftests.packagemanager.PERFTEST" />
+ </intent-filter>
+ </activity>
+ </application>
+
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.perftests.packagemanager"/>
+
+</manifest>
diff --git a/apct-tests/perftests/packagemanager/AndroidTest.xml b/apct-tests/perftests/packagemanager/AndroidTest.xml
new file mode 100644
index 000000000000..c112d87d83e1
--- /dev/null
+++ b/apct-tests/perftests/packagemanager/AndroidTest.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<configuration description="Runs PackageManagerPerfTests metric instrumentation.">
+ <option name="test-suite-tag" value="apct" />
+ <option name="test-suite-tag" value="apct-metric-instrumentation" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="PackageManagerPerfTests.apk" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="force-queryable" value="false" />
+ <option name="test-file-name" value="QueriesAll0.apk" />
+ <option name="test-file-name" value="QueriesAll1.apk" />
+ <option name="test-file-name" value="QueriesAll2.apk" />
+ <option name="test-file-name" value="QueriesAll3.apk" />
+ <option name="test-file-name" value="QueriesAll4.apk" />
+ <option name="test-file-name" value="QueriesAll5.apk" />
+ <option name="test-file-name" value="QueriesAll6.apk" />
+ <option name="test-file-name" value="QueriesAll7.apk" />
+ <option name="test-file-name" value="QueriesAll8.apk" />
+ <option name="test-file-name" value="QueriesAll9.apk" />
+ <option name="test-file-name" value="QueriesAll10.apk" />
+ <option name="test-file-name" value="QueriesAll11.apk" />
+ <option name="test-file-name" value="QueriesAll12.apk" />
+ <option name="test-file-name" value="QueriesAll13.apk" />
+ <option name="test-file-name" value="QueriesAll14.apk" />
+ <option name="test-file-name" value="QueriesAll15.apk" />
+ <option name="test-file-name" value="QueriesAll16.apk" />
+ <option name="test-file-name" value="QueriesAll17.apk" />
+ <option name="test-file-name" value="QueriesAll18.apk" />
+ <option name="test-file-name" value="QueriesAll19.apk" />
+ <option name="test-file-name" value="QueriesAll20.apk" />
+ <option name="test-file-name" value="QueriesAll21.apk" />
+ <option name="test-file-name" value="QueriesAll22.apk" />
+ <option name="test-file-name" value="QueriesAll23.apk" />
+ <option name="test-file-name" value="QueriesAll24.apk" />
+ <option name="test-file-name" value="QueriesAll25.apk" />
+ <option name="test-file-name" value="QueriesAll26.apk" />
+ <option name="test-file-name" value="QueriesAll27.apk" />
+ <option name="test-file-name" value="QueriesAll28.apk" />
+ <option name="test-file-name" value="QueriesAll29.apk" />
+ <option name="test-file-name" value="QueriesAll30.apk" />
+ <option name="test-file-name" value="QueriesAll31.apk" />
+ <option name="test-file-name" value="QueriesAll32.apk" />
+ <option name="test-file-name" value="QueriesAll33.apk" />
+ <option name="test-file-name" value="QueriesAll34.apk" />
+ <option name="test-file-name" value="QueriesAll35.apk" />
+ <option name="test-file-name" value="QueriesAll36.apk" />
+ <option name="test-file-name" value="QueriesAll37.apk" />
+ <option name="test-file-name" value="QueriesAll38.apk" />
+ <option name="test-file-name" value="QueriesAll39.apk" />
+ <option name="test-file-name" value="QueriesAll40.apk" />
+ <option name="test-file-name" value="QueriesAll41.apk" />
+ <option name="test-file-name" value="QueriesAll42.apk" />
+ <option name="test-file-name" value="QueriesAll43.apk" />
+ <option name="test-file-name" value="QueriesAll44.apk" />
+ <option name="test-file-name" value="QueriesAll45.apk" />
+ <option name="test-file-name" value="QueriesAll46.apk" />
+ <option name="test-file-name" value="QueriesAll47.apk" />
+ <option name="test-file-name" value="QueriesAll48.apk" />
+ <option name="test-file-name" value="QueriesAll49.apk" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="com.android.perftests.packagemanager" />
+ <option name="hidden-api-checks" value="false"/>
+ </test>
+
+ <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector">
+ <option name="directory-keys" value="/data/local/PackageManagerPerfTests" />
+ <option name="collect-on-run-ended-only" value="true" />
+ </metrics_collector>
+</configuration>
diff --git a/apct-tests/perftests/packagemanager/apps/query-all/Android.bp b/apct-tests/perftests/packagemanager/apps/query-all/Android.bp
new file mode 100644
index 000000000000..3cb1589bc376
--- /dev/null
+++ b/apct-tests/perftests/packagemanager/apps/query-all/Android.bp
@@ -0,0 +1,314 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test_helper_app {
+ name: "QueriesAll0",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration0",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll1",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration1",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll2",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration2",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll3",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration3",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll4",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration4",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll5",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration5",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll6",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration6",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll7",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration7",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll8",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration8",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll9",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration9",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll10",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration10",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll11",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration11",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll12",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration12",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll13",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration13",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll14",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration14",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll15",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration15",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll16",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration16",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll17",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration17",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll18",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration18",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll19",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration19",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll20",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration20",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll21",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration21",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll22",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration22",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll23",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration23",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll24",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration24",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll25",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration25",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll26",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration26",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll27",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration27",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll28",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration28",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll29",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration29",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll30",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration30",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll31",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration31",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll32",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration32",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll33",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration33",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll34",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration34",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll35",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration35",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll36",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration36",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll37",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration37",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll38",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration38",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll39",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration39",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll40",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration40",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll41",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration41",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll42",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration42",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll43",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration43",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll44",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration44",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll45",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration45",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll46",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration46",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll47",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration47",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll48",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration48",
+ ]
+}
+android_test_helper_app {
+ name: "QueriesAll49",
+ aaptflags: [
+ "--rename-manifest-package com.android.perftests.appenumeration49",
+ ]
+}
diff --git a/apct-tests/perftests/packagemanager/apps/query-all/AndroidManifest.xml b/apct-tests/perftests/packagemanager/apps/query-all/AndroidManifest.xml
new file mode 100644
index 000000000000..e2cfa0430a32
--- /dev/null
+++ b/apct-tests/perftests/packagemanager/apps/query-all/AndroidManifest.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.perftests.appenumeration">
+
+ <application android:hasCode="false" >
+ <activity android:name="android.perftests.utils.PerfTestActivity">
+ <intent-filter>
+ <action android:name="com.android.perftests.packagemanager.PERFTEST" />
+ </intent-filter>
+ </activity>
+ </application>
+
+ <queries>
+ <package android:name="com.android.perftests.appenumeration0" />
+ <package android:name="com.android.perftests.appenumeration1" />
+ <package android:name="com.android.perftests.appenumeration2" />
+ <package android:name="com.android.perftests.appenumeration3" />
+ <package android:name="com.android.perftests.appenumeration4" />
+ <package android:name="com.android.perftests.appenumeration5" />
+ <package android:name="com.android.perftests.appenumeration6" />
+ <package android:name="com.android.perftests.appenumeration7" />
+ <package android:name="com.android.perftests.appenumeration8" />
+ <package android:name="com.android.perftests.appenumeration9" />
+ <package android:name="com.android.perftests.appenumeration10" />
+ <package android:name="com.android.perftests.appenumeration11" />
+ <package android:name="com.android.perftests.appenumeration12" />
+ <package android:name="com.android.perftests.appenumeration13" />
+ <package android:name="com.android.perftests.appenumeration14" />
+ <package android:name="com.android.perftests.appenumeration15" />
+ <package android:name="com.android.perftests.appenumeration16" />
+ <package android:name="com.android.perftests.appenumeration17" />
+ <package android:name="com.android.perftests.appenumeration18" />
+ <package android:name="com.android.perftests.appenumeration19" />
+ <package android:name="com.android.perftests.appenumeration20" />
+ <package android:name="com.android.perftests.appenumeration21" />
+ <package android:name="com.android.perftests.appenumeration22" />
+ <package android:name="com.android.perftests.appenumeration23" />
+ <package android:name="com.android.perftests.appenumeration24" />
+ <package android:name="com.android.perftests.appenumeration25" />
+ <package android:name="com.android.perftests.appenumeration26" />
+ <package android:name="com.android.perftests.appenumeration27" />
+ <package android:name="com.android.perftests.appenumeration28" />
+ <package android:name="com.android.perftests.appenumeration29" />
+ <package android:name="com.android.perftests.appenumeration30" />
+ <package android:name="com.android.perftests.appenumeration31" />
+ <package android:name="com.android.perftests.appenumeration32" />
+ <package android:name="com.android.perftests.appenumeration33" />
+ <package android:name="com.android.perftests.appenumeration34" />
+ <package android:name="com.android.perftests.appenumeration35" />
+ <package android:name="com.android.perftests.appenumeration36" />
+ <package android:name="com.android.perftests.appenumeration37" />
+ <package android:name="com.android.perftests.appenumeration38" />
+ <package android:name="com.android.perftests.appenumeration39" />
+ <package android:name="com.android.perftests.appenumeration40" />
+ <package android:name="com.android.perftests.appenumeration41" />
+ <package android:name="com.android.perftests.appenumeration42" />
+ <package android:name="com.android.perftests.appenumeration43" />
+ <package android:name="com.android.perftests.appenumeration44" />
+ <package android:name="com.android.perftests.appenumeration45" />
+ <package android:name="com.android.perftests.appenumeration46" />
+ <package android:name="com.android.perftests.appenumeration47" />
+ <package android:name="com.android.perftests.appenumeration48" />
+ <package android:name="com.android.perftests.appenumeration49" />
+ </queries>
+
+</manifest> \ No newline at end of file
diff --git a/apct-tests/perftests/packagemanager/src/android/os/PackageManagerPerfTest.java b/apct-tests/perftests/packagemanager/src/android/os/PackageManagerPerfTest.java
new file mode 100644
index 000000000000..d7428cf0ab8a
--- /dev/null
+++ b/apct-tests/perftests/packagemanager/src/android/os/PackageManagerPerfTest.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.os;
+
+import static libcore.junit.util.compat.CoreCompatChangeRule.DisableCompatChanges;
+import static libcore.junit.util.compat.CoreCompatChangeRule.EnableCompatChanges;
+
+import android.compat.testing.PlatformCompatChangeRule;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.perftests.utils.BenchmarkState;
+import android.perftests.utils.PerfStatusReporter;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.LargeTest;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+@LargeTest
+public class PackageManagerPerfTest {
+ private static final String PERMISSION_NAME_EXISTS =
+ "com.android.perftests.packagemanager.TestPermission";
+ private static final String PERMISSION_NAME_DOESNT_EXIST =
+ "com.android.perftests.packagemanager.TestBadPermission";
+ private static final String OTHER_PACKAGE_NAME = "com.android.perftests.appenumeration0";
+ private static final ComponentName TEST_ACTIVITY =
+ new ComponentName(OTHER_PACKAGE_NAME,
+ "android.perftests.utils.PerfTestActivity");
+
+ @Rule
+ public final PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
+
+ @Rule
+ public final PlatformCompatChangeRule mPlatformCompatChangeRule =
+ new PlatformCompatChangeRule();
+
+ public PackageManagerPerfTest() throws PackageManager.NameNotFoundException {
+ final Context context = InstrumentationRegistry.getInstrumentation().getContext();
+ }
+
+ @Test
+ @DisableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testCheckPermissionExists() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final PackageManager pm =
+ InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageManager();
+ final String packageName = TEST_ACTIVITY.getPackageName();
+
+ while (state.keepRunning()) {
+ int ret = pm.checkPermission(PERMISSION_NAME_EXISTS, packageName);
+ }
+ }
+
+ @Test
+ @EnableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testCheckPermissionExistsWithFiltering() {
+ testCheckPermissionExists();
+ }
+
+ @Test
+ @DisableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testCheckPermissionDoesntExist() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final PackageManager pm =
+ InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageManager();
+ final String packageName = TEST_ACTIVITY.getPackageName();
+
+ while (state.keepRunning()) {
+ int ret = pm.checkPermission(PERMISSION_NAME_DOESNT_EXIST, packageName);
+ }
+ }
+
+ @Test
+ @EnableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testCheckPermissionDoesntExistWithFiltering() {
+ testCheckPermissionDoesntExist();
+ }
+
+ @Test
+ @DisableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testQueryIntentActivities() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final PackageManager pm =
+ InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageManager();
+ final Intent intent = new Intent("com.android.perftests.core.PERFTEST");
+
+ while (state.keepRunning()) {
+ pm.queryIntentActivities(intent, 0);
+ }
+ }
+
+ @Test
+ @EnableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testQueryIntentActivitiesWithFiltering() {
+ testQueryIntentActivities();
+ }
+
+ @Test
+ @DisableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testGetPackageInfo() throws Exception {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final PackageManager pm =
+ InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageManager();
+
+ while (state.keepRunning()) {
+ pm.getPackageInfo(OTHER_PACKAGE_NAME, 0);
+ }
+ }
+
+ @Test
+ @EnableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testGetPackageInfoWithFiltering() throws Exception {
+ testGetPackageInfo();
+ }
+
+ @Test
+ @DisableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testGetApplicationInfo() throws Exception {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final PackageManager pm =
+ InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageManager();
+
+ while (state.keepRunning()) {
+ pm.getApplicationInfo(OTHER_PACKAGE_NAME, 0);
+ }
+ }
+
+ @Test
+ @EnableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testGetApplicationInfoWithFiltering() throws Exception {
+ testGetApplicationInfo();
+ }
+
+ @Test
+ @DisableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testGetActivityInfo() throws Exception {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final PackageManager pm =
+ InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageManager();
+
+ while (state.keepRunning()) {
+ pm.getActivityInfo(TEST_ACTIVITY, 0);
+ }
+ }
+
+ @Test
+ @EnableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testGetActivityInfoWithFiltering() throws Exception {
+ testGetActivityInfo();
+ }
+
+ @Test
+ @DisableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testGetInstalledPackages() throws Exception {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final PackageManager pm =
+ InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageManager();
+
+ while (state.keepRunning()) {
+ pm.getInstalledPackages(0);
+ }
+ }
+
+ @Test
+ @EnableCompatChanges(PackageManager.FILTER_APPLICATION_QUERY)
+ public void testGetInstalledPackagesWithFiltering() throws Exception {
+ testGetInstalledPackages();
+ }
+}
diff --git a/apct-tests/perftests/textclassifier/src/android/view/textclassifier/TextClassificationManagerPerfTest.java b/apct-tests/perftests/textclassifier/src/android/view/textclassifier/TextClassificationManagerPerfTest.java
index bd3b6737f505..f61ea8549236 100644
--- a/apct-tests/perftests/textclassifier/src/android/view/textclassifier/TextClassificationManagerPerfTest.java
+++ b/apct-tests/perftests/textclassifier/src/android/view/textclassifier/TextClassificationManagerPerfTest.java
@@ -18,35 +18,60 @@ package android.view.textclassifier;
import android.content.Context;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;
-import android.perftests.utils.SettingsHelper;
-import android.provider.Settings;
+import android.provider.DeviceConfig;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
@LargeTest
public class TextClassificationManagerPerfTest {
+ private static final String WRITE_DEVICE_CONFIG_PERMISSION =
+ "android.permission.WRITE_DEVICE_CONFIG";
@Rule
public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
+ private String mOriginalSystemTextclassifierStatus;
+
+ @BeforeClass
+ public static void setUpClass() {
+ InstrumentationRegistry.getInstrumentation().getUiAutomation()
+ .adoptShellPermissionIdentity(
+ WRITE_DEVICE_CONFIG_PERMISSION);
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ InstrumentationRegistry
+ .getInstrumentation()
+ .getUiAutomation()
+ .dropShellPermissionIdentity();
+ }
+
+ @Before
+ public void setUp() {
+ // Saves config original value.
+ mOriginalSystemTextclassifierStatus = DeviceConfig.getProperty(
+ DeviceConfig.NAMESPACE_TEXTCLASSIFIER, "system_textclassifier_enabled");
+ }
+
@After
public void tearDown() {
- SettingsHelper.delete(
- SettingsHelper.NAMESPACE_GLOBAL, Settings.Global.TEXT_CLASSIFIER_CONSTANTS);
+ // Restores config original value.
+ enableSystemTextclassifier(mOriginalSystemTextclassifierStatus);
}
@Test
public void testGetTextClassifier_systemTextClassifierDisabled() {
Context context = InstrumentationRegistry.getTargetContext();
- SettingsHelper.set(
- SettingsHelper.NAMESPACE_GLOBAL,
- Settings.Global.TEXT_CLASSIFIER_CONSTANTS,
- "system_textclassifier_enabled=false");
+ enableSystemTextclassifier(String.valueOf(false));
TextClassificationManager textClassificationManager =
context.getSystemService(TextClassificationManager.class);
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
@@ -59,10 +84,7 @@ public class TextClassificationManagerPerfTest {
@Test
public void testGetTextClassifier_systemTextClassifierEnabled() {
Context context = InstrumentationRegistry.getTargetContext();
- SettingsHelper.set(
- SettingsHelper.NAMESPACE_GLOBAL,
- Settings.Global.TEXT_CLASSIFIER_CONSTANTS,
- "system_textclassifier_enabled=true");
+ enableSystemTextclassifier(String.valueOf(true));
TextClassificationManager textClassificationManager =
context.getSystemService(TextClassificationManager.class);
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
@@ -71,4 +93,9 @@ public class TextClassificationManagerPerfTest {
textClassificationManager.invalidateForTesting();
}
}
+
+ private void enableSystemTextclassifier(String enabled) {
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TEXTCLASSIFIER,
+ "system_textclassifier_enabled", enabled, /* makeDefault */ false);
+ }
}