diff options
388 files changed, 5214 insertions, 2163 deletions
diff --git a/apct-tests/perftests/core/src/android/libcore/AdditionPerfTest.java b/apct-tests/perftests/core/src/android/libcore/AdditionPerfTest.java index 80cd86cf9a5b..237c747e3a6f 100644 --- a/apct-tests/perftests/core/src/android/libcore/AdditionPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/AdditionPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -34,11 +34,11 @@ import org.junit.runner.RunWith; public class AdditionPerfTest { @Rule - public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeAddConstantToLocalInt() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); int result = 0; while (state.keepRunning()) { result += 123; @@ -46,7 +46,7 @@ public class AdditionPerfTest { } @Test public void timeAddTwoLocalInts() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); int result = 0; int constant = 123; while (state.keepRunning()) { @@ -55,7 +55,7 @@ public class AdditionPerfTest { } @Test public void timeAddConstantToLocalLong() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); long result = 0; while (state.keepRunning()) { result += 123L; @@ -63,7 +63,7 @@ public class AdditionPerfTest { } @Test public void timeAddTwoLocalLongs() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); long result = 0; long constant = 123L; while (state.keepRunning()) { @@ -72,7 +72,7 @@ public class AdditionPerfTest { } @Test public void timeAddConstantToLocalFloat() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); float result = 0.0f; while (state.keepRunning()) { result += 123.0f; @@ -80,7 +80,7 @@ public class AdditionPerfTest { } @Test public void timeAddTwoLocalFloats() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); float result = 0.0f; float constant = 123.0f; while (state.keepRunning()) { @@ -89,7 +89,7 @@ public class AdditionPerfTest { } @Test public void timeAddConstantToLocalDouble() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); double result = 0.0; while (state.keepRunning()) { result += 123.0; @@ -97,7 +97,7 @@ public class AdditionPerfTest { } @Test public void timeAddTwoLocalDoubles() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); double result = 0.0; double constant = 123.0; while (state.keepRunning()) { diff --git a/apct-tests/perftests/core/src/android/libcore/ArrayCopyPerfTest.java b/apct-tests/perftests/core/src/android/libcore/ArrayCopyPerfTest.java index 2f6c37832d04..1222bc242564 100644 --- a/apct-tests/perftests/core/src/android/libcore/ArrayCopyPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/ArrayCopyPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -33,11 +33,11 @@ import java.util.Arrays; public class ArrayCopyPerfTest { @Rule - public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeManualArrayCopy() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); char[] src = new char[8192]; while (state.keepRunning()) { char[] dst = new char[8192]; @@ -49,7 +49,7 @@ public class ArrayCopyPerfTest { @Test public void time_System_arrayCopy() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); char[] src = new char[8192]; while (state.keepRunning()) { char[] dst = new char[8192]; @@ -59,7 +59,7 @@ public class ArrayCopyPerfTest { @Test public void time_Arrays_copyOf() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); char[] src = new char[8192]; while (state.keepRunning()) { char[] dst = Arrays.copyOf(src, 8192); @@ -68,7 +68,7 @@ public class ArrayCopyPerfTest { @Test public void time_Arrays_copyOfRange() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); char[] src = new char[8192]; while (state.keepRunning()) { char[] dst = Arrays.copyOfRange(src, 0, 8192); diff --git a/apct-tests/perftests/core/src/android/libcore/ArrayIterationPerfTest.java b/apct-tests/perftests/core/src/android/libcore/ArrayIterationPerfTest.java index d17add767257..3f95e3e44f84 100644 --- a/apct-tests/perftests/core/src/android/libcore/ArrayIterationPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/ArrayIterationPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -38,7 +38,7 @@ public class ArrayIterationPerfTest { } @Rule - public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); Foo[] mArray = new Foo[27]; { @@ -46,7 +46,7 @@ public class ArrayIterationPerfTest { } @Test public void timeArrayIteration() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { int sum = 0; for (int i = 0; i < mArray.length; i++) { @@ -56,7 +56,7 @@ public class ArrayIterationPerfTest { } @Test public void timeArrayIterationCached() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { int sum = 0; Foo[] localArray = mArray; @@ -69,7 +69,7 @@ public class ArrayIterationPerfTest { } @Test public void timeArrayIterationForEach() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { int sum = 0; for (Foo a: mArray) { diff --git a/apct-tests/perftests/core/src/android/libcore/ArrayListIterationPerfTest.java b/apct-tests/perftests/core/src/android/libcore/ArrayListIterationPerfTest.java index 3a57db8f323f..1423a13b43dc 100644 --- a/apct-tests/perftests/core/src/android/libcore/ArrayListIterationPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/ArrayListIterationPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -39,7 +39,7 @@ public class ArrayListIterationPerfTest { int mSplat; } @Rule - public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); ArrayList<Foo> mList = new ArrayList<Foo>(); { @@ -47,7 +47,7 @@ public class ArrayListIterationPerfTest { } @Test public void timeArrayListIterationIndexed() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { int sum = 0; ArrayList<Foo> list = mList; @@ -59,7 +59,7 @@ public class ArrayListIterationPerfTest { } @Test public void timeArrayListIterationForEach() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { int sum = 0; for (Foo a : mList) { diff --git a/apct-tests/perftests/core/src/android/libcore/BigIntegerPerfTest.java b/apct-tests/perftests/core/src/android/libcore/BigIntegerPerfTest.java index 3fb3bc8c0ff2..02831055ff56 100644 --- a/apct-tests/perftests/core/src/android/libcore/BigIntegerPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/BigIntegerPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -38,7 +38,8 @@ import java.math.BigInteger; @RunWith(AndroidJUnit4.class) @LargeTest public class BigIntegerPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); // A simple sum of products computation, mostly so we can check timing in the // absence of any division. Computes the sum from 1 to n of ((10^prec) << 30) + 1)^2, @@ -61,7 +62,7 @@ public class BigIntegerPerfTest { // Execute the above rep times, optionally timing it. @Test public void repeatInner() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 10; i <= 10_000; i *= 10) { inner(100, i); @@ -85,7 +86,7 @@ public class BigIntegerPerfTest { // Check results for equality, and print one, to compaare against reference. @Test public void repeatHarmonic1000() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 5; i <= 5_000; i *= 10) { BigInteger refRes = harmonic1000(i); @@ -106,7 +107,7 @@ public class BigIntegerPerfTest { // us to time and check it for consistency as well. @Test public void repeatToString() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 5; i <= 5_000; i *= 10) { BigInteger refRes = harmonic1000(i); @@ -146,7 +147,7 @@ public class BigIntegerPerfTest { // to compare to reference. @Test public void repeatEApprox() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 10; i <= 10_000; i *= 10) { BigInteger refRes = eApprox(100_000, i); @@ -165,7 +166,7 @@ public class BigIntegerPerfTest { // Test / time modPow() @Test public void repeatModPow() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 5; i <= 500; i *= 10) { BigInteger odd1 = BigInteger.TEN.pow(i / 2).add(BigInteger.ONE); @@ -198,7 +199,7 @@ public class BigIntegerPerfTest { // Test / time modInverse() @Test public void repeatModInverse() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 10; i <= 10_000; i *= 10) { BigInteger odd1 = BigInteger.TEN.pow(i / 2).add(BigInteger.ONE); diff --git a/apct-tests/perftests/core/src/android/libcore/BufferedZipFilePerfTest.java b/apct-tests/perftests/core/src/android/libcore/BufferedZipFilePerfTest.java index 2a1b5d1cc6ce..11ca73acd45b 100644 --- a/apct-tests/perftests/core/src/android/libcore/BufferedZipFilePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/BufferedZipFilePerfTest.java @@ -16,8 +16,9 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; + import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -39,7 +40,8 @@ import java.util.zip.ZipOutputStream; @RunWith(AndroidJUnit4.class) @LargeTest public final class BufferedZipFilePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); int[] mReadSize = new int[] {4, 32, 128}; int[] mCompressedSize = new int[] {128, 1024, 8192, 65536}; @@ -67,7 +69,7 @@ public final class BufferedZipFilePerfTest { @Test public void timeUnbufferedRead() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < mCompressedSize.length; i++) { for (int j = 0; j < mReadSize.length; j++) { @@ -87,7 +89,7 @@ public final class BufferedZipFilePerfTest { @Test public void timeBufferedRead() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < mCompressedSize.length; i++) { for (int j = 0; j < mReadSize.length; j++) { diff --git a/apct-tests/perftests/core/src/android/libcore/ClassLoaderResourcePerfTest.java b/apct-tests/perftests/core/src/android/libcore/ClassLoaderResourcePerfTest.java index 5f599ea85eb4..0abe194b6fdb 100644 --- a/apct-tests/perftests/core/src/android/libcore/ClassLoaderResourcePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/ClassLoaderResourcePerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -30,7 +30,8 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class ClassLoaderResourcePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private static final String EXISTENT_RESOURCE = "java/util/logging/logging.properties"; private static final String MISSING_RESOURCE = "missing_entry"; @@ -40,7 +41,7 @@ public class ClassLoaderResourcePerfTest { ClassLoader currentClassLoader = getClass().getClassLoader(); Assert.assertNotNull(currentClassLoader.getResource(EXISTENT_RESOURCE)); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { currentClassLoader.getResource(EXISTENT_RESOURCE); } @@ -51,7 +52,7 @@ public class ClassLoaderResourcePerfTest { ClassLoader currentClassLoader = getClass().getClassLoader(); Assert.assertNull(currentClassLoader.getResource(MISSING_RESOURCE)); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { currentClassLoader.getResource(MISSING_RESOURCE); } diff --git a/apct-tests/perftests/core/src/android/libcore/ClonePerfTest.java b/apct-tests/perftests/core/src/android/libcore/ClonePerfTest.java index ea249848daad..52441d1d868e 100644 --- a/apct-tests/perftests/core/src/android/libcore/ClonePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/ClonePerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -29,7 +29,8 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class ClonePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static class CloneableObject implements Cloneable { public Object clone() throws CloneNotSupportedException { @@ -1127,7 +1128,7 @@ public class ClonePerfTest { public void time_Object_clone() { try { CloneableObject o = new CloneableObject(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { o.clone(); } @@ -1140,7 +1141,7 @@ public class ClonePerfTest { public void time_Object_manyFieldClone() { try { CloneableManyFieldObject o = new CloneableManyFieldObject(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { o.clone(); } @@ -1153,7 +1154,7 @@ public class ClonePerfTest { public void time_Object_deepClone() { try { DeepCloneable o = new DeepCloneable(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { o.clone(); } @@ -1165,7 +1166,7 @@ public class ClonePerfTest { @Test public void time_Array_clone() { int[] o = new int[32]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { o.clone(); } @@ -1177,7 +1178,7 @@ public class ClonePerfTest { for (int i = 0; i < o.length / 2; ++i) { o[i] = new Object(); } - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { o.clone(); } @@ -1189,7 +1190,7 @@ public class ClonePerfTest { for (int i = 0; i < o.length / 2; ++i) { o[i] = new Object(); } - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { o.clone(); } diff --git a/apct-tests/perftests/core/src/android/libcore/DeepArrayOpsPerfTest.java b/apct-tests/perftests/core/src/android/libcore/DeepArrayOpsPerfTest.java index 82247dcee772..e6c5aca2c330 100644 --- a/apct-tests/perftests/core/src/android/libcore/DeepArrayOpsPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/DeepArrayOpsPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -36,7 +36,8 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class DeepArrayOpsPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private Object[] mArray; private Object[] mArray2; @@ -99,7 +100,7 @@ public class DeepArrayOpsPerfTest { @Parameters(method = "getData") public void deepHashCode(int arrayLength) throws Exception { setUp(arrayLength); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Arrays.deepHashCode(mArray); } @@ -109,7 +110,7 @@ public class DeepArrayOpsPerfTest { @Parameters(method = "getData") public void deepEquals(int arrayLength) throws Exception { setUp(arrayLength); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Arrays.deepEquals(mArray, mArray2); } diff --git a/apct-tests/perftests/core/src/android/libcore/FieldAccessPerfTest.java b/apct-tests/perftests/core/src/android/libcore/FieldAccessPerfTest.java index 0bebf04c6897..378137b417e9 100644 --- a/apct-tests/perftests/core/src/android/libcore/FieldAccessPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/FieldAccessPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -30,7 +30,8 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class FieldAccessPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private static class Inner { public int mPublicInnerIntVal; @@ -47,7 +48,7 @@ public class FieldAccessPerfTest { @Test public void timeField() { int result = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = mIntVal; } @@ -56,7 +57,7 @@ public class FieldAccessPerfTest { @Test public void timeFieldFinal() { int result = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = mFinalIntVal; } @@ -65,7 +66,7 @@ public class FieldAccessPerfTest { @Test public void timeFieldStatic() { int result = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = sStaticIntVal; } @@ -74,7 +75,7 @@ public class FieldAccessPerfTest { @Test public void timeFieldStaticFinal() { int result = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = FINAL_INT_VAL; } @@ -84,7 +85,7 @@ public class FieldAccessPerfTest { public void timeFieldCached() { int result = 0; int cachedIntVal = this.mIntVal; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = cachedIntVal; } @@ -94,7 +95,7 @@ public class FieldAccessPerfTest { public void timeFieldPrivateInnerClassPublicField() { int result = 0; Inner inner = new Inner(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = inner.mPublicInnerIntVal; } @@ -104,7 +105,7 @@ public class FieldAccessPerfTest { public void timeFieldPrivateInnerClassProtectedField() { int result = 0; Inner inner = new Inner(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = inner.mProtectedInnerIntVal; } @@ -114,7 +115,7 @@ public class FieldAccessPerfTest { public void timeFieldPrivateInnerClassPrivateField() { int result = 0; Inner inner = new Inner(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = inner.mPrivateInnerIntVal; } @@ -124,7 +125,7 @@ public class FieldAccessPerfTest { public void timeFieldPrivateInnerClassPackageField() { int result = 0; Inner inner = new Inner(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = inner.mPackageInnerIntVal; } diff --git a/apct-tests/perftests/core/src/android/libcore/HashedCollectionsPerfTest.java b/apct-tests/perftests/core/src/android/libcore/HashedCollectionsPerfTest.java index 55c1027e1add..610e8e56c951 100644 --- a/apct-tests/perftests/core/src/android/libcore/HashedCollectionsPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/HashedCollectionsPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -35,13 +35,14 @@ import java.util.concurrent.ConcurrentHashMap; @RunWith(AndroidJUnit4.class) @LargeTest public class HashedCollectionsPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeHashMapGet() { HashMap<String, String> map = new HashMap<String, String>(); map.put("hello", "world"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { map.get("hello"); } @@ -53,7 +54,7 @@ public class HashedCollectionsPerfTest { synchronized (map) { map.put("hello", "world"); } - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { synchronized (map) { map.get("hello"); @@ -65,7 +66,7 @@ public class HashedCollectionsPerfTest { public void timeHashtableGet() { Hashtable<String, String> map = new Hashtable<String, String>(); map.put("hello", "world"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { map.get("hello"); } @@ -75,7 +76,7 @@ public class HashedCollectionsPerfTest { public void timeLinkedHashMapGet() { LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(); map.put("hello", "world"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { map.get("hello"); } @@ -85,7 +86,7 @@ public class HashedCollectionsPerfTest { public void timeConcurrentHashMapGet() { ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>(); map.put("hello", "world"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { map.get("hello"); } diff --git a/apct-tests/perftests/core/src/android/libcore/ImtConflictPerfTest.java b/apct-tests/perftests/core/src/android/libcore/ImtConflictPerfTest.java index da60a7773528..40c07e05bbde 100644 --- a/apct-tests/perftests/core/src/android/libcore/ImtConflictPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/ImtConflictPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -41,7 +41,8 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class ImtConflictPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Before public void setup() { @@ -280,7 +281,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth01() { C0 c0 = new C0(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c0); callF0(c0); @@ -308,7 +309,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth02() { C1 c1 = new C1(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c1); callF19(c1); @@ -336,7 +337,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth03() { C2 c2 = new C2(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c2); callF19(c2); @@ -364,7 +365,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth04() { C3 c3 = new C3(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c3); callF19(c3); @@ -392,7 +393,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth05() { C4 c4 = new C4(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c4); callF19(c4); @@ -420,7 +421,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth06() { C5 c5 = new C5(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c5); callF19(c5); @@ -448,7 +449,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth07() { C6 c6 = new C6(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c6); callF19(c6); @@ -476,7 +477,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth08() { C7 c7 = new C7(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c7); callF19(c7); @@ -504,7 +505,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth09() { C8 c8 = new C8(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c8); callF19(c8); @@ -532,7 +533,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth10() { C9 c9 = new C9(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c9); callF19(c9); @@ -560,7 +561,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth11() { C10 c10 = new C10(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c10); callF19(c10); @@ -588,7 +589,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth12() { C11 c11 = new C11(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c11); callF19(c11); @@ -616,7 +617,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth13() { C12 c12 = new C12(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c12); callF19(c12); @@ -644,7 +645,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth14() { C13 c13 = new C13(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c13); callF19(c13); @@ -672,7 +673,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth15() { C14 c14 = new C14(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c14); callF19(c14); @@ -700,7 +701,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth16() { C15 c15 = new C15(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c15); callF19(c15); @@ -728,7 +729,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth17() { C16 c16 = new C16(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c16); callF19(c16); @@ -756,7 +757,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth18() { C17 c17 = new C17(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c17); callF19(c17); @@ -784,7 +785,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth19() { C18 c18 = new C18(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c18); callF19(c18); @@ -812,7 +813,7 @@ public class ImtConflictPerfTest { @Test public void timeConflictDepth20() { C19 c19 = new C19(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { callF0(c19); callF19(c19); diff --git a/apct-tests/perftests/core/src/android/libcore/MethodInvocationPerfTest.java b/apct-tests/perftests/core/src/android/libcore/MethodInvocationPerfTest.java index 6d9d0c92ff25..e1d0bf2f9491 100644 --- a/apct-tests/perftests/core/src/android/libcore/MethodInvocationPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/MethodInvocationPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -30,7 +30,8 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class MethodInvocationPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); interface I { void emptyInterface(); @@ -65,12 +66,12 @@ public class MethodInvocationPerfTest { } public void timeInternalGetter() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); new C().timeInternalGetter(state); } public void timeInternalFieldAccess() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); new C().timeInternalFieldAccess(state); } @@ -78,7 +79,7 @@ public class MethodInvocationPerfTest { @Test public void timeStringLength() { int result = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = "hello, world!".length(); } @@ -87,7 +88,7 @@ public class MethodInvocationPerfTest { @Test public void timeEmptyStatic() { C c = new C(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { c.emptyStatic(); } @@ -96,7 +97,7 @@ public class MethodInvocationPerfTest { @Test public void timeEmptyVirtual() { C c = new C(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { c.emptyVirtual(); } @@ -105,7 +106,7 @@ public class MethodInvocationPerfTest { @Test public void timeEmptyInterface() { I c = new C(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { c.emptyInterface(); } @@ -138,7 +139,7 @@ public class MethodInvocationPerfTest { @Test public void timePrivateInnerPublicMethod() { Inner inner = new Inner(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { inner.publicMethod(); } @@ -147,7 +148,7 @@ public class MethodInvocationPerfTest { @Test public void timePrivateInnerProtectedMethod() { Inner inner = new Inner(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { inner.protectedMethod(); } @@ -156,7 +157,7 @@ public class MethodInvocationPerfTest { @Test public void timePrivateInnerPrivateMethod() { Inner inner = new Inner(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { inner.privateMethod(); } @@ -165,7 +166,7 @@ public class MethodInvocationPerfTest { @Test public void timePrivateInnerPackageMethod() { Inner inner = new Inner(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { inner.packageMethod(); } @@ -174,7 +175,7 @@ public class MethodInvocationPerfTest { @Test public void timePrivateInnerFinalPackageMethod() { Inner inner = new Inner(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { inner.finalPackageMethod(); } diff --git a/apct-tests/perftests/core/src/android/libcore/MultiplicationPerfTest.java b/apct-tests/perftests/core/src/android/libcore/MultiplicationPerfTest.java index 09b09771e9de..c5e9d1e1d5e4 100644 --- a/apct-tests/perftests/core/src/android/libcore/MultiplicationPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/MultiplicationPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -30,12 +30,13 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class MultiplicationPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeMultiplyIntByConstant10() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= 10; } @@ -44,7 +45,7 @@ public class MultiplicationPerfTest { @Test public void timeMultiplyIntByConstant8() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= 8; } @@ -54,7 +55,7 @@ public class MultiplicationPerfTest { public void timeMultiplyIntByVariable10() { int result = 1; int factor = 10; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= factor; } @@ -64,7 +65,7 @@ public class MultiplicationPerfTest { public void timeMultiplyIntByVariable8() { int result = 1; int factor = 8; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= factor; } diff --git a/apct-tests/perftests/core/src/android/libcore/ReferenceGetPerfTest.java b/apct-tests/perftests/core/src/android/libcore/ReferenceGetPerfTest.java index ba21ed33bdb2..d073f9163f39 100644 --- a/apct-tests/perftests/core/src/android/libcore/ReferenceGetPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/ReferenceGetPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -35,7 +35,8 @@ import java.lang.reflect.Field; @RunWith(AndroidJUnit4.class) @LargeTest public class ReferenceGetPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); boolean mIntrinsicDisabled; @@ -51,7 +52,7 @@ public class ReferenceGetPerfTest { @Test public void timeSoftReferenceGet() throws Exception { Reference soft = new SoftReference(mObj); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Object o = soft.get(); } @@ -60,7 +61,7 @@ public class ReferenceGetPerfTest { @Test public void timeWeakReferenceGet() throws Exception { Reference weak = new WeakReference(mObj); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Object o = weak.get(); } @@ -71,7 +72,7 @@ public class ReferenceGetPerfTest { Reference weak = new WeakReference(mObj); mObj = null; Runtime.getRuntime().gc(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Object o = weak.get(); } diff --git a/apct-tests/perftests/core/src/android/libcore/ReferencePerfTest.java b/apct-tests/perftests/core/src/android/libcore/ReferencePerfTest.java index 293752ee5dd1..af13773dd177 100644 --- a/apct-tests/perftests/core/src/android/libcore/ReferencePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/ReferencePerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -34,7 +34,8 @@ import java.util.concurrent.atomic.AtomicInteger; @RunWith(AndroidJUnit4.class) @LargeTest public class ReferencePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private Object mObject; @@ -42,7 +43,7 @@ public class ReferencePerfTest { @Test public void timeAlloc() { ReferenceQueue<Object> queue = new ReferenceQueue<Object>(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new PhantomReference(mObject, queue); } @@ -52,7 +53,7 @@ public class ReferencePerfTest { @Test public void timeAllocAndEnqueue() { ReferenceQueue<Object> queue = new ReferenceQueue<Object>(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { (new PhantomReference<Object>(mObject, queue)).enqueue(); } @@ -62,7 +63,7 @@ public class ReferencePerfTest { @Test public void timeAllocEnqueueAndPoll() { ReferenceQueue<Object> queue = new ReferenceQueue<Object>(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { (new PhantomReference<Object>(mObject, queue)).enqueue(); queue.poll(); @@ -73,7 +74,7 @@ public class ReferencePerfTest { @Test public void timeAllocEnqueueAndRemove() { ReferenceQueue<Object> queue = new ReferenceQueue<Object>(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { (new PhantomReference<Object>(mObject, queue)).enqueue(); try { @@ -102,7 +103,7 @@ public class ReferencePerfTest { // Allocate a bunch of finalizable objects. int n = 0; AtomicInteger count = new AtomicInteger(0); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { n++; new FinalizableObject(count); diff --git a/apct-tests/perftests/core/src/android/libcore/SmallBigIntegerPerfTest.java b/apct-tests/perftests/core/src/android/libcore/SmallBigIntegerPerfTest.java index 528b751d1551..cf573fa6f250 100644 --- a/apct-tests/perftests/core/src/android/libcore/SmallBigIntegerPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/SmallBigIntegerPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -41,7 +41,9 @@ import java.util.Random; @RunWith(AndroidJUnit4.class) @LargeTest public class SmallBigIntegerPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); + // We allocate about 2 1/3 BigIntegers per iteration. // Assuming 100 bytes/BigInteger, this gives us around 500MB total. static final BigInteger BIG_THREE = BigInteger.valueOf(3); @@ -51,7 +53,7 @@ public class SmallBigIntegerPerfTest { public void testSmallBigInteger() { final Random r = new Random(); BigInteger x = new BigInteger(20, r); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { // We know this converges, but the compiler doesn't. if (x.and(BigInteger.ONE).equals(BigInteger.ONE)) { diff --git a/apct-tests/perftests/core/src/android/libcore/StringDexCachePerfTest.java b/apct-tests/perftests/core/src/android/libcore/StringDexCachePerfTest.java index 1f301acd1dc6..d28154c76067 100644 --- a/apct-tests/perftests/core/src/android/libcore/StringDexCachePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/StringDexCachePerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -30,13 +30,14 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class StringDexCachePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeStringDexCacheAccess() { int v = 0; int count = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { // Deliberately obscured to make optimizations less likely. String s = (count >= 0) ? "hello, world!" : null; diff --git a/apct-tests/perftests/core/src/android/libcore/StringIterationPerfTest.java b/apct-tests/perftests/core/src/android/libcore/StringIterationPerfTest.java index 4268325f8c64..40a8db0c5903 100644 --- a/apct-tests/perftests/core/src/android/libcore/StringIterationPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/StringIterationPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -30,12 +30,13 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class StringIterationPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeStringIteration0() { String s = "hello, world!"; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { char ch; for (int i = 0; i < s.length(); ++i) { @@ -47,7 +48,7 @@ public class StringIterationPerfTest { @Test public void timeStringIteration1() { String s = "hello, world!"; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { char ch; for (int i = 0, length = s.length(); i < length; ++i) { @@ -59,7 +60,7 @@ public class StringIterationPerfTest { @Test public void timeStringIteration2() { String s = "hello, world!"; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { char ch; char[] chars = s.toCharArray(); @@ -72,7 +73,7 @@ public class StringIterationPerfTest { @Test public void timeStringToCharArray() { String s = "hello, world!"; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { char[] chars = s.toCharArray(); } diff --git a/apct-tests/perftests/core/src/android/libcore/VirtualVersusInterfacePerfTest.java b/apct-tests/perftests/core/src/android/libcore/VirtualVersusInterfacePerfTest.java index cb3d3acb337f..147ea50f3a3c 100644 --- a/apct-tests/perftests/core/src/android/libcore/VirtualVersusInterfacePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/VirtualVersusInterfacePerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -36,12 +36,13 @@ import java.util.Map; @RunWith(AndroidJUnit4.class) @LargeTest public class VirtualVersusInterfacePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeMapPut() { Map<String, String> map = new HashMap<String, String>(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { map.put("hello", "world"); } @@ -50,7 +51,7 @@ public class VirtualVersusInterfacePerfTest { @Test public void timeHashMapPut() { HashMap<String, String> map = new HashMap<String, String>(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { map.put("hello", "world"); } diff --git a/apct-tests/perftests/core/src/android/libcore/XmlSerializePerfTest.java b/apct-tests/perftests/core/src/android/libcore/XmlSerializePerfTest.java index 5be8ee6e67e2..bb1c298c67b2 100644 --- a/apct-tests/perftests/core/src/android/libcore/XmlSerializePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/XmlSerializePerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -36,7 +36,8 @@ import java.util.Random; @RunWith(JUnitParamsRunner.class) @LargeTest public class XmlSerializePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private Object[] getParams() { return new Object[][] { @@ -108,7 +109,7 @@ public class XmlSerializePerfTest { private void internalTimeSerializer(Constructor<? extends XmlSerializer> ctor, int seed) throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { serializeRandomXml(ctor, seed); } diff --git a/apct-tests/perftests/core/src/android/libcore/XmlSerializerPerfTest.java b/apct-tests/perftests/core/src/android/libcore/XmlSerializerPerfTest.java index a37b89ddf033..9360a25fc86a 100644 --- a/apct-tests/perftests/core/src/android/libcore/XmlSerializerPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/XmlSerializerPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import android.util.Xml; import androidx.test.filters.LargeTest; @@ -44,11 +44,11 @@ import java.nio.charset.StandardCharsets; public class XmlSerializerPerfTest { @Rule - public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeFastSerializer_nonIndent_depth100() throws IOException { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { XmlSerializer serializer = Xml.newFastSerializer(); runTest(serializer, 100); @@ -57,7 +57,7 @@ public class XmlSerializerPerfTest { @Test public void timeFastSerializer_indent_depth100() throws IOException { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { XmlSerializer serializer = Xml.newFastSerializer(); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); @@ -67,7 +67,7 @@ public class XmlSerializerPerfTest { @Test public void timeKXmlSerializer_nonIndent_depth100() throws IOException { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { XmlSerializer serializer = XmlObjectFactory.newXmlSerializer(); runTest(serializer, 100); @@ -76,7 +76,7 @@ public class XmlSerializerPerfTest { @Test public void timeKXmlSerializer_indent_depth100() throws IOException { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { XmlSerializer serializer = XmlObjectFactory.newXmlSerializer(); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); diff --git a/apct-tests/perftests/core/src/android/libcore/ZipFilePerfTest.java b/apct-tests/perftests/core/src/android/libcore/ZipFilePerfTest.java index ed669beae1ce..03f183a01d11 100644 --- a/apct-tests/perftests/core/src/android/libcore/ZipFilePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/ZipFilePerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -42,7 +42,8 @@ import java.util.zip.ZipOutputStream; @RunWith(JUnitParamsRunner.class) @LargeTest public class ZipFilePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private File mFile; @@ -65,7 +66,7 @@ public class ZipFilePerfTest { @Parameters(method = "getData") public void timeZipFileOpen(int numEntries) throws Exception { setUp(numEntries); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { ZipFile zf = new ZipFile(mFile); state.pauseTiming(); diff --git a/apct-tests/perftests/core/src/android/libcore/ZipFileReadPerfTest.java b/apct-tests/perftests/core/src/android/libcore/ZipFileReadPerfTest.java index d239a054fac7..36140611c978 100644 --- a/apct-tests/perftests/core/src/android/libcore/ZipFileReadPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/ZipFileReadPerfTest.java @@ -16,8 +16,8 @@ package android.libcore; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -44,7 +44,8 @@ import java.util.zip.ZipOutputStream; @RunWith(JUnitParamsRunner.class) @LargeTest public class ZipFileReadPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList(new Object[][] {{1024}, {16384}, {65536}}); @@ -91,7 +92,7 @@ public class ZipFileReadPerfTest { @Parameters(method = "getData") public void timeZipFileRead(int readBufferSize) throws Exception { byte[] readBuffer = new byte[readBufferSize]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { ZipFile zipFile = new ZipFile(mFile); for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements(); ) { diff --git a/apct-tests/perftests/core/src/android/libcore/regression/AnnotatedElementPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/AnnotatedElementPerfTest.java index 487295c03c0e..8890f51fe5cd 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/AnnotatedElementPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/AnnotatedElementPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -35,7 +35,8 @@ import java.lang.reflect.Method; @RunWith(AndroidJUnit4.class) @LargeTest public class AnnotatedElementPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private Class<?> mType; private Field mField; @@ -52,7 +53,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetTypeAnnotations() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mType.getAnnotations(); } @@ -60,7 +61,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetFieldAnnotations() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mField.getAnnotations(); } @@ -68,7 +69,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetMethodAnnotations() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mMethod.getAnnotations(); } @@ -76,7 +77,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetParameterAnnotations() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mMethod.getParameterAnnotations(); } @@ -84,7 +85,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetTypeAnnotation() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mType.getAnnotation(Marker.class); } @@ -92,7 +93,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetFieldAnnotation() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mField.getAnnotation(Marker.class); } @@ -100,7 +101,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetMethodAnnotation() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mMethod.getAnnotation(Marker.class); } @@ -108,7 +109,7 @@ public class AnnotatedElementPerfTest { @Test public void timeIsTypeAnnotationPresent() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mType.isAnnotationPresent(Marker.class); } @@ -116,7 +117,7 @@ public class AnnotatedElementPerfTest { @Test public void timeIsFieldAnnotationPresent() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mField.isAnnotationPresent(Marker.class); } @@ -124,7 +125,7 @@ public class AnnotatedElementPerfTest { @Test public void timeIsMethodAnnotationPresent() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mMethod.isAnnotationPresent(Marker.class); } @@ -134,7 +135,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetAllReturnsLargeAnnotation() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { HasLargeAnnotation.class.getAnnotations(); } @@ -142,7 +143,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetAllReturnsSmallAnnotation() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { HasSmallAnnotation.class.getAnnotations(); } @@ -150,7 +151,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetAllReturnsMarkerAnnotation() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { HasMarkerAnnotation.class.getAnnotations(); } @@ -158,7 +159,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetAllReturnsNoAnnotation() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { HasNoAnnotations.class.getAnnotations(); } @@ -166,7 +167,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetAllReturnsThreeAnnotations() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { HasThreeAnnotations.class.getAnnotations(); } @@ -176,7 +177,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetAnnotationsOnSubclass() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { ExtendsHasThreeAnnotations.class.getAnnotations(); } @@ -184,7 +185,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetDeclaredAnnotationsOnSubclass() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { ExtendsHasThreeAnnotations.class.getDeclaredAnnotations(); } @@ -194,7 +195,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetDeclaredClasses() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { AnnotatedElementPerfTest.class.getDeclaredClasses(); } @@ -202,7 +203,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetDeclaringClass() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { HasSmallAnnotation.class.getDeclaringClass(); } @@ -211,7 +212,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetEnclosingClass() { Object anonymousClass = new Object() {}; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { anonymousClass.getClass().getEnclosingClass(); } @@ -220,7 +221,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetEnclosingConstructor() { Object anonymousClass = new Object() {}; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { anonymousClass.getClass().getEnclosingConstructor(); } @@ -229,7 +230,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetEnclosingMethod() { Object anonymousClass = new Object() {}; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { anonymousClass.getClass().getEnclosingMethod(); } @@ -237,7 +238,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetModifiers() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { HasSmallAnnotation.class.getModifiers(); } @@ -245,7 +246,7 @@ public class AnnotatedElementPerfTest { @Test public void timeGetSimpleName() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { HasSmallAnnotation.class.getSimpleName(); } @@ -254,7 +255,7 @@ public class AnnotatedElementPerfTest { @Test public void timeIsAnonymousClass() { Object anonymousClass = new Object() {}; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { anonymousClass.getClass().isAnonymousClass(); } @@ -262,7 +263,7 @@ public class AnnotatedElementPerfTest { @Test public void timeIsLocalClass() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { HasSmallAnnotation.class.isLocalClass(); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/BidiPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/BidiPerfTest.java index adc5d8c2bb3e..baab8602b265 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/BidiPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/BidiPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -34,14 +34,14 @@ import java.text.DecimalFormat; @RunWith(AndroidJUnit4.class) @LargeTest public class BidiPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private static final AttributedCharacterIterator CHAR_ITER = DecimalFormat.getInstance().formatToCharacterIterator(new BigDecimal(Math.PI)); @Test public void time_createBidiFromIter() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Bidi bidi = new Bidi(CHAR_ITER); } @@ -49,7 +49,7 @@ public class BidiPerfTest { @Test public void time_createBidiFromCharArray() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Bidi bd = new Bidi( @@ -64,7 +64,7 @@ public class BidiPerfTest { @Test public void time_createBidiFromString() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Bidi bidi = new Bidi("Hello", Bidi.DIRECTION_LEFT_TO_RIGHT); } @@ -72,7 +72,7 @@ public class BidiPerfTest { @Test public void time_reorderVisually() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Bidi.reorderVisually( new byte[] {2, 1, 3, 0, 4}, 0, new String[] {"H", "e", "l", "l", "o"}, 0, 5); @@ -81,7 +81,7 @@ public class BidiPerfTest { @Test public void time_hebrewBidi() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Bidi bd = new Bidi( @@ -104,7 +104,7 @@ public class BidiPerfTest { @Test public void time_complicatedOverrideBidi() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Bidi bd = new Bidi( @@ -119,7 +119,7 @@ public class BidiPerfTest { @Test public void time_requiresBidi() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Bidi.requiresBidi("\u05D0".toCharArray(), 1, 1); // false. Bidi.requiresBidi("\u05D0".toCharArray(), 0, 1); // true. diff --git a/apct-tests/perftests/core/src/android/libcore/regression/BigIntegerPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/BigIntegerPerfTest.java index 286d70339c5f..8a539f89d3ca 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/BigIntegerPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/BigIntegerPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -32,14 +32,14 @@ import java.util.Random; @RunWith(AndroidJUnit4.class) @LargeTest public class BigIntegerPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeRandomDivision() throws Exception { Random r = new Random(); BigInteger x = new BigInteger(1024, r); BigInteger y = new BigInteger(1024, r); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x.divide(y); } @@ -50,7 +50,7 @@ public class BigIntegerPerfTest { Random r = new Random(); BigInteger x = new BigInteger(1024, r); BigInteger y = new BigInteger(1024, r); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x.gcd(y); } @@ -61,7 +61,7 @@ public class BigIntegerPerfTest { Random r = new Random(); BigInteger x = new BigInteger(1024, r); BigInteger y = new BigInteger(1024, r); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x.multiply(y); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/BitSetPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/BitSetPerfTest.java index d6462024a380..1b46ff4f433a 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/BitSetPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/BitSetPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -35,7 +35,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class BitSetPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList(new Object[][] {{1000}, {10000}}); @@ -45,7 +45,7 @@ public class BitSetPerfTest { @Parameters(method = "getData") public void timeIsEmptyTrue(int size) { BitSet bitSet = new BitSet(size); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { if (!bitSet.isEmpty()) throw new RuntimeException(); } @@ -56,7 +56,7 @@ public class BitSetPerfTest { public void timeIsEmptyFalse(int size) { BitSet bitSet = new BitSet(size); bitSet.set(bitSet.size() - 1); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { if (bitSet.isEmpty()) throw new RuntimeException(); } @@ -66,7 +66,7 @@ public class BitSetPerfTest { @Parameters(method = "getData") public void timeGet(int size) { BitSet bitSet = new BitSet(size); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); int i = 1; while (state.keepRunning()) { bitSet.get(++i % size); @@ -77,7 +77,7 @@ public class BitSetPerfTest { @Parameters(method = "getData") public void timeClear(int size) { BitSet bitSet = new BitSet(size); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); int i = 1; while (state.keepRunning()) { bitSet.clear(++i % size); @@ -89,7 +89,7 @@ public class BitSetPerfTest { public void timeSet(int size) { BitSet bitSet = new BitSet(size); int i = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { bitSet.set(++i % size); } @@ -100,7 +100,7 @@ public class BitSetPerfTest { public void timeSetOn(int size) { BitSet bitSet = new BitSet(size); int i = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { bitSet.set(++i % size, true); } @@ -111,7 +111,7 @@ public class BitSetPerfTest { public void timeSetOff(int size) { BitSet bitSet = new BitSet(size); int i = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { bitSet.set(++i % size, false); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/BreakIteratorPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/BreakIteratorPerfTest.java index b887f4033462..3c5e4fd159c8 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/BreakIteratorPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/BreakIteratorPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -36,7 +36,7 @@ import java.util.Locale; @RunWith(JUnitParamsRunner.class) @LargeTest public final class BreakIteratorPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public enum Text { LIPSUM( @@ -165,7 +165,7 @@ public final class BreakIteratorPerfTest { @Test @Parameters(method = "getData") public void timeBreakIterator(Text text) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { BreakIterator it = BreakIterator.getLineInstance(text.mLocale); it.setText(text.mText); @@ -179,7 +179,7 @@ public final class BreakIteratorPerfTest { @Test @Parameters(method = "getData") public void timeIcuBreakIterator(Text text) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { android.icu.text.BreakIterator it = android.icu.text.BreakIterator.getLineInstance(text.mLocale); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/BulkPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/BulkPerfTest.java index e4eaf12e9dcb..6df67bccae06 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/BulkPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/BulkPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -39,7 +39,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class BulkPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList( @@ -120,7 +120,7 @@ public class BulkPerfTest { throws Exception { ByteBuffer src = BulkPerfTest.newBuffer(align, sBuf, size); ByteBuffer data = BulkPerfTest.newBuffer(align, dBuf, size); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(align ? 0 : 1); data.position(align ? 0 : 1); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/ByteBufferPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/ByteBufferPerfTest.java index cb2438e519da..4cf46e5364ea 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/ByteBufferPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/ByteBufferPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -46,7 +46,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class ByteBufferPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public enum MyByteOrder { BIG(ByteOrder.BIG_ENDIAN), @@ -121,7 +121,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_getByte( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -136,7 +136,7 @@ public class ByteBufferPerfTest { MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); byte[] dst = new byte[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { src.position(aligned ? 0 : 1); @@ -150,7 +150,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_getByte_indexed( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -164,7 +164,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_getChar( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -180,7 +180,7 @@ public class ByteBufferPerfTest { CharBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asCharBuffer(); char[] dst = new char[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { src.position(0); @@ -194,7 +194,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_getChar_indexed( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -208,7 +208,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_getDouble( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -224,7 +224,7 @@ public class ByteBufferPerfTest { DoubleBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asDoubleBuffer(); double[] dst = new double[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { src.position(0); @@ -238,7 +238,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_getFloat( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -254,7 +254,7 @@ public class ByteBufferPerfTest { FloatBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asFloatBuffer(); float[] dst = new float[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { src.position(0); @@ -268,7 +268,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_getInt( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -283,7 +283,7 @@ public class ByteBufferPerfTest { MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { IntBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asIntBuffer(); int[] dst = new int[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { src.position(0); @@ -297,7 +297,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_getLong( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -313,7 +313,7 @@ public class ByteBufferPerfTest { LongBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asLongBuffer(); long[] dst = new long[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { src.position(0); @@ -327,7 +327,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_getShort( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -343,7 +343,7 @@ public class ByteBufferPerfTest { ShortBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asShortBuffer(); short[] dst = new short[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { src.position(0); @@ -361,7 +361,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_putByte( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(0); for (int i = 0; i < 1024; ++i) { @@ -376,7 +376,7 @@ public class ByteBufferPerfTest { MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer dst = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); byte[] src = new byte[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { dst.position(aligned ? 0 : 1); @@ -390,7 +390,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_putChar( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -406,7 +406,7 @@ public class ByteBufferPerfTest { CharBuffer dst = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asCharBuffer(); char[] src = new char[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { dst.position(0); @@ -420,7 +420,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_putDouble( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -436,7 +436,7 @@ public class ByteBufferPerfTest { DoubleBuffer dst = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asDoubleBuffer(); double[] src = new double[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { dst.position(0); @@ -450,7 +450,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_putFloat( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -466,7 +466,7 @@ public class ByteBufferPerfTest { FloatBuffer dst = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asFloatBuffer(); float[] src = new float[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { dst.position(0); @@ -480,7 +480,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_putInt( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -495,7 +495,7 @@ public class ByteBufferPerfTest { MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { IntBuffer dst = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asIntBuffer(); int[] src = new int[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { dst.position(0); @@ -509,7 +509,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_putLong( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -525,7 +525,7 @@ public class ByteBufferPerfTest { LongBuffer dst = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asLongBuffer(); long[] src = new long[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { dst.position(0); @@ -539,7 +539,7 @@ public class ByteBufferPerfTest { public void timeByteBuffer_putShort( MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); for (int i = 0; i < 1024; ++i) { @@ -555,7 +555,7 @@ public class ByteBufferPerfTest { ShortBuffer dst = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asShortBuffer(); short[] src = new short[1024]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < 1024; ++i) { dst.position(0); @@ -567,7 +567,7 @@ public class ByteBufferPerfTest { @Test @Parameters(method = "getData") public void time_new_byteArray() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { byte[] bs = new byte[8192]; } @@ -576,7 +576,7 @@ public class ByteBufferPerfTest { @Test @Parameters(method = "getData") public void time_ByteBuffer_allocate() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { ByteBuffer bs = ByteBuffer.allocate(8192); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/ByteBufferScalarVersusVectorPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/ByteBufferScalarVersusVectorPerfTest.java index 9ee927cfc353..8c318cd0a298 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/ByteBufferScalarVersusVectorPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/ByteBufferScalarVersusVectorPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -35,7 +35,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class ByteBufferScalarVersusVectorPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList( @@ -112,7 +112,7 @@ public class ByteBufferScalarVersusVectorPerfTest { throws Exception { ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); ByteBuffer dst = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(0); dst.position(0); @@ -127,7 +127,7 @@ public class ByteBufferScalarVersusVectorPerfTest { public void timeByteBufferBulkGet(boolean aligned) throws Exception { ByteBuffer src = ByteBuffer.allocate(aligned ? 8192 : 8192 + 1); byte[] dst = new byte[8192]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); src.get(dst, 0, dst.length); @@ -139,7 +139,7 @@ public class ByteBufferScalarVersusVectorPerfTest { public void timeDirectByteBufferBulkGet(boolean aligned) throws Exception { ByteBuffer src = ByteBuffer.allocateDirect(aligned ? 8192 : 8192 + 1); byte[] dst = new byte[8192]; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { src.position(aligned ? 0 : 1); src.get(dst, 0, dst.length); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/CharacterPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/CharacterPerfTest.java index e4a4db739235..12c1f8cca0ec 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/CharacterPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/CharacterPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -38,7 +38,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class CharacterPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList( @@ -84,7 +84,7 @@ public class CharacterPerfTest { public void timeIsSpace(CharacterSet characterSet, Overload overload) { setUp(characterSet); boolean fake = false; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -104,7 +104,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeDigit(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -124,7 +124,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeGetNumericValue(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -144,7 +144,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeIsDigit(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -164,7 +164,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeIsIdentifierIgnorable(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -184,7 +184,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeIsJavaIdentifierPart(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -204,7 +204,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeIsJavaIdentifierStart(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -224,7 +224,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeIsLetter(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -244,7 +244,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeIsLetterOrDigit(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -264,7 +264,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeIsLowerCase(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -284,7 +284,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeIsSpaceChar(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -304,7 +304,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeIsUpperCase(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -324,7 +324,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeIsWhitespace(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -344,7 +344,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeToLowerCase(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { @@ -364,7 +364,7 @@ public class CharacterPerfTest { @Parameters(method = "getData") public void timeToUpperCase(CharacterSet characterSet, Overload overload) { setUp(characterSet); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); if (overload == Overload.CHAR) { while (state.keepRunning()) { for (int ch = 0; ch < 65536; ++ch) { diff --git a/apct-tests/perftests/core/src/android/libcore/regression/CharsetForNamePerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/CharsetForNamePerfTest.java index 858c101fc33e..4dd890ad2a45 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/CharsetForNamePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/CharsetForNamePerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -33,7 +33,7 @@ import java.nio.charset.Charset; @RunWith(JUnitParamsRunner.class) @LargeTest public class CharsetForNamePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static String[] charsetNames() { return new String[] { @@ -52,7 +52,7 @@ public class CharsetForNamePerfTest { @Test @Parameters(method = "charsetNames") public void timeCharsetForName(String charsetName) throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Charset.forName(charsetName); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/CharsetPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/CharsetPerfTest.java index a2fb7d7f83d8..3a71ce9692bd 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/CharsetPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/CharsetPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -34,7 +34,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class CharsetPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList( @@ -91,7 +91,7 @@ public class CharsetPerfTest { @Parameters(method = "getData") public void time_new_String_BString(int length, String name) throws Exception { byte[] bytes = makeBytes(makeString(length)); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new String(bytes, name); } @@ -101,7 +101,7 @@ public class CharsetPerfTest { @Parameters(method = "getData") public void time_new_String_BII(int length, String name) throws Exception { byte[] bytes = makeBytes(makeString(length)); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new String(bytes, 0, bytes.length); } @@ -111,7 +111,7 @@ public class CharsetPerfTest { @Parameters(method = "getData") public void time_new_String_BIIString(int length, String name) throws Exception { byte[] bytes = makeBytes(makeString(length)); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new String(bytes, 0, bytes.length, name); } @@ -121,7 +121,7 @@ public class CharsetPerfTest { @Parameters(method = "getData") public void time_String_getBytes(int length, String name) throws Exception { String string = makeString(length); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { string.getBytes(name); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/CharsetUtf8PerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/CharsetUtf8PerfTest.java index 2047444a7f52..6c30a163f519 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/CharsetUtf8PerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/CharsetUtf8PerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; import android.icu.lang.UCharacter; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -35,7 +35,7 @@ import java.nio.charset.Charset; @RunWith(AndroidJUnit4.class) @LargeTest public class CharsetUtf8PerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private void makeUnicodeRange(int startingCodePoint, int endingCodePoint) { StringBuilder builder = new StringBuilder(); @@ -46,7 +46,7 @@ public class CharsetUtf8PerfTest { } String str = builder.toString(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder builder2 = new StringBuilder(); builder2.append(str); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/ChecksumPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/ChecksumPerfTest.java index 4ce8b41de403..dcdfd371e7f6 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/ChecksumPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/ChecksumPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -32,13 +32,13 @@ import java.util.zip.CRC32; @RunWith(AndroidJUnit4.class) @LargeTest public class ChecksumPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeAdler_block() throws Exception { byte[] bytes = new byte[10000]; Adler32 adler = new Adler32(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { adler.update(bytes); } @@ -47,7 +47,7 @@ public class ChecksumPerfTest { @Test public void timeAdler_byte() throws Exception { Adler32 adler = new Adler32(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { adler.update(1); } @@ -57,7 +57,7 @@ public class ChecksumPerfTest { public void timeCrc_block() throws Exception { byte[] bytes = new byte[10000]; CRC32 crc = new CRC32(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { crc.update(bytes); } @@ -66,7 +66,7 @@ public class ChecksumPerfTest { @Test public void timeCrc_byte() throws Exception { CRC32 crc = new CRC32(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { crc.update(1); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/CipherInputStreamPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/CipherInputStreamPerfTest.java index 6a7ec1ad62e9..6c175b191429 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/CipherInputStreamPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/CipherInputStreamPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -41,7 +41,7 @@ import javax.crypto.spec.IvParameterSpec; @RunWith(AndroidJUnit4.class) @LargeTest public class CipherInputStreamPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private static final int DATA_SIZE = 1024 * 1024; private static final byte[] DATA = new byte[DATA_SIZE]; @@ -80,7 +80,7 @@ public class CipherInputStreamPerfTest { @Test public void timeEncrypt() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mCipherEncrypt.init(Cipher.ENCRYPT_MODE, mKey, mSpec); InputStream is = new CipherInputStream(new ByteArrayInputStream(DATA), mCipherEncrypt); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/CipherPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/CipherPerfTest.java index 238c028fa0cf..136822ec7002 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/CipherPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/CipherPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -47,7 +47,7 @@ import javax.crypto.spec.IvParameterSpec; @RunWith(JUnitParamsRunner.class) @LargeTest public class CipherPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection getCases() { int[] keySizes = new int[] {128, 192, 256}; @@ -180,7 +180,7 @@ public class CipherPerfTest { Mode mode, Padding padding, int keySize, int inputSize, Implementation implementation) throws Exception { setUp(mode, padding, keySize, implementation); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mCipherEncrypt.doFinal(DATA, 0, inputSize, mOutput); } @@ -192,7 +192,7 @@ public class CipherPerfTest { Mode mode, Padding padding, int keySize, int inputSize, Implementation implementation) throws Exception { setUp(mode, padding, keySize, implementation); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mCipherDecrypt.doFinal(DATA, 0, inputSize, mOutput); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/CollatorPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/CollatorPerfTest.java index 7e5566055fb4..9efb7ce7c2d0 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/CollatorPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/CollatorPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -33,7 +33,7 @@ import java.util.Locale; @RunWith(AndroidJUnit4.class) @LargeTest public class CollatorPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private static final RuleBasedCollator COLLATOR = (RuleBasedCollator) Collator.getInstance(Locale.US); @@ -41,7 +41,7 @@ public class CollatorPerfTest { @Test public void timeCollatorPrimary() { COLLATOR.setStrength(Collator.PRIMARY); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { COLLATOR.compare("abcde", "abcdf"); COLLATOR.compare("abcde", "abcde"); @@ -52,7 +52,7 @@ public class CollatorPerfTest { @Test public void timeCollatorSecondary() { COLLATOR.setStrength(Collator.SECONDARY); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { COLLATOR.compare("abcdÂ", "abcdÄ"); COLLATOR.compare("abcdÂ", "abcdÂ"); @@ -63,7 +63,7 @@ public class CollatorPerfTest { @Test public void timeCollatorTertiary() { COLLATOR.setStrength(Collator.TERTIARY); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { COLLATOR.compare("abcdE", "abcde"); COLLATOR.compare("abcde", "abcde"); @@ -74,7 +74,7 @@ public class CollatorPerfTest { @Test public void timeCollatorIdentical() { COLLATOR.setStrength(Collator.IDENTICAL); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { COLLATOR.compare("abcdȪ", "abcdȫ"); COLLATOR.compare("abcdȪ", "abcdȪ"); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/CollectionsPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/CollectionsPerfTest.java index 100798a7957b..4e5ceaf12403 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/CollectionsPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/CollectionsPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -40,7 +40,7 @@ import java.util.Vector; @RunWith(JUnitParamsRunner.class) @LargeTest public class CollectionsPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList(new Object[][] {{4}, {16}, {64}, {256}, {1024}}); @@ -60,7 +60,7 @@ public class CollectionsPerfTest { @Parameters(method = "getData") public void timeSort_arrayList(int arrayListLength) throws Exception { List<Integer> input = buildList(arrayListLength, ArrayList.class); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Collections.sort(input); } @@ -70,7 +70,7 @@ public class CollectionsPerfTest { @Parameters(method = "getData") public void timeSortWithComparator_arrayList(int arrayListLength) throws Exception { List<Integer> input = buildList(arrayListLength, ArrayList.class); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Collections.sort(input, REVERSE); } @@ -80,7 +80,7 @@ public class CollectionsPerfTest { @Parameters(method = "getData") public void timeSort_vector(int arrayListLength) throws Exception { List<Integer> input = buildList(arrayListLength, Vector.class); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Collections.sort(input); } @@ -90,7 +90,7 @@ public class CollectionsPerfTest { @Parameters(method = "getData") public void timeSortWithComparator_vector(int arrayListLength) throws Exception { List<Integer> input = buildList(arrayListLength, Vector.class); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Collections.sort(input, REVERSE); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/DateFormatPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/DateFormatPerfTest.java index b6784a8d3867..b0ccd9925d83 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/DateFormatPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/DateFormatPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -33,7 +33,7 @@ import java.util.Locale; @RunWith(AndroidJUnit4.class) @LargeTest public final class DateFormatPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private Locale mLocale1; private Locale mLocale2; @@ -50,7 +50,7 @@ public final class DateFormatPerfTest { @Test public void timeGetDateTimeInstance() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { DateFormat.getDateTimeInstance(); } @@ -58,7 +58,7 @@ public final class DateFormatPerfTest { @Test public void timeGetDateTimeInstance_multiple() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, mLocale1); DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, mLocale2); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/DecimalFormatPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/DecimalFormatPerfTest.java index 52f98738481f..3a2f6fab5460 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/DecimalFormatPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/DecimalFormatPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -34,7 +34,7 @@ import java.util.Locale; @RunWith(AndroidJUnit4.class) @LargeTest public class DecimalFormatPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private static final String EXP_PATTERN = "##E0"; @@ -58,7 +58,7 @@ public class DecimalFormatPerfTest { public void formatWithGrouping(Object obj) { DF.setGroupingSize(3); DF.setGroupingUsed(true); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { DF.format(obj); } @@ -66,21 +66,21 @@ public class DecimalFormatPerfTest { public void format(String pattern, Object obj) { PATTERN_INSTANCE.applyPattern(pattern); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { PATTERN_INSTANCE.format(obj); } } public void format(Object obj) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { DF.format(obj); } } public void formatToCharacterIterator(Object obj) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { DF.formatToCharacterIterator(obj); } @@ -88,14 +88,14 @@ public class DecimalFormatPerfTest { public void formatCurrencyUS(Object obj) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { DF_CURRENCY_US.format(obj); } } public void formatCurrencyFR(Object obj) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { DF_CURRENCY_FR.format(obj); } @@ -213,7 +213,7 @@ public class DecimalFormatPerfTest { @Test public void time_instantiation() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new DecimalFormat(); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/DecimalFormatSymbolsPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/DecimalFormatSymbolsPerfTest.java index 610542061107..4bc550ebb9f1 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/DecimalFormatSymbolsPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/DecimalFormatSymbolsPerfTest.java @@ -15,8 +15,8 @@ */ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -31,13 +31,13 @@ import java.util.Locale; @RunWith(AndroidJUnit4.class) @LargeTest public class DecimalFormatSymbolsPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private static Locale sLocale = Locale.getDefault(Locale.Category.FORMAT); @Test public void time_instantiation() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new DecimalFormatSymbols(sLocale); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/DefaultCharsetPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/DefaultCharsetPerfTest.java index fae74a5e8620..597447bef90e 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/DefaultCharsetPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/DefaultCharsetPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -31,11 +31,11 @@ import java.nio.charset.Charset; @RunWith(AndroidJUnit4.class) @LargeTest public class DefaultCharsetPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void time_defaultCharset() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Charset.defaultCharset(); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/DnsPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/DnsPerfTest.java index 2915363786f3..b17d0f4194d8 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/DnsPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/DnsPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -32,7 +32,7 @@ import java.net.UnknownHostException; @RunWith(AndroidJUnit4.class) @LargeTest public class DnsPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeDns() throws Exception { @@ -53,7 +53,7 @@ public class DnsPerfTest { "www.cnn.com", "bad.host.mtv.corp.google.com", }; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); int i = 0; while (state.keepRunning()) { try { diff --git a/apct-tests/perftests/core/src/android/libcore/regression/DoPrivilegedPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/DoPrivilegedPerfTest.java index dd7e5cc1057b..4c8a8eaea8c6 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/DoPrivilegedPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/DoPrivilegedPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -32,11 +32,11 @@ import java.security.PrivilegedAction; @RunWith(AndroidJUnit4.class) @LargeTest public class DoPrivilegedPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeDirect() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String lineSeparator = System.getProperty("line.separator"); } @@ -44,7 +44,7 @@ public class DoPrivilegedPerfTest { @Test public void timeFastAndSlow() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String lineSeparator; if (System.getSecurityManager() == null) { @@ -61,7 +61,7 @@ public class DoPrivilegedPerfTest { @Test public void timeNewAction() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String lineSeparator = AccessController.doPrivileged(new PrivilegedAction<String>() { public String run() { @@ -74,7 +74,7 @@ public class DoPrivilegedPerfTest { @Test public void timeReusedAction() throws Exception { final PrivilegedAction<String> action = new ReusableAction("line.separator"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String lineSeparator = AccessController.doPrivileged(action); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/DoublePerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/DoublePerfTest.java index e034a47e79d2..4ff65b197947 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/DoublePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/DoublePerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -29,7 +29,7 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class DoublePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private double mD = 1.2; private long mL = 4608083138725491507L; @@ -37,7 +37,7 @@ public class DoublePerfTest { @Test public void timeDoubleToLongBits() { long result = 123; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Double.doubleToLongBits(mD); } @@ -49,7 +49,7 @@ public class DoublePerfTest { @Test public void timeDoubleToRawLongBits() { long result = 123; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Double.doubleToRawLongBits(mD); } @@ -61,7 +61,7 @@ public class DoublePerfTest { @Test public void timeLongBitsToDouble() { double result = 123.0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Double.longBitsToDouble(mL); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/EqualsHashCodePerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/EqualsHashCodePerfTest.java index fe1b599cc5ad..aacdcee13e8d 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/EqualsHashCodePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/EqualsHashCodePerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -37,7 +37,7 @@ import java.util.List; @RunWith(JUnitParamsRunner.class) @LargeTest public final class EqualsHashCodePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private enum Type { URI() { @@ -82,7 +82,7 @@ public final class EqualsHashCodePerfTest { mA2 = type.newInstance("https://mail.google.com/mail/u/0/?shva=1#inbox"); mB1 = type.newInstance("http://developer.android.com/reference/java/net/URI.html"); mB2 = type.newInstance("http://developer.android.com/reference/java/net/URI.html"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mA1.equals(mB1); mA1.equals(mA2); @@ -95,7 +95,7 @@ public final class EqualsHashCodePerfTest { public void timeHashCode(Type type) throws Exception { mA1 = type.newInstance("https://mail.google.com/mail/u/0/?shva=1#inbox"); mB1 = type.newInstance("http://developer.android.com/reference/java/net/URI.html"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mA1.hashCode(); mB1.hashCode(); @@ -112,7 +112,7 @@ public final class EqualsHashCodePerfTest { "http://developer.android.com/query?q=" + QUERY.substring(0, QUERY.length() - 3) + "%AF"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mC1.equals(mC2); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/ExpensiveObjectsPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/ExpensiveObjectsPerfTest.java index ecbfc7169945..9a6864ea5f66 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/ExpensiveObjectsPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/ExpensiveObjectsPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -41,11 +41,11 @@ import java.util.Locale; @RunWith(AndroidJUnit4.class) @LargeTest public class ExpensiveObjectsPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeNewDateFormatTimeInstance() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT); df.format(System.currentTimeMillis()); @@ -55,7 +55,7 @@ public class ExpensiveObjectsPerfTest { @Test(timeout = 900000) public void timeClonedDateFormatTimeInstance() { DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { ((DateFormat) df.clone()).format(System.currentTimeMillis()); } @@ -64,7 +64,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeReusedDateFormatTimeInstance() { DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { synchronized (df) { df.format(System.currentTimeMillis()); @@ -74,7 +74,7 @@ public class ExpensiveObjectsPerfTest { @Test(timeout = 900000) public void timeNewCollator() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Collator.getInstance(Locale.US); } @@ -83,7 +83,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeClonedCollator() { Collator c = Collator.getInstance(Locale.US); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { c.clone(); } @@ -91,7 +91,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeNewDateFormatSymbols() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new DateFormatSymbols(Locale.US); } @@ -100,7 +100,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeClonedDateFormatSymbols() { DateFormatSymbols dfs = new DateFormatSymbols(Locale.US); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { dfs.clone(); } @@ -108,7 +108,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeNewDecimalFormatSymbols() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new DecimalFormatSymbols(Locale.US); } @@ -117,7 +117,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeClonedDecimalFormatSymbols() { DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { dfs.clone(); } @@ -125,7 +125,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeNewNumberFormat() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { NumberFormat.getInstance(Locale.US); } @@ -134,7 +134,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeClonedNumberFormat() { NumberFormat nf = NumberFormat.getInstance(Locale.US); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { nf.clone(); } @@ -142,7 +142,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeLongToString() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Long.toString(1024L); } @@ -151,7 +151,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeNumberFormatTrivialFormatDouble() { NumberFormat nf = NumberFormat.getInstance(Locale.US); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { nf.format(1024.0); } @@ -159,7 +159,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeNewSimpleDateFormat() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new SimpleDateFormat(); } @@ -167,7 +167,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeNewGregorianCalendar() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new GregorianCalendar(); } @@ -176,7 +176,7 @@ public class ExpensiveObjectsPerfTest { @Test public void timeClonedGregorianCalendar() { GregorianCalendar gc = new GregorianCalendar(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { gc.clone(); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/FilePerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/FilePerfTest.java index 0c14d64c27a9..cef7e8c739d7 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/FilePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/FilePerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -31,11 +31,11 @@ import java.io.File; @RunWith(AndroidJUnit4.class) @LargeTest public final class FilePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeFileCreationWithEmptyChild() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new File("/foo", "/"); } @@ -43,7 +43,7 @@ public final class FilePerfTest { @Test public void timeFileCreationWithNormalizationNecessary() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new File("/foo//bar//baz//bag", "/baz/"); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/FloatPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/FloatPerfTest.java index 7d7d83b3fdbf..645c02357970 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/FloatPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/FloatPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -29,7 +29,7 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class FloatPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private float mFloat = 1.2f; private int mInt = 1067030938; @@ -37,7 +37,7 @@ public class FloatPerfTest { @Test public void timeFloatToIntBits() { int result = 123; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Float.floatToIntBits(mFloat); } @@ -49,7 +49,7 @@ public class FloatPerfTest { @Test public void timeFloatToRawIntBits() { int result = 123; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Float.floatToRawIntBits(mFloat); } @@ -61,7 +61,7 @@ public class FloatPerfTest { @Test public void timeIntBitsToFloat() { float result = 123.0f; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Float.intBitsToFloat(mInt); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/FormatterPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/FormatterPerfTest.java index 08dda5314eac..cf76137d5ec3 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/FormatterPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/FormatterPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -35,11 +35,11 @@ import java.util.Locale; @RunWith(AndroidJUnit4.class) @LargeTest public class FormatterPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeFormatter_NoFormatting() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Formatter f = new Formatter(); f.format("this is a reasonably short string that doesn't actually need any formatting"); @@ -48,7 +48,7 @@ public class FormatterPerfTest { @Test public void timeStringBuilder_NoFormatting() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); sb.append("this is a reasonably short string that doesn't actually need formatting"); @@ -58,7 +58,7 @@ public class FormatterPerfTest { @Test public void timeFormatter_OneInt() { Integer value = Integer.valueOf(1024); // We're not trying to benchmark boxing here. - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Formatter f = new Formatter(); f.format("this is a reasonably short string that has an int %d in it", value); @@ -69,7 +69,7 @@ public class FormatterPerfTest { public void timeFormatter_OneIntArabic() { Locale arabic = new Locale("ar"); Integer value = Integer.valueOf(1024); // We're not trying to benchmark boxing here. - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Formatter f = new Formatter(); f.format(arabic, "this is a reasonably short string that has an int %d in it", value); @@ -78,7 +78,7 @@ public class FormatterPerfTest { @Test public void timeStringBuilder_OneInt() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); sb.append("this is a reasonably short string that has an int "); @@ -90,7 +90,7 @@ public class FormatterPerfTest { @Test public void timeFormatter_OneHexInt() { Integer value = Integer.valueOf(1024); // We're not trying to benchmark boxing here. - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Formatter f = new Formatter(); f.format("this is a reasonably short string that has an int %x in it", value); @@ -99,7 +99,7 @@ public class FormatterPerfTest { @Test public void timeStringBuilder_OneHexInt() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); sb.append("this is a reasonably short string that has an int "); @@ -111,7 +111,7 @@ public class FormatterPerfTest { @Test public void timeFormatter_OneFloat() { Float value = Float.valueOf(10.24f); // We're not trying to benchmark boxing here. - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Formatter f = new Formatter(); f.format("this is a reasonably short string that has a float %f in it", value); @@ -121,7 +121,7 @@ public class FormatterPerfTest { @Test public void timeFormatter_OneFloat_dot2f() { Float value = Float.valueOf(10.24f); // We're not trying to benchmark boxing here. - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Formatter f = new Formatter(); f.format("this is a reasonably short string that has a float %.2f in it", value); @@ -131,7 +131,7 @@ public class FormatterPerfTest { @Test public void timeFormatter_TwoFloats() { Float value = Float.valueOf(10.24f); // We're not trying to benchmark boxing here. - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Formatter f = new Formatter(); f.format("this is a short string that has two floats %f and %f in it", value, value); @@ -140,7 +140,7 @@ public class FormatterPerfTest { @Test public void timeStringBuilder_OneFloat() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); sb.append("this is a reasonably short string that has a float "); @@ -151,7 +151,7 @@ public class FormatterPerfTest { @Test public void timeFormatter_OneString() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Formatter f = new Formatter(); f.format("this is a reasonably short string that has a string %s in it", "hello"); @@ -160,7 +160,7 @@ public class FormatterPerfTest { @Test public void timeStringBuilder_OneString() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); sb.append("this is a reasonably short string that has a string "); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/IdnPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/IdnPerfTest.java index a09ad809a6a2..833575afe8dc 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/IdnPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/IdnPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -31,11 +31,11 @@ import java.net.IDN; @RunWith(AndroidJUnit4.class) @LargeTest public class IdnPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeToUnicode() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { IDN.toASCII("fass.de"); IDN.toASCII("faß.de"); @@ -51,7 +51,7 @@ public class IdnPerfTest { @Test public void timeToAscii() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { IDN.toUnicode("xn--fss-qla.de"); IDN.toUnicode("xn--n00d.com"); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/IntConstantDivisionPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/IntConstantDivisionPerfTest.java index be22814ef8f4..1c901c867fe7 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/IntConstantDivisionPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/IntConstantDivisionPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -29,12 +29,12 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class IntConstantDivisionPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeDivideIntByConstant2() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result /= 2; } @@ -43,7 +43,7 @@ public class IntConstantDivisionPerfTest { @Test public void timeDivideIntByConstant8() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result /= 8; } @@ -52,7 +52,7 @@ public class IntConstantDivisionPerfTest { @Test public void timeDivideIntByConstant10() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result /= 10; } @@ -61,7 +61,7 @@ public class IntConstantDivisionPerfTest { @Test public void timeDivideIntByConstant100() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result /= 100; } @@ -70,7 +70,7 @@ public class IntConstantDivisionPerfTest { @Test public void timeDivideIntByConstant100_HandOptimized() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = (int) ((0x51eb851fL * result) >>> 37); } @@ -79,7 +79,7 @@ public class IntConstantDivisionPerfTest { @Test public void timeDivideIntByConstant2048() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result /= 2048; } @@ -89,7 +89,7 @@ public class IntConstantDivisionPerfTest { public void timeDivideIntByVariable2() { int result = 1; int factor = 2; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result /= factor; } @@ -99,7 +99,7 @@ public class IntConstantDivisionPerfTest { public void timeDivideIntByVariable10() { int result = 1; int factor = 10; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result /= factor; } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/IntConstantMultiplicationPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/IntConstantMultiplicationPerfTest.java index 4337c903ecd6..3d3af4cdb04c 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/IntConstantMultiplicationPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/IntConstantMultiplicationPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -29,12 +29,12 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class IntConstantMultiplicationPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeMultiplyIntByConstant6() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= 6; } @@ -43,7 +43,7 @@ public class IntConstantMultiplicationPerfTest { @Test public void timeMultiplyIntByConstant7() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= 7; } @@ -52,7 +52,7 @@ public class IntConstantMultiplicationPerfTest { @Test public void timeMultiplyIntByConstant8() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= 8; } @@ -61,7 +61,7 @@ public class IntConstantMultiplicationPerfTest { @Test public void timeMultiplyIntByConstant8_Shift() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result <<= 3; } @@ -70,7 +70,7 @@ public class IntConstantMultiplicationPerfTest { @Test public void timeMultiplyIntByConstant10() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= 10; } @@ -79,7 +79,7 @@ public class IntConstantMultiplicationPerfTest { @Test public void timeMultiplyIntByConstant10_Shift() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = (result + (result << 2)) << 1; } @@ -88,7 +88,7 @@ public class IntConstantMultiplicationPerfTest { @Test public void timeMultiplyIntByConstant2047() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= 2047; } @@ -97,7 +97,7 @@ public class IntConstantMultiplicationPerfTest { @Test public void timeMultiplyIntByConstant2048() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= 2048; } @@ -106,7 +106,7 @@ public class IntConstantMultiplicationPerfTest { @Test public void timeMultiplyIntByConstant2049() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= 2049; } @@ -116,7 +116,7 @@ public class IntConstantMultiplicationPerfTest { public void timeMultiplyIntByVariable10() { int result = 1; int factor = 10; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= factor; } @@ -126,7 +126,7 @@ public class IntConstantMultiplicationPerfTest { public void timeMultiplyIntByVariable8() { int result = 1; int factor = 8; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result *= factor; } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/IntConstantRemainderPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/IntConstantRemainderPerfTest.java index 1b6c5026e1f6..7c86633accdc 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/IntConstantRemainderPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/IntConstantRemainderPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -29,12 +29,12 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class IntConstantRemainderPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeRemainderIntByConstant2() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result %= 2; } @@ -43,7 +43,7 @@ public class IntConstantRemainderPerfTest { @Test public void timeRemainderIntByConstant8() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result %= 8; } @@ -52,7 +52,7 @@ public class IntConstantRemainderPerfTest { @Test public void timeRemainderIntByConstant10() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result %= 10; } @@ -61,7 +61,7 @@ public class IntConstantRemainderPerfTest { @Test public void timeRemainderIntByConstant100() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result %= 100; } @@ -70,7 +70,7 @@ public class IntConstantRemainderPerfTest { @Test public void timeRemainderIntByConstant2048() { int result = 1; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result %= 2048; } @@ -80,7 +80,7 @@ public class IntConstantRemainderPerfTest { public void timeRemainderIntByVariable2() { int result = 1; int factor = 2; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result %= factor; } @@ -90,7 +90,7 @@ public class IntConstantRemainderPerfTest { public void timeRemainderIntByVariable10() { int result = 1; int factor = 10; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result %= factor; } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/IntegerPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/IntegerPerfTest.java index 170bb58c46ed..e2a9dcc8f93d 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/IntegerPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/IntegerPerfTest.java @@ -16,20 +16,20 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import org.junit.Rule; import org.junit.Test; public class IntegerPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeLongSignumBranch() { int t = 0; int i = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { t += signum1(-(++i)); t += signum1(0); @@ -41,7 +41,7 @@ public class IntegerPerfTest { public void timeLongSignumBranchFree() { int t = 0; int i = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { t += signum2(-(++i)); t += signum2(0); @@ -61,7 +61,7 @@ public class IntegerPerfTest { public void timeLongBitCount_BitSet() { int t = 0; int i = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { t += pop((long) ++i); } @@ -89,7 +89,7 @@ public class IntegerPerfTest { public void timeLongBitCount_2Int() { int t = 0; int i = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { t += pop2((long) ++i); } @@ -105,7 +105,7 @@ public class IntegerPerfTest { public void timeLongBitCount_Long() { int t = 0; int i = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { t += Long.bitCount((long) ++i); } @@ -140,7 +140,7 @@ public class IntegerPerfTest { public void timeNumberOfTrailingZerosHD() { int t = 0; int i = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { t += numberOfTrailingZerosHD(++i); } @@ -150,7 +150,7 @@ public class IntegerPerfTest { public void timeNumberOfTrailingZerosOL() { int t = 0; int i = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { t += numberOfTrailingZerosOL(++i); } @@ -163,7 +163,7 @@ public class IntegerPerfTest { "0", "1", "12", "123", "1234", "12345", "123456", "1234567", "12345678" }; int t = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int j = 0; j < intStrings.length; ++j) { t += Integer.valueOf(intStrings[j]); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/IntegralToStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/IntegralToStringPerfTest.java index 0aa854ecfa80..669bfbfb2b8d 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/IntegralToStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/IntegralToStringPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -29,7 +29,7 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class IntegralToStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private static final int SMALL = 12; private static final int MEDIUM = 12345; @@ -37,7 +37,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToString_small() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toString(SMALL); } @@ -45,7 +45,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToString_medium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toString(MEDIUM); } @@ -53,7 +53,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToString_large() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toString(LARGE); } @@ -61,7 +61,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToString2_small() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toString(SMALL, 2); } @@ -69,7 +69,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToString2_medium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toString(MEDIUM, 2); } @@ -77,7 +77,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToString2_large() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toString(LARGE, 2); } @@ -85,7 +85,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToString10_small() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toString(SMALL, 10); } @@ -93,7 +93,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToString10_medium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toString(MEDIUM, 10); } @@ -101,7 +101,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToString10_large() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toString(LARGE, 10); } @@ -109,7 +109,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToString16_small() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toString(SMALL, 16); } @@ -117,7 +117,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToString16_medium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toString(MEDIUM, 16); } @@ -125,7 +125,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToString16_large() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toString(LARGE, 16); } @@ -133,7 +133,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToBinaryString_small() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toBinaryString(SMALL); } @@ -141,7 +141,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToBinaryString_medium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toBinaryString(MEDIUM); } @@ -149,7 +149,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToBinaryString_large() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toBinaryString(LARGE); } @@ -157,7 +157,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToHexString_small() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toHexString(SMALL); } @@ -165,7 +165,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToHexString_medium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toHexString(MEDIUM); } @@ -173,7 +173,7 @@ public class IntegralToStringPerfTest { @Test public void time_IntegerToHexString_large() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Integer.toHexString(LARGE); } @@ -181,7 +181,7 @@ public class IntegralToStringPerfTest { @Test public void time_StringBuilder_small() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new StringBuilder().append(SMALL); } @@ -189,7 +189,7 @@ public class IntegralToStringPerfTest { @Test public void time_StringBuilder_medium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new StringBuilder().append(MEDIUM); } @@ -197,7 +197,7 @@ public class IntegralToStringPerfTest { @Test public void time_StringBuilder_large() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new StringBuilder().append(LARGE); } @@ -205,7 +205,7 @@ public class IntegralToStringPerfTest { @Test public void time_Formatter_small() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String.format("%d", SMALL); } @@ -213,7 +213,7 @@ public class IntegralToStringPerfTest { @Test public void time_Formatter_medium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String.format("%d", MEDIUM); } @@ -221,7 +221,7 @@ public class IntegralToStringPerfTest { @Test public void time_Formatter_large() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String.format("%d", LARGE); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/KeyPairGeneratorPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/KeyPairGeneratorPerfTest.java index 9b3d7a044720..cda8512ad6af 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/KeyPairGeneratorPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/KeyPairGeneratorPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -36,7 +36,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class KeyPairGeneratorPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList( @@ -78,7 +78,7 @@ public class KeyPairGeneratorPerfTest { @Parameters(method = "getData") public void time(Algorithm algorithm, Implementation implementation) throws Exception { setUp(algorithm, implementation); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { KeyPair keyPair = mGenerator.generateKeyPair(); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/LoopingBackwardsPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/LoopingBackwardsPerfTest.java index 1a9e19aeb78d..8b062d390dbb 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/LoopingBackwardsPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/LoopingBackwardsPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -39,7 +39,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class LoopingBackwardsPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList(new Object[][] {{2}, {20}, {2000}, {20000000}}); @@ -49,7 +49,7 @@ public class LoopingBackwardsPerfTest { @Parameters(method = "getData") public void timeForwards(int max) { int fake = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int j = 0; j < max; j++) { fake += j; @@ -61,7 +61,7 @@ public class LoopingBackwardsPerfTest { @Parameters(method = "getData") public void timeBackwards(int max) { int fake = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int j = max - 1; j >= 0; j--) { fake += j; diff --git a/apct-tests/perftests/core/src/android/libcore/regression/MathPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/MathPerfTest.java index a8a704c09d6d..bcf556c26716 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/MathPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/MathPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -33,7 +33,7 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class MathPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private final double mDouble = 1.2; private final float mFloat = 1.2f; @@ -48,7 +48,7 @@ public class MathPerfTest { @Test public void timeAbsD() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.abs(mDouble); } @@ -57,7 +57,7 @@ public class MathPerfTest { @Test public void timeAbsF() { float result = mFloat; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.abs(mFloat); } @@ -66,7 +66,7 @@ public class MathPerfTest { @Test public void timeAbsI() { int result = mInt; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.abs(mInt); } @@ -75,7 +75,7 @@ public class MathPerfTest { @Test public void timeAbsL() { long result = mLong; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.abs(mLong); } @@ -84,7 +84,7 @@ public class MathPerfTest { @Test public void timeAcos() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.acos(mDouble); } @@ -93,7 +93,7 @@ public class MathPerfTest { @Test public void timeAsin() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.asin(mDouble); } @@ -102,7 +102,7 @@ public class MathPerfTest { @Test public void timeAtan() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.atan(mDouble); } @@ -111,7 +111,7 @@ public class MathPerfTest { @Test public void timeAtan2() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.atan2(3, 4); } @@ -120,7 +120,7 @@ public class MathPerfTest { @Test public void timeCbrt() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.cbrt(mDouble); } @@ -129,7 +129,7 @@ public class MathPerfTest { @Test public void timeCeil() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.ceil(mDouble); } @@ -138,7 +138,7 @@ public class MathPerfTest { @Test public void timeCopySignD() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.copySign(mDouble, mDouble); } @@ -147,7 +147,7 @@ public class MathPerfTest { @Test public void timeCopySignF() { float result = mFloat; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.copySign(mFloat, mFloat); } @@ -156,7 +156,7 @@ public class MathPerfTest { @Test public void timeCopySignD_strict() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = StrictMath.copySign(mDouble, mDouble); } @@ -165,7 +165,7 @@ public class MathPerfTest { @Test public void timeCopySignF_strict() { float result = mFloat; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = StrictMath.copySign(mFloat, mFloat); } @@ -174,7 +174,7 @@ public class MathPerfTest { @Test public void timeCos() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.cos(mDouble); } @@ -183,7 +183,7 @@ public class MathPerfTest { @Test public void timeCosh() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.cosh(mDouble); } @@ -192,7 +192,7 @@ public class MathPerfTest { @Test public void timeExp() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.exp(mDouble); } @@ -201,7 +201,7 @@ public class MathPerfTest { @Test public void timeExpm1() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.expm1(mDouble); } @@ -210,7 +210,7 @@ public class MathPerfTest { @Test public void timeFloor() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.floor(mDouble); } @@ -219,7 +219,7 @@ public class MathPerfTest { @Test public void timeGetExponentD() { int result = mInt; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.getExponent(mDouble); } @@ -228,7 +228,7 @@ public class MathPerfTest { @Test public void timeGetExponentF() { int result = mInt; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.getExponent(mFloat); } @@ -237,7 +237,7 @@ public class MathPerfTest { @Test public void timeHypot() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.hypot(mDouble, mDouble); } @@ -246,7 +246,7 @@ public class MathPerfTest { @Test public void timeIEEEremainder() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.IEEEremainder(mDouble, mDouble); } @@ -255,7 +255,7 @@ public class MathPerfTest { @Test public void timeLog() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.log(mDouble); } @@ -264,7 +264,7 @@ public class MathPerfTest { @Test public void timeLog10() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.log10(mDouble); } @@ -273,7 +273,7 @@ public class MathPerfTest { @Test public void timeLog1p() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.log1p(mDouble); } @@ -282,7 +282,7 @@ public class MathPerfTest { @Test public void timeMaxD() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.max(mDouble, mDouble); } @@ -291,7 +291,7 @@ public class MathPerfTest { @Test public void timeMaxF() { float result = mFloat; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.max(mFloat, mFloat); } @@ -300,7 +300,7 @@ public class MathPerfTest { @Test public void timeMaxI() { int result = mInt; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.max(mInt, mInt); } @@ -309,7 +309,7 @@ public class MathPerfTest { @Test public void timeMaxL() { long result = mLong; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.max(mLong, mLong); } @@ -318,7 +318,7 @@ public class MathPerfTest { @Test public void timeMinD() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.min(mDouble, mDouble); } @@ -327,7 +327,7 @@ public class MathPerfTest { @Test public void timeMinF() { float result = mFloat; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.min(mFloat, mFloat); } @@ -336,7 +336,7 @@ public class MathPerfTest { @Test public void timeMinI() { int result = mInt; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.min(mInt, mInt); } @@ -345,7 +345,7 @@ public class MathPerfTest { @Test public void timeMinL() { long result = mLong; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.min(mLong, mLong); } @@ -354,7 +354,7 @@ public class MathPerfTest { @Test public void timeNextAfterD() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.nextAfter(mDouble, mDouble); } @@ -363,7 +363,7 @@ public class MathPerfTest { @Test public void timeNextAfterF() { float result = mFloat; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.nextAfter(mFloat, mFloat); } @@ -372,7 +372,7 @@ public class MathPerfTest { @Test public void timeNextUpD() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.nextUp(mDouble); } @@ -381,7 +381,7 @@ public class MathPerfTest { @Test public void timeNextUpF() { float result = mFloat; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.nextUp(mFloat); } @@ -390,7 +390,7 @@ public class MathPerfTest { @Test public void timePow() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.pow(mDouble, mDouble); } @@ -399,7 +399,7 @@ public class MathPerfTest { @Test public void timeRandom() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.random(); } @@ -408,7 +408,7 @@ public class MathPerfTest { @Test public void timeRint() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.rint(mDouble); } @@ -417,7 +417,7 @@ public class MathPerfTest { @Test public void timeRoundD() { long result = mLong; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.round(mDouble); } @@ -426,7 +426,7 @@ public class MathPerfTest { @Test public void timeRoundF() { int result = mInt; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.round(mFloat); } @@ -435,7 +435,7 @@ public class MathPerfTest { @Test public void timeScalbD() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.scalb(mDouble, 5); } @@ -444,7 +444,7 @@ public class MathPerfTest { @Test public void timeScalbF() { float result = mFloat; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.scalb(mFloat, 5); } @@ -453,7 +453,7 @@ public class MathPerfTest { @Test public void timeSignumD() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.signum(mDouble); } @@ -462,7 +462,7 @@ public class MathPerfTest { @Test public void timeSignumF() { float result = mFloat; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.signum(mFloat); } @@ -471,7 +471,7 @@ public class MathPerfTest { @Test public void timeSin() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.sin(mDouble); } @@ -480,7 +480,7 @@ public class MathPerfTest { @Test public void timeSinh() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.sinh(mDouble); } @@ -489,7 +489,7 @@ public class MathPerfTest { @Test public void timeSqrt() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.sqrt(mDouble); } @@ -498,7 +498,7 @@ public class MathPerfTest { @Test public void timeTan() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.tan(mDouble); } @@ -507,7 +507,7 @@ public class MathPerfTest { @Test public void timeTanh() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.tanh(mDouble); } @@ -516,7 +516,7 @@ public class MathPerfTest { @Test public void timeToDegrees() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.toDegrees(mDouble); } @@ -525,7 +525,7 @@ public class MathPerfTest { @Test public void timeToRadians() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.toRadians(mDouble); } @@ -534,7 +534,7 @@ public class MathPerfTest { @Test public void timeUlpD() { double result = mDouble; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.ulp(mDouble); } @@ -543,7 +543,7 @@ public class MathPerfTest { @Test public void timeUlpF() { float result = mFloat; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result = Math.ulp(mFloat); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/MessageDigestPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/MessageDigestPerfTest.java index 6da9666db23b..8325dae67797 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/MessageDigestPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/MessageDigestPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -36,7 +36,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class MessageDigestPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList( @@ -97,7 +97,7 @@ public class MessageDigestPerfTest { @Test @Parameters(method = "getData") public void time(Algorithm algorithm) throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider); digest.update(DATA, 0, DATA_SIZE); @@ -108,7 +108,7 @@ public class MessageDigestPerfTest { @Test @Parameters(method = "getData") public void timeLargeArray(Algorithm algorithm) throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider); digest.update(LARGE_DATA, 0, LARGE_DATA_SIZE); @@ -119,7 +119,7 @@ public class MessageDigestPerfTest { @Test @Parameters(method = "getData") public void timeSmallChunkOfLargeArray(Algorithm algorithm) throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider); digest.update(LARGE_DATA, LARGE_DATA_SIZE / 2, DATA_SIZE); @@ -130,7 +130,7 @@ public class MessageDigestPerfTest { @Test @Parameters(method = "getData") public void timeSmallByteBuffer(Algorithm algorithm) throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider); SMALL_BUFFER.position(0); @@ -143,7 +143,7 @@ public class MessageDigestPerfTest { @Test @Parameters(method = "getData") public void timeSmallDirectByteBuffer(Algorithm algorithm) throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider); SMALL_DIRECT_BUFFER.position(0); @@ -156,7 +156,7 @@ public class MessageDigestPerfTest { @Test @Parameters(method = "getData") public void timeLargeByteBuffer(Algorithm algorithm) throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider); LARGE_BUFFER.position(0); @@ -169,7 +169,7 @@ public class MessageDigestPerfTest { @Test @Parameters(method = "getData") public void timeLargeDirectByteBuffer(Algorithm algorithm) throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider); LARGE_DIRECT_BUFFER.position(0); @@ -182,7 +182,7 @@ public class MessageDigestPerfTest { @Test @Parameters(method = "getData") public void timeSmallChunkOfLargeByteBuffer(Algorithm algorithm) throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider); LARGE_BUFFER.position(LARGE_BUFFER.capacity() / 2); @@ -195,7 +195,7 @@ public class MessageDigestPerfTest { @Test @Parameters(method = "getData") public void timeSmallChunkOfLargeDirectByteBuffer(Algorithm algorithm) throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider); LARGE_DIRECT_BUFFER.position(LARGE_DIRECT_BUFFER.capacity() / 2); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/MutableIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/MutableIntPerfTest.java index 060d18fb3de3..266d42cba6f0 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/MutableIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/MutableIntPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -35,7 +35,7 @@ import java.util.concurrent.atomic.AtomicInteger; @RunWith(JUnitParamsRunner.class) @LargeTest public final class MutableIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); enum Kind { ARRAY() { @@ -105,21 +105,21 @@ public final class MutableIntPerfTest { @Test @Parameters(method = "getData") public void timeCreate(Kind kind) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); kind.timeCreate(state); } @Test @Parameters(method = "getData") public void timeIncrement(Kind kind) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); kind.timeIncrement(state); } @Test @Parameters(method = "getData") public void timeGet(Kind kind) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); kind.timeGet(state); } } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/NumberFormatPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/NumberFormatPerfTest.java index 7cb3b2283779..c2f84fb71405 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/NumberFormatPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/NumberFormatPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -32,13 +32,13 @@ import java.util.Locale; @RunWith(AndroidJUnit4.class) @LargeTest public class NumberFormatPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private static Locale sLocale = Locale.getDefault(Locale.Category.FORMAT); @Test public void time_instantiation() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { NumberFormat.getInstance(sLocale); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/NumberFormatTrivialFormatLongPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/NumberFormatTrivialFormatLongPerfTest.java index 272b45a3affe..cdf0911c74ab 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/NumberFormatTrivialFormatLongPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/NumberFormatTrivialFormatLongPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -36,12 +36,12 @@ import java.util.Locale; @LargeTest public class NumberFormatTrivialFormatLongPerfTest { @Rule - public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeNumberFormatTrivialFormatLong() { NumberFormat nf = NumberFormat.getInstance(Locale.US); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { nf.format(1024L); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/PriorityQueuePerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/PriorityQueuePerfTest.java index c3a09662fd1f..51f47bb60ac7 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/PriorityQueuePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/PriorityQueuePerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -39,7 +39,7 @@ import java.util.Random; @RunWith(JUnitParamsRunner.class) @LargeTest public class PriorityQueuePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList( @@ -108,7 +108,7 @@ public class PriorityQueuePerfTest { // At most allow the queue to empty 10%. int resizingThreshold = queueSize / 10; int i = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { // Reset queue every so often. This will be called more often for smaller // queueSizes, but since a copy is linear, it will also cost proportionally diff --git a/apct-tests/perftests/core/src/android/libcore/regression/PropertyAccessPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/PropertyAccessPerfTest.java index 2ac56bed1910..1f20cae0c162 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/PropertyAccessPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/PropertyAccessPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -33,7 +33,7 @@ import java.lang.reflect.Method; @RunWith(AndroidJUnit4.class) @LargeTest public final class PropertyAccessPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private View mView = new View(); private Method mSetX; @@ -50,7 +50,7 @@ public final class PropertyAccessPerfTest { @Test public void timeDirectSetter() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mView.mSetX(0.1f); } @@ -58,7 +58,7 @@ public final class PropertyAccessPerfTest { @Test public void timeDirectFieldSet() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mView.mX = 0.1f; } @@ -66,7 +66,7 @@ public final class PropertyAccessPerfTest { @Test public void timeDirectSetterAndBomXing() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Float value = 0.1f; mView.mSetX(value); @@ -75,7 +75,7 @@ public final class PropertyAccessPerfTest { @Test public void timeDirectFieldSetAndBomXing() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Float value = 0.1f; mView.mX = value; @@ -84,7 +84,7 @@ public final class PropertyAccessPerfTest { @Test public void timeReflectionSetterAndTwoBomXes() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mSetX.invoke(mView, 0.1f); } @@ -92,7 +92,7 @@ public final class PropertyAccessPerfTest { @Test public void timeReflectionSetterAndOneBomX() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mArgsBomX[0] = 0.1f; mSetX.invoke(mView, mArgsBomX); @@ -101,7 +101,7 @@ public final class PropertyAccessPerfTest { @Test public void timeReflectionFieldSet() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mX.setFloat(mView, 0.1f); } @@ -109,7 +109,7 @@ public final class PropertyAccessPerfTest { @Test public void timeGeneratedSetter() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mGeneratedSetter.setFloat(mView, 0.1f); } @@ -117,7 +117,7 @@ public final class PropertyAccessPerfTest { @Test public void timeGeneratedFieldSet() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mGeneratedField.setFloat(mView, 0.1f); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/ProviderPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/ProviderPerfTest.java index 7ad0141c8471..0c16265fa6f7 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/ProviderPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/ProviderPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -34,11 +34,11 @@ import javax.crypto.Cipher; @RunWith(AndroidJUnit4.class) @LargeTest public class ProviderPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeStableProviders() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Cipher c = Cipher.getInstance("RSA"); } @@ -46,7 +46,7 @@ public class ProviderPerfTest { @Test public void timeWithNewProvider() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Security.addProvider(new MockProvider()); try { diff --git a/apct-tests/perftests/core/src/android/libcore/regression/RandomPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/RandomPerfTest.java index c7b6cb5a190c..5f1bfc29129e 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/RandomPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/RandomPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -32,11 +32,11 @@ import java.util.Random; @RunWith(AndroidJUnit4.class) @LargeTest public class RandomPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeNewRandom() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Random rng = new Random(); rng.nextInt(); @@ -46,7 +46,7 @@ public class RandomPerfTest { @Test public void timeReusedRandom() throws Exception { Random rng = new Random(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { rng.nextInt(); } @@ -55,7 +55,7 @@ public class RandomPerfTest { @Test public void timeReusedSecureRandom() throws Exception { SecureRandom rng = new SecureRandom(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { rng.nextInt(); } @@ -63,7 +63,7 @@ public class RandomPerfTest { @Test public void timeNewSecureRandom() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { SecureRandom rng = new SecureRandom(); rng.nextInt(); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/RealToStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/RealToStringPerfTest.java index 44e5f227b00a..008c94c52492 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/RealToStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/RealToStringPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -29,7 +29,7 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class RealToStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private static final float SMALL = -123.45f; private static final float MEDIUM = -123.45e8f; @@ -37,7 +37,7 @@ public class RealToStringPerfTest { @Test public void timeFloat_toString_NaN() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Float.toString(Float.NaN); } @@ -45,7 +45,7 @@ public class RealToStringPerfTest { @Test public void timeFloat_toString_NEGATIVE_INFINITY() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Float.toString(Float.NEGATIVE_INFINITY); } @@ -53,7 +53,7 @@ public class RealToStringPerfTest { @Test public void timeFloat_toString_POSITIVE_INFINITY() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Float.toString(Float.POSITIVE_INFINITY); } @@ -61,7 +61,7 @@ public class RealToStringPerfTest { @Test public void timeFloat_toString_zero() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Float.toString(0.0f); } @@ -69,7 +69,7 @@ public class RealToStringPerfTest { @Test public void timeFloat_toString_minusZero() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Float.toString(-0.0f); } @@ -77,7 +77,7 @@ public class RealToStringPerfTest { @Test public void timeFloat_toString_small() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Float.toString(SMALL); } @@ -85,7 +85,7 @@ public class RealToStringPerfTest { @Test public void timeFloat_toString_medium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Float.toString(MEDIUM); } @@ -93,7 +93,7 @@ public class RealToStringPerfTest { @Test public void timeFloat_toString_large() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Float.toString(LARGE); } @@ -101,7 +101,7 @@ public class RealToStringPerfTest { @Test public void timeStringBuilder_small() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new StringBuilder().append(SMALL); } @@ -109,7 +109,7 @@ public class RealToStringPerfTest { @Test public void timeStringBuilder_medium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new StringBuilder().append(MEDIUM); } @@ -117,7 +117,7 @@ public class RealToStringPerfTest { @Test public void timeStringBuilder_large() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new StringBuilder().append(LARGE); } @@ -125,7 +125,7 @@ public class RealToStringPerfTest { @Test public void timeFormatter_small() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String.format("%f", SMALL); } @@ -133,7 +133,7 @@ public class RealToStringPerfTest { @Test public void timeFormatter_medium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String.format("%f", MEDIUM); } @@ -141,7 +141,7 @@ public class RealToStringPerfTest { @Test public void timeFormatter_large() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String.format("%f", LARGE); } @@ -149,7 +149,7 @@ public class RealToStringPerfTest { @Test public void timeFormatter_dot2f_small() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String.format("%.2f", SMALL); } @@ -157,7 +157,7 @@ public class RealToStringPerfTest { @Test public void timeFormatter_dot2f_medium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String.format("%.2f", MEDIUM); } @@ -165,7 +165,7 @@ public class RealToStringPerfTest { @Test public void timeFormatter_dot2f_large() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { String.format("%.2f", LARGE); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/ReflectionPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/ReflectionPerfTest.java index 6e00b10838a6..45b623d740ee 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/ReflectionPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/ReflectionPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -33,12 +33,12 @@ import java.lang.reflect.Method; @RunWith(AndroidJUnit4.class) @LargeTest public class ReflectionPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeObject_getClass() throws Exception { C c = new C(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { c.getClass(); } @@ -47,7 +47,7 @@ public class ReflectionPerfTest { @Test public void timeClass_getField() throws Exception { Class<?> klass = C.class; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { klass.getField("f"); } @@ -56,7 +56,7 @@ public class ReflectionPerfTest { @Test public void timeClass_getDeclaredField() throws Exception { Class<?> klass = C.class; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { klass.getDeclaredField("f"); } @@ -65,7 +65,7 @@ public class ReflectionPerfTest { @Test public void timeClass_getConstructor() throws Exception { Class<?> klass = C.class; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { klass.getConstructor(); } @@ -75,7 +75,7 @@ public class ReflectionPerfTest { public void timeClass_newInstance() throws Exception { Class<?> klass = C.class; Constructor constructor = klass.getConstructor(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { constructor.newInstance(); } @@ -84,7 +84,7 @@ public class ReflectionPerfTest { @Test public void timeClass_getMethod() throws Exception { Class<?> klass = C.class; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { klass.getMethod("m"); } @@ -93,7 +93,7 @@ public class ReflectionPerfTest { @Test public void timeClass_getDeclaredMethod() throws Exception { Class<?> klass = C.class; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { klass.getDeclaredMethod("m"); } @@ -104,7 +104,7 @@ public class ReflectionPerfTest { Class<?> klass = C.class; Field f = klass.getDeclaredField("f"); C instance = new C(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { f.setInt(instance, 1); } @@ -115,7 +115,7 @@ public class ReflectionPerfTest { Class<?> klass = C.class; Field f = klass.getDeclaredField("f"); C instance = new C(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { f.getInt(instance); } @@ -126,7 +126,7 @@ public class ReflectionPerfTest { Class<?> klass = C.class; Method m = klass.getDeclaredMethod("m"); C instance = new C(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { m.invoke(instance); } @@ -136,7 +136,7 @@ public class ReflectionPerfTest { public void timeMethod_invokeStaticV() throws Exception { Class<?> klass = C.class; Method m = klass.getDeclaredMethod("sm"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { m.invoke(null); } @@ -147,7 +147,7 @@ public class ReflectionPerfTest { Class<?> klass = C.class; Method m = klass.getDeclaredMethod("setField", int.class); C instance = new C(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { m.invoke(instance, 1); } @@ -159,7 +159,7 @@ public class ReflectionPerfTest { Method m = klass.getDeclaredMethod("setField", int.class); C instance = new C(); Integer one = Integer.valueOf(1); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { m.invoke(instance, one); } @@ -169,7 +169,7 @@ public class ReflectionPerfTest { public void timeMethod_invokeStaticI() throws Exception { Class<?> klass = C.class; Method m = klass.getDeclaredMethod("setStaticField", int.class); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { m.invoke(null, 1); } @@ -180,7 +180,7 @@ public class ReflectionPerfTest { Class<?> klass = C.class; Method m = klass.getDeclaredMethod("setStaticField", int.class); Integer one = Integer.valueOf(1); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { m.invoke(null, one); } @@ -189,7 +189,7 @@ public class ReflectionPerfTest { @Test public void timeRegularMethodInvocation() throws Exception { C instance = new C(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { instance.setField(1); } @@ -197,7 +197,7 @@ public class ReflectionPerfTest { @Test public void timeRegularConstructor() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { new C(); } @@ -206,7 +206,7 @@ public class ReflectionPerfTest { @Test public void timeClass_classNewInstance() throws Exception { Class<?> klass = C.class; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { klass.newInstance(); } @@ -216,7 +216,7 @@ public class ReflectionPerfTest { public void timeClass_isInstance() throws Exception { D d = new D(); Class<?> klass = IC.class; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { klass.isInstance(d); } @@ -224,7 +224,7 @@ public class ReflectionPerfTest { @Test public void timeGetInstanceField() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { // TODO: Write a test script that generates both the classes we're // reflecting on and the test case for each of its fields. @@ -234,7 +234,7 @@ public class ReflectionPerfTest { @Test public void timeGetStaticField() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { R.class.getField("WEEK_NUMBER_COLOR"); } @@ -242,7 +242,7 @@ public class ReflectionPerfTest { @Test public void timeGetInterfaceStaticField() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { F.class.getField("SF"); } @@ -250,7 +250,7 @@ public class ReflectionPerfTest { @Test public void timeGetSuperClassField() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { G.class.getField("f"); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/SSLLoopbackPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/SSLLoopbackPerfTest.java index 5a9b5c36d0d3..da69f9fc9fcf 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/SSLLoopbackPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/SSLLoopbackPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -35,11 +35,11 @@ import javax.net.ssl.SSLSocket; @RunWith(AndroidJUnit4.class) @LargeTest public class SSLLoopbackPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void time() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { TestSSLContext context = TestSSLContext.create(TestKeyStore.getClient(), TestKeyStore.getServer()); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/SSLSocketFactoryPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/SSLSocketFactoryPerfTest.java index 6d48cf26c971..9f2c312f33ee 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/SSLSocketFactoryPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/SSLSocketFactoryPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -31,11 +31,11 @@ import javax.net.ssl.SSLSocketFactory; @RunWith(AndroidJUnit4.class) @LargeTest public class SSLSocketFactoryPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void time() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { SSLSocketFactory.getDefault(); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/SchemePrefixPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/SchemePrefixPerfTest.java index 86416291f26d..7c60c05ef679 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/SchemePrefixPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/SchemePrefixPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -37,7 +37,7 @@ import java.util.regex.Pattern; @RunWith(JUnitParamsRunner.class) @LargeTest public final class SchemePrefixPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); enum Strategy { JAVA() { @@ -94,7 +94,7 @@ public final class SchemePrefixPerfTest { @Test @Parameters(method = "getData") public void timeSchemePrefix(Strategy strategy) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { strategy.execute("http://android.com"); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/SerializationPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/SerializationPerfTest.java index afd1191a07fa..181298305cb5 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/SerializationPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/SerializationPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -37,7 +37,7 @@ import java.util.ArrayList; @RunWith(AndroidJUnit4.class) @LargeTest public class SerializationPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private static byte[] bytes(Object o) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); @@ -110,7 +110,7 @@ public class SerializationPerfTest { public void timeWriteNoObjects() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); ObjectOutputStream out = new ObjectOutputStream(baos); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { out.reset(); baos.reset(); @@ -121,7 +121,7 @@ public class SerializationPerfTest { private void readSingleObject(Object object) throws Exception { byte[] bytes = bytes(object); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { ObjectInputStream in = new ObjectInputStream(bais); in.readObject(); @@ -133,7 +133,7 @@ public class SerializationPerfTest { private void writeSingleObject(Object o) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); ObjectOutputStream out = new ObjectOutputStream(baos); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { out.writeObject(o); out.reset(); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/SignaturePerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/SignaturePerfTest.java index 6c261332aa99..34e9bfb84813 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/SignaturePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/SignaturePerfTest.java @@ -15,8 +15,8 @@ */ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -41,7 +41,7 @@ import java.util.Map; @RunWith(JUnitParamsRunner.class) @LargeTest public class SignaturePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList( @@ -117,7 +117,7 @@ public class SignaturePerfTest { @Parameters(method = "getData") public void timeSign(Algorithm algorithm, Implementation implementation) throws Exception { setUp(algorithm); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Signature signer; switch (implementation) { @@ -140,7 +140,7 @@ public class SignaturePerfTest { @Parameters(method = "getData") public void timeVerify(Algorithm algorithm, Implementation implementation) throws Exception { setUp(algorithm); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Signature verifier; switch (implementation) { diff --git a/apct-tests/perftests/core/src/android/libcore/regression/SimpleDateFormatPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/SimpleDateFormatPerfTest.java index 274b51f6fae4..2fe67985d205 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/SimpleDateFormatPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/SimpleDateFormatPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -37,11 +37,11 @@ import java.util.Date; @RunWith(AndroidJUnit4.class) @LargeTest public class SimpleDateFormatPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void time_createFormatWithTimeZone() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd z"); } @@ -50,7 +50,7 @@ public class SimpleDateFormatPerfTest { @Test public void time_parseWithTimeZoneShort() throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd z"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { sdf.parse("2000.01.01 PST"); } @@ -59,7 +59,7 @@ public class SimpleDateFormatPerfTest { @Test public void time_parseWithTimeZoneLong() throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd zzzz"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { sdf.parse("2000.01.01 Pacific Standard Time"); } @@ -68,7 +68,7 @@ public class SimpleDateFormatPerfTest { @Test public void time_parseWithoutTimeZone() throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { sdf.parse("2000.01.01"); } @@ -76,7 +76,7 @@ public class SimpleDateFormatPerfTest { @Test public void time_createAndParseWithTimeZoneShort() throws ParseException { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd z"); sdf.parse("2000.01.01 PST"); @@ -85,7 +85,7 @@ public class SimpleDateFormatPerfTest { @Test public void time_createAndParseWithTimeZoneLong() throws ParseException { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd zzzz"); sdf.parse("2000.01.01 Pacific Standard Time"); @@ -95,7 +95,7 @@ public class SimpleDateFormatPerfTest { @Test public void time_formatWithTimeZoneShort() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd z"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { sdf.format(new Date()); } @@ -104,7 +104,7 @@ public class SimpleDateFormatPerfTest { @Test public void time_formatWithTimeZoneLong() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd zzzz"); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { sdf.format(new Date()); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/StrictMathPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/StrictMathPerfTest.java index b4c427beac65..fbe3cefff776 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/StrictMathPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/StrictMathPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -33,7 +33,7 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class StrictMathPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private final double mDouble = 1.2; private final float mFloat = 1.2f; @@ -74,7 +74,7 @@ public class StrictMathPerfTest { @Test public void timeAbsD() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.abs(mDouble); } @@ -82,7 +82,7 @@ public class StrictMathPerfTest { @Test public void timeAbsF() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.abs(mFloat); } @@ -90,7 +90,7 @@ public class StrictMathPerfTest { @Test public void timeAbsI() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.abs(mInt); } @@ -98,7 +98,7 @@ public class StrictMathPerfTest { @Test public void timeAbsL() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.abs(mLong); } @@ -106,7 +106,7 @@ public class StrictMathPerfTest { @Test public void timeAcos() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.acos(mDouble); } @@ -114,7 +114,7 @@ public class StrictMathPerfTest { @Test public void timeAsin() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.asin(mDouble); } @@ -122,7 +122,7 @@ public class StrictMathPerfTest { @Test public void timeAtan() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.atan(mDouble); } @@ -130,7 +130,7 @@ public class StrictMathPerfTest { @Test public void timeAtan2() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.atan2(3, 4); } @@ -138,7 +138,7 @@ public class StrictMathPerfTest { @Test public void timeCbrt() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.cbrt(mDouble); } @@ -146,7 +146,7 @@ public class StrictMathPerfTest { @Test public void timeCeilOverInterestingValues() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < CEIL_DOUBLES.length; ++i) { StrictMath.ceil(CEIL_DOUBLES[i]); @@ -156,7 +156,7 @@ public class StrictMathPerfTest { @Test public void timeCopySignD() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.copySign(mDouble, mDouble); } @@ -164,7 +164,7 @@ public class StrictMathPerfTest { @Test public void timeCopySignF() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.copySign(mFloat, mFloat); } @@ -172,7 +172,7 @@ public class StrictMathPerfTest { @Test public void timeCos() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.cos(mDouble); } @@ -180,7 +180,7 @@ public class StrictMathPerfTest { @Test public void timeCosh() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.cosh(mDouble); } @@ -188,7 +188,7 @@ public class StrictMathPerfTest { @Test public void timeExp() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.exp(mDouble); } @@ -196,7 +196,7 @@ public class StrictMathPerfTest { @Test public void timeExpm1() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.expm1(mDouble); } @@ -204,7 +204,7 @@ public class StrictMathPerfTest { @Test public void timeFloorOverInterestingValues() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < FLOOR_DOUBLES.length; ++i) { StrictMath.floor(FLOOR_DOUBLES[i]); @@ -214,7 +214,7 @@ public class StrictMathPerfTest { @Test public void timeGetExponentD() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.getExponent(mDouble); } @@ -222,7 +222,7 @@ public class StrictMathPerfTest { @Test public void timeGetExponentF() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.getExponent(mFloat); } @@ -230,7 +230,7 @@ public class StrictMathPerfTest { @Test public void timeHypot() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.hypot(mDouble, mDouble); } @@ -238,7 +238,7 @@ public class StrictMathPerfTest { @Test public void timeIEEEremainder() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.IEEEremainder(mDouble, mDouble); } @@ -246,7 +246,7 @@ public class StrictMathPerfTest { @Test public void timeLog() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.log(mDouble); } @@ -254,7 +254,7 @@ public class StrictMathPerfTest { @Test public void timeLog10() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.log10(mDouble); } @@ -262,7 +262,7 @@ public class StrictMathPerfTest { @Test public void timeLog1p() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.log1p(mDouble); } @@ -270,7 +270,7 @@ public class StrictMathPerfTest { @Test public void timeMaxD() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.max(mDouble, mDouble); } @@ -278,7 +278,7 @@ public class StrictMathPerfTest { @Test public void timeMaxF() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.max(mFloat, mFloat); } @@ -286,7 +286,7 @@ public class StrictMathPerfTest { @Test public void timeMaxI() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.max(mInt, mInt); } @@ -294,7 +294,7 @@ public class StrictMathPerfTest { @Test public void timeMaxL() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.max(mLong, mLong); } @@ -302,7 +302,7 @@ public class StrictMathPerfTest { @Test public void timeMinD() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.min(mDouble, mDouble); } @@ -310,7 +310,7 @@ public class StrictMathPerfTest { @Test public void timeMinF() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.min(mFloat, mFloat); } @@ -318,7 +318,7 @@ public class StrictMathPerfTest { @Test public void timeMinI() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.min(mInt, mInt); } @@ -326,7 +326,7 @@ public class StrictMathPerfTest { @Test public void timeMinL() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.min(mLong, mLong); } @@ -334,7 +334,7 @@ public class StrictMathPerfTest { @Test public void timeNextAfterD() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.nextAfter(mDouble, mDouble); } @@ -342,7 +342,7 @@ public class StrictMathPerfTest { @Test public void timeNextAfterF() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.nextAfter(mFloat, mFloat); } @@ -350,7 +350,7 @@ public class StrictMathPerfTest { @Test public void timeNextUpD() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.nextUp(mDouble); } @@ -358,7 +358,7 @@ public class StrictMathPerfTest { @Test public void timeNextUpF() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.nextUp(mFloat); } @@ -366,7 +366,7 @@ public class StrictMathPerfTest { @Test public void timePow() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.pow(mDouble, mDouble); } @@ -374,7 +374,7 @@ public class StrictMathPerfTest { @Test public void timeRandom() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.random(); } @@ -382,7 +382,7 @@ public class StrictMathPerfTest { @Test public void timeRint() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.rint(mDouble); } @@ -390,7 +390,7 @@ public class StrictMathPerfTest { @Test public void timeRoundD() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.round(mDouble); } @@ -398,7 +398,7 @@ public class StrictMathPerfTest { @Test public void timeRoundF() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.round(mFloat); } @@ -406,7 +406,7 @@ public class StrictMathPerfTest { @Test public void timeScalbD() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.scalb(mDouble, 5); } @@ -414,7 +414,7 @@ public class StrictMathPerfTest { @Test public void timeScalbF() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.scalb(mFloat, 5); } @@ -422,7 +422,7 @@ public class StrictMathPerfTest { @Test public void timeSignumD() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.signum(mDouble); } @@ -430,7 +430,7 @@ public class StrictMathPerfTest { @Test public void timeSignumF() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.signum(mFloat); } @@ -438,7 +438,7 @@ public class StrictMathPerfTest { @Test public void timeSin() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.sin(mDouble); } @@ -446,7 +446,7 @@ public class StrictMathPerfTest { @Test public void timeSinh() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.sinh(mDouble); } @@ -454,7 +454,7 @@ public class StrictMathPerfTest { @Test public void timeSqrt() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.sqrt(mDouble); } @@ -462,7 +462,7 @@ public class StrictMathPerfTest { @Test public void timeTan() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.tan(mDouble); } @@ -470,7 +470,7 @@ public class StrictMathPerfTest { @Test public void timeTanh() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.tanh(mDouble); } @@ -478,7 +478,7 @@ public class StrictMathPerfTest { @Test public void timeToDegrees() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.toDegrees(mDouble); } @@ -486,7 +486,7 @@ public class StrictMathPerfTest { @Test public void timeToRadians() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.toRadians(mDouble); } @@ -494,7 +494,7 @@ public class StrictMathPerfTest { @Test public void timeUlpD() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.ulp(mDouble); } @@ -502,7 +502,7 @@ public class StrictMathPerfTest { @Test public void timeUlpF() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StrictMath.ulp(mFloat); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/StringBuilderPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/StringBuilderPerfTest.java index 2235cc5611a4..0155154037df 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/StringBuilderPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/StringBuilderPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -30,13 +30,13 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class StringBuilderPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public int mLength = 100; @Test public void timeAppendBoolean() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < mLength; ++j) { @@ -47,7 +47,7 @@ public class StringBuilderPerfTest { @Test public void timeAppendChar() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < mLength; ++j) { @@ -59,7 +59,7 @@ public class StringBuilderPerfTest { @Test public void timeAppendCharArray() { char[] chars = "chars".toCharArray(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < mLength; ++j) { @@ -71,7 +71,7 @@ public class StringBuilderPerfTest { @Test public void timeAppendCharSequence() { CharSequence cs = "chars"; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < mLength; ++j) { @@ -83,7 +83,7 @@ public class StringBuilderPerfTest { @Test public void timeAppendSubCharSequence() { CharSequence cs = "chars"; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < mLength; ++j) { @@ -95,7 +95,7 @@ public class StringBuilderPerfTest { @Test public void timeAppendDouble() { double d = 1.2; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < mLength; ++j) { @@ -107,7 +107,7 @@ public class StringBuilderPerfTest { @Test public void timeAppendFloat() { float f = 1.2f; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < mLength; ++j) { @@ -119,7 +119,7 @@ public class StringBuilderPerfTest { @Test public void timeAppendInt() { int n = 123; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < mLength; ++j) { @@ -131,7 +131,7 @@ public class StringBuilderPerfTest { @Test public void timeAppendLong() { long l = 123; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < mLength; ++j) { @@ -150,7 +150,7 @@ public class StringBuilderPerfTest { return "constant"; } }; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < mLength; ++j) { @@ -162,7 +162,7 @@ public class StringBuilderPerfTest { @Test public void timeAppendString() { String s = "chars"; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < mLength; ++j) { diff --git a/apct-tests/perftests/core/src/android/libcore/regression/StringEqualsPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/StringEqualsPerfTest.java index 9ab50005e62a..55337452611b 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/StringEqualsPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/StringEqualsPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -38,7 +38,7 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class StringEqualsPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private final String mLong1 = "Ahead-of-time compilation is possible as the compiler may just convert an instruction" @@ -226,7 +226,7 @@ public class StringEqualsPerfTest { // Benchmark cases of String.equals(null) @Test public void timeEqualsNull() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < mMediumStrings.length; i++) { mMediumStrings[i][0].equals(null); @@ -237,7 +237,7 @@ public class StringEqualsPerfTest { // Benchmark cases with very short (<5 character) Strings @Test public void timeEqualsShort() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < mShortStrings.length; i++) { mShortStrings[i][0].equals(mShortStrings[i][1]); @@ -248,7 +248,7 @@ public class StringEqualsPerfTest { // Benchmark cases with medium length (10-15 character) Strings @Test public void timeEqualsMedium() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < mMediumStrings.length; i++) { mMediumStrings[i][0].equals(mMediumStrings[i][1]); @@ -259,7 +259,7 @@ public class StringEqualsPerfTest { // Benchmark cases with long (>100 character) Strings @Test public void timeEqualsLong() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < mLongStrings.length; i++) { mLongStrings[i][0].equals(mLongStrings[i][1]); @@ -270,7 +270,7 @@ public class StringEqualsPerfTest { // Benchmark cases with very long (>1000 character) Strings @Test public void timeEqualsVeryLong() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < mVeryLongStrings.length; i++) { mVeryLongStrings[i][0].equals(mVeryLongStrings[i][1]); @@ -281,7 +281,7 @@ public class StringEqualsPerfTest { // Benchmark cases with non-word aligned Strings @Test public void timeEqualsNonWordAligned() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < mNonalignedStrings.length; i++) { mNonalignedStrings[i][0].equals(mNonalignedStrings[i][1]); @@ -292,7 +292,7 @@ public class StringEqualsPerfTest { // Benchmark cases with slight differences in the endings @Test public void timeEqualsEnd() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < mEndStrings.length; i++) { mEndStrings[i][0].equals(mEndStrings[i][1]); @@ -303,7 +303,7 @@ public class StringEqualsPerfTest { // Benchmark cases of comparing a string to a non-string object @Test public void timeEqualsNonString() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { for (int i = 0; i < mMediumStrings.length; i++) { mMediumStrings[i][0].equals(mObjects[i]); diff --git a/apct-tests/perftests/core/src/android/libcore/regression/StringIsEmptyPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/StringIsEmptyPerfTest.java index b1e749cc538c..a5662b0a33bd 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/StringIsEmptyPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/StringIsEmptyPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -29,12 +29,12 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class StringIsEmptyPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeIsEmpty_NonEmpty() { boolean result = true; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result &= !("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".isEmpty()); } @@ -44,7 +44,7 @@ public class StringIsEmptyPerfTest { @Test public void timeIsEmpty_Empty() { boolean result = true; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result &= ("".isEmpty()); } @@ -54,7 +54,7 @@ public class StringIsEmptyPerfTest { @Test public void timeLengthEqualsZero() { boolean result = true; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result &= !("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".length() == 0); } @@ -64,7 +64,7 @@ public class StringIsEmptyPerfTest { @Test public void timeEqualsEmpty() { boolean result = true; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { result &= !"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".equals(""); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/StringLengthPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/StringLengthPerfTest.java index 9e5759171a6f..41e64f2810c3 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/StringLengthPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/StringLengthPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -29,12 +29,12 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class StringLengthPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeLength() { int length = 0; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { length = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".length(); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/StringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/StringPerfTest.java index a80514c72e95..2cd2a0976451 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/StringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/StringPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -34,7 +34,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class StringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); enum StringLengths { EMPTY(""), @@ -69,7 +69,7 @@ public class StringPerfTest { @Test @Parameters(method = "getData") public void timeHashCode(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.hashCode(); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/StringReplaceAllPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/StringReplaceAllPerfTest.java index 78ae3952719b..219dccf6901b 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/StringReplaceAllPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/StringReplaceAllPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -34,7 +34,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class StringReplaceAllPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); // NOTE: These estimates of MOVEABLE / NON_MOVEABLE are based on a knowledge of // ART implementation details. They make a difference here because JNI calls related @@ -86,7 +86,7 @@ public class StringReplaceAllPerfTest { @Test @Parameters(method = "getData") public void timeReplaceAllTrivialPatternNonExistent(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.replaceAll("fish", "0"); } @@ -95,7 +95,7 @@ public class StringReplaceAllPerfTest { @Test @Parameters(method = "getData") public void timeReplaceTrivialPatternAllRepeated(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.replaceAll("jklm", "0"); } @@ -104,7 +104,7 @@ public class StringReplaceAllPerfTest { @Test @Parameters(method = "getData") public void timeReplaceAllTrivialPatternSingleOccurrence(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.replaceAll("qrst", "0"); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/StringReplacePerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/StringReplacePerfTest.java index 73911c71c351..d6fef5ed84e7 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/StringReplacePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/StringReplacePerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -34,7 +34,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class StringReplacePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); enum StringLengths { EMPTY(""), @@ -80,7 +80,7 @@ public class StringReplacePerfTest { @Test @Parameters(method = "getData") public void timeReplaceCharNonExistent(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.replace('z', '0'); } @@ -89,7 +89,7 @@ public class StringReplacePerfTest { @Test @Parameters(method = "getData") public void timeReplaceCharRepeated(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.replace('a', '0'); } @@ -98,7 +98,7 @@ public class StringReplacePerfTest { @Test @Parameters(method = "getData") public void timeReplaceSingleChar(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.replace('q', '0'); } @@ -107,7 +107,7 @@ public class StringReplacePerfTest { @Test @Parameters(method = "getData") public void timeReplaceSequenceNonExistent(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.replace("fish", "0"); } @@ -116,7 +116,7 @@ public class StringReplacePerfTest { @Test @Parameters(method = "getData") public void timeReplaceSequenceRepeated(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.replace("jklm", "0"); } @@ -125,7 +125,7 @@ public class StringReplacePerfTest { @Test @Parameters(method = "getData") public void timeReplaceSingleSequence(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.replace("qrst", "0"); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/StringSplitPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/StringSplitPerfTest.java index 1539271c2b3c..9d0ec2f368c9 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/StringSplitPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/StringSplitPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -31,11 +31,11 @@ import java.util.regex.Pattern; @RunWith(AndroidJUnit4.class) @LargeTest public class StringSplitPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeStringSplitComma() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { "this,is,a,simple,example".split(","); } @@ -43,7 +43,7 @@ public class StringSplitPerfTest { @Test public void timeStringSplitLiteralDot() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { "this.is.a.simple.example".split("\\."); } @@ -51,7 +51,7 @@ public class StringSplitPerfTest { @Test public void timeStringSplitNewline() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { "this\nis\na\nsimple\nexample\n".split("\n"); } @@ -60,7 +60,7 @@ public class StringSplitPerfTest { @Test public void timePatternSplitComma() { Pattern p = Pattern.compile(","); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { p.split("this,is,a,simple,example"); } @@ -69,7 +69,7 @@ public class StringSplitPerfTest { @Test public void timePatternSplitLiteralDot() { Pattern p = Pattern.compile("\\."); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { p.split("this.is.a.simple.example"); } @@ -77,7 +77,7 @@ public class StringSplitPerfTest { @Test public void timeStringSplitHard() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { "this,is,a,harder,example".split("[,]"); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/StringToBytesPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/StringToBytesPerfTest.java index 0d5e62b4268c..11950b70ab3d 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/StringToBytesPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/StringToBytesPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -35,7 +35,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class StringToBytesPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); enum StringLengths { EMPTY(""), @@ -89,7 +89,7 @@ public class StringToBytesPerfTest { @Test @Parameters(method = "getData") public void timeGetBytesUtf8(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.getBytes(StandardCharsets.UTF_8); } @@ -98,7 +98,7 @@ public class StringToBytesPerfTest { @Test @Parameters(method = "getData") public void timeGetBytesIso88591(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.getBytes(StandardCharsets.ISO_8859_1); } @@ -107,7 +107,7 @@ public class StringToBytesPerfTest { @Test @Parameters(method = "getData") public void timeGetBytesAscii(StringLengths stringLengths) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { stringLengths.mValue.getBytes(StandardCharsets.US_ASCII); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/StringToRealPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/StringToRealPerfTest.java index ecdf809f1610..4b27a16538ab 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/StringToRealPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/StringToRealPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -34,7 +34,7 @@ import java.util.Collection; @RunWith(JUnitParamsRunner.class) @LargeTest public class StringToRealPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList( @@ -53,7 +53,7 @@ public class StringToRealPerfTest { @Test @Parameters(method = "getData") public void timeFloat_parseFloat(String string) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Float.parseFloat(string); } @@ -62,7 +62,7 @@ public class StringToRealPerfTest { @Test @Parameters(method = "getData") public void timeDouble_parseDouble(String string) { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { Double.parseDouble(string); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/ThreadLocalPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/ThreadLocalPerfTest.java index 2b2a6b5727de..0ab012dc2871 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/ThreadLocalPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/ThreadLocalPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -29,7 +29,7 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class ThreadLocalPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private static final ThreadLocal<char[]> BUFFER = new ThreadLocal<char[]>() { @@ -41,7 +41,7 @@ public class ThreadLocalPerfTest { @Test public void timeThreadLocal_get() { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { BUFFER.get(); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/TimeZonePerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/TimeZonePerfTest.java index 6eb8fccf5b2a..ddf410eccbcb 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/TimeZonePerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/TimeZonePerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -31,11 +31,11 @@ import java.util.TimeZone; @RunWith(AndroidJUnit4.class) @LargeTest public class TimeZonePerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); @Test public void timeTimeZone_getDefault() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { TimeZone.getDefault(); } @@ -43,7 +43,7 @@ public class TimeZonePerfTest { @Test public void timeTimeZone_getTimeZoneUTC() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { TimeZone.getTimeZone("UTC"); } @@ -52,7 +52,7 @@ public class TimeZonePerfTest { @Test public void timeTimeZone_getTimeZone_default() throws Exception { String defaultId = TimeZone.getDefault().getID(); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { TimeZone.getTimeZone(defaultId); } @@ -61,7 +61,7 @@ public class TimeZonePerfTest { // A time zone with relatively few transitions. @Test public void timeTimeZone_getTimeZone_America_Caracas() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { TimeZone.getTimeZone("America/Caracas"); } @@ -70,7 +70,7 @@ public class TimeZonePerfTest { // A time zone with a lot of transitions. @Test public void timeTimeZone_getTimeZone_America_Santiago() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { TimeZone.getTimeZone("America/Santiago"); } @@ -78,7 +78,7 @@ public class TimeZonePerfTest { @Test public void timeTimeZone_getTimeZone_GMT_plus_10() throws Exception { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { TimeZone.getTimeZone("GMT+10"); } diff --git a/apct-tests/perftests/core/src/android/libcore/regression/XMLEntitiesPerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/XMLEntitiesPerfTest.java index 288c646ec67d..a38763b6ffad 100644 --- a/apct-tests/perftests/core/src/android/libcore/regression/XMLEntitiesPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/regression/XMLEntitiesPerfTest.java @@ -16,8 +16,8 @@ package android.libcore.regression; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; @@ -42,7 +42,7 @@ import javax.xml.parsers.DocumentBuilderFactory; @RunWith(JUnitParamsRunner.class) @LargeTest public final class XMLEntitiesPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public static Collection<Object[]> getData() { return Arrays.asList( @@ -85,7 +85,7 @@ public final class XMLEntitiesPerfTest { @Parameters(method = "getData") public void timeXmlParser(int length, float entityFraction) throws Exception { setUp(length, entityFraction); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { XmlPullParser parser = mXmlPullParserFactory.newPullParser(); parser.setInput(new StringReader(mXml)); @@ -99,7 +99,7 @@ public final class XMLEntitiesPerfTest { @Parameters(method = "getData") public void timeDocumentBuilder(int length, float entityFraction) throws Exception { setUp(length, entityFraction); - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { DocumentBuilder documentBuilder = mDocumentBuilderFactory.newDocumentBuilder(); documentBuilder.parse(new InputSource(new StringReader(mXml))); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetFieldLittleEndianIntPerfTest.java index 003c957d894f..4076c9d18e57 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetFieldLittleEndianIntPerfTest.java @@ -13,25 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; + import java.lang.reflect.Field; @RunWith(AndroidJUnit4.class) @LargeTest public class ReflectGetFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); Field mField; int mValue; @@ -42,7 +47,7 @@ public class ReflectGetFieldLittleEndianIntPerfTest { @Test public void run() throws Throwable { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mField.getInt(this); x = (int) mField.getInt(this); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetFieldLittleEndianStringPerfTest.java index 4f216181d5e3..2c65dd4a90f3 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetFieldLittleEndianStringPerfTest.java @@ -13,25 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; + import java.lang.reflect.Field; @RunWith(AndroidJUnit4.class) @LargeTest public class ReflectGetFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); Field mField; String mValue; @@ -42,7 +47,7 @@ public class ReflectGetFieldLittleEndianStringPerfTest { @Test public void run() throws Throwable { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mField.get(this); x = (String) mField.get(this); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetStaticFieldLittleEndianIntPerfTest.java index 210014ad3f6e..dcd25db01f18 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetStaticFieldLittleEndianIntPerfTest.java @@ -13,25 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; + import java.lang.reflect.Field; @RunWith(AndroidJUnit4.class) @LargeTest public class ReflectGetStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); Field mField; static int sValue; @@ -42,7 +47,7 @@ public class ReflectGetStaticFieldLittleEndianIntPerfTest { @Test public void run() throws Throwable { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mField.getInt(null); x = (int) mField.getInt(null); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetStaticFieldLittleEndianStringPerfTest.java index 22c68273bf12..c938a4cda5a0 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectGetStaticFieldLittleEndianStringPerfTest.java @@ -13,25 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; + import java.lang.reflect.Field; @RunWith(AndroidJUnit4.class) @LargeTest public class ReflectGetStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); Field mField; static String sValue; @@ -42,7 +47,7 @@ public class ReflectGetStaticFieldLittleEndianStringPerfTest { @Test public void run() throws Throwable { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mField.get(null); x = (String) mField.get(null); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetFieldLittleEndianIntPerfTest.java index 5b391091253b..618e1b5f5b41 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetFieldLittleEndianIntPerfTest.java @@ -13,25 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; + import java.lang.reflect.Field; @RunWith(AndroidJUnit4.class) @LargeTest public class ReflectSetFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); Field mField; int mValue; @@ -41,7 +46,7 @@ public class ReflectSetFieldLittleEndianIntPerfTest { @Test public void run() throws Throwable { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mField.setInt(this, 42); mField.setInt(this, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetFieldLittleEndianStringPerfTest.java index 883e8a76586b..8c2e3ca8d586 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetFieldLittleEndianStringPerfTest.java @@ -13,25 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; + import java.lang.reflect.Field; @RunWith(AndroidJUnit4.class) @LargeTest public class ReflectSetFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); Field mField; String mValue; @@ -41,7 +46,7 @@ public class ReflectSetFieldLittleEndianStringPerfTest { @Test public void run() throws Throwable { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mField.set(this, "qwerty"); mField.set(this, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetStaticFieldLittleEndianIntPerfTest.java index 50bc85c31280..e888cc68d471 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetStaticFieldLittleEndianIntPerfTest.java @@ -13,25 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; + import java.lang.reflect.Field; @RunWith(AndroidJUnit4.class) @LargeTest public class ReflectSetStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); Field mField; static int sValue; @@ -41,7 +46,7 @@ public class ReflectSetStaticFieldLittleEndianIntPerfTest { @Test public void run() throws Throwable { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mField.setInt(null, 42); mField.setInt(null, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetStaticFieldLittleEndianStringPerfTest.java index 13fa2bf7d230..7016611a1b1d 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/ReflectSetStaticFieldLittleEndianStringPerfTest.java @@ -13,25 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; + import java.lang.reflect.Field; @RunWith(AndroidJUnit4.class) @LargeTest public class ReflectSetStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); Field mField; static String sValue; @@ -41,7 +46,7 @@ public class ReflectSetStaticFieldLittleEndianStringPerfTest { @Test public void run() throws Throwable { - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mField.set(null, "qwerty"); mField.set(null, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireFieldLittleEndianIntPerfTest.java index 85c9bae9a9d9..65c82cca87be 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandexchangeAcquireFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandexchangeAcquireFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.compareAndExchangeAcquire(this, mField, ~42); x = (int) mVh.compareAndExchangeAcquire(this, mField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireFieldLittleEndianStringPerfTest.java index 2b8f430440f5..a350b61da20b 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandexchangeAcquireFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandexchangeAcquireFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.compareAndExchangeAcquire(this, mField, null); x = (String) mVh.compareAndExchangeAcquire(this, mField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireStaticFieldLittleEndianIntPerfTest.java index 246fa43d0dca..34f596eea6aa 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandexchangeAcquireStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandexchangeAcquireStaticFieldLittleEndianIntPerfTes @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.compareAndExchangeAcquire(sField, ~42); x = (int) mVh.compareAndExchangeAcquire(sField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireStaticFieldLittleEndianStringPerfTest.java index d12ffae25c5e..2216d7b2a507 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeAcquireStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,20 +34,19 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandexchangeAcquireStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; - public VarHandleCompareandexchangeAcquireStaticFieldLittleEndianStringPerfTest() - throws Throwable { + public VarHandleCompareandexchangeAcquireStaticFieldLittleEndianStringPerfTest() throws Throwable { mVh = MethodHandles.lookup().findStaticVarHandle(this.getClass(), "sField", String.class); } @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.compareAndExchangeAcquire(sField, null); x = (String) mVh.compareAndExchangeAcquire(sField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeFieldLittleEndianIntPerfTest.java index 5ced1157cb73..bda551fd9069 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandexchangeFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandexchangeFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.compareAndExchange(this, mField, ~42); x = (int) mVh.compareAndExchange(this, mField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeFieldLittleEndianStringPerfTest.java index b955d506fe85..f4d7893a64c2 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandexchangeFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandexchangeFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.compareAndExchange(this, mField, null); x = (String) mVh.compareAndExchange(this, mField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseFieldLittleEndianIntPerfTest.java index 601ff3461f5b..f4380870f7fc 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandexchangeReleaseFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandexchangeReleaseFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.compareAndExchangeRelease(this, mField, ~42); x = (int) mVh.compareAndExchangeRelease(this, mField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseFieldLittleEndianStringPerfTest.java index 0e567f9568e6..78df5c0eaf07 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandexchangeReleaseFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandexchangeReleaseFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.compareAndExchangeRelease(this, mField, null); x = (String) mVh.compareAndExchangeRelease(this, mField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseStaticFieldLittleEndianIntPerfTest.java index 6be287006f42..f45cc6247fc0 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandexchangeReleaseStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandexchangeReleaseStaticFieldLittleEndianIntPerfTes @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.compareAndExchangeRelease(sField, ~42); x = (int) mVh.compareAndExchangeRelease(sField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseStaticFieldLittleEndianStringPerfTest.java index 84c186bd24e6..08aa7e254dcb 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeReleaseStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,20 +34,19 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandexchangeReleaseStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; - public VarHandleCompareandexchangeReleaseStaticFieldLittleEndianStringPerfTest() - throws Throwable { + public VarHandleCompareandexchangeReleaseStaticFieldLittleEndianStringPerfTest() throws Throwable { mVh = MethodHandles.lookup().findStaticVarHandle(this.getClass(), "sField", String.class); } @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.compareAndExchangeRelease(sField, null); x = (String) mVh.compareAndExchangeRelease(sField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeStaticFieldLittleEndianIntPerfTest.java index b093234b2bc5..5d4b2e0978f3 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandexchangeStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandexchangeStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.compareAndExchange(sField, ~42); x = (int) mVh.compareAndExchange(sField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeStaticFieldLittleEndianStringPerfTest.java index 0d2037b4ab27..ba4f2c8a8d7d 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandexchangeStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandexchangeStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandexchangeStaticFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.compareAndExchange(sField, null); x = (String) mVh.compareAndExchange(sField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetFieldLittleEndianIntPerfTest.java index ee31973c308a..7fca4504b2c6 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandsetFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandsetFieldLittleEndianIntPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.compareAndSet(this, mField, ~42); success = mVh.compareAndSet(this, mField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetFieldLittleEndianStringPerfTest.java index 0571fefe2a43..7eb7ac026517 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandsetFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandsetFieldLittleEndianStringPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.compareAndSet(this, mField, null); success = mVh.compareAndSet(this, mField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetStaticFieldLittleEndianIntPerfTest.java index f619dabdd50a..ddfd407eda11 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandsetStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandsetStaticFieldLittleEndianIntPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.compareAndSet(sField, ~42); success = mVh.compareAndSet(sField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetStaticFieldLittleEndianStringPerfTest.java index fc443fa362bc..f1f39681dce0 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleCompareandsetStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleCompareandsetStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleCompareandsetStaticFieldLittleEndianStringPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.compareAndSet(sField, null); success = mVh.compareAndSet(sField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireFieldLittleEndianIntPerfTest.java index bf3d58b68692..09127c4eed7b 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireFieldLittleEndianIntPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetAcquireFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetAcquireFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAcquire(this); x = (int) mVh.getAcquire(this); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireFieldLittleEndianStringPerfTest.java index 1f4bc31f24c6..87be4a66aa52 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireFieldLittleEndianStringPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetAcquireFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetAcquireFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.getAcquire(this); x = (String) mVh.getAcquire(this); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireStaticFieldLittleEndianIntPerfTest.java index 2085552e91dd..5d5fc110cbaf 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetAcquireStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetAcquireStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAcquire(); x = (int) mVh.getAcquire(); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireStaticFieldLittleEndianStringPerfTest.java index d9c7d7b7695e..c7034b80a008 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetAcquireStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetAcquireStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetAcquireStaticFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.getAcquire(); x = (String) mVh.getAcquire(); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetArrayLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetArrayLittleEndianIntPerfTest.java index acd2533a38e4..f22865b01009 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetArrayLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetArrayLittleEndianIntPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,9 +34,9 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetArrayLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int ELEMENT_VALUE = 42; - int[] mArray = {ELEMENT_VALUE}; + int[] mArray = { ELEMENT_VALUE }; VarHandle mVh; public VarHandleGetArrayLittleEndianIntPerfTest() throws Throwable { @@ -54,7 +55,7 @@ public class VarHandleGetArrayLittleEndianIntPerfTest { public void run() { int[] a = mArray; int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.get(a, 0); x = (int) mVh.get(a, 0); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetArrayLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetArrayLittleEndianStringPerfTest.java index de9944a8c274..fdb9e84fa847 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetArrayLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetArrayLittleEndianStringPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,9 +34,9 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetArrayLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String ELEMENT_VALUE = "qwerty"; - String[] mArray = {ELEMENT_VALUE}; + String[] mArray = { ELEMENT_VALUE }; VarHandle mVh; public VarHandleGetArrayLittleEndianStringPerfTest() throws Throwable { @@ -54,7 +55,7 @@ public class VarHandleGetArrayLittleEndianStringPerfTest { public void run() { String[] a = mArray; String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.get(a, 0); x = (String) mVh.get(a, 0); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetByteArrayViewBigEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetByteArrayViewBigEndianIntPerfTest.java index a8639292cbb3..347b0cf4effb 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetByteArrayViewBigEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetByteArrayViewBigEndianIntPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -29,22 +30,22 @@ import org.junit.runner.RunWith; import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; + +import java.util.Arrays; import java.nio.ByteOrder; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetByteArrayViewBigEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int VALUE = 42; - byte[] mArray1 = { - (byte) (VALUE >> 24), (byte) (VALUE >> 16), (byte) (VALUE >> 8), (byte) VALUE - }; - byte[] mArray2 = {(byte) (-1 >> 24), (byte) (-1 >> 16), (byte) (-1 >> 8), (byte) VALUE}; + byte[] mArray1 = { (byte) (VALUE >> 24), (byte) (VALUE >> 16), (byte) (VALUE >> 8), (byte) VALUE }; + byte[] mArray2 = { (byte) (-1 >> 24), (byte) (-1 >> 16), (byte) (-1 >> 8), (byte) VALUE }; VarHandle mVh; public VarHandleGetByteArrayViewBigEndianIntPerfTest() throws Throwable { mVh = MethodHandles.byteArrayViewVarHandle(int[].class, ByteOrder.BIG_ENDIAN); - } + } @Before public void setup() { @@ -58,7 +59,7 @@ public class VarHandleGetByteArrayViewBigEndianIntPerfTest { public void run() { byte[] a = mArray1; int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.get(a, 0); x = (int) mVh.get(a, 0); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetByteArrayViewLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetByteArrayViewLittleEndianIntPerfTest.java index 4999b9bf6850..dedc94f278bf 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetByteArrayViewLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetByteArrayViewLittleEndianIntPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -29,22 +30,22 @@ import org.junit.runner.RunWith; import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; + +import java.util.Arrays; import java.nio.ByteOrder; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetByteArrayViewLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int VALUE = 42; - byte[] mArray1 = { - (byte) VALUE, (byte) (VALUE >> 8), (byte) (VALUE >> 16), (byte) (VALUE >> 24) - }; - byte[] mArray2 = {(byte) VALUE, (byte) (-1 >> 8), (byte) (-1 >> 16), (byte) (-1 >> 24)}; + byte[] mArray1 = { (byte) VALUE, (byte) (VALUE >> 8), (byte) (VALUE >> 16), (byte) (VALUE >> 24) }; + byte[] mArray2 = { (byte) VALUE, (byte) (-1 >> 8), (byte) (-1 >> 16), (byte) (-1 >> 24) }; VarHandle mVh; public VarHandleGetByteArrayViewLittleEndianIntPerfTest() throws Throwable { mVh = MethodHandles.byteArrayViewVarHandle(int[].class, ByteOrder.LITTLE_ENDIAN); - } + } @Before public void setup() { @@ -58,7 +59,7 @@ public class VarHandleGetByteArrayViewLittleEndianIntPerfTest { public void run() { byte[] a = mArray1; int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.get(a, 0); x = (int) mVh.get(a, 0); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetFieldLittleEndianIntPerfTest.java index ee80a6f72c93..3f0f624dfccb 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetFieldLittleEndianIntPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.get(this); x = (int) mVh.get(this); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetFieldLittleEndianStringPerfTest.java index ec29f7a33b39..9db6328ea4c5 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetFieldLittleEndianStringPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.get(this); x = (String) mVh.get(this); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueFieldLittleEndianIntPerfTest.java index ee6a669f2f83..17b74a8d807e 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueFieldLittleEndianIntPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetOpaqueFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetOpaqueFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getOpaque(this); x = (int) mVh.getOpaque(this); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueFieldLittleEndianStringPerfTest.java index 1702b84e703b..5df13800365b 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueFieldLittleEndianStringPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetOpaqueFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetOpaqueFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.getOpaque(this); x = (String) mVh.getOpaque(this); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueStaticFieldLittleEndianIntPerfTest.java index 514ddb9c4b11..f656ef239625 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetOpaqueStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetOpaqueStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getOpaque(); x = (int) mVh.getOpaque(); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueStaticFieldLittleEndianStringPerfTest.java index fbcee6906bd7..1087df3d11c5 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetOpaqueStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetOpaqueStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetOpaqueStaticFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.getOpaque(); x = (String) mVh.getOpaque(); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetStaticFieldLittleEndianIntPerfTest.java index 2c5658810b05..004345187c96 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.get(); x = (int) mVh.get(); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetStaticFieldLittleEndianStringPerfTest.java index 8fce69e62033..0162637f7a64 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetStaticFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.get(); x = (String) mVh.get(); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileFieldLittleEndianIntPerfTest.java index ef530607bb56..b0c4631574e8 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileFieldLittleEndianIntPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetVolatileFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetVolatileFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getVolatile(this); x = (int) mVh.getVolatile(this); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileFieldLittleEndianStringPerfTest.java index 64c08983a063..5cbbc08521ad 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileFieldLittleEndianStringPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetVolatileFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetVolatileFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.getVolatile(this); x = (String) mVh.getVolatile(this); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileStaticFieldLittleEndianIntPerfTest.java index 939100c47c05..368ae69ab8f5 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetVolatileStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetVolatileStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getVolatile(); x = (int) mVh.getVolatile(); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileStaticFieldLittleEndianStringPerfTest.java index 728b1995ff52..3387a8da60c1 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetVolatileStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetVolatileStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -53,7 +54,7 @@ public class VarHandleGetVolatileStaticFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.getVolatile(); x = (String) mVh.getVolatile(); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireFieldLittleEndianFloatPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireFieldLittleEndianFloatPerfTest.java index bf5ef99ff456..781e04f6b818 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireFieldLittleEndianFloatPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireFieldLittleEndianFloatPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandaddAcquireFieldLittleEndianFloatPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final float FIELD_VALUE = 3.14f; float mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandaddAcquireFieldLittleEndianFloatPerfTest { @Test public void run() { float x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (float) mVh.getAndAddAcquire(this, 2.17f); x = (float) mVh.getAndAddAcquire(this, 2.17f); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireFieldLittleEndianIntPerfTest.java index d15705e9106d..97f29ba38bc1 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandaddAcquireFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandaddAcquireFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndAddAcquire(this, ~42); x = (int) mVh.getAndAddAcquire(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireStaticFieldLittleEndianFloatPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireStaticFieldLittleEndianFloatPerfTest.java index 222a60da3550..e108f7f4edbc 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireStaticFieldLittleEndianFloatPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireStaticFieldLittleEndianFloatPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandaddAcquireStaticFieldLittleEndianFloatPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final float FIELD_VALUE = 3.14f; static float sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandaddAcquireStaticFieldLittleEndianFloatPerfTest { @Test public void run() { float x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (float) mVh.getAndAddAcquire(2.17f); x = (float) mVh.getAndAddAcquire(2.17f); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireStaticFieldLittleEndianIntPerfTest.java index 7436476b5329..d0ae322987f3 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddAcquireStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandaddAcquireStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandaddAcquireStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndAddAcquire(~42); x = (int) mVh.getAndAddAcquire(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddFieldLittleEndianFloatPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddFieldLittleEndianFloatPerfTest.java index cca97f42e4b7..1b80c4064741 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddFieldLittleEndianFloatPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddFieldLittleEndianFloatPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandaddFieldLittleEndianFloatPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final float FIELD_VALUE = 3.14f; float mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandaddFieldLittleEndianFloatPerfTest { @Test public void run() { float x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (float) mVh.getAndAdd(this, 2.17f); x = (float) mVh.getAndAdd(this, 2.17f); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddFieldLittleEndianIntPerfTest.java index 170ee7313891..edacf181149b 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandaddFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandaddFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndAdd(this, ~42); x = (int) mVh.getAndAdd(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseFieldLittleEndianFloatPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseFieldLittleEndianFloatPerfTest.java index 184f796ad61c..0e86b0d6f76b 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseFieldLittleEndianFloatPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseFieldLittleEndianFloatPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandaddReleaseFieldLittleEndianFloatPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final float FIELD_VALUE = 3.14f; float mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandaddReleaseFieldLittleEndianFloatPerfTest { @Test public void run() { float x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (float) mVh.getAndAddRelease(this, 2.17f); x = (float) mVh.getAndAddRelease(this, 2.17f); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseFieldLittleEndianIntPerfTest.java index 7e75c44089ff..83446ff85b9a 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandaddReleaseFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandaddReleaseFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndAddRelease(this, ~42); x = (int) mVh.getAndAddRelease(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseStaticFieldLittleEndianFloatPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseStaticFieldLittleEndianFloatPerfTest.java index 39c386b645d8..c1f1e6f44c80 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseStaticFieldLittleEndianFloatPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseStaticFieldLittleEndianFloatPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandaddReleaseStaticFieldLittleEndianFloatPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final float FIELD_VALUE = 3.14f; static float sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandaddReleaseStaticFieldLittleEndianFloatPerfTest { @Test public void run() { float x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (float) mVh.getAndAddRelease(2.17f); x = (float) mVh.getAndAddRelease(2.17f); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseStaticFieldLittleEndianIntPerfTest.java index 04ab5310655c..1b154a157622 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddReleaseStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandaddReleaseStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandaddReleaseStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndAddRelease(~42); x = (int) mVh.getAndAddRelease(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddStaticFieldLittleEndianFloatPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddStaticFieldLittleEndianFloatPerfTest.java index b71351fca81c..7de128d7a5a5 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddStaticFieldLittleEndianFloatPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddStaticFieldLittleEndianFloatPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandaddStaticFieldLittleEndianFloatPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final float FIELD_VALUE = 3.14f; static float sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandaddStaticFieldLittleEndianFloatPerfTest { @Test public void run() { float x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (float) mVh.getAndAdd(2.17f); x = (float) mVh.getAndAdd(2.17f); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddStaticFieldLittleEndianIntPerfTest.java index e3955c051890..c9a0926db637 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandaddStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandaddStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandaddStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndAdd(~42); x = (int) mVh.getAndAdd(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndAcquireFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndAcquireFieldLittleEndianIntPerfTest.java index adf05a6befb1..fd9d9b13e9b2 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndAcquireFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndAcquireFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseAndAcquireFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseAndAcquireFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseAndAcquire(this, ~42); x = (int) mVh.getAndBitwiseAndAcquire(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndAcquireStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndAcquireStaticFieldLittleEndianIntPerfTest.java index 4d657d9a3511..c3c367f80c26 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndAcquireStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndAcquireStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseAndAcquireStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseAndAcquireStaticFieldLittleEndianIntPerfTest @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseAndAcquire(~42); x = (int) mVh.getAndBitwiseAndAcquire(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndFieldLittleEndianIntPerfTest.java index dc6417416917..e073d28a820f 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseAndFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseAndFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseAnd(this, ~42); x = (int) mVh.getAndBitwiseAnd(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndReleaseFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndReleaseFieldLittleEndianIntPerfTest.java index 25d5631308ef..ca78f5ac53ec 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndReleaseFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndReleaseFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseAndReleaseFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseAndReleaseFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseAndRelease(this, ~42); x = (int) mVh.getAndBitwiseAndRelease(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndReleaseStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndReleaseStaticFieldLittleEndianIntPerfTest.java index de2d5489dbcc..599f18669695 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndReleaseStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndReleaseStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseAndReleaseStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseAndReleaseStaticFieldLittleEndianIntPerfTest @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseAndRelease(~42); x = (int) mVh.getAndBitwiseAndRelease(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndStaticFieldLittleEndianIntPerfTest.java index 36544c6f8f50..71fc0ae08196 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseAndStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseAndStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseAndStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseAnd(~42); x = (int) mVh.getAndBitwiseAnd(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrAcquireFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrAcquireFieldLittleEndianIntPerfTest.java index fb36d0cb495f..8fc4eabbaccc 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrAcquireFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrAcquireFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseOrAcquireFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseOrAcquireFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseOrAcquire(this, ~42); x = (int) mVh.getAndBitwiseOrAcquire(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrAcquireStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrAcquireStaticFieldLittleEndianIntPerfTest.java index 4194b12a4a6e..33689533d565 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrAcquireStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrAcquireStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseOrAcquireStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseOrAcquireStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseOrAcquire(~42); x = (int) mVh.getAndBitwiseOrAcquire(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrFieldLittleEndianIntPerfTest.java index 355c6e823803..583a3a029059 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseOrFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseOrFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseOr(this, ~42); x = (int) mVh.getAndBitwiseOr(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrReleaseFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrReleaseFieldLittleEndianIntPerfTest.java index 401079d0bece..1592fa6b9a8c 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrReleaseFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrReleaseFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseOrReleaseFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseOrReleaseFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseOrRelease(this, ~42); x = (int) mVh.getAndBitwiseOrRelease(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrReleaseStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrReleaseStaticFieldLittleEndianIntPerfTest.java index 322dcbf7453e..d496083416a3 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrReleaseStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrReleaseStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseOrReleaseStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseOrReleaseStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseOrRelease(~42); x = (int) mVh.getAndBitwiseOrRelease(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrStaticFieldLittleEndianIntPerfTest.java index c98281416012..87276a591699 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseOrStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseOrStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseOrStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseOr(~42); x = (int) mVh.getAndBitwiseOr(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorAcquireFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorAcquireFieldLittleEndianIntPerfTest.java index 0b1cb32528ff..f7a372fc806f 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorAcquireFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorAcquireFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseXorAcquireFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseXorAcquireFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseXorAcquire(this, ~42); x = (int) mVh.getAndBitwiseXorAcquire(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorAcquireStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorAcquireStaticFieldLittleEndianIntPerfTest.java index 473707201782..22726fcaa151 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorAcquireStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorAcquireStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseXorAcquireStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseXorAcquireStaticFieldLittleEndianIntPerfTest @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseXorAcquire(~42); x = (int) mVh.getAndBitwiseXorAcquire(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorFieldLittleEndianIntPerfTest.java index 204cd70b2f9e..d071d6ead1ef 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseXorFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseXorFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseXor(this, ~42); x = (int) mVh.getAndBitwiseXor(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorReleaseFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorReleaseFieldLittleEndianIntPerfTest.java index b3ffed7de91a..be2aa9cf61b4 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorReleaseFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorReleaseFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseXorReleaseFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseXorReleaseFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseXorRelease(this, ~42); x = (int) mVh.getAndBitwiseXorRelease(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorReleaseStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorReleaseStaticFieldLittleEndianIntPerfTest.java index d0ab8de4502d..b0a7dcf2e7d3 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorReleaseStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorReleaseStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseXorReleaseStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseXorReleaseStaticFieldLittleEndianIntPerfTest @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseXorRelease(~42); x = (int) mVh.getAndBitwiseXorRelease(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorStaticFieldLittleEndianIntPerfTest.java index b378b684114e..c5f99deff29c 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandbitwiseXorStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandbitwiseXorStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandbitwiseXorStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndBitwiseXor(~42); x = (int) mVh.getAndBitwiseXor(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireFieldLittleEndianIntPerfTest.java index c7c66fe20513..572e0c8dc57b 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandsetAcquireFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandsetAcquireFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndSetAcquire(this, ~42); x = (int) mVh.getAndSetAcquire(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireFieldLittleEndianStringPerfTest.java index 98d6bd71c610..09be6d9d3204 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandsetAcquireFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandsetAcquireFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.getAndSetAcquire(this, null); x = (String) mVh.getAndSetAcquire(this, null); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireStaticFieldLittleEndianIntPerfTest.java index 206358f21c1d..4e0554a541b2 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandsetAcquireStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandsetAcquireStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndSetAcquire(~42); x = (int) mVh.getAndSetAcquire(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireStaticFieldLittleEndianStringPerfTest.java index 0532e73c9d66..5491522b0122 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetAcquireStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandsetAcquireStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandsetAcquireStaticFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.getAndSetAcquire(null); x = (String) mVh.getAndSetAcquire(null); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetFieldLittleEndianIntPerfTest.java index f192d7153fce..a9303c6cff57 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandsetFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandsetFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndSet(this, ~42); x = (int) mVh.getAndSet(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetFieldLittleEndianStringPerfTest.java index 0a8909c6c7b5..bd4703f6a5d6 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandsetFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandsetFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.getAndSet(this, null); x = (String) mVh.getAndSet(this, null); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseFieldLittleEndianIntPerfTest.java index bfcb0f410256..d9aee0037a0c 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandsetReleaseFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandsetReleaseFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndSetRelease(this, ~42); x = (int) mVh.getAndSetRelease(this, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseFieldLittleEndianStringPerfTest.java index c6b0509d619b..2c79ca2634b3 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandsetReleaseFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandsetReleaseFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.getAndSetRelease(this, null); x = (String) mVh.getAndSetRelease(this, null); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseStaticFieldLittleEndianIntPerfTest.java index 45a01eda2fd5..ceff81634f62 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandsetReleaseStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandsetReleaseStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndSetRelease(~42); x = (int) mVh.getAndSetRelease(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseStaticFieldLittleEndianStringPerfTest.java index 30472811d5d6..9b83504b94d6 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetReleaseStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandsetReleaseStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandsetReleaseStaticFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.getAndSetRelease(null); x = (String) mVh.getAndSetRelease(null); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetStaticFieldLittleEndianIntPerfTest.java index 6f1f1a016039..638da6fd37b6 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandsetStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandsetStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (int) mVh.getAndSet(~42); x = (int) mVh.getAndSet(~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetStaticFieldLittleEndianStringPerfTest.java index c4d279f37a4c..25d411417fb8 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleGetandsetStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleGetandsetStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleGetandsetStaticFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { x = (String) mVh.getAndSet(null); x = (String) mVh.getAndSet(null); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetArrayLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetArrayLittleEndianIntPerfTest.java index c4f600593067..64ea9f32b698 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetArrayLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetArrayLittleEndianIntPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,9 +34,9 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetArrayLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int ELEMENT_VALUE = 42; - int[] mArray = {ELEMENT_VALUE}; + int[] mArray = { ELEMENT_VALUE }; VarHandle mVh; public VarHandleSetArrayLittleEndianIntPerfTest() throws Throwable { @@ -53,7 +54,7 @@ public class VarHandleSetArrayLittleEndianIntPerfTest { public void run() { int[] a = mArray; int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.set(a, 0, ~42); mVh.set(a, 0, ~42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetArrayLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetArrayLittleEndianStringPerfTest.java index a6858c261eb0..989d682f1b9f 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetArrayLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetArrayLittleEndianStringPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,9 +34,9 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetArrayLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String ELEMENT_VALUE = "qwerty"; - String[] mArray = {ELEMENT_VALUE}; + String[] mArray = { ELEMENT_VALUE }; VarHandle mVh; public VarHandleSetArrayLittleEndianStringPerfTest() throws Throwable { @@ -53,7 +54,7 @@ public class VarHandleSetArrayLittleEndianStringPerfTest { public void run() { String[] a = mArray; String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.set(a, 0, null); mVh.set(a, 0, null); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetByteArrayViewBigEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetByteArrayViewBigEndianIntPerfTest.java index a994cbeaf02c..9d6d6b8c0963 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetByteArrayViewBigEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetByteArrayViewBigEndianIntPerfTest.java @@ -13,59 +13,52 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; -import java.nio.ByteOrder; + import java.util.Arrays; +import java.nio.ByteOrder; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetByteArrayViewBigEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int VALUE = 42; - byte[] mArray1 = { - (byte) (VALUE >> 24), (byte) (VALUE >> 16), (byte) (VALUE >> 8), (byte) VALUE - }; - byte[] mArray2 = {(byte) (-1 >> 24), (byte) (-1 >> 16), (byte) (-1 >> 8), (byte) VALUE}; + byte[] mArray1 = { (byte) (VALUE >> 24), (byte) (VALUE >> 16), (byte) (VALUE >> 8), (byte) VALUE }; + byte[] mArray2 = { (byte) (-1 >> 24), (byte) (-1 >> 16), (byte) (-1 >> 8), (byte) VALUE }; VarHandle mVh; public VarHandleSetByteArrayViewBigEndianIntPerfTest() throws Throwable { mVh = MethodHandles.byteArrayViewVarHandle(int[].class, ByteOrder.BIG_ENDIAN); - } + } @After public void teardown() { if (!Arrays.equals(mArray2, mArray1)) { - throw new RuntimeException( - "array has unexpected values: " - + mArray2[0] - + " " - + mArray2[1] - + " " - + mArray2[2] - + " " - + mArray2[3]); + throw new RuntimeException("array has unexpected values: " + + mArray2[0] + " " + mArray2[1] + " " + mArray2[2] + " " + mArray2[3]); } } @Test public void run() { byte[] a = mArray2; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.set(a, 0, VALUE); mVh.set(a, 0, VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetByteArrayViewLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetByteArrayViewLittleEndianIntPerfTest.java index 65412ec84aa4..e8c3fa3cd01b 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetByteArrayViewLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetByteArrayViewLittleEndianIntPerfTest.java @@ -13,59 +13,52 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; -import java.nio.ByteOrder; + import java.util.Arrays; +import java.nio.ByteOrder; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetByteArrayViewLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int VALUE = 42; - byte[] mArray1 = { - (byte) VALUE, (byte) (VALUE >> 8), (byte) (VALUE >> 16), (byte) (VALUE >> 24) - }; - byte[] mArray2 = {(byte) VALUE, (byte) (-1 >> 8), (byte) (-1 >> 16), (byte) (-1 >> 24)}; + byte[] mArray1 = { (byte) VALUE, (byte) (VALUE >> 8), (byte) (VALUE >> 16), (byte) (VALUE >> 24) }; + byte[] mArray2 = { (byte) VALUE, (byte) (-1 >> 8), (byte) (-1 >> 16), (byte) (-1 >> 24) }; VarHandle mVh; public VarHandleSetByteArrayViewLittleEndianIntPerfTest() throws Throwable { mVh = MethodHandles.byteArrayViewVarHandle(int[].class, ByteOrder.LITTLE_ENDIAN); - } + } @After public void teardown() { if (!Arrays.equals(mArray2, mArray1)) { - throw new RuntimeException( - "array has unexpected values: " - + mArray2[0] - + " " - + mArray2[1] - + " " - + mArray2[2] - + " " - + mArray2[3]); + throw new RuntimeException("array has unexpected values: " + + mArray2[0] + " " + mArray2[1] + " " + mArray2[2] + " " + mArray2[3]); } } @Test public void run() { byte[] a = mArray2; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.set(a, 0, VALUE); mVh.set(a, 0, VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetFieldLittleEndianIntPerfTest.java index 573b0ff277cc..08294c06d438 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetFieldLittleEndianIntPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.set(this, FIELD_VALUE); mVh.set(this, FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetFieldLittleEndianStringPerfTest.java index fe3c0fc04a84..1e8a5bfd2a53 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetFieldLittleEndianStringPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.set(this, FIELD_VALUE); mVh.set(this, FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueFieldLittleEndianIntPerfTest.java index f398899880ce..2e5fb1815b4b 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueFieldLittleEndianIntPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetOpaqueFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetOpaqueFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.setOpaque(this, FIELD_VALUE); mVh.setOpaque(this, FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueFieldLittleEndianStringPerfTest.java index 74931205fd3e..86a771f75b73 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueFieldLittleEndianStringPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetOpaqueFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetOpaqueFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.setOpaque(this, FIELD_VALUE); mVh.setOpaque(this, FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueStaticFieldLittleEndianIntPerfTest.java index 5e7326985c9d..903b31003510 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueStaticFieldLittleEndianIntPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetOpaqueStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetOpaqueStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.setOpaque(FIELD_VALUE); mVh.setOpaque(FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueStaticFieldLittleEndianStringPerfTest.java index 9a217d1fd142..63cf7d25d0fd 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetOpaqueStaticFieldLittleEndianStringPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetOpaqueStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetOpaqueStaticFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.setOpaque(FIELD_VALUE); mVh.setOpaque(FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseFieldLittleEndianIntPerfTest.java index 1ce2270ecc58..d1a358dc662e 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseFieldLittleEndianIntPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetReleaseFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetReleaseFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.setRelease(this, FIELD_VALUE); mVh.setRelease(this, FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseFieldLittleEndianStringPerfTest.java index ed84528fe869..b65832469685 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseFieldLittleEndianStringPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetReleaseFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetReleaseFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.setRelease(this, FIELD_VALUE); mVh.setRelease(this, FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseStaticFieldLittleEndianIntPerfTest.java index aeb96404a223..47cb77959f2e 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseStaticFieldLittleEndianIntPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetReleaseStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetReleaseStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.setRelease(FIELD_VALUE); mVh.setRelease(FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseStaticFieldLittleEndianStringPerfTest.java index 8959a0c3d50c..e48374e2224a 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetReleaseStaticFieldLittleEndianStringPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetReleaseStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetReleaseStaticFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.setRelease(FIELD_VALUE); mVh.setRelease(FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetStaticFieldLittleEndianIntPerfTest.java index 400772231d48..0470d67180c9 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetStaticFieldLittleEndianIntPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.set(FIELD_VALUE); mVh.set(FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetStaticFieldLittleEndianStringPerfTest.java index 732315862eb2..00abb0bab6bb 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetStaticFieldLittleEndianStringPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetStaticFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.set(FIELD_VALUE); mVh.set(FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileFieldLittleEndianIntPerfTest.java index f4119c28b826..c66b23b19938 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileFieldLittleEndianIntPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetVolatileFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetVolatileFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.setVolatile(this, FIELD_VALUE); mVh.setVolatile(this, FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileFieldLittleEndianStringPerfTest.java index 9b9c2612fe25..1b364504d1d5 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileFieldLittleEndianStringPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetVolatileFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetVolatileFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.setVolatile(this, FIELD_VALUE); mVh.setVolatile(this, FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileStaticFieldLittleEndianIntPerfTest.java index f125384706ca..75f927494f88 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileStaticFieldLittleEndianIntPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetVolatileStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetVolatileStaticFieldLittleEndianIntPerfTest { @Test public void run() { int x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.setVolatile(FIELD_VALUE); mVh.setVolatile(FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileStaticFieldLittleEndianStringPerfTest.java index 2ad605d83d04..8289d4fdc0aa 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleSetVolatileStaticFieldLittleEndianStringPerfTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleSetVolatileStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -52,7 +53,7 @@ public class VarHandleSetVolatileStaticFieldLittleEndianStringPerfTest { @Test public void run() { String x; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { mVh.setVolatile(FIELD_VALUE); mVh.setVolatile(FIELD_VALUE); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireFieldLittleEndianIntPerfTest.java index 5ef3bf00204b..9fac8427eacf 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetAcquireFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetAcquireFieldLittleEndianIntPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSetAcquire(this, mField, ~42); success = mVh.weakCompareAndSetAcquire(this, mField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireFieldLittleEndianStringPerfTest.java index 0c4ed66fc6b7..2f601273076e 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetAcquireFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetAcquireFieldLittleEndianStringPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSetAcquire(this, mField, null); success = mVh.weakCompareAndSetAcquire(this, mField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianIntPerfTest.java index db6bd2429e26..4efbd3e50637 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianIntPerfTest @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSetAcquire(sField, ~42); success = mVh.weakCompareAndSetAcquire(sField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianStringPerfTest.java index d2b0bf76158f..099640c624e1 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,20 +34,19 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; - public VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianStringPerfTest() - throws Throwable { + public VarHandleWeakcompareandsetAcquireStaticFieldLittleEndianStringPerfTest() throws Throwable { mVh = MethodHandles.lookup().findStaticVarHandle(this.getClass(), "sField", String.class); } @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSetAcquire(sField, null); success = mVh.weakCompareAndSetAcquire(sField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetFieldLittleEndianIntPerfTest.java index 3cd5ae6533b6..ce8f0f0ac269 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetFieldLittleEndianIntPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSet(this, mField, ~42); success = mVh.weakCompareAndSet(this, mField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetFieldLittleEndianStringPerfTest.java index 6ddfc25deca9..c4119dc5411b 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetFieldLittleEndianStringPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSet(this, mField, null); success = mVh.weakCompareAndSet(this, mField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainFieldLittleEndianIntPerfTest.java index 375f0bc08027..abd981c78f41 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetPlainFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetPlainFieldLittleEndianIntPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSetPlain(this, mField, ~42); success = mVh.weakCompareAndSetPlain(this, mField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainFieldLittleEndianStringPerfTest.java index 7e2492ace1dd..c71e65f77983 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetPlainFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetPlainFieldLittleEndianStringPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSetPlain(this, mField, null); success = mVh.weakCompareAndSetPlain(this, mField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainStaticFieldLittleEndianIntPerfTest.java index 190118c551e6..f3c8f3ac0656 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetPlainStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetPlainStaticFieldLittleEndianIntPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSetPlain(sField, ~42); success = mVh.weakCompareAndSetPlain(sField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainStaticFieldLittleEndianStringPerfTest.java index 484ba1b88183..5c943a46cedc 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetPlainStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetPlainStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetPlainStaticFieldLittleEndianStringPerfTes @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSetPlain(sField, null); success = mVh.weakCompareAndSetPlain(sField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseFieldLittleEndianIntPerfTest.java index 80e4e153a41f..1755a15aae76 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetReleaseFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; int mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetReleaseFieldLittleEndianIntPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSetRelease(this, mField, ~42); success = mVh.weakCompareAndSetRelease(this, mField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseFieldLittleEndianStringPerfTest.java index fa26c59304f9..77175b007af9 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetReleaseFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; String mField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetReleaseFieldLittleEndianStringPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSetRelease(this, mField, null); success = mVh.weakCompareAndSetRelease(this, mField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianIntPerfTest.java index 16bf2a208870..985519e890af 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianIntPerfTest @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSetRelease(sField, ~42); success = mVh.weakCompareAndSetRelease(sField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianStringPerfTest.java index e1716dede024..69e6ca7cce9c 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,20 +34,19 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; - public VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianStringPerfTest() - throws Throwable { + public VarHandleWeakcompareandsetReleaseStaticFieldLittleEndianStringPerfTest() throws Throwable { mVh = MethodHandles.lookup().findStaticVarHandle(this.getClass(), "sField", String.class); } @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSetRelease(sField, null); success = mVh.weakCompareAndSetRelease(sField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetStaticFieldLittleEndianIntPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetStaticFieldLittleEndianIntPerfTest.java index dc6f2adfe951..88df5ff60341 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetStaticFieldLittleEndianIntPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetStaticFieldLittleEndianIntPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetStaticFieldLittleEndianIntPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final int FIELD_VALUE = 42; static int sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetStaticFieldLittleEndianIntPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSet(sField, ~42); success = mVh.weakCompareAndSet(sField, 42); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetStaticFieldLittleEndianStringPerfTest.java b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetStaticFieldLittleEndianStringPerfTest.java index d1096c629ed8..c296f66814a4 100644 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetStaticFieldLittleEndianStringPerfTest.java +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/VarHandleWeakcompareandsetStaticFieldLittleEndianStringPerfTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// This file is generated by generate_java.py do not directly modify! + // This file is generated by generate_java.py do not directly modify! package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +34,7 @@ import java.lang.invoke.VarHandle; @RunWith(AndroidJUnit4.class) @LargeTest public class VarHandleWeakcompareandsetStaticFieldLittleEndianStringPerfTest { - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final String FIELD_VALUE = "qwerty"; static String sField = FIELD_VALUE; VarHandle mVh; @@ -44,7 +46,7 @@ public class VarHandleWeakcompareandsetStaticFieldLittleEndianStringPerfTest { @Test public void run() { boolean success; - BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { success = mVh.weakCompareAndSet(sField, null); success = mVh.weakCompareAndSet(sField, "qwerty"); diff --git a/apct-tests/perftests/core/src/android/libcore/varhandles/generate_java.py b/apct-tests/perftests/core/src/android/libcore/varhandles/generate_java.py index cfcb1d2a02d4..a43569a13813 100755 --- a/apct-tests/perftests/core/src/android/libcore/varhandles/generate_java.py +++ b/apct-tests/perftests/core/src/android/libcore/varhandles/generate_java.py @@ -42,7 +42,7 @@ def to_camel_case(word): return ''.join(c for c in word.title() if not c == '_') -LOOP ="BenchmarkState state = mPerfStatusReporter.getBenchmarkState();\n while (state.keepRunning())" +LOOP ="final BenchmarkState state = mBenchmarkRule.getState();\n while (state.keepRunning())" class Benchmark: def __init__(self, code, static, vartype, flavour, klass, method, memloc, @@ -158,8 +158,8 @@ BANNER = """/* VH_IMPORTS = """ package android.libcore.varhandles; -import android.perftests.utils.BenchmarkState; -import android.perftests.utils.PerfStatusReporter; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -179,7 +179,7 @@ VH_START = BANNER + VH_IMPORTS + """ @RunWith(AndroidJUnit4.class) @LargeTest public class {name} {{ - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final {vartype} FIELD_VALUE = {value1}; {static_kwd}{vartype} {static_prefix}Field = FIELD_VALUE; VarHandle mVh; @@ -273,7 +273,7 @@ VH_START_ARRAY = BANNER + VH_IMPORTS + """ @RunWith(AndroidJUnit4.class) @LargeTest public class {name} {{ - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final {vartype} ELEMENT_VALUE = {value1}; {vartype}[] mArray = {{ ELEMENT_VALUE }}; VarHandle mVh; @@ -324,7 +324,7 @@ import java.nio.ByteOrder; @RunWith(AndroidJUnit4.class) @LargeTest public class {name} {{ - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); static final {vartype} VALUE = {value1}; byte[] mArray1 = {value1_byte_array}; byte[] mArray2 = {value2_byte_array}; @@ -375,7 +375,7 @@ import java.lang.reflect.Field; @RunWith(AndroidJUnit4.class) @LargeTest public class {name} {{ - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); Field mField; {static_kwd}{vartype} {static_prefix}Value; @@ -407,7 +407,7 @@ import jdk.internal.misc.Unsafe; @RunWith(AndroidJUnit4.class) @LargeTest public class {name} {{ - @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + @Rule public BenchmarkRule mBenchmarkRule = new BenchmarkRule(); long mOffset; public {static_kwd}{vartype} {static_prefix}Value = {value1}; diff --git a/core/api/current.txt b/core/api/current.txt index f96e4fdbeeb9..baf142a0640c 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -46100,7 +46100,7 @@ package android.telephony { method public int getCardIdForDefaultEuicc(); method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) @WorkerThread public android.os.PersistableBundle getCarrierConfig(); method public int getCarrierIdFromSimMccMnc(); - method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public void getCarrierRestrictionStatus(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>); + method @RequiresPermission(anyOf={android.Manifest.permission.READ_BASIC_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public void getCarrierRestrictionStatus(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>); method @Deprecated @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public android.telephony.CellLocation getCellLocation(); method public int getDataActivity(); method @RequiresPermission(anyOf={android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.READ_BASIC_PHONE_STATE}) public int getDataNetworkType(); diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 177b859da0ad..ce0d38ffe9ad 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -4426,7 +4426,9 @@ package android.window { public class WindowInfosListenerForTest { ctor public WindowInfosListenerForTest(); + method @Deprecated @RequiresPermission(android.Manifest.permission.ACCESS_SURFACE_FLINGER) public void addWindowInfosListener(@NonNull java.util.function.Consumer<java.util.List<android.window.WindowInfosListenerForTest.WindowInfo>>); method @RequiresPermission(android.Manifest.permission.ACCESS_SURFACE_FLINGER) public void addWindowInfosListener(@NonNull java.util.function.BiConsumer<java.util.List<android.window.WindowInfosListenerForTest.WindowInfo>,java.util.List<android.window.WindowInfosListenerForTest.DisplayInfo>>); + method @Deprecated public void removeWindowInfosListener(@NonNull java.util.function.Consumer<java.util.List<android.window.WindowInfosListenerForTest.WindowInfo>>); method public void removeWindowInfosListener(@NonNull java.util.function.BiConsumer<java.util.List<android.window.WindowInfosListenerForTest.WindowInfo>,java.util.List<android.window.WindowInfosListenerForTest.DisplayInfo>>); } diff --git a/core/java/android/app/IUiAutomationConnection.aidl b/core/java/android/app/IUiAutomationConnection.aidl index 69c3bd3976bc..9dcfe89ebf07 100644 --- a/core/java/android/app/IUiAutomationConnection.aidl +++ b/core/java/android/app/IUiAutomationConnection.aidl @@ -45,7 +45,7 @@ interface IUiAutomationConnection { void injectInputEventToInputFilter(in InputEvent event); void syncInputTransactions(boolean waitForAnimations); boolean setRotation(int rotation); - boolean takeScreenshot(in Rect crop, in ScreenCaptureListener listener); + boolean takeScreenshot(in Rect crop, in ScreenCaptureListener listener, int displayId); boolean takeSurfaceControlScreenshot(in SurfaceControl surfaceControl, in ScreenCaptureListener listener); boolean clearWindowContentFrameStats(int windowId); WindowContentFrameStats getWindowContentFrameStats(int windowId); diff --git a/core/java/android/app/TaskInfo.java b/core/java/android/app/TaskInfo.java index c83dd65233de..99e622053fee 100644 --- a/core/java/android/app/TaskInfo.java +++ b/core/java/android/app/TaskInfo.java @@ -66,6 +66,12 @@ public class TaskInfo { public int taskId; /** + * The current effective uid of the identity of this task. + * @hide + */ + public int effectiveUid; + + /** * Whether or not this task has any running activities. */ public boolean isRunning; @@ -491,6 +497,7 @@ public class TaskInfo { void readFromParcel(Parcel source) { userId = source.readInt(); taskId = source.readInt(); + effectiveUid = source.readInt(); displayId = source.readInt(); isRunning = source.readBoolean(); baseIntent = source.readTypedObject(Intent.CREATOR); @@ -541,6 +548,7 @@ public class TaskInfo { void writeToParcel(Parcel dest, int flags) { dest.writeInt(userId); dest.writeInt(taskId); + dest.writeInt(effectiveUid); dest.writeInt(displayId); dest.writeBoolean(isRunning); dest.writeTypedObject(baseIntent, 0); @@ -589,6 +597,7 @@ public class TaskInfo { @Override public String toString() { return "TaskInfo{userId=" + userId + " taskId=" + taskId + + " effectiveUid=" + effectiveUid + " displayId=" + displayId + " isRunning=" + isRunning + " baseIntent=" + baseIntent + " baseActivity=" + baseActivity diff --git a/core/java/android/app/UiAutomation.java b/core/java/android/app/UiAutomation.java index a249c394467d..6f8e335cff80 100644 --- a/core/java/android/app/UiAutomation.java +++ b/core/java/android/app/UiAutomation.java @@ -1274,7 +1274,7 @@ public final class UiAutomation { ScreenCapture.createSyncCaptureListener(); try { if (!mUiAutomationConnection.takeScreenshot( - new Rect(0, 0, displaySize.x, displaySize.y), syncScreenCapture)) { + new Rect(0, 0, displaySize.x, displaySize.y), syncScreenCapture, mDisplayId)) { return null; } } catch (RemoteException re) { diff --git a/core/java/android/app/UiAutomationConnection.java b/core/java/android/app/UiAutomationConnection.java index 5e21e05193fc..12f2081ebb94 100644 --- a/core/java/android/app/UiAutomationConnection.java +++ b/core/java/android/app/UiAutomationConnection.java @@ -16,8 +16,6 @@ package android.app; -import static android.view.Display.DEFAULT_DISPLAY; - import android.accessibilityservice.AccessibilityServiceInfo; import android.accessibilityservice.IAccessibilityServiceClient; import android.annotation.NonNull; @@ -228,7 +226,8 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub { } @Override - public boolean takeScreenshot(Rect crop, ScreenCapture.ScreenCaptureListener listener) { + public boolean takeScreenshot(Rect crop, ScreenCapture.ScreenCaptureListener listener, + int displayId) { synchronized (mLock) { throwIfCalledByNotTrustedUidLocked(); throwIfShutdownLocked(); @@ -240,7 +239,7 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub { final CaptureArgs captureArgs = new CaptureArgs.Builder<>() .setSourceCrop(crop) .build(); - mWindowManager.captureDisplay(DEFAULT_DISPLAY, captureArgs, listener); + mWindowManager.captureDisplay(displayId, captureArgs, listener); } catch (RemoteException re) { re.rethrowAsRuntimeException(); } finally { diff --git a/core/java/android/app/notification.aconfig b/core/java/android/app/notification.aconfig index f05c24fece6c..606ca3393de0 100644 --- a/core/java/android/app/notification.aconfig +++ b/core/java/android/app/notification.aconfig @@ -21,6 +21,16 @@ flag { } flag { + name: "modes_ui_icons" + namespace: "systemui" + description: "Shows current Priority Mode icon in lockscreen, status bar, and QS; dependent on flags modes_api and modes_ui" + bug: "360399800" + metadata { + purpose: PURPOSE_BUGFIX + } +} + +flag { name: "modes_ui_test" namespace: "systemui" description: "Guards new CTS tests for Modes; dependent on flags modes_api and modes_ui" diff --git a/core/java/android/app/usage/OWNERS b/core/java/android/app/usage/OWNERS index 57d958f2b1f5..745e7242d5ef 100644 --- a/core/java/android/app/usage/OWNERS +++ b/core/java/android/app/usage/OWNERS @@ -1,9 +1 @@ -# Bug component: 532296 - -yamasani@google.com -mwachens@google.com -varunshah@google.com -guanxin@google.com - -per-file *StorageStats* = file:/core/java/android/os/storage/OWNERS -per-file *Broadcast* = sudheersai@google.com +include /services/usage/OWNERS
\ No newline at end of file diff --git a/core/java/android/window/WindowInfosListenerForTest.java b/core/java/android/window/WindowInfosListenerForTest.java index d1d403114106..ac9bec305fff 100644 --- a/core/java/android/window/WindowInfosListenerForTest.java +++ b/core/java/android/window/WindowInfosListenerForTest.java @@ -37,6 +37,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.function.BiConsumer; +import java.util.function.Consumer; /** * Wrapper class to provide access to WindowInfosListener within tests. @@ -184,11 +185,15 @@ public class WindowInfosListenerForTest { private static final String TAG = "WindowInfosListenerForTest"; - private ArrayMap<BiConsumer<List<WindowInfo>, List<DisplayInfo>>, WindowInfosListener> + private final ArrayMap<BiConsumer<List<WindowInfo>, List<DisplayInfo>>, WindowInfosListener> mListeners; + private final ArrayMap<Consumer<List<WindowInfo>>, BiConsumer<List<WindowInfo>, + List<DisplayInfo>>> + mConsumersToBiConsumers; public WindowInfosListenerForTest() { mListeners = new ArrayMap<>(); + mConsumersToBiConsumers = new ArrayMap<>(); } /** @@ -197,6 +202,29 @@ public class WindowInfosListenerForTest { * * @param consumer Consumer that is called with reverse Z ordered lists of WindowInfo instances * where the first value is the topmost window. + * + * @deprecated Use {@link #addWindowInfosListener(BiConsumer)} which provides window and + * display info. + */ + @Deprecated + @SuppressLint("UnflaggedApi") // The API is only used for tests. + @RequiresPermission(Manifest.permission.ACCESS_SURFACE_FLINGER) + public void addWindowInfosListener(@NonNull Consumer<List<WindowInfo>> consumer) { + // This method isn't used in current versions of CTS but can't be removed yet because + // newer builds need to pass on some older versions of CTS. + BiConsumer<List<WindowInfo>, List<DisplayInfo>> biConsumer = + (windowHandles, displayInfos) -> consumer.accept(windowHandles); + mConsumersToBiConsumers.put(consumer, biConsumer); + addWindowInfosListener(biConsumer); + } + + /** + * Register a listener that is called when the system's list of visible windows or displays has + * changes in position or visibility. + * + * @param consumer Consumer that is called with window and display info. {@code WindowInfo} + * instances are passed as a reverse Z ordered list of WindowInfo instances + * where the first value is the topmost window. */ @SuppressLint("UnflaggedApi") // The API is only used for tests. @RequiresPermission(Manifest.permission.ACCESS_SURFACE_FLINGER) @@ -228,6 +256,29 @@ public class WindowInfosListenerForTest { calledWithInitialState.countDown(); } + /** + * Unregisters the listener. + * + * @deprecated Use {@link #addWindowInfosListener(BiConsumer)} and + * {@link #removeWindowInfosListener(BiConsumer)} instead. + */ + @Deprecated + @SuppressLint("UnflaggedApi") // The API is only used for tests. + public void removeWindowInfosListener( + @NonNull Consumer<List<WindowInfo>> consumer) { + // This method isn't used in current versions of CTS but can't be removed yet because + // newer builds need to pass on some older versions of CTS. + var biConsumer = mConsumersToBiConsumers.remove(consumer); + if (biConsumer == null) { + return; + } + WindowInfosListener listener = mListeners.remove(biConsumer); + if (listener == null) { + return; + } + listener.unregister(); + } + /** Unregisters the listener. */ @SuppressLint("UnflaggedApi") // The API is only used for tests. public void removeWindowInfosListener( diff --git a/core/java/com/android/internal/accessibility/util/ShortcutUtils.java b/core/java/com/android/internal/accessibility/util/ShortcutUtils.java index 48f86ffe8456..1c26687c97e9 100644 --- a/core/java/com/android/internal/accessibility/util/ShortcutUtils.java +++ b/core/java/com/android/internal/accessibility/util/ShortcutUtils.java @@ -16,18 +16,31 @@ package com.android.internal.accessibility.util; +import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE; +import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU; +import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_GESTURE; +import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR; + import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME; import static com.android.internal.accessibility.common.ShortcutConstants.AccessibilityFragmentType.INVISIBLE_TOGGLE; import static com.android.internal.accessibility.common.ShortcutConstants.SERVICES_SEPARATOR; import static com.android.internal.accessibility.common.ShortcutConstants.USER_SHORTCUT_TYPES; +import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.GESTURE; +import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.HARDWARE; +import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS; +import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE; +import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TRIPLETAP; +import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TWOFINGER_DOUBLETAP; import android.accessibilityservice.AccessibilityServiceInfo; import android.annotation.NonNull; +import android.annotation.UserIdInt; import android.content.ComponentName; import android.content.Context; import android.provider.Settings; import android.text.TextUtils; import android.util.ArraySet; +import android.util.Slog; import android.view.accessibility.AccessibilityManager; import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType; @@ -45,6 +58,7 @@ public final class ShortcutUtils { private static final TextUtils.SimpleStringSplitter sStringColonSplitter = new TextUtils.SimpleStringSplitter(SERVICES_SEPARATOR); + private static final String TAG = "AccessibilityShortcutUtils"; /** * Opts in component id into colon-separated {@link UserShortcutType} @@ -164,17 +178,17 @@ public final class ShortcutUtils { */ public static String convertToKey(@UserShortcutType int type) { switch (type) { - case UserShortcutType.SOFTWARE: + case SOFTWARE: return Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS; - case UserShortcutType.GESTURE: + case GESTURE: return Settings.Secure.ACCESSIBILITY_GESTURE_TARGETS; - case UserShortcutType.HARDWARE: + case HARDWARE: return Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE; - case UserShortcutType.TRIPLETAP: + case TRIPLETAP: return Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED; - case UserShortcutType.TWOFINGER_DOUBLETAP: + case TWOFINGER_DOUBLETAP: return Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED; - case UserShortcutType.QUICK_SETTINGS: + case QUICK_SETTINGS: return Settings.Secure.ACCESSIBILITY_QS_TARGETS; default: throw new IllegalArgumentException( @@ -191,14 +205,14 @@ public final class ShortcutUtils { @UserShortcutType public static int convertToType(String key) { return switch (key) { - case Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS -> UserShortcutType.SOFTWARE; - case Settings.Secure.ACCESSIBILITY_GESTURE_TARGETS -> UserShortcutType.GESTURE; - case Settings.Secure.ACCESSIBILITY_QS_TARGETS -> UserShortcutType.QUICK_SETTINGS; - case Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE -> UserShortcutType.HARDWARE; + case Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS -> SOFTWARE; + case Settings.Secure.ACCESSIBILITY_GESTURE_TARGETS -> GESTURE; + case Settings.Secure.ACCESSIBILITY_QS_TARGETS -> QUICK_SETTINGS; + case Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE -> HARDWARE; case Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED -> - UserShortcutType.TRIPLETAP; + TRIPLETAP; case Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED -> - UserShortcutType.TWOFINGER_DOUBLETAP; + TWOFINGER_DOUBLETAP; default -> throw new IllegalArgumentException( "Unsupported user shortcut key: " + key); }; @@ -296,4 +310,42 @@ public final class ShortcutUtils { return Collections.unmodifiableSet(targets); } } + + /** + * Retrieves the button mode of the provided context. + * Returns -1 if the button mode is undefined. + * Valid button modes: + * {@link Settings.Secure#ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR}, + * {@link Settings.Secure#ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU}, + * {@link Settings.Secure#ACCESSIBILITY_BUTTON_MODE_GESTURE} + */ + public static int getButtonMode(Context context, @UserIdInt int userId) { + return Settings.Secure.getIntForUser(context.getContentResolver(), + ACCESSIBILITY_BUTTON_MODE, /* default value = */ -1, userId); + } + + /** + * Sets the button mode of the provided context. + * Must be a valid button mode, or it will return false. + * Returns true if the setting was changed, false otherwise. + * Valid button modes: + * {@link Settings.Secure#ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR}, + * {@link Settings.Secure#ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU}, + * {@link Settings.Secure#ACCESSIBILITY_BUTTON_MODE_GESTURE} + */ + public static boolean setButtonMode(Context context, int mode, @UserIdInt int userId) { + // Input validation + if (getButtonMode(context, userId) == mode) { + return false; + } + if ((mode + & (ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR + | ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU + | ACCESSIBILITY_BUTTON_MODE_GESTURE)) != mode) { + Slog.w(TAG, "Tried to set button mode to unexpected value " + mode); + return false; + } + return Settings.Secure.putIntForUser( + context.getContentResolver(), ACCESSIBILITY_BUTTON_MODE, mode, userId); + } } diff --git a/core/java/com/android/internal/app/TEST_MAPPING b/core/java/com/android/internal/app/TEST_MAPPING index 08e1d5751529..b7930bc2d3f4 100644 --- a/core/java/com/android/internal/app/TEST_MAPPING +++ b/core/java/com/android/internal/app/TEST_MAPPING @@ -5,19 +5,7 @@ "file_patterns": ["(/|^)SuspendedAppActivity\\.java"] }, { - "name": "FrameworksCoreTests", - "options": [ - { - "include-filter": "com.android.internal.app." - }, - // Exclude currently failing tests from presubmit - { - "exclude-filter": "com.android.internal.app.IntentForwarderActivityTest" - }, - { - "exclude-filter": "com.android.internal.app.WindowDecorActionBarTest" - } - ] + "name": "FrameworksCoreTests_internal_app" } ] } diff --git a/core/java/com/android/internal/os/TEST_MAPPING b/core/java/com/android/internal/os/TEST_MAPPING index 154da5c76b01..258f402cf831 100644 --- a/core/java/com/android/internal/os/TEST_MAPPING +++ b/core/java/com/android/internal/os/TEST_MAPPING @@ -49,7 +49,7 @@ ], "postsubmit": [ { - "name": "FrameworksCoreTests", + "name": "PowerStatsTests", "options": [ { "include-filter": "com.android.server.power.stats.BstatsCpuTimesValidationTest" diff --git a/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java b/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java index 78b5cfed1771..49ed55dbdb9f 100644 --- a/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java +++ b/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java @@ -431,15 +431,10 @@ public class PerfettoProtoLogImpl extends IProtoLogClient.Stub implements IProto Log.d(LOG_TAG, "Dumping viewer config to trace"); - ProtoInputStream pis = mViewerConfigInputStreamProvider.getInputStream(); - - if (pis == null) { - Slog.w(LOG_TAG, "Failed to get viewer input stream."); - return; - } - mDataSource.trace(ctx -> { try { + ProtoInputStream pis = mViewerConfigInputStreamProvider.getInputStream(); + final ProtoOutputStream os = ctx.newTracePacket(); os.write(TIMESTAMP, SystemClock.elapsedRealtimeNanos()); diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index c0027f4928f5..de7477ea5443 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -3031,9 +3031,8 @@ <bool name="config_multiuserDelayUserDataLocking">false</bool> <!-- Whether the device allows full users to start in background visible on displays. - Note: this flag does NOT control the Communal Profile, which is not a full user. - Should be false for all devices in production. Can be enabled only for development use - in automotive vehicles with passenger displays. --> + Should be false for most devices, except automotive vehicle with passenger displays. + Note: this flag does NOT control the Communal Profile, which is not a full user. --> <bool name="config_multiuserVisibleBackgroundUsers">false</bool> <!-- Whether the device allows full users to start in background visible on the default display. diff --git a/core/tests/coretests/Android.bp b/core/tests/coretests/Android.bp index e86515f8da37..edf461a4d5a6 100644 --- a/core/tests/coretests/Android.bp +++ b/core/tests/coretests/Android.bp @@ -119,6 +119,7 @@ android_test { "libpowermanagertest_jni", "libviewRootImplTest_jni", "libworksourceparceltest_jni", + "libAppOpsTest_jni", ], sdk_version: "core_platform", @@ -139,6 +140,7 @@ android_test { ":com.android.cts.helpers.aosp", ":BinderProxyCountingTestApp", ":BinderProxyCountingTestService", + ":AppThatUsesAppOps", ], } diff --git a/core/tests/coretests/AndroidManifest.xml b/core/tests/coretests/AndroidManifest.xml index 0dcb1ce525d6..da7da7ddc3c5 100644 --- a/core/tests/coretests/AndroidManifest.xml +++ b/core/tests/coretests/AndroidManifest.xml @@ -19,6 +19,8 @@ package="com.android.frameworks.coretests" android:sharedUserId="com.android.uid.test"> + <attribution android:tag="testAttribution" android:label="@string/testAttributionLabel" /> + <permission android:name="com.android.frameworks.coretests.permission.TEST_GRANTED" android:protectionLevel="normal" android:label="@string/permlab_testGranted" @@ -41,6 +43,7 @@ <uses-permission android:name="android.permission.ACCESS_FPS_COUNTER" /> <uses-permission android:name="android.permission.DOWNLOAD_CACHE_NON_PURGEABLE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.BLUETOOTH" /> @@ -167,6 +170,9 @@ <uses-permission android:name="android.permission.MANAGE_ACCESSIBILITY" /> <uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" /> + <!-- AppOpsLoggingTest permissions --> + <uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" /> + <application android:theme="@style/Theme" android:supportsRtl="true" @@ -1654,15 +1660,6 @@ </intent-filter> </activity> - <activity android:name="android.widget.TextViewContextMenuActivity" - android:screenOrientation="locked" - android:exported="true"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" /> - </intent-filter> - </activity> - <activity android:name="android.animation.AnimatorSetActivity" android:screenOrientation="locked" android:exported="true"> diff --git a/core/tests/coretests/AndroidTest.xml b/core/tests/coretests/AndroidTest.xml index bf2a5b875dba..99b73a4afb93 100644 --- a/core/tests/coretests/AndroidTest.xml +++ b/core/tests/coretests/AndroidTest.xml @@ -24,6 +24,7 @@ <option name="test-file-name" value="BinderDeathRecipientHelperApp2.apk" /> <option name="test-file-name" value="BinderProxyCountingTestApp.apk" /> <option name="test-file-name" value="BinderProxyCountingTestService.apk" /> + <option name="test-file-name" value="AppThatUsesAppOps.apk" /> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> diff --git a/core/tests/coretests/AppThatUsesAppOps/Android.bp b/core/tests/coretests/AppThatUsesAppOps/Android.bp new file mode 100644 index 000000000000..6266435c65c1 --- /dev/null +++ b/core/tests/coretests/AppThatUsesAppOps/Android.bp @@ -0,0 +1,30 @@ +// Copyright (C) 2024 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 { + default_team: "trendy_team_android_permissions", + default_applicable_licenses: ["Android-Apache-2.0"], +} + +android_test_helper_app { + name: "AppThatUsesAppOps", + + srcs: ["src/**/*.kt"], + + static_libs: [ + "coretests-aidl", + "truth", + "junit", + ], +} diff --git a/core/tests/coretests/AppThatUsesAppOps/AndroidManifest.xml b/core/tests/coretests/AppThatUsesAppOps/AndroidManifest.xml new file mode 100644 index 000000000000..7c8d2f23eb57 --- /dev/null +++ b/core/tests/coretests/AppThatUsesAppOps/AndroidManifest.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + ~ Copyright (C) 2024 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="android.app.appops.appthatusesappops"> + <attribution android:tag="testAttribution" android:label="@string/testAttributionLabel" /> + + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> + <uses-permission android:name="android.permission.GET_ACCOUNTS" /> + + <application + android:attributionsAreUserVisible="true"> + <service android:name=".AppOpsUserService" android:exported="true" /> + </application> +</manifest> diff --git a/core/tests/coretests/AppThatUsesAppOps/res/values/strings.xml b/core/tests/coretests/AppThatUsesAppOps/res/values/strings.xml new file mode 100644 index 000000000000..f2127fcbf0ae --- /dev/null +++ b/core/tests/coretests/AppThatUsesAppOps/res/values/strings.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2024 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. + --> + +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="testAttributionLabel">An attribution</string> +</resources> diff --git a/core/tests/coretests/AppThatUsesAppOps/src/android/app/appops/appthatusesappops/AppOpsUserService.kt b/core/tests/coretests/AppThatUsesAppOps/src/android/app/appops/appthatusesappops/AppOpsUserService.kt new file mode 100644 index 000000000000..48053c11f2d1 --- /dev/null +++ b/core/tests/coretests/AppThatUsesAppOps/src/android/app/appops/appthatusesappops/AppOpsUserService.kt @@ -0,0 +1,199 @@ +/* + * Copyright (C) 2024 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.app.appops.appthatusesappops + +import android.app.AppOpsManager +import android.app.AppOpsManager.OPSTR_COARSE_LOCATION +import android.app.AsyncNotedAppOp +import android.app.Service +import android.app.SyncNotedAppOp +import android.content.Intent +import android.os.IBinder +import android.util.Log +import com.android.frameworks.coretests.aidl.IAppOpsUserClient +import com.android.frameworks.coretests.aidl.IAppOpsUserService +import com.google.common.truth.Truth.assertThat +import java.io.PrintWriter +import java.io.StringWriter + +private const val LOG_TAG = "AppOpsUserService" +private const val TIMEOUT_MILLIS = 10000L + +class AppOpsUserService : Service() { + private val testUid by lazy { + packageManager.getPackageUid("com.android.frameworks.coretests", 0) + } + + /** + * Make sure that a lambda eventually finishes without throwing an exception. + * + * @param r The lambda to run. + * @param timeout the maximum time to wait + * + * @return the return value from the lambda + * + * @throws NullPointerException If the return value never becomes non-null + */ + fun <T> eventually(timeout: Long = TIMEOUT_MILLIS, r: () -> T): T { + val start = System.currentTimeMillis() + + while (true) { + try { + return r() + } catch (e: Throwable) { + val elapsed = System.currentTimeMillis() - start + + if (elapsed < timeout) { + Log.d(LOG_TAG, "Ignoring exception", e) + + Thread.sleep(minOf(100, timeout - elapsed)) + } else { + throw e + } + } + } + } + + override fun onBind(intent: Intent?): IBinder { + return object : IAppOpsUserService.Stub() { + private val appOpsManager = getSystemService(AppOpsManager::class.java)!! + + // Collected note-op calls inside of this process + private val noted = mutableListOf<Pair<SyncNotedAppOp, Array<StackTraceElement>>>() + private val selfNoted = mutableListOf<Pair<SyncNotedAppOp, Array<StackTraceElement>>>() + private val asyncNoted = mutableListOf<AsyncNotedAppOp>() + + private fun setNotedAppOpsCollector() { + appOpsManager.setOnOpNotedCallback(mainExecutor, + object : AppOpsManager.OnOpNotedCallback() { + override fun onNoted(op: SyncNotedAppOp) { + noted.add(op to Throwable().stackTrace) + } + + override fun onSelfNoted(op: SyncNotedAppOp) { + selfNoted.add(op to Throwable().stackTrace) + } + + override fun onAsyncNoted(asyncOp: AsyncNotedAppOp) { + asyncNoted.add(asyncOp) + } + }) + } + + init { + try { + appOpsManager.setOnOpNotedCallback(null, null) + } catch (ignored: IllegalStateException) { + } + setNotedAppOpsCollector() + } + + /** + * Cheapo variant of {@link ParcelableException} + */ + inline fun forwardThrowableFrom(r: () -> Unit) { + try { + r() + } catch (t: Throwable) { + val sw = StringWriter() + t.printStackTrace(PrintWriter(sw)) + + throw IllegalArgumentException("\n" + sw.toString() + "called by") + } + } + + override fun callApiThatNotesSyncOpNativelyAndCheckLog(client: IAppOpsUserClient) { + forwardThrowableFrom { + client.noteSyncOpNative() + + // All native notes will be reported as async notes + eventually { + assertThat(asyncNoted.map { it.op }).containsExactly(OPSTR_COARSE_LOCATION) + } + assertThat(noted).isEmpty() + assertThat(selfNoted).isEmpty() + } + } + + override fun callApiThatNotesNonPermissionSyncOpNativelyAndCheckLog( + client: IAppOpsUserClient + ) { + forwardThrowableFrom { + client.noteNonPermissionSyncOpNative() + + // All native notes will be reported as async notes + assertThat(noted).isEmpty() + assertThat(selfNoted).isEmpty() + assertThat(asyncNoted).isEmpty() + } + } + + override fun callOnewayApiThatNotesSyncOpNativelyAndCheckLog( + client: IAppOpsUserClient + ) { + forwardThrowableFrom { + client.noteSyncOpOnewayNative() + + // There is no return value from a one-way call, hence async note is the only + // option + eventually { + assertThat(asyncNoted.map { it.op }).containsExactly(OPSTR_COARSE_LOCATION) + } + assertThat(noted).isEmpty() + assertThat(selfNoted).isEmpty() + } + } + + override fun callApiThatNotesSyncOpOtherUidNativelyAndCheckLog( + client: IAppOpsUserClient + ) { + forwardThrowableFrom { + client.noteSyncOpOtherUidNative() + + assertThat(noted).isEmpty() + assertThat(selfNoted).isEmpty() + assertThat(asyncNoted).isEmpty() + } + } + + override fun callApiThatNotesAsyncOpNativelyAndCheckLog(client: IAppOpsUserClient) { + forwardThrowableFrom { + client.noteAsyncOpNative() + + eventually { + assertThat(asyncNoted.map { it.op }).containsExactly(OPSTR_COARSE_LOCATION) + } + assertThat(noted).isEmpty() + assertThat(selfNoted).isEmpty() + } + } + + override fun callApiThatNotesAsyncOpNativelyAndCheckCustomMessage( + client: IAppOpsUserClient + ) { + forwardThrowableFrom { + client.noteAsyncOpNativeWithCustomMessage() + + eventually { + assertThat(asyncNoted[0].notingUid).isEqualTo(testUid) + assertThat(asyncNoted[0].message).isEqualTo("native custom msg") + } + } + } + } + } +} diff --git a/core/tests/coretests/OWNERS b/core/tests/coretests/OWNERS index b669e3bc4f30..6aefb638e537 100644 --- a/core/tests/coretests/OWNERS +++ b/core/tests/coretests/OWNERS @@ -4,3 +4,4 @@ per-file BinderTest.java = file:platform/frameworks/native:/libs/binder/OWNERS per-file ParcelTest.java = file:platform/frameworks/native:/libs/binder/OWNERS per-file SurfaceControlRegistryTests.java = file:/services/core/java/com/android/server/wm/OWNERS per-file VintfObjectTest.java = file:platform/system/libvintf:/OWNERS +per-file AppOpsLoggingTest.kt,AppOpsLoggingTest.cpp,IAppOps*.aidl,AppThatUsesAppOps/* = file:/core/java/android/permission/OWNERS diff --git a/core/tests/coretests/src/android/widget/TextViewContextMenuActivity.java b/core/tests/coretests/aidl/com/android/frameworks/coretests/aidl/IAppOpsUserClient.aidl index 616f29b7462b..68b393c0ced2 100644 --- a/core/tests/coretests/src/android/widget/TextViewContextMenuActivity.java +++ b/core/tests/coretests/aidl/com/android/frameworks/coretests/aidl/IAppOpsUserClient.aidl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 The Android Open Source Project + * Copyright (C) 2024 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. @@ -14,17 +14,13 @@ * limitations under the License. */ -package android.widget; +package com.android.frameworks.coretests.aidl; -import android.app.Activity; -import android.os.Bundle; - -import com.android.frameworks.coretests.R; - -public class TextViewContextMenuActivity extends Activity { - @Override - public void onCreate(Bundle savedBundleInstance) { - super.onCreate(savedBundleInstance); - setContentView(R.layout.textview_contextmenu); - } +interface IAppOpsUserClient { + void noteSyncOpNative(); + void noteNonPermissionSyncOpNative(); + oneway void noteSyncOpOnewayNative(); + void noteSyncOpOtherUidNative(); + void noteAsyncOpNative(); + void noteAsyncOpNativeWithCustomMessage(); } diff --git a/core/tests/coretests/aidl/com/android/frameworks/coretests/aidl/IAppOpsUserService.aidl b/core/tests/coretests/aidl/com/android/frameworks/coretests/aidl/IAppOpsUserService.aidl new file mode 100644 index 000000000000..f5673c43df09 --- /dev/null +++ b/core/tests/coretests/aidl/com/android/frameworks/coretests/aidl/IAppOpsUserService.aidl @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2024 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.frameworks.coretests.aidl; + +import com.android.frameworks.coretests.aidl.IAppOpsUserClient; + +interface IAppOpsUserService { + void callApiThatNotesSyncOpNativelyAndCheckLog(in IAppOpsUserClient client); + void callApiThatNotesNonPermissionSyncOpNativelyAndCheckLog(in IAppOpsUserClient client); + void callOnewayApiThatNotesSyncOpNativelyAndCheckLog(in IAppOpsUserClient client); + void callApiThatNotesSyncOpOtherUidNativelyAndCheckLog(in IAppOpsUserClient client); + void callApiThatNotesAsyncOpNativelyAndCheckCustomMessage(in IAppOpsUserClient client); + void callApiThatNotesAsyncOpNativelyAndCheckLog(in IAppOpsUserClient client); +} diff --git a/core/tests/coretests/jni/Android.bp b/core/tests/coretests/jni/Android.bp index 538e7f3d66e9..d6379ca8c3e6 100644 --- a/core/tests/coretests/jni/Android.bp +++ b/core/tests/coretests/jni/Android.bp @@ -91,3 +91,23 @@ cc_test_library { ], gtest: false, } + +cc_test_library { + name: "libAppOpsTest_jni", + srcs: ["AppOpsLoggingTest*.cpp"], + shared_libs: [ + "libbinder", + "libpermission", + "libutils", + "liblog", + ], + + header_libs: ["jni_headers"], + stl: "libc++_static", + cflags: [ + "-Wall", + "-Werror", + "-Wno-unused-parameter", + ], + gtest: false, +} diff --git a/core/tests/coretests/jni/AppOpsLoggingTest.cpp b/core/tests/coretests/jni/AppOpsLoggingTest.cpp new file mode 100644 index 000000000000..98707addf351 --- /dev/null +++ b/core/tests/coretests/jni/AppOpsLoggingTest.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2024 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. + */ + +#include <jni.h> +#include <binder/AppOpsManager.h> +#include <utils/String16.h> + +using namespace android; + +#include "android/log.h" +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AppOpsLoggingTest" + +// Note op from native code +extern "C" JNIEXPORT void JNICALL +Java_android_app_AppOpsLoggingTestKt_nativeNoteOp(JNIEnv* env, jobject obj, + jint op, jint uid, jstring jCallingPackageName, jstring jAttributionTag, jstring jMessage) { + AppOpsManager appOpsManager; + + const char *nativeCallingPackageName = env->GetStringUTFChars(jCallingPackageName, 0); + String16 callingPackageName(nativeCallingPackageName); + + const char *nativeAttributionTag; + std::optional<String16> attributionTag; + if (jAttributionTag != nullptr) { + nativeAttributionTag = env->GetStringUTFChars(jAttributionTag, 0); + attributionTag = String16(nativeAttributionTag); + } + + const char *nativeMessage; + String16 message; + if (jMessage != nullptr) { + nativeMessage = env->GetStringUTFChars(jMessage, 0); + message = String16(nativeMessage); + } + + appOpsManager.noteOp(op, uid, callingPackageName, attributionTag, message); + + env->ReleaseStringUTFChars(jCallingPackageName, nativeCallingPackageName); + + if (jAttributionTag != nullptr) { + env->ReleaseStringUTFChars(jAttributionTag, nativeAttributionTag); + } + + if (jMessage != nullptr) { + env->ReleaseStringUTFChars(jMessage, nativeMessage); + } +} diff --git a/core/tests/coretests/res/values/strings.xml b/core/tests/coretests/res/values/strings.xml index 09e1c690f4e2..209fb10d26aa 100644 --- a/core/tests/coretests/res/values/strings.xml +++ b/core/tests/coretests/res/values/strings.xml @@ -161,4 +161,7 @@ <!-- Html description of the accessibility shortcut [CHAR LIMIT=NONE] --> <string name="accessibility_shortcut_html_description">Accessibility shortcut html description</string> + + <!-- Attribution tag label [CHAR LIMIT=NONE] --> + <string name="testAttributionLabel">An attribution</string> </resources> diff --git a/core/tests/coretests/src/android/app/AppOpsLoggingTest.kt b/core/tests/coretests/src/android/app/AppOpsLoggingTest.kt new file mode 100644 index 000000000000..a10d6a9e0823 --- /dev/null +++ b/core/tests/coretests/src/android/app/AppOpsLoggingTest.kt @@ -0,0 +1,323 @@ +/* + * Copyright (C) 2024 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.app + +import android.app.AppOpsManager.OPSTR_ACCESS_ACCESSIBILITY +import android.app.AppOpsManager.OPSTR_COARSE_LOCATION +import android.app.AppOpsManager.OnOpNotedCallback +import android.app.AppOpsManager.strOpToOp +import android.content.BroadcastReceiver +import android.content.ComponentName +import android.content.Context +import android.content.Context.BIND_AUTO_CREATE +import android.content.Intent +import android.content.ServiceConnection +import android.location.LocationManager +import android.os.Binder +import android.os.Handler +import android.os.IBinder +import android.os.Looper +import android.os.Process +import android.platform.test.annotations.AppModeFull +import android.util.Log +import androidx.test.platform.app.InstrumentationRegistry +import com.android.frameworks.coretests.aidl.IAppOpsUserClient +import com.android.frameworks.coretests.aidl.IAppOpsUserService +import com.google.common.truth.Truth.assertThat +import org.junit.After +import org.junit.Assert.fail +import org.junit.Before +import org.junit.Test +import java.util.concurrent.CompletableFuture +import java.util.concurrent.TimeUnit.MILLISECONDS + +private const val LOG_TAG = "AppOpsLoggingTest" + +private const val TEST_SERVICE_PKG = "android.app.appops.appthatusesappops" +private const val TIMEOUT_MILLIS = 10000L +private const val TEST_ATTRIBUTION_TAG = "testAttribution" + +private external fun nativeNoteOp( + op: Int, + uid: Int, + packageName: String, + attributionTag: String? = null, + message: String? = null +) + +@AppModeFull(reason = "Test relies on other app to connect to. Instant apps can't see other apps") +class AppOpsLoggingTest { + + private val context = InstrumentationRegistry.getInstrumentation().targetContext as Context + private val appOpsManager = context.getSystemService(AppOpsManager::class.java)!! + + private val myUid = Process.myUid() + private val myUserHandle = Process.myUserHandle() + private val myPackage = context.packageName + + private var wasLocationEnabled = false + + private lateinit var testService: IAppOpsUserService + private lateinit var serviceConnection: ServiceConnection + + // Collected note-op calls inside of this process + private val noted = mutableListOf<Pair<SyncNotedAppOp, Array<StackTraceElement>>>() + private val selfNoted = mutableListOf<Pair<SyncNotedAppOp, Array<StackTraceElement>>>() + private val asyncNoted = mutableListOf<AsyncNotedAppOp>() + + @Before + fun setLocationEnabled() { + val locationManager = context.getSystemService(LocationManager::class.java)!! + wasLocationEnabled = locationManager.isLocationEnabled + locationManager.setLocationEnabledForUser(true, myUserHandle) + } + + @After + fun restoreLocationEnabled() { + val locationManager = context.getSystemService(LocationManager::class.java)!! + locationManager.setLocationEnabledForUser(wasLocationEnabled, myUserHandle) + } + + @Before + fun loadNativeCode() { + System.loadLibrary("AppOpsTest_jni") + } + + @Before + fun setNotedAppOpsCollectorAndClearCollectedNoteOps() { + setNotedAppOpsCollector() + clearCollectedNotedOps() + } + + @Before + fun connectToService() { + val serviceIntent = Intent() + serviceIntent.component = ComponentName(TEST_SERVICE_PKG, + "$TEST_SERVICE_PKG.AppOpsUserService" + ) + + val newService = CompletableFuture<IAppOpsUserService>() + serviceConnection = object : ServiceConnection { + override fun onServiceConnected(name: ComponentName?, service: IBinder?) { + newService.complete(IAppOpsUserService.Stub.asInterface(service)) + } + + override fun onServiceDisconnected(name: ComponentName?) { + fail("test service disconnected") + } + } + + context.bindService(serviceIntent, serviceConnection, BIND_AUTO_CREATE) + testService = newService.get(TIMEOUT_MILLIS, MILLISECONDS) + } + + private fun clearCollectedNotedOps() { + noted.clear() + selfNoted.clear() + asyncNoted.clear() + } + + private fun setNotedAppOpsCollector() { + appOpsManager.setOnOpNotedCallback( + { it.run() }, + object : OnOpNotedCallback() { + override fun onNoted(op: SyncNotedAppOp) { + Log.i("OPALA", "sync op: $, stack: $".format(op, Throwable().stackTrace)) + noted.add(op to Throwable().stackTrace) + } + + override fun onSelfNoted(op: SyncNotedAppOp) { + Log.i("OPALA", "self op: $, stack: $".format(op, Throwable().stackTrace)) + selfNoted.add(op to Throwable().stackTrace) + } + + override fun onAsyncNoted(asyncOp: AsyncNotedAppOp) { + Log.i("OPALA", "async op: $".format(asyncOp)) + asyncNoted.add(asyncOp) + } + }) + } + + private inline fun rethrowThrowableFrom(r: () -> Unit) { + try { + r() + } catch (e: Throwable) { + throw e.cause ?: e + } + } + + private fun <T> eventually(timeout: Long = TIMEOUT_MILLIS, r: () -> T): T { + val start = System.currentTimeMillis() + + while (true) { + try { + return r() + } catch (e: Throwable) { + val elapsed = System.currentTimeMillis() - start + + if (elapsed < timeout) { + Log.d(LOG_TAG, "Ignoring exception", e) + + Thread.sleep(minOf(100, timeout - elapsed)) + } else { + throw e + } + } + } + } + + @Test + fun noteSyncOpOnewayNative() { + rethrowThrowableFrom { + testService.callOnewayApiThatNotesSyncOpNativelyAndCheckLog(AppOpsUserClient(context)) + } + } + + @Test + fun noteSyncOpOtherUidNativeAndCheckLog() { + rethrowThrowableFrom { + testService.callApiThatNotesSyncOpOtherUidNativelyAndCheckLog(AppOpsUserClient(context)) + } + } + + @Test + fun nativeSelfNoteAndCheckLog() { + nativeNoteOp(strOpToOp(OPSTR_COARSE_LOCATION), myUid, myPackage) + + assertThat(noted).isEmpty() + assertThat(selfNoted).isEmpty() + + // All native notes will be reported as async notes + eventually { + assertThat(asyncNoted[0].attributionTag).isEqualTo(null) + // There is always a message. + assertThat(asyncNoted[0].message).isNotEqualTo(null) + assertThat(asyncNoted[0].op).isEqualTo(OPSTR_COARSE_LOCATION) + assertThat(asyncNoted[0].notingUid).isEqualTo(myUid) + } + } + + @Test + fun noteSyncOpNativeAndCheckLog() { + rethrowThrowableFrom { + testService.callApiThatNotesSyncOpNativelyAndCheckLog(AppOpsUserClient(context)) + } + } + + @Test + fun noteNonPermissionSyncOpNativeAndCheckLog() { + rethrowThrowableFrom { + testService.callApiThatNotesNonPermissionSyncOpNativelyAndCheckLog( + AppOpsUserClient(context)) + } + } + + @Test + fun noteAsyncOpNativelyAndCheckCustomMessage() { + rethrowThrowableFrom { + testService.callApiThatNotesAsyncOpNativelyAndCheckCustomMessage( + AppOpsUserClient(context)) + } + } + + @Test + fun noteAsyncOpNativeAndCheckLog() { + rethrowThrowableFrom { + testService.callApiThatNotesAsyncOpNativelyAndCheckLog(AppOpsUserClient(context)) + } + } + + @Test + fun nativeSelfNoteWithAttributionAndMsgAndCheckLog() { + nativeNoteOp(strOpToOp(OPSTR_COARSE_LOCATION), myUid, myPackage, + attributionTag = TEST_ATTRIBUTION_TAG, message = "testMsg") + + // All native notes will be reported as async notes + eventually { + assertThat(asyncNoted[0].attributionTag).isEqualTo(TEST_ATTRIBUTION_TAG) + assertThat(asyncNoted[0].message).isEqualTo("testMsg") + } + } + + @After + fun removeNotedAppOpsCollector() { + appOpsManager.setOnOpNotedCallback(null, null) + } + + @After + fun disconnectFromService() { + context.unbindService(serviceConnection) + } + + private inner class AppOpsUserClient( + context: Context + ) : IAppOpsUserClient.Stub() { + private val handler = Handler(Looper.getMainLooper()) + + private val myUid = Process.myUid() + private val myPackage = context.packageName + + override fun noteSyncOpNative() { + nativeNoteOp(strOpToOp(OPSTR_COARSE_LOCATION), Binder.getCallingUid(), TEST_SERVICE_PKG) + } + + override fun noteNonPermissionSyncOpNative() { + nativeNoteOp( + strOpToOp(OPSTR_ACCESS_ACCESSIBILITY), Binder.getCallingUid(), TEST_SERVICE_PKG + ) + } + + override fun noteSyncOpOnewayNative() { + nativeNoteOp(strOpToOp(OPSTR_COARSE_LOCATION), Binder.getCallingUid(), TEST_SERVICE_PKG) + } + + override fun noteSyncOpOtherUidNative() { + nativeNoteOp(strOpToOp(OPSTR_COARSE_LOCATION), myUid, myPackage) + } + + override fun noteAsyncOpNative() { + val callingUid = Binder.getCallingUid() + + handler.post { + nativeNoteOp(strOpToOp(OPSTR_COARSE_LOCATION), callingUid, TEST_SERVICE_PKG) + } + } + + override fun noteAsyncOpNativeWithCustomMessage() { + val callingUid = Binder.getCallingUid() + + handler.post { + nativeNoteOp( + strOpToOp(OPSTR_COARSE_LOCATION), + callingUid, + TEST_SERVICE_PKG, + message = "native custom msg" + ) + } + } + } +} + +class PublicActionReceiver : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent?) { + } +} + +class ProtectedActionReceiver : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent?) { + } +} diff --git a/core/tests/coretests/src/android/content/res/TEST_MAPPING b/core/tests/coretests/src/android/content/res/TEST_MAPPING index 25927de55d33..4cce70e86e66 100644 --- a/core/tests/coretests/src/android/content/res/TEST_MAPPING +++ b/core/tests/coretests/src/android/content/res/TEST_MAPPING @@ -6,21 +6,7 @@ ], "postsubmit": [ { - "name": "FrameworksCoreTests", - "options": [ - { - "include-filter": "android.content.res." - }, - { - "include-annotation": "android.platform.test.annotations.Postsubmit" - }, - { - "exclude-annotation": "androidx.test.filters.FlakyTest" - }, - { - "exclude-annotation": "org.junit.Ignore" - } - ] + "name": "FrameworksCoreTests_android_content_res_PostSubmit" } ] } diff --git a/core/tests/coretests/src/android/widget/TextViewContextMenuTest.java b/core/tests/coretests/src/android/widget/TextViewContextMenuTest.java index b11307e0393d..bcf1053e8ddd 100644 --- a/core/tests/coretests/src/android/widget/TextViewContextMenuTest.java +++ b/core/tests/coretests/src/android/widget/TextViewContextMenuTest.java @@ -16,6 +16,8 @@ package android.widget; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; + import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -31,9 +33,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import android.app.Activity; import android.app.PendingIntent; import android.app.RemoteAction; +import android.content.Context; import android.content.Intent; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; @@ -42,15 +44,9 @@ import android.view.ContextMenu; import android.view.MenuItem; import android.view.textclassifier.TextClassification; -import androidx.test.annotation.UiThreadTest; import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.filters.MediumTest; -import androidx.test.rule.ActivityTestRule; - -import com.android.frameworks.coretests.R; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -59,17 +55,12 @@ import org.mockito.ArgumentCaptor; * TextViewTest tests {@link TextView}. */ @RunWith(AndroidJUnit4.class) -@MediumTest public class TextViewContextMenuTest { private static final String INTENT_ACTION_MOCK_ACTION_TEXT_CLASSIFICATION = "android.text.coretest.textclassifiation"; private static final String ACTION_TITLE = "ACTION_TITLE"; private static final String ACTION_DESCRIPTION = "ACTION_DESCRIPTION"; - @Rule - public final ActivityTestRule<TextViewContextMenuActivity> mActivityRule = - new ActivityTestRule<>(TextViewContextMenuActivity.class); - // Setup MenuItem mock with chaining. private MenuItem newMockMenuItem() { MenuItem mockItem = mock(MenuItem.class); @@ -83,43 +74,39 @@ public class TextViewContextMenuTest { return mockItem; } - private RemoteAction createRemoteAction() { + private RemoteAction createRemoteAction(Context context) { Intent intent = new Intent(INTENT_ACTION_MOCK_ACTION_TEXT_CLASSIFICATION) - .setPackage(mActivity.getPackageName()); - PendingIntent pIntent = PendingIntent.getBroadcast(mActivity, 0, intent, + .setPackage(context.getPackageName()); + PendingIntent pIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_MUTABLE); return new RemoteAction( - Icon.createWithResource(mActivity, android.R.drawable.btn_star), + Icon.createWithResource(context, android.R.drawable.btn_star), ACTION_TITLE, ACTION_DESCRIPTION, pIntent); } - private Activity mActivity; private SelectionActionModeHelper mMockHelper; - private Editor.AssistantCallbackHelper mCallbackHelper; @Before public void setUp() { - mActivity = mActivityRule.getActivity(); - EditText et = mActivity.findViewById(R.id.editText); - mMockHelper = mock(SelectionActionModeHelper.class); - mCallbackHelper = et.getEditorForTesting().new AssistantCallbackHelper(mMockHelper); } - @UiThreadTest @Test public void testNoMenuInteraction_noTextClassification() { when(mMockHelper.getTextClassification()).thenReturn(null); ContextMenu menu = mock(ContextMenu.class); - mCallbackHelper.updateAssistMenuItems(menu, null); + EditText et = new EditText(getInstrumentation().getContext()); + Editor.AssistantCallbackHelper cbh = + et.getEditorForTesting().new AssistantCallbackHelper(mMockHelper); + cbh.updateAssistMenuItems(menu, null); verifyNoMoreInteractions(menu); } - @UiThreadTest @Test public void testAddMenuForTextClassification() { // Setup - RemoteAction action = createRemoteAction(); + Context context = getInstrumentation().getContext(); + RemoteAction action = createRemoteAction(context); TextClassification classification = new TextClassification.Builder() .addAction(action).build(); when(mMockHelper.getTextClassification()).thenReturn(classification); @@ -129,7 +116,10 @@ public class TextViewContextMenuTest { when(menu.add(anyInt(), anyInt(), anyInt(), any())).thenReturn(mockMenuItem); // Execute - mCallbackHelper.updateAssistMenuItems(menu, null); + EditText et = new EditText(context); + Editor.AssistantCallbackHelper cbh = + et.getEditorForTesting().new AssistantCallbackHelper(mMockHelper); + cbh.updateAssistMenuItems(menu, null); // Verify ArgumentCaptor<Integer> idCaptor = ArgumentCaptor.forClass(Integer.class); @@ -142,14 +132,14 @@ public class TextViewContextMenuTest { verify(mockMenuItem, times(1)).setContentDescription(eq(ACTION_DESCRIPTION)); } - @UiThreadTest @Test public void testAddMenuForLegacyTextClassification() { // Setup + Context context = getInstrumentation().getContext(); Intent intent = new Intent(INTENT_ACTION_MOCK_ACTION_TEXT_CLASSIFICATION) - .setPackage(mActivity.getPackageName()); + .setPackage(context.getPackageName()); TextClassification classification = new TextClassification.Builder() - .setIcon(mActivity.getResources().getDrawable(android.R.drawable.star_on)) + .setIcon(context.getResources().getDrawable(android.R.drawable.star_on)) .setLabel(ACTION_TITLE) .setIntent(intent) .build(); @@ -160,7 +150,10 @@ public class TextViewContextMenuTest { when(menu.add(anyInt(), anyInt(), anyInt(), any())).thenReturn(mockMenuItem); // Execute - mCallbackHelper.updateAssistMenuItems(menu, null); + EditText et = new EditText(context); + Editor.AssistantCallbackHelper cbh = + et.getEditorForTesting().new AssistantCallbackHelper(mMockHelper); + cbh.updateAssistMenuItems(menu, null); // Verify ArgumentCaptor<Integer> idCaptor = ArgumentCaptor.forClass(Integer.class); @@ -172,7 +165,6 @@ public class TextViewContextMenuTest { assertThat(titleCaptor.getValue().toString()).isEqualTo(ACTION_TITLE); } - @UiThreadTest @Test public void testAdjustIconSpaces() { GradientDrawable gd = new GradientDrawable(); @@ -195,9 +187,8 @@ public class TextViewContextMenuTest { when(menu.getItem(1)).thenReturn(mockNoIconMenu); when(menu.getItem(2)).thenReturn(mockNoIconMenu2); - // Execute the test method - EditText et = mActivity.findViewById(R.id.editText); + EditText et = new EditText(getInstrumentation().getContext()); Editor editor = et.getEditorForTesting(); editor.adjustIconSpacing(menu); @@ -217,7 +208,6 @@ public class TextViewContextMenuTest { assertThat(paddingDrawable2).isSameInstanceAs(paddingDrawable); } - @UiThreadTest @Test public void testAdjustIconSpacesNoIconCase() { // Setup mocks @@ -234,7 +224,7 @@ public class TextViewContextMenuTest { when(menu.getItem(1)).thenReturn(mockNoIconMenu2); // Execute the test method - EditText et = mActivity.findViewById(R.id.editText); + EditText et = new EditText(getInstrumentation().getContext()); Editor editor = et.getEditorForTesting(); editor.adjustIconSpacing(menu); @@ -243,7 +233,6 @@ public class TextViewContextMenuTest { verify(mockNoIconMenu2, times(0)).setIcon(any()); } - @UiThreadTest @Test public void testAutofillMenuItemEnabledWhenNoTextSelected() { ContextMenu menu = mock(ContextMenu.class); @@ -253,18 +242,17 @@ public class TextViewContextMenuTest { when(menu.add(anyInt(), eq(TextView.ID_AUTOFILL), anyInt(), anyInt())) .thenReturn(mockAutofillMenuItem); - EditText et = spy(mActivity.findViewById(R.id.editText)); + EditText et = spy(new EditText(getInstrumentation().getContext())); doReturn(true).when(et).canRequestAutofill(); doReturn(null).when(et).getSelectedText(); - Editor editor = et.getEditorForTesting(); - editor.onCreateContextMenu(menu); + Editor editor = new Editor(et); + editor.setTextContextMenuItems(menu); verify(menu).add(anyInt(), eq(TextView.ID_AUTOFILL), anyInt(), anyInt()); verify(mockAutofillMenuItem).setEnabled(true); } - @UiThreadTest @Test public void testAutofillMenuItemNotEnabledWhenTextSelected() { ContextMenu menu = mock(ContextMenu.class); @@ -274,7 +262,7 @@ public class TextViewContextMenuTest { when(menu.add(anyInt(), eq(TextView.ID_AUTOFILL), anyInt(), anyInt())) .thenReturn(mockAutofillMenuItem); - EditText et = spy(mActivity.findViewById(R.id.editText)); + EditText et = spy(new EditText(getInstrumentation().getContext())); doReturn(true).when(et).canRequestAutofill(); doReturn("test").when(et).getSelectedText(); Editor editor = new Editor(et); @@ -283,5 +271,4 @@ public class TextViewContextMenuTest { verify(menu).add(anyInt(), eq(TextView.ID_AUTOFILL), anyInt(), anyInt()); verify(mockAutofillMenuItem).setEnabled(false); } - } diff --git a/core/tests/resourceflaggingtests/Android.bp b/core/tests/resourceflaggingtests/Android.bp index efb843735aef..40bdc2bc61e1 100644 --- a/core/tests/resourceflaggingtests/Android.bp +++ b/core/tests/resourceflaggingtests/Android.bp @@ -26,6 +26,7 @@ android_test { name: "ResourceFlaggingTests", srcs: [ "src/**/*.java", + ":resource-flagging-test-app-r-java", ], platform_apis: true, certificate: "platform", diff --git a/core/tests/resourceflaggingtests/src/com/android/resourceflaggingtests/ResourceFlaggingTest.java b/core/tests/resourceflaggingtests/src/com/android/resourceflaggingtests/ResourceFlaggingTest.java index 471b4021545a..005538a4d401 100644 --- a/core/tests/resourceflaggingtests/src/com/android/resourceflaggingtests/ResourceFlaggingTest.java +++ b/core/tests/resourceflaggingtests/src/com/android/resourceflaggingtests/ResourceFlaggingTest.java @@ -19,15 +19,22 @@ package com.android.resourceflaggingtests; import static com.google.common.truth.Truth.assertThat; import android.content.Context; +import android.content.ContextWrapper; +import android.content.res.ApkAssets; import android.content.res.AssetManager; import android.content.res.Configuration; import android.content.res.Resources; import android.os.FileUtils; import android.util.DisplayMetrics; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; +import com.android.intenal.flaggedresources.R; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -46,7 +53,14 @@ public class ResourceFlaggingTest { public void setUp() throws Exception { mContext = InstrumentationRegistry.getTargetContext(); AssetManager assets = new AssetManager(); - assertThat(assets.addAssetPath(extractApkAndGetPath(R.raw.resapp))).isNotEqualTo(0); + assets.setApkAssets( + new ApkAssets[]{ + ApkAssets.loadFromPath( + extractApkAndGetPath( + com.android.resourceflaggingtests.R.raw.resapp + ) + ) + }, true); final DisplayMetrics dm = new DisplayMetrics(); dm.setToDefaults(); @@ -55,54 +69,60 @@ public class ResourceFlaggingTest { @Test public void testFlagDisabled() { - assertThat(getBoolean("res1")).isTrue(); + assertThat(mResources.getBoolean(R.bool.bool1)).isTrue(); } @Test public void testFlagEnabled() { - assertThat(getBoolean("res2")).isTrue(); + assertThat(mResources.getBoolean(R.bool.bool2)).isTrue(); } @Test public void testFlagEnabledDifferentCompilationUnit() { - assertThat(getBoolean("res3")).isTrue(); + assertThat(mResources.getBoolean(R.bool.bool3)).isTrue(); } @Test public void testFlagDisabledStringArrayElement() { - assertThat(getStringArray("strarr1")).isEqualTo(new String[]{"one", "two", "three"}); + assertThat(mResources.getStringArray(R.array.strarr1)) + .isEqualTo(new String[]{"one", "two", "three"}); } @Test public void testFlagDisabledIntArrayElement() { - assertThat(getIntArray("intarr1")).isEqualTo(new int[]{1, 2, 3}); - } - - private boolean getBoolean(String name) { - int resId = mResources.getIdentifier( - name, - "bool", - "com.android.intenal.flaggedresources"); - assertThat(resId).isNotEqualTo(0); - return mResources.getBoolean(resId); + assertThat(mResources.getIntArray(R.array.intarr1)).isEqualTo(new int[]{1, 2, 3}); } - private String[] getStringArray(String name) { - int resId = mResources.getIdentifier( - name, - "array", - "com.android.intenal.flaggedresources"); - assertThat(resId).isNotEqualTo(0); - return mResources.getStringArray(resId); + @Test + public void testLayoutWithDisabledElements() { + LinearLayout ll = (LinearLayout) getLayoutInflater().inflate(R.layout.layout1, null); + assertThat(ll).isNotNull(); + assertThat((View) ll.findViewById(R.id.text1)).isNotNull(); + assertThat((View) ll.findViewById(R.id.disabled_text)).isNull(); + assertThat((View) ll.findViewById(R.id.text2)).isNotNull(); } - private int[] getIntArray(String name) { - int resId = mResources.getIdentifier( - name, - "array", - "com.android.intenal.flaggedresources"); - assertThat(resId).isNotEqualTo(0); - return mResources.getIntArray(resId); + private LayoutInflater getLayoutInflater() { + ContextWrapper c = new ContextWrapper(mContext) { + private LayoutInflater mInflater; + + @Override + public Resources getResources() { + return mResources; + } + + @Override + public Object getSystemService(String name) { + if (LAYOUT_INFLATER_SERVICE.equals(name)) { + if (mInflater == null) { + mInflater = LayoutInflater.from(getBaseContext()).cloneInContext(this); + } + return mInflater; + } + return super.getSystemService(name); + } + }; + return LayoutInflater.from(c); } private String extractApkAndGetPath(int id) throws Exception { diff --git a/data/fonts/Android.bp b/data/fonts/Android.bp index f1a6b6974b06..1a3a0f60f2dc 100644 --- a/data/fonts/Android.bp +++ b/data/fonts/Android.bp @@ -86,3 +86,11 @@ prebuilt_fonts_xml { // Because `system.img` is a dependency of `fontchain_lint`, it cannot be // converted to Android.bp for now. // After system.img can be generated by Soong, then it can be converted to Android.bp. + +filegroup { + name: "DroidSansMono", + srcs: ["font_config.json"], + required: [ + "DroidSansMono.ttf", + ], +} diff --git a/data/fonts/font_config.json b/data/fonts/font_config.json new file mode 100644 index 000000000000..427e6cfe7307 --- /dev/null +++ b/data/fonts/font_config.json @@ -0,0 +1,12 @@ +[ + { + "name": "monospace", + "fonts": [ + { + "file": "DroidSansMono.ttf", + "weight": "400", + "style": "normal" + } + ] + } +]
\ No newline at end of file diff --git a/libs/WindowManager/Shell/res/drawable/desktop_mode_header_ic_minimize.xml b/libs/WindowManager/Shell/res/drawable/desktop_mode_header_ic_minimize.xml new file mode 100644 index 000000000000..b35dc022e210 --- /dev/null +++ b/libs/WindowManager/Shell/res/drawable/desktop_mode_header_ic_minimize.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2024 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. + --> +<vector + xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportHeight="24" + android:viewportWidth="24"> + <path + android:fillColor="#FF000000" + android:pathData="M6,21V19H18V21Z"/> +</vector> diff --git a/libs/WindowManager/Shell/res/layout/desktop_mode_app_header.xml b/libs/WindowManager/Shell/res/layout/desktop_mode_app_header.xml index 7b31c1420a7c..7dcb3c237c51 100644 --- a/libs/WindowManager/Shell/res/layout/desktop_mode_app_header.xml +++ b/libs/WindowManager/Shell/res/layout/desktop_mode_app_header.xml @@ -76,6 +76,18 @@ android:layout_height="40dp" android:layout_weight="1"/> + <ImageButton + android:id="@+id/minimize_window" + android:layout_width="44dp" + android:layout_height="40dp" + android:paddingHorizontal="10dp" + android:paddingVertical="8dp" + android:layout_marginEnd="8dp" + android:contentDescription="@string/minimize_button_text" + android:src="@drawable/desktop_mode_header_ic_minimize" + android:scaleType="centerCrop" + android:gravity="end"/> + <com.android.wm.shell.windowdecor.MaximizeButtonView android:id="@+id/maximize_button_view" android:layout_width="44dp" diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml index 08a746fdf867..2d98a2b675a3 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -460,6 +460,11 @@ start of this area. --> <dimen name="desktop_mode_customizable_caption_margin_end">152dp</dimen> + <!-- The width of the right-aligned region that is taken up by caption elements and extra + margins when the caption has the minimize button. This will be merged with the above value + once the minimize button becomes default. --> + <dimen name="desktop_mode_customizable_caption_with_minimize_button_margin_end">204dp</dimen> + <!-- The default minimum allowed window width when resizing a window in desktop mode. --> <dimen name="desktop_mode_minimum_window_width">386dp</dimen> @@ -579,6 +584,13 @@ <!-- The vertical inset to apply to the app chip's ripple drawable --> <dimen name="desktop_mode_header_app_chip_ripple_inset_vertical">4dp</dimen> + <!-- The corner radius of the minimize button's ripple drawable --> + <dimen name="desktop_mode_header_minimize_ripple_radius">18dp</dimen> + <!-- The vertical inset to apply to the minimize button's ripple drawable --> + <dimen name="desktop_mode_header_minimize_ripple_inset_vertical">4dp</dimen> + <!-- The horizontal inset to apply to the minimize button's ripple drawable --> + <dimen name="desktop_mode_header_minimize_ripple_inset_horizontal">6dp</dimen> + <!-- The corner radius of the maximize button's ripple drawable --> <dimen name="desktop_mode_header_maximize_ripple_radius">18dp</dimen> <!-- The vertical inset to apply to the maximize button's ripple drawable --> diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayController.java index 7c51a6994306..f532be6b8277 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayController.java @@ -211,7 +211,9 @@ public class DisplayController { dr.mDisplayLayout.resizeTo(dr.mContext.getResources(), new Size(endAbsBounds.width(), endAbsBounds.height())); } - dr.mDisplayLayout.rotateTo(dr.mContext.getResources(), toRotation); + if (fromRotation != toRotation) { + dr.mDisplayLayout.rotateTo(dr.mContext.getResources(), toRotation); + } } mChangeController.dispatchOnDisplayChange( diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java index d94732681f72..4db8a82eb5af 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java @@ -236,7 +236,8 @@ public abstract class WMShellModule { RootTaskDisplayAreaOrganizer rootTaskDisplayAreaOrganizer, InteractionJankMonitor interactionJankMonitor, AppToWebGenericLinksParser genericLinksParser, - MultiInstanceHelper multiInstanceHelper) { + MultiInstanceHelper multiInstanceHelper, + Optional<DesktopTasksLimiter> desktopTasksLimiter) { if (DesktopModeStatus.canEnterDesktopMode(context)) { return new DesktopModeWindowDecorViewModel( context, @@ -257,7 +258,8 @@ public abstract class WMShellModule { rootTaskDisplayAreaOrganizer, interactionJankMonitor, genericLinksParser, - multiInstanceHelper); + multiInstanceHelper, + desktopTasksLimiter); } return new CaptionWindowDecorViewModel( context, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeLoggerTransitionObserver.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeLoggerTransitionObserver.kt index a6ed3b8cb50c..2e36ffe67727 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeLoggerTransitionObserver.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeLoggerTransitionObserver.kt @@ -86,6 +86,10 @@ class DesktopModeLoggerTransitionObserver( // Caching whether the previous transition was exit to overview. private var wasPreviousTransitionExitToOverview: Boolean = false + // Caching whether the previous transition was exit due to screen off. This helps check if a + // following enter reason could be Screen On + private var wasPreviousTransitionExitByScreenOff: Boolean = false + // The instanceId for the current logging session private var loggerInstanceId: InstanceId? = null @@ -328,7 +332,7 @@ class DesktopModeLoggerTransitionObserver( val positionInParent = taskInfo.positionInParent return TaskUpdate( instanceId = taskInfo.taskId, - uid = taskInfo.userId, + uid = taskInfo.effectiveUid, taskHeight = screenBounds.height(), taskWidth = screenBounds.width(), taskX = positionInParent.x, @@ -337,9 +341,12 @@ class DesktopModeLoggerTransitionObserver( } /** Get [EnterReason] for this session enter */ - private fun getEnterReason(transitionInfo: TransitionInfo): EnterReason = - when { - transitionInfo.type == WindowManager.TRANSIT_WAKE -> EnterReason.SCREEN_ON + private fun getEnterReason(transitionInfo: TransitionInfo): EnterReason { + val enterReason = when { + transitionInfo.type == WindowManager.TRANSIT_WAKE + // If there is a screen lock, desktop window entry is after dismissing keyguard + || (transitionInfo.type == WindowManager.TRANSIT_TO_BACK + && wasPreviousTransitionExitByScreenOff) -> EnterReason.SCREEN_ON transitionInfo.type == Transitions.TRANSIT_DESKTOP_MODE_END_DRAG_TO_DESKTOP -> EnterReason.APP_HANDLE_DRAG transitionInfo.type == TRANSIT_ENTER_DESKTOP_FROM_APP_HANDLE_MENU_BUTTON -> @@ -367,11 +374,17 @@ class DesktopModeLoggerTransitionObserver( EnterReason.UNKNOWN_ENTER } } + wasPreviousTransitionExitByScreenOff = false + return enterReason + } /** Get [ExitReason] for this session exit */ private fun getExitReason(transitionInfo: TransitionInfo): ExitReason = when { - transitionInfo.type == WindowManager.TRANSIT_SLEEP -> ExitReason.SCREEN_OFF + transitionInfo.type == WindowManager.TRANSIT_SLEEP -> { + wasPreviousTransitionExitByScreenOff = true + ExitReason.SCREEN_OFF + } transitionInfo.type == WindowManager.TRANSIT_CLOSE -> ExitReason.TASK_FINISHED transitionInfo.type == TRANSIT_EXIT_DESKTOP_MODE_TASK_DRAG -> ExitReason.DRAG_TO_EXIT transitionInfo.type == TRANSIT_EXIT_DESKTOP_MODE_HANDLE_MENU_BUTTON -> diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt index 33794d242c03..c97066a6e892 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt @@ -431,6 +431,20 @@ class DesktopTasksController( taskRepository.addClosingTask(displayId, taskId) } + /** + * Perform clean up of the desktop wallpaper activity if the minimized window task is the last + * active task. + * + * @param wct transaction to modify if the last active task is minimized + * @param taskId task id of the window that's being minimized + */ + fun onDesktopWindowMinimize(wct: WindowContainerTransaction, taskId: Int) { + if (taskRepository.isOnlyVisibleNonClosingTask(taskId)) { + removeWallpaperActivity(wct) + } + // Do not call taskRepository.minimizeTask because it will be called by DekstopTasksLimiter. + } + /** Move a task with given `taskId` to fullscreen */ fun moveToFullscreen(taskId: Int, transitionSource: DesktopModeTransitionSource) { shellTaskOrganizer.getRunningTaskInfo(taskId)?.let { task -> diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionHandler.java index 4284d06a293f..1ffa54103d62 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionHandler.java @@ -18,6 +18,7 @@ package com.android.wm.shell.freeform; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; + import static com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_EXIT_MODE_ON_LAST_WINDOW_CLOSE; import android.animation.Animator; @@ -116,9 +117,11 @@ public class FreeformTaskTransitionHandler } @Override - public void startMinimizedModeTransition(WindowContainerTransaction wct) { + public IBinder startMinimizedModeTransition(WindowContainerTransaction wct) { final int type = WindowManager.TRANSIT_TO_BACK; - mPendingTransitionTokens.add(mTransitions.startTransition(type, wct, this)); + final IBinder token = mTransitions.startTransition(type, wct, this); + mPendingTransitionTokens.add(token); + return token; } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionStarter.java b/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionStarter.java index 8da4c6ab4b36..ea68a694c3b9 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionStarter.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionStarter.java @@ -16,6 +16,7 @@ package com.android.wm.shell.freeform; +import android.os.IBinder; import android.window.WindowContainerTransaction; /** @@ -38,8 +39,9 @@ public interface FreeformTaskTransitionStarter { * * @param wct the {@link WindowContainerTransaction} that changes the windowing mode * + * @return the started transition */ - void startMinimizedModeTransition(WindowContainerTransaction wct); + IBinder startMinimizedModeTransition(WindowContainerTransaction wct); /** * Starts close window transition diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java index 5ec0c11109a0..755e9581326a 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java @@ -240,6 +240,12 @@ public class PipController implements PipTransitionController.PipTransitionCallb */ private final DisplayChangeController.OnDisplayChangingListener mRotationController = ( displayId, fromRotation, toRotation, newDisplayAreaInfo, t) -> { + if (fromRotation == toRotation) { + // OnDisplayChangingListener also gets triggered upon Display size changes; + // in PiP1, those are handled separately by OnDisplaysChangedListener callbacks. + return; + } + if (mPipTransitionController.handleRotateDisplay(fromRotation, toRotation, t)) { return; } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java index 501e85675ce3..11976aed9315 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java @@ -27,7 +27,6 @@ import static android.view.WindowManager.TRANSIT_CHANGE; import android.app.ActivityManager.RunningTaskInfo; import android.content.ContentResolver; import android.content.Context; -import android.graphics.Color; import android.graphics.Point; import android.graphics.Rect; import android.graphics.Region; @@ -181,7 +180,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { } decoration.relayout(taskInfo); - setupCaptionColor(taskInfo, decoration); } @Override @@ -243,15 +241,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { decoration.close(); } - private void setupCaptionColor(RunningTaskInfo taskInfo, CaptionWindowDecoration decoration) { - if (TaskInfoKt.isTransparentCaptionBarAppearance(taskInfo)) { - decoration.setCaptionColor(Color.TRANSPARENT); - } else { - final int statusBarColor = taskInfo.taskDescription.getStatusBarColor(); - decoration.setCaptionColor(statusBarColor); - } - } - private boolean shouldShowWindowDecor(RunningTaskInfo taskInfo) { if (taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) { return true; @@ -320,7 +309,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { windowDecoration.setTaskDragResizer(taskPositioner); windowDecoration.relayout(taskInfo, startT, finishT, false /* applyStartTransactionOnDraw */, false /* setTaskCropAndPosition */); - setupCaptionColor(taskInfo, windowDecoration); } private class CaptionTouchEventListener implements diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java index 231570f5d90e..349ee0b1fcda 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java @@ -35,7 +35,6 @@ import android.graphics.Insets; import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.GradientDrawable; -import android.graphics.drawable.VectorDrawable; import android.os.Handler; import android.util.Size; import android.view.Choreographer; @@ -310,6 +309,9 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL } private void bindData(View rootView, RunningTaskInfo taskInfo) { + // Set up the tint first so that the drawable can be stylized when loaded. + setupCaptionColor(taskInfo); + final boolean isFullscreen = taskInfo.getWindowingMode() == WindowConfiguration.WINDOWING_MODE_FULLSCREEN; rootView.findViewById(R.id.maximize_window) @@ -317,7 +319,16 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL : R.drawable.decor_maximize_button_dark); } - void setCaptionColor(int captionColor) { + private void setupCaptionColor(RunningTaskInfo taskInfo) { + if (TaskInfoKt.isTransparentCaptionBarAppearance(taskInfo)) { + setCaptionColor(Color.TRANSPARENT); + } else { + final int statusBarColor = taskInfo.taskDescription.getStatusBarColor(); + setCaptionColor(statusBarColor); + } + } + + private void setCaptionColor(int captionColor) { if (mResult.mRootView == null) { return; } @@ -334,20 +345,16 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL caption.getResources().getColorStateList(buttonTintColorRes, null /* theme */); final View back = caption.findViewById(R.id.back_button); - final VectorDrawable backBackground = (VectorDrawable) back.getBackground(); - backBackground.setTintList(buttonTintColor); + back.setBackgroundTintList(buttonTintColor); final View minimize = caption.findViewById(R.id.minimize_window); - final VectorDrawable minimizeBackground = (VectorDrawable) minimize.getBackground(); - minimizeBackground.setTintList(buttonTintColor); + minimize.setBackgroundTintList(buttonTintColor); final View maximize = caption.findViewById(R.id.maximize_window); - final VectorDrawable maximizeBackground = (VectorDrawable) maximize.getBackground(); - maximizeBackground.setTintList(buttonTintColor); + maximize.setBackgroundTintList(buttonTintColor); final View close = caption.findViewById(R.id.close_window); - final VectorDrawable closeBackground = (VectorDrawable) close.getBackground(); - closeBackground.setTintList(buttonTintColor); + close.setBackgroundTintList(buttonTintColor); } boolean isHandlingDragResize() { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java index 457b5112076e..b1cb834db9bf 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java @@ -56,6 +56,7 @@ import android.graphics.Region; import android.hardware.input.InputManager; import android.net.Uri; import android.os.Handler; +import android.os.IBinder; import android.os.Looper; import android.os.RemoteException; import android.os.UserHandle; @@ -100,6 +101,7 @@ import com.android.wm.shell.common.desktopmode.DesktopModeTransitionSource; import com.android.wm.shell.desktopmode.DesktopModeVisualIndicator; import com.android.wm.shell.desktopmode.DesktopTasksController; import com.android.wm.shell.desktopmode.DesktopTasksController.SnapPosition; +import com.android.wm.shell.desktopmode.DesktopTasksLimiter; import com.android.wm.shell.desktopmode.DesktopWallpaperActivity; import com.android.wm.shell.freeform.FreeformTaskTransitionStarter; import com.android.wm.shell.shared.annotations.ShellBackgroundThread; @@ -150,6 +152,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { private final InputManager mInputManager; private final InteractionJankMonitor mInteractionJankMonitor; private final MultiInstanceHelper mMultiInstanceHelper; + private final Optional<DesktopTasksLimiter> mDesktopTasksLimiter; private boolean mTransitionDragActive; private SparseArray<EventReceiver> mEventReceiversByDisplay = new SparseArray<>(); @@ -211,7 +214,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { RootTaskDisplayAreaOrganizer rootTaskDisplayAreaOrganizer, InteractionJankMonitor interactionJankMonitor, AppToWebGenericLinksParser genericLinksParser, - MultiInstanceHelper multiInstanceHelper + MultiInstanceHelper multiInstanceHelper, + Optional<DesktopTasksLimiter> desktopTasksLimiter ) { this( context, @@ -236,7 +240,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { SurfaceControl.Transaction::new, rootTaskDisplayAreaOrganizer, new SparseArray<>(), - interactionJankMonitor); + interactionJankMonitor, + desktopTasksLimiter); } @VisibleForTesting @@ -263,7 +268,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { Supplier<SurfaceControl.Transaction> transactionFactory, RootTaskDisplayAreaOrganizer rootTaskDisplayAreaOrganizer, SparseArray<DesktopModeWindowDecoration> windowDecorByTaskId, - InteractionJankMonitor interactionJankMonitor) { + InteractionJankMonitor interactionJankMonitor, + Optional<DesktopTasksLimiter> desktopTasksLimiter) { mContext = context; mMainExecutor = shellExecutor; mMainHandler = mainHandler; @@ -290,6 +296,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { mSysUIPackageName = mContext.getResources().getString( com.android.internal.R.string.config_systemUi); mInteractionJankMonitor = interactionJankMonitor; + mDesktopTasksLimiter = desktopTasksLimiter; mOnDisplayChangingListener = (displayId, fromRotation, toRotation, displayAreaInfo, t) -> { DesktopModeWindowDecoration decoration; RunningTaskInfo taskInfo; @@ -615,6 +622,12 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { // {@link DesktopModeWindowDecoration#setOnMaximizeOrRestoreClickListener}, which // should shared with the maximize menu's maximize/restore actions. onMaximizeOrRestore(decoration.mTaskInfo.taskId, "caption_bar_button"); + } else if (id == R.id.minimize_window) { + final WindowContainerTransaction wct = new WindowContainerTransaction(); + mDesktopTasksController.onDesktopWindowMinimize(wct, mTaskId); + final IBinder transition = mTaskOperations.minimizeTask(mTaskToken, wct); + mDesktopTasksLimiter.ifPresent(limiter -> + limiter.addPendingMinimizeChange(transition, mDisplayId, mTaskId)); } } @@ -628,7 +641,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { } if (id != R.id.caption_handle && id != R.id.desktop_mode_caption && id != R.id.open_menu_button && id != R.id.close_window - && id != R.id.maximize_window) { + && id != R.id.maximize_window && id != R.id.minimize_window) { return false; } @@ -768,7 +781,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { return true; } final boolean touchingButton = (id == R.id.close_window || id == R.id.maximize_window - || id == R.id.open_menu_button); + || id == R.id.open_menu_button || id == R.id.minimize_window); switch (e.getActionMasked()) { case MotionEvent.ACTION_DOWN: { mDragPointerId = e.getPointerId(0); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java index 75a6cd7b720e..8e87d0ff33c6 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java @@ -643,6 +643,10 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin final RelayoutParams.OccludingCaptionElement controlsElement = new RelayoutParams.OccludingCaptionElement(); controlsElement.mWidthResId = R.dimen.desktop_mode_customizable_caption_margin_end; + if (Flags.enableMinimizeButton()) { + controlsElement.mWidthResId = + R.dimen.desktop_mode_customizable_caption_with_minimize_button_margin_end; + } controlsElement.mAlignment = RelayoutParams.OccludingCaptionElement.Alignment.END; relayoutParams.mOccludingCaptionElements.add(controlsElement); } else if (isAppHandle && !Flags.enableAdditionalWindowsAboveStatusBar()) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskOperations.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskOperations.java index ad238c35dd83..61b93932013c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskOperations.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskOperations.java @@ -23,6 +23,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import android.app.ActivityManager.RunningTaskInfo; import android.content.Context; import android.hardware.input.InputManager; +import android.os.IBinder; import android.os.SystemClock; import android.util.Log; import android.view.InputDevice; @@ -84,13 +85,17 @@ class TaskOperations { } } - void minimizeTask(WindowContainerToken taskToken) { - WindowContainerTransaction wct = new WindowContainerTransaction(); + IBinder minimizeTask(WindowContainerToken taskToken) { + return minimizeTask(taskToken, new WindowContainerTransaction()); + } + + IBinder minimizeTask(WindowContainerToken taskToken, WindowContainerTransaction wct) { wct.reorder(taskToken, false); if (Transitions.ENABLE_SHELL_TRANSITIONS) { - mTransitionStarter.startMinimizedModeTransition(wct); + return mTransitionStarter.startMinimizedModeTransition(wct); } else { mSyncQueue.queue(wct); + return null; } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHeaderViewHolder.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHeaderViewHolder.kt index d0eb6da36702..033d69583725 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHeaderViewHolder.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHeaderViewHolder.kt @@ -35,6 +35,7 @@ import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.ui.graphics.toArgb import androidx.core.content.withStyledAttributes +import androidx.core.view.isGone import androidx.core.view.isVisible import com.android.internal.R.attr.materialColorOnSecondaryContainer import com.android.internal.R.attr.materialColorOnSurface @@ -42,6 +43,7 @@ import com.android.internal.R.attr.materialColorSecondaryContainer import com.android.internal.R.attr.materialColorSurfaceContainerHigh import com.android.internal.R.attr.materialColorSurfaceContainerLow import com.android.internal.R.attr.materialColorSurfaceDim +import com.android.window.flags.Flags.enableMinimizeButton import com.android.wm.shell.R import com.android.wm.shell.shared.desktopmode.DesktopModeFlags import com.android.wm.shell.windowdecor.MaximizeButtonView @@ -82,9 +84,9 @@ internal class AppHeaderViewHolder( .getDimensionPixelSize(R.dimen.desktop_mode_header_buttons_ripple_radius) /** - * The app chip, maximize and close button's height extends to the top & bottom edges of the - * header, and their width may be larger than their height. This is by design to increase the - * clickable and hover-able bounds of the view as much as possible. However, to prevent the + * The app chip, minimize, maximize and close button's height extends to the top & bottom edges + * of the header, and their width may be larger than their height. This is by design to increase + * the clickable and hover-able bounds of the view as much as possible. However, to prevent the * ripple drawable from being as large as the views (and asymmetrical), insets are applied to * the background ripple drawable itself to give the appearance of a smaller button * (with padding between itself and the header edges / sibling buttons) but without affecting @@ -94,6 +96,12 @@ internal class AppHeaderViewHolder( vertical = context.resources .getDimensionPixelSize(R.dimen.desktop_mode_header_app_chip_ripple_inset_vertical) ) + private val minimizeDrawableInsets = DrawableInsets( + vertical = context.resources + .getDimensionPixelSize(R.dimen.desktop_mode_header_minimize_ripple_inset_vertical), + horizontal = context.resources + .getDimensionPixelSize(R.dimen.desktop_mode_header_minimize_ripple_inset_horizontal) + ) private val maximizeDrawableInsets = DrawableInsets( vertical = context.resources .getDimensionPixelSize(R.dimen.desktop_mode_header_maximize_ripple_inset_vertical), @@ -115,6 +123,7 @@ internal class AppHeaderViewHolder( private val maximizeButtonView: MaximizeButtonView = rootView.requireViewById(R.id.maximize_button_view) private val maximizeWindowButton: ImageButton = rootView.requireViewById(R.id.maximize_window) + private val minimizeWindowButton: ImageButton = rootView.requireViewById(R.id.minimize_window) private val appNameTextView: TextView = rootView.requireViewById(R.id.application_name) private val appIconImageView: ImageView = rootView.requireViewById(R.id.application_icon) val appNameTextWidth: Int @@ -131,6 +140,8 @@ internal class AppHeaderViewHolder( maximizeWindowButton.setOnGenericMotionListener(onCaptionGenericMotionListener) maximizeWindowButton.onLongClickListener = onLongClickListener closeWindowButton.setOnTouchListener(onCaptionTouchListener) + minimizeWindowButton.setOnClickListener(onCaptionButtonClickListener) + minimizeWindowButton.setOnTouchListener(onCaptionTouchListener) appNameTextView.text = appName appIconImageView.setImageBitmap(appIconBitmap) maximizeButtonView.onHoverAnimationFinishedListener = @@ -157,11 +168,13 @@ internal class AppHeaderViewHolder( val alpha = Color.alpha(color) closeWindowButton.imageTintList = ColorStateList.valueOf(color) maximizeWindowButton.imageTintList = ColorStateList.valueOf(color) + minimizeWindowButton.imageTintList = ColorStateList.valueOf(color) expandMenuButton.imageTintList = ColorStateList.valueOf(color) appNameTextView.isVisible = !taskInfo.isTransparentCaptionBarAppearance appNameTextView.setTextColor(color) appIconImageView.imageAlpha = alpha maximizeWindowButton.imageAlpha = alpha + minimizeWindowButton.imageAlpha = alpha closeWindowButton.imageAlpha = alpha expandMenuButton.imageAlpha = alpha context.withStyledAttributes( @@ -176,8 +189,10 @@ internal class AppHeaderViewHolder( openMenuButton.background = getDrawable(0) maximizeWindowButton.background = getDrawable(1) closeWindowButton.background = getDrawable(1) + minimizeWindowButton.background = getDrawable(1) } maximizeButtonView.setAnimationTints(isDarkMode()) + minimizeWindowButton.isGone = !enableMinimizeButton() } private fun bindDataWithThemedHeaders(taskInfo: RunningTaskInfo) { @@ -212,6 +227,16 @@ internal class AppHeaderViewHolder( } appIconImageView.imageAlpha = foregroundAlpha } + // Minimize button. + minimizeWindowButton.apply { + imageTintList = colorStateList + background = createRippleDrawable( + color = foregroundColor, + cornerRadius = headerButtonsRippleRadius, + drawableInsets = minimizeDrawableInsets + ) + } + minimizeWindowButton.isGone = !enableMinimizeButton() // Maximize button. maximizeButtonView.setAnimationTints( darkMode = header.appTheme == Theme.DARK, diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeLoggerTransitionObserverTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeLoggerTransitionObserverTest.kt index d4596396840e..74fc7b09a654 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeLoggerTransitionObserverTest.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeLoggerTransitionObserverTest.kt @@ -349,6 +349,47 @@ class DesktopModeLoggerTransitionObserverTest : ShellTestCase() { } @Test + fun transitBack_previousExitReasonScreenOff_logTaskAddedAndEnterReasonScreenOn() { + val freeformTask = createTaskInfo(WINDOWING_MODE_FREEFORM) + // Previous Exit reason recorded as Screen Off + val sessionId = 1 + transitionObserver.addTaskInfosToCachedMap(freeformTask) + transitionObserver.setLoggerSessionId(sessionId) + callOnTransitionReady(TransitionInfoBuilder(TRANSIT_SLEEP).build()) + verifyTaskRemovedAndExitLogging(sessionId, ExitReason.SCREEN_OFF, DEFAULT_TASK_UPDATE) + // Enter desktop through back transition, this happens when user enters after dismissing + // keyguard + val change = createChange(TRANSIT_TO_FRONT, freeformTask) + val transitionInfo = TransitionInfoBuilder(TRANSIT_TO_BACK, 0).addChange(change).build() + + callOnTransitionReady(transitionInfo) + + verifyTaskAddedAndEnterLogging(EnterReason.SCREEN_ON, DEFAULT_TASK_UPDATE) + } + + @Test + fun transitEndDragToDesktop_previousExitReasonScreenOff_logTaskAddedAndEnterReasonAppDrag() { + val freeformTask = createTaskInfo(WINDOWING_MODE_FREEFORM) + // Previous Exit reason recorded as Screen Off + val sessionId = 1 + transitionObserver.addTaskInfosToCachedMap(freeformTask) + transitionObserver.setLoggerSessionId(sessionId) + callOnTransitionReady(TransitionInfoBuilder(TRANSIT_SLEEP).build()) + verifyTaskRemovedAndExitLogging(sessionId, ExitReason.SCREEN_OFF, DEFAULT_TASK_UPDATE) + + // Enter desktop through app handle drag. This represents cases where instead of moving to + // desktop right after turning the screen on, we move to fullscreen then move another task + // to desktop + val transitionInfo = + TransitionInfoBuilder(Transitions.TRANSIT_DESKTOP_MODE_END_DRAG_TO_DESKTOP, 0) + .addChange(createChange(TRANSIT_TO_FRONT, freeformTask)) + .build() + callOnTransitionReady(transitionInfo) + + verifyTaskAddedAndEnterLogging(EnterReason.APP_HANDLE_DRAG, DEFAULT_TASK_UPDATE) + } + + @Test fun transitSleep_logTaskRemovedAndExitReasonScreenOff_sessionIdNull() { val sessionId = 1 // add a freeform task @@ -674,7 +715,7 @@ class DesktopModeLoggerTransitionObserverTest : ShellTestCase() { ) = ActivityManager.RunningTaskInfo().apply { taskId = id - userId = uid + effectiveUid = uid configuration.windowConfiguration.apply { windowingMode = windowMode positionInParent = Point(taskX, taskY) diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt index a841e168af18..2e0af273f2b6 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt @@ -1429,6 +1429,78 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test + fun onDesktopWindowMinimize_noActiveTask_doesntUpdateTransaction() { + val wct = WindowContainerTransaction() + controller.onDesktopWindowMinimize(wct, taskId = 1) + // Nothing happens. + assertThat(wct.hierarchyOps).isEmpty() + } + + @Test + fun onDesktopWindowMinimize_singleActiveTask_noWallpaperActivityToken_doesntUpdateTransaction() { + val task = setUpFreeformTask() + val wct = WindowContainerTransaction() + controller.onDesktopWindowMinimize(wct, taskId = task.taskId) + // Nothing happens. + assertThat(wct.hierarchyOps).isEmpty() + } + + @Test + fun onDesktopWindowMinimize_singleActiveTask_hasWallpaperActivityToken_removesWallpaper() { + val task = setUpFreeformTask() + val wallpaperToken = MockToken().token() + taskRepository.wallpaperActivityToken = wallpaperToken + + val wct = WindowContainerTransaction() + // The only active task is being minimized. + controller.onDesktopWindowMinimize(wct, taskId = task.taskId) + // Adds remove wallpaper operation + wct.assertRemoveAt(index = 0, wallpaperToken) + } + + @Test + fun onDesktopWindowMinimize_singleActiveTask_alreadyMinimized_doesntUpdateTransaction() { + val task = setUpFreeformTask() + val wallpaperToken = MockToken().token() + taskRepository.wallpaperActivityToken = wallpaperToken + taskRepository.minimizeTask(DEFAULT_DISPLAY, task.taskId) + + val wct = WindowContainerTransaction() + // The only active task is already minimized. + controller.onDesktopWindowMinimize(wct, taskId = task.taskId) + // Doesn't modify transaction + assertThat(wct.hierarchyOps).isEmpty() + } + + @Test + fun onDesktopWindowMinimize_multipleActiveTasks_doesntUpdateTransaction() { + val task1 = setUpFreeformTask() + setUpFreeformTask() + val wallpaperToken = MockToken().token() + taskRepository.wallpaperActivityToken = wallpaperToken + + val wct = WindowContainerTransaction() + controller.onDesktopWindowMinimize(wct, taskId = task1.taskId) + // Doesn't modify transaction + assertThat(wct.hierarchyOps).isEmpty() + } + + @Test + fun onDesktopWindowMinimize_multipleActiveTasks_minimizesTheOnlyVisibleTask_removesWallpaper() { + val task1 = setUpFreeformTask() + val task2 = setUpFreeformTask() + val wallpaperToken = MockToken().token() + taskRepository.wallpaperActivityToken = wallpaperToken + taskRepository.minimizeTask(DEFAULT_DISPLAY, task2.taskId) + + val wct = WindowContainerTransaction() + // task1 is the only visible task as task2 is minimized. + controller.onDesktopWindowMinimize(wct, taskId = task1.taskId) + // Adds remove wallpaper operation + wct.assertRemoveAt(index = 0, wallpaperToken) + } + + @Test fun handleRequest_fullscreenTask_freeformVisible_returnSwitchToFreeformWCT() { assumeTrue(ENABLE_SHELL_TRANSITIONS) diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt index 4d6b3b907a65..f7ac3e416938 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt @@ -82,6 +82,7 @@ import com.android.wm.shell.common.SyncTransactionQueue import com.android.wm.shell.common.desktopmode.DesktopModeTransitionSource import com.android.wm.shell.desktopmode.DesktopTasksController import com.android.wm.shell.desktopmode.DesktopTasksController.SnapPosition +import com.android.wm.shell.desktopmode.DesktopTasksLimiter import com.android.wm.shell.freeform.FreeformTaskTransitionStarter import com.android.wm.shell.shared.desktopmode.DesktopModeStatus import com.android.wm.shell.splitscreen.SplitScreenController @@ -112,6 +113,7 @@ import org.mockito.Mockito.never import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.kotlin.any +import org.mockito.kotlin.anyOrNull import org.mockito.kotlin.argThat import org.mockito.kotlin.argumentCaptor import org.mockito.kotlin.doNothing @@ -163,6 +165,8 @@ class DesktopModeWindowDecorViewModelTests : ShellTestCase() { @Mock private lateinit var mockToast: Toast private val bgExecutor = TestShellExecutor() @Mock private lateinit var mockMultiInstanceHelper: MultiInstanceHelper + @Mock private lateinit var mockTasksLimiter: DesktopTasksLimiter + @Mock private lateinit var mockFreeformTaskTransitionStarter: FreeformTaskTransitionStarter private lateinit var spyContext: TestableContext private val transactionFactory = Supplier<SurfaceControl.Transaction> { @@ -215,7 +219,8 @@ class DesktopModeWindowDecorViewModelTests : ShellTestCase() { transactionFactory, mockRootTaskDisplayAreaOrganizer, windowDecorByTaskIdSpy, - mockInteractionJankMonitor + mockInteractionJankMonitor, + Optional.of(mockTasksLimiter) ) desktopModeWindowDecorViewModel.setSplitScreenController(mockSplitScreenController) whenever(mockDisplayController.getDisplayLayout(any())).thenReturn(mockDisplayLayout) @@ -346,9 +351,8 @@ class DesktopModeWindowDecorViewModelTests : ShellTestCase() { val inputManager = mock(InputManager::class.java) spyContext.addMockSystemService(InputManager::class.java, inputManager) - val freeformTaskTransitionStarter = mock(FreeformTaskTransitionStarter::class.java) desktopModeWindowDecorViewModel - .setFreeformTaskTransitionStarter(freeformTaskTransitionStarter) + .setFreeformTaskTransitionStarter(mockFreeformTaskTransitionStarter) onClickListener.onClick(view) @@ -371,14 +375,13 @@ class DesktopModeWindowDecorViewModelTests : ShellTestCase() { val view = mock(View::class.java) whenever(view.id).thenReturn(R.id.close_window) - val freeformTaskTransitionStarter = mock(FreeformTaskTransitionStarter::class.java) desktopModeWindowDecorViewModel - .setFreeformTaskTransitionStarter(freeformTaskTransitionStarter) + .setFreeformTaskTransitionStarter(mockFreeformTaskTransitionStarter) onClickListenerCaptor.value.onClick(view) val transactionCaptor = argumentCaptor<WindowContainerTransaction>() - verify(freeformTaskTransitionStarter).startRemoveTransition(transactionCaptor.capture()) + verify(mockFreeformTaskTransitionStarter).startRemoveTransition(transactionCaptor.capture()) val wct = transactionCaptor.firstValue assertEquals(1, wct.getHierarchyOps().size) @@ -388,6 +391,38 @@ class DesktopModeWindowDecorViewModelTests : ShellTestCase() { } @Test + @EnableFlags(Flags.FLAG_ENABLE_MINIMIZE_BUTTON) + fun testMinimizeButtonInFreefrom_minimizeWindow() { + val onClickListenerCaptor = forClass(View.OnClickListener::class.java) + as ArgumentCaptor<View.OnClickListener> + val decor = createOpenTaskDecoration( + windowingMode = WINDOWING_MODE_FREEFORM, + onCaptionButtonClickListener = onClickListenerCaptor + ) + + val view = mock(View::class.java) + whenever(view.id).thenReturn(R.id.minimize_window) + + desktopModeWindowDecorViewModel + .setFreeformTaskTransitionStarter(mockFreeformTaskTransitionStarter) + + onClickListenerCaptor.value.onClick(view) + + val transactionCaptor = argumentCaptor<WindowContainerTransaction>() + verify(mockFreeformTaskTransitionStarter) + .startMinimizedModeTransition(transactionCaptor.capture()) + val wct = transactionCaptor.firstValue + + verify(mockTasksLimiter).addPendingMinimizeChange( + anyOrNull(), eq(DEFAULT_DISPLAY), eq(decor.mTaskInfo.taskId)) + + assertEquals(1, wct.getHierarchyOps().size) + assertEquals(HierarchyOp.HIERARCHY_OP_TYPE_REORDER, wct.getHierarchyOps().get(0).getType()) + assertFalse(wct.getHierarchyOps().get(0).getToTop()) + assertEquals(decor.mTaskInfo.token.asBinder(), wct.getHierarchyOps().get(0).getContainer()) + } + + @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY) fun testDecorationIsCreatedForTopTranslucentActivitiesWithStyleFloating() { val task = createTask(windowingMode = WINDOWING_MODE_FULLSCREEN, focused = true).apply { diff --git a/nfc/api/system-current.txt b/nfc/api/system-current.txt index 2ff9829ddfd7..25a01b9c1b8d 100644 --- a/nfc/api/system-current.txt +++ b/nfc/api/system-current.txt @@ -62,10 +62,29 @@ package android.nfc { method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void registerCallback(@NonNull java.util.concurrent.Executor, @NonNull android.nfc.NfcOemExtension.Callback); method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void synchronizeScreenState(); method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void unregisterCallback(@NonNull android.nfc.NfcOemExtension.Callback); + field public static final int HCE_ACTIVATE = 1; // 0x1 + field public static final int HCE_DATA_TRANSFERRED = 2; // 0x2 + field public static final int HCE_DEACTIVATE = 3; // 0x3 + field public static final int STATUS_OK = 0; // 0x0 + field public static final int STATUS_UNKNOWN_ERROR = 1; // 0x1 } public static interface NfcOemExtension.Callback { + method public void onApplyRouting(@NonNull java.util.function.Consumer<java.lang.Boolean>); + method public void onBootFinished(int); + method public void onBootStarted(); + method public void onDisable(@NonNull java.util.function.Consumer<java.lang.Boolean>); + method public void onDisableFinished(int); + method public void onDisableStarted(); + method public void onEnable(@NonNull java.util.function.Consumer<java.lang.Boolean>); + method public void onEnableFinished(int); + method public void onEnableStarted(); + method public void onHceEventReceived(int); + method public void onNdefRead(@NonNull java.util.function.Consumer<java.lang.Boolean>); + method public void onRoutingChanged(); + method public void onStateUpdated(int); method public void onTagConnected(boolean, @NonNull android.nfc.Tag); + method public void onTagDispatch(@NonNull java.util.function.Consumer<java.lang.Boolean>); } } diff --git a/nfc/api/system-lint-baseline.txt b/nfc/api/system-lint-baseline.txt index 761c8e63df81..c7a618125add 100644 --- a/nfc/api/system-lint-baseline.txt +++ b/nfc/api/system-lint-baseline.txt @@ -9,6 +9,18 @@ BroadcastBehavior: android.nfc.NfcAdapter#ACTION_TRANSACTION_DETECTED: Field 'ACTION_TRANSACTION_DETECTED' is missing @BroadcastBehavior +CallbackMethodName: android.nfc.NfcOemExtension.Callback#shouldSkipRoutingChange(): + Callback method names must follow the on<Something> style: shouldSkipRoutingChange + + +MethodNameTense: android.nfc.NfcOemExtension.Callback#onEnable(): + Unexpected tense; probably meant `enabled`, was `onEnable` + + +MissingNullability: android.nfc.cardemulation.CardEmulation#overrideRoutingTable(android.app.Activity, String, String) parameter #1: + Missing nullability on parameter `protocol` in method `overrideRoutingTable` +MissingNullability: android.nfc.cardemulation.CardEmulation#overrideRoutingTable(android.app.Activity, String, String) parameter #2: + Missing nullability on parameter `technology` in method `overrideRoutingTable` MissingNullability: android.nfc.cardemulation.OffHostApduService#onBind(android.content.Intent): Missing nullability on method `onBind` return MissingNullability: android.nfc.cardemulation.OffHostApduService#onBind(android.content.Intent) parameter #0: @@ -96,10 +108,12 @@ RequiresPermission: android.nfc.tech.TagTechnology#close(): RequiresPermission: android.nfc.tech.TagTechnology#connect(): Method 'connect' documentation mentions permissions without declaring @RequiresPermission + SamShouldBeLast: android.nfc.NfcAdapter#enableReaderMode(android.app.Activity, android.nfc.NfcAdapter.ReaderCallback, int, android.os.Bundle): SAM-compatible parameters (such as parameter 2, "callback", in android.nfc.NfcAdapter.enableReaderMode) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions SamShouldBeLast: android.nfc.NfcAdapter#ignore(android.nfc.Tag, int, android.nfc.NfcAdapter.OnTagRemovedListener, android.os.Handler): SAM-compatible parameters (such as parameter 3, "tagRemovedListener", in android.nfc.NfcAdapter.ignore) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions + SdkConstant: android.nfc.NfcAdapter#ACTION_REQUIRE_UNLOCK_FOR_NFC: Field 'ACTION_REQUIRE_UNLOCK_FOR_NFC' is missing @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) diff --git a/nfc/java/android/nfc/INfcOemExtensionCallback.aidl b/nfc/java/android/nfc/INfcOemExtensionCallback.aidl index 6c9096d5d03e..c19a44ba0ff1 100644 --- a/nfc/java/android/nfc/INfcOemExtensionCallback.aidl +++ b/nfc/java/android/nfc/INfcOemExtensionCallback.aidl @@ -16,10 +16,25 @@ package android.nfc; import android.nfc.Tag; +import android.os.ResultReceiver; /** * @hide */ interface INfcOemExtensionCallback { void onTagConnected(boolean connected, in Tag tag); + void onStateUpdated(int state); + void onApplyRouting(in ResultReceiver isSkipped); + void onNdefRead(in ResultReceiver isSkipped); + void onEnable(in ResultReceiver isAllowed); + void onDisable(in ResultReceiver isAllowed); + void onBootStarted(); + void onEnableStarted(); + void onDisableStarted(); + void onBootFinished(int status); + void onEnableFinished(int status); + void onDisableFinished(int status); + void onTagDispatch(in ResultReceiver isSkipped); + void onRoutingChanged(); + void onHceEventReceived(int action); } diff --git a/nfc/java/android/nfc/NfcOemExtension.java b/nfc/java/android/nfc/NfcOemExtension.java index 204ba9fbefad..6c02edd0eafa 100644 --- a/nfc/java/android/nfc/NfcOemExtension.java +++ b/nfc/java/android/nfc/NfcOemExtension.java @@ -18,17 +18,31 @@ package android.nfc; import android.annotation.CallbackExecutor; import android.annotation.FlaggedApi; +import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.RequiresPermission; +import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.content.Context; import android.os.Binder; import android.os.RemoteException; +import android.os.ResultReceiver; import android.util.Log; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; /** * Used for OEM extension APIs. @@ -50,6 +64,52 @@ public final class NfcOemExtension { private final Object mLock = new Object(); /** + * Event that Host Card Emulation is activated. + */ + public static final int HCE_ACTIVATE = 1; + /** + * Event that some data is transferred in Host Card Emulation. + */ + public static final int HCE_DATA_TRANSFERRED = 2; + /** + * Event that Host Card Emulation is deactivated. + */ + public static final int HCE_DEACTIVATE = 3; + /** + * Possible events from {@link Callback#onHceEventReceived}. + * + * @hide + */ + @IntDef(value = { + HCE_ACTIVATE, + HCE_DATA_TRANSFERRED, + HCE_DEACTIVATE + }) + @Retention(RetentionPolicy.SOURCE) + public @interface HostCardEmulationAction {} + + /** + * Status OK + */ + public static final int STATUS_OK = 0; + /** + * Status unknown error + */ + public static final int STATUS_UNKNOWN_ERROR = 1; + + /** + * Status codes passed to OEM extension callbacks. + * + * @hide + */ + @IntDef(value = { + STATUS_OK, + STATUS_UNKNOWN_ERROR + }) + @Retention(RetentionPolicy.SOURCE) + public @interface StatusCode {} + + /** * Interface for Oem extensions for NFC. */ public interface Callback { @@ -61,21 +121,114 @@ public final class NfcOemExtension { * @param tag Tag details */ void onTagConnected(boolean connected, @NonNull Tag tag); + + /** + * Update the Nfc Adapter State + * @param state new state that need to be updated + */ + void onStateUpdated(@NfcAdapter.AdapterState int state); + /** + * Check if NfcService apply routing method need to be skipped for + * some feature. + * @param isSkipped The {@link Consumer} to be completed. If apply routing can be skipped, + * the {@link Consumer#accept(Object)} should be called with + * {@link Boolean#TRUE}, otherwise call with {@link Boolean#FALSE}. + */ + void onApplyRouting(@NonNull Consumer<Boolean> isSkipped); + /** + * Check if NfcService ndefRead method need to be skipped To skip + * and start checking for presence of tag + * @param isSkipped The {@link Consumer} to be completed. If Ndef read can be skipped, + * the {@link Consumer#accept(Object)} should be called with + * {@link Boolean#TRUE}, otherwise call with {@link Boolean#FALSE}. + */ + void onNdefRead(@NonNull Consumer<Boolean> isSkipped); + /** + * Method to check if Nfc is allowed to be enabled by OEMs. + * @param isAllowed The {@link Consumer} to be completed. If enabling NFC is allowed, + * the {@link Consumer#accept(Object)} should be called with + * {@link Boolean#TRUE}, otherwise call with {@link Boolean#FALSE}. + * false if NFC cannot be enabled at this time. + */ + @SuppressLint("MethodNameTense") + void onEnable(@NonNull Consumer<Boolean> isAllowed); + /** + * Method to check if Nfc is allowed to be disabled by OEMs. + * @param isAllowed The {@link Consumer} to be completed. If disabling NFC is allowed, + * the {@link Consumer#accept(Object)} should be called with + * {@link Boolean#TRUE}, otherwise call with {@link Boolean#FALSE}. + * false if NFC cannot be disabled at this time. + */ + void onDisable(@NonNull Consumer<Boolean> isAllowed); + + /** + * Callback to indicate that Nfc starts to boot. + */ + void onBootStarted(); + + /** + * Callback to indicate that Nfc starts to enable. + */ + void onEnableStarted(); + + /** + * Callback to indicate that Nfc starts to enable. + */ + void onDisableStarted(); + + /** + * Callback to indicate if NFC boots successfully or not. + * @param status the status code indicating if boot finished successfully + */ + void onBootFinished(@StatusCode int status); + + /** + * Callback to indicate if NFC is successfully enabled. + * @param status the status code indicating if enable finished successfully + */ + void onEnableFinished(@StatusCode int status); + + /** + * Callback to indicate if NFC is successfully disabled. + * @param status the status code indicating if disable finished successfully + */ + void onDisableFinished(@StatusCode int status); + + /** + * Check if NfcService tag dispatch need to be skipped. + * @param isSkipped The {@link Consumer} to be completed. If tag dispatch can be skipped, + * the {@link Consumer#accept(Object)} should be called with + * {@link Boolean#TRUE}, otherwise call with {@link Boolean#FALSE}. + */ + void onTagDispatch(@NonNull Consumer<Boolean> isSkipped); + + /** + * Notifies routing configuration is changed. + */ + void onRoutingChanged(); + + /** + * API to activate start stop cpu boost on hce event. + * + * <p>When HCE is activated, transferring data, and deactivated, + * must call this method to activate, start and stop cpu boost respectively. + * @param action Flag indicating actions to activate, start and stop cpu boost. + */ + void onHceEventReceived(@HostCardEmulationAction int action); } /** * Constructor to be used only by {@link NfcAdapter}. - * @hide */ - public NfcOemExtension(@NonNull Context context, @NonNull NfcAdapter adapter) { + NfcOemExtension(@NonNull Context context, @NonNull NfcAdapter adapter) { mContext = context; mAdapter = adapter; mOemNfcExtensionCallback = new NfcOemExtensionCallback(); } /** - * Register an {@link Callback} to listen for UWB oem extension callbacks + * Register an {@link Callback} to listen for NFC oem extension callbacks * <p>The provided callback will be invoked by the given {@link Executor}. * * @param executor an {@link Executor} to execute given callback @@ -183,5 +336,162 @@ public final class NfcOemExtension { } } } + @Override + public void onStateUpdated(int state) throws RemoteException { + handleVoidCallback(state, mCallback::onStateUpdated); + } + @Override + public void onApplyRouting(ResultReceiver isSkipped) throws RemoteException { + handleVoidCallback( + new ReceiverWrapper(isSkipped), mCallback::onApplyRouting); + } + @Override + public void onNdefRead(ResultReceiver isSkipped) throws RemoteException { + handleVoidCallback( + new ReceiverWrapper(isSkipped), mCallback::onNdefRead); + } + @Override + public void onEnable(ResultReceiver isAllowed) throws RemoteException { + handleVoidCallback( + new ReceiverWrapper(isAllowed), mCallback::onEnable); + } + @Override + public void onDisable(ResultReceiver isAllowed) throws RemoteException { + handleVoidCallback( + new ReceiverWrapper(isAllowed), mCallback::onDisable); + } + @Override + public void onBootStarted() throws RemoteException { + handleVoidCallback(null, (Object input) -> mCallback.onBootStarted()); + } + @Override + public void onEnableStarted() throws RemoteException { + handleVoidCallback(null, (Object input) -> mCallback.onEnableStarted()); + } + @Override + public void onDisableStarted() throws RemoteException { + handleVoidCallback(null, (Object input) -> mCallback.onDisableStarted()); + } + @Override + public void onBootFinished(int status) throws RemoteException { + handleVoidCallback(status, mCallback::onBootFinished); + } + @Override + public void onEnableFinished(int status) throws RemoteException { + handleVoidCallback(status, mCallback::onEnableFinished); + } + @Override + public void onDisableFinished(int status) throws RemoteException { + handleVoidCallback(status, mCallback::onDisableFinished); + } + @Override + public void onTagDispatch(ResultReceiver isSkipped) throws RemoteException { + handleVoidCallback( + new ReceiverWrapper(isSkipped), mCallback::onTagDispatch); + } + @Override + public void onRoutingChanged() throws RemoteException { + handleVoidCallback(null, (Object input) -> mCallback.onRoutingChanged()); + } + @Override + public void onHceEventReceived(int action) throws RemoteException { + handleVoidCallback(action, mCallback::onHceEventReceived); + } + + private <T> void handleVoidCallback(T input, Consumer<T> callbackMethod) { + synchronized (mLock) { + if (mCallback == null || mExecutor == null) { + return; + } + final long identity = Binder.clearCallingIdentity(); + try { + mExecutor.execute(() -> callbackMethod.accept(input)); + } finally { + Binder.restoreCallingIdentity(identity); + } + } + } + + private <S, T> S handleNonVoidCallbackWithInput( + S defaultValue, T input, Function<T, S> callbackMethod) throws RemoteException { + synchronized (mLock) { + if (mCallback == null) { + return defaultValue; + } + final long identity = Binder.clearCallingIdentity(); + S result = defaultValue; + try { + ExecutorService executor = Executors.newSingleThreadExecutor(); + FutureTask<S> futureTask = new FutureTask<>( + () -> callbackMethod.apply(input) + ); + executor.submit(futureTask); + try { + result = futureTask.get( + OEM_EXTENSION_RESPONSE_THRESHOLD_MS, TimeUnit.MILLISECONDS); + } catch (ExecutionException | InterruptedException e) { + e.printStackTrace(); + } catch (TimeoutException e) { + Log.w(TAG, "Callback timed out: " + callbackMethod); + e.printStackTrace(); + } finally { + executor.shutdown(); + } + } finally { + Binder.restoreCallingIdentity(identity); + } + return result; + } + } + + private <T> T handleNonVoidCallbackWithoutInput(T defaultValue, Supplier<T> callbackMethod) + throws RemoteException { + synchronized (mLock) { + if (mCallback == null) { + return defaultValue; + } + final long identity = Binder.clearCallingIdentity(); + T result = defaultValue; + try { + ExecutorService executor = Executors.newSingleThreadExecutor(); + FutureTask<T> futureTask = new FutureTask<>( + callbackMethod::get + ); + executor.submit(futureTask); + try { + result = futureTask.get( + OEM_EXTENSION_RESPONSE_THRESHOLD_MS, TimeUnit.MILLISECONDS); + } catch (ExecutionException | InterruptedException e) { + e.printStackTrace(); + } catch (TimeoutException e) { + Log.w(TAG, "Callback timed out: " + callbackMethod); + e.printStackTrace(); + } finally { + executor.shutdown(); + } + } finally { + Binder.restoreCallingIdentity(identity); + } + return result; + } + } + } + + private class ReceiverWrapper implements Consumer<Boolean> { + private final ResultReceiver mResultReceiver; + + ReceiverWrapper(ResultReceiver resultReceiver) { + mResultReceiver = resultReceiver; + } + + @Override + public void accept(Boolean result) { + mResultReceiver.send(result ? 1 : 0, null); + } + + @Override + public Consumer<Boolean> andThen(Consumer<? super Boolean> after) { + return Consumer.super.andThen(after); + } } } diff --git a/packages/SettingsLib/src/com/android/settingslib/notification/data/repository/FakeZenModeRepository.kt b/packages/SettingsLib/src/com/android/settingslib/notification/data/repository/FakeZenModeRepository.kt index e5d79a1b4aca..4371f05ead9f 100644 --- a/packages/SettingsLib/src/com/android/settingslib/notification/data/repository/FakeZenModeRepository.kt +++ b/packages/SettingsLib/src/com/android/settingslib/notification/data/repository/FakeZenModeRepository.kt @@ -16,6 +16,7 @@ package com.android.settingslib.notification.data.repository +import android.app.AutomaticZenRule import android.app.NotificationManager import android.provider.Settings import com.android.settingslib.notification.modes.TestModeBuilder @@ -58,8 +59,9 @@ class FakeZenModeRepository : ZenModeRepository { mutableModesFlow.value += zenModes } - fun addMode(id: String, active: Boolean = false) { - mutableModesFlow.value += newMode(id, active) + fun addMode(id: String, @AutomaticZenRule.Type type: Int = AutomaticZenRule.TYPE_UNKNOWN, + active: Boolean = false) { + mutableModesFlow.value += newMode(id, type, active) } fun removeMode(id: String) { @@ -128,6 +130,6 @@ fun FakeZenModeRepository.updateNotificationPolicy( ) ) -private fun newMode(id: String, active: Boolean = false): ZenMode { - return TestModeBuilder().setId(id).setName("Mode $id").setActive(active).build() +private fun newMode(id: String, @AutomaticZenRule.Type type: Int, active: Boolean): ZenMode { + return TestModeBuilder().setId(id).setName("Mode $id").setType(type).setActive(active).build() } diff --git a/packages/SettingsLib/src/com/android/settingslib/notification/modes/ZenMode.java b/packages/SettingsLib/src/com/android/settingslib/notification/modes/ZenMode.java index c13b2612d37e..d36b55f8961a 100644 --- a/packages/SettingsLib/src/com/android/settingslib/notification/modes/ZenMode.java +++ b/packages/SettingsLib/src/com/android/settingslib/notification/modes/ZenMode.java @@ -112,7 +112,7 @@ public class ZenMode implements Parcelable { }; // Manual DND first, Bedtime/Driving, then alphabetically. - static final Comparator<ZenMode> PRIORITIZING_COMPARATOR = Comparator + public static final Comparator<ZenMode> PRIORITIZING_COMPARATOR = Comparator .comparing(ZenMode::isManualDnd).reversed() .thenComparing(ZenMode::getType, PRIORITIZED_TYPE_COMPARATOR) .thenComparing(ZenMode::getName); diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt index 8751ca761e07..39fc7ef53235 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt @@ -2,6 +2,7 @@ package com.android.systemui.scene.ui.composable import androidx.compose.foundation.gestures.Orientation import com.android.compose.animation.scene.Edge +import com.android.compose.animation.scene.ProgressConverter import com.android.compose.animation.scene.transitions import com.android.systemui.bouncer.ui.composable.Bouncer import com.android.systemui.notifications.ui.composable.Notifications @@ -41,6 +42,9 @@ import com.android.systemui.shade.ui.composable.Shade */ val SceneContainerTransitions = transitions { + // Overscroll progress starts linearly with some resistance (3f) and slowly approaches 0.2f + defaultOverscrollProgressConverter = ProgressConverter.tanh(maxProgress = 0.2f, tilt = 3f) + // Scene transitions from(Scenes.Bouncer, to = Scenes.Gone) { bouncerToGoneTransition() } diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt index 9c3896b90124..83db7248f9dd 100644 --- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt +++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt @@ -1024,10 +1024,6 @@ internal class NestedScrollHandlerImpl( val canStart = when (behavior) { - NestedScrollBehavior.DuringTransitionBetweenScenes -> { - canChangeScene = false // unused: added for consistency - false - } NestedScrollBehavior.EdgeNoPreview -> { canChangeScene = isZeroOffset isZeroOffset && hasNextScene(offsetAvailable) diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/NestedScrollToScene.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/NestedScrollToScene.kt index 945043d8fe95..8a0e4627d10c 100644 --- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/NestedScrollToScene.kt +++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/NestedScrollToScene.kt @@ -35,13 +35,6 @@ import androidx.compose.ui.platform.InspectorInfo */ enum class NestedScrollBehavior(val canStartOnPostFling: Boolean) { /** - * During scene transitions, if we are within - * [SceneTransitionLayoutImpl.transitionInterceptionThreshold], the [SceneTransitionLayout] - * consumes scroll events instead of the scrollable component. - */ - DuringTransitionBetweenScenes(canStartOnPostFling = false), - - /** * Overscroll will only be used by the [SceneTransitionLayout] to move to the next scene if the * gesture begins at the edge of the scrollable component (so that a scroll in that direction * can no longer be consumed). If the gesture is partially consumed by the scrollable component, diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt index dc5b2f78180f..6360f852de57 100644 --- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt +++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt @@ -28,7 +28,6 @@ import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.Velocity import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.android.compose.animation.scene.NestedScrollBehavior.DuringTransitionBetweenScenes import com.android.compose.animation.scene.NestedScrollBehavior.EdgeAlways import com.android.compose.animation.scene.NestedScrollBehavior.EdgeNoPreview import com.android.compose.animation.scene.NestedScrollBehavior.EdgeWithPreview @@ -730,13 +729,6 @@ class DraggableHandlerTest { } @Test - fun flingAfterScroll_DuringTransitionBetweenScenes_doNothing() = runGestureTest { - flingAfterScroll(use = DuringTransitionBetweenScenes, idleAfterScroll = true) - - assertIdle(currentScene = SceneA) - } - - @Test fun flingAfterScroll_EdgeNoOverscroll_goToNextScene() = runGestureTest { flingAfterScroll(use = EdgeNoPreview, idleAfterScroll = false) @@ -789,13 +781,6 @@ class DraggableHandlerTest { } @Test - fun flingAfterScrollStartedInScene_DuringTransitionBetweenScenes_doNothing() = runGestureTest { - flingAfterScrollStartedInScene(use = DuringTransitionBetweenScenes, idleAfterScroll = true) - - assertIdle(currentScene = SceneA) - } - - @Test fun flingAfterScrollStartedInScene_EdgeNoOverscroll_doNothing() = runGestureTest { flingAfterScrollStartedInScene(use = EdgeNoPreview, idleAfterScroll = true) diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/NestedScrollToSceneTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/NestedScrollToSceneTest.kt index d8a06f54e74b..ccefe3d38937 100644 --- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/NestedScrollToSceneTest.kt +++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/NestedScrollToSceneTest.kt @@ -133,33 +133,6 @@ class NestedScrollToSceneTest { } @Test - fun customizeStlNestedScrollBehavior_DuringTransitionBetweenScenes() { - var canScroll = true - val state = setup2ScenesAndScrollTouchSlop { - Modifier.verticalNestedScrollToScene( - bottomBehavior = NestedScrollBehavior.DuringTransitionBetweenScenes - ) - .scrollable(rememberScrollableState { if (canScroll) it else 0f }, Vertical) - } - - scrollUp(percent = 0.5f) - assertThat(state.transitionState).isIdle() - - // Reach the end of the scrollable element - canScroll = false - scrollUp(percent = 0.5f) - assertThat(state.transitionState).isIdle() - - pointerUp() - assertThat(state.transitionState).isIdle() - - // Start a new gesture - pointerDownAndScrollTouchSlop() - scrollUp(percent = 0.5f) - assertThat(state.transitionState).isIdle() - } - - @Test fun customizeStlNestedScrollBehavior_EdgeNoPreview() { var canScroll = true val state = setup2ScenesAndScrollTouchSlop { @@ -253,19 +226,24 @@ class NestedScrollToSceneTest { @Test fun customizeStlNestedScrollBehavior_multipleRequests() { + var canScroll = true val state = setup2ScenesAndScrollTouchSlop { Modifier // This verticalNestedScrollToScene is closer the STL (an ancestor node) .verticalNestedScrollToScene(bottomBehavior = NestedScrollBehavior.EdgeAlways) // Another verticalNestedScrollToScene modifier - .verticalNestedScrollToScene( - bottomBehavior = NestedScrollBehavior.DuringTransitionBetweenScenes - ) - .scrollable(rememberScrollableState { 0f }, Vertical) + .verticalNestedScrollToScene(bottomBehavior = NestedScrollBehavior.EdgeNoPreview) + .scrollable(rememberScrollableState { if (canScroll) it else 0f }, Vertical) } scrollUp(percent = 0.5f) - // EdgeAlways always consume the remaining scroll, DuringTransitionBetweenScenes does not. + assertThat(state.transitionState).isIdle() + + // Reach the end of the scrollable element + canScroll = false + + scrollUp(percent = 0.5f) + // EdgeAlways always consume the remaining scroll, EdgeNoPreview does not. val transition = assertThat(state.transitionState).isTransition() assertThat(transition).hasProgress(0.5f) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthControllerTest.java index 752c93e077ac..b7d99d2754fa 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthControllerTest.java @@ -79,6 +79,7 @@ import android.view.WindowManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; +import com.android.app.viewcapture.ViewCapture; import com.android.internal.R; import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.widget.LockPatternUtils; @@ -96,6 +97,8 @@ import com.android.systemui.util.concurrency.FakeExecution; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; +import dagger.Lazy; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -165,6 +168,8 @@ public class AuthControllerTest extends SysuiTestCase { private PromptViewModel mPromptViewModel; @Mock private UdfpsUtils mUdfpsUtils; + @Mock + private Lazy<ViewCapture> mLazyViewCapture; @Captor private ArgumentCaptor<IFingerprintAuthenticatorsRegisteredCallback> mFpAuthenticatorsRegisteredCaptor; @@ -1060,7 +1065,8 @@ public class AuthControllerTest extends SysuiTestCase { mWakefulnessLifecycle, mUserManager, mLockPatternUtils, () -> mUdfpsLogger, () -> mLogContextInteractor, () -> mPromptSelectionInteractor, () -> mCredentialViewModel, () -> mPromptViewModel, mInteractionJankMonitor, - mHandler, mBackgroundExecutor, mUdfpsUtils, mVibratorHelper); + mHandler, mBackgroundExecutor, mUdfpsUtils, mVibratorHelper, + mLazyViewCapture); } @Override diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt index c44836a70642..620e90dcaa62 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt @@ -117,7 +117,11 @@ class InternetTileMapperTest : SysuiTestCase() { label, activationState, secondaryLabel, - setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK), + setOf( + QSTileState.UserAction.CLICK, + QSTileState.UserAction.TOGGLE_CLICK, + QSTileState.UserAction.LONG_CLICK + ), contentDescription, null, QSTileState.SideViewIcon.Chevron, diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileUserActionInteractorTest.kt index e1f3d97eb35c..52c476ec92cc 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileUserActionInteractorTest.kt @@ -27,6 +27,7 @@ import com.android.systemui.qs.tiles.base.actions.FakeQSTileIntentUserInputHandl import com.android.systemui.qs.tiles.base.actions.QSTileIntentUserInputHandlerSubject import com.android.systemui.qs.tiles.base.interactor.QSTileInputTestKtx import com.android.systemui.qs.tiles.dialog.InternetDialogManager +import com.android.systemui.qs.tiles.dialog.WifiStateWorker import com.android.systemui.qs.tiles.impl.internet.domain.model.InternetTileModel import com.android.systemui.statusbar.connectivity.AccessPointController import com.android.systemui.util.mockito.mock @@ -40,6 +41,8 @@ import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.ArgumentMatchers.eq import org.mockito.Mock import org.mockito.Mockito.verify +import org.mockito.kotlin.times +import org.mockito.kotlin.whenever @SmallTest @EnabledOnRavenwood @@ -51,17 +54,20 @@ class InternetTileUserActionInteractorTest : SysuiTestCase() { private lateinit var underTest: InternetTileUserActionInteractor @Mock private lateinit var internetDialogManager: InternetDialogManager + @Mock private lateinit var wifiStateWorker: WifiStateWorker @Mock private lateinit var controller: AccessPointController @Before fun setup() { internetDialogManager = mock<InternetDialogManager>() + wifiStateWorker = mock<WifiStateWorker>() controller = mock<AccessPointController>() underTest = InternetTileUserActionInteractor( kosmos.testScope.coroutineContext, internetDialogManager, + wifiStateWorker, controller, inputHandler, ) @@ -110,4 +116,24 @@ class InternetTileUserActionInteractorTest : SysuiTestCase() { Truth.assertThat(it.intent.action).isEqualTo(Settings.ACTION_WIFI_SETTINGS) } } + + @Test + fun handleSecondaryClickWhenWifiOn() = + kosmos.testScope.runTest { + whenever(wifiStateWorker.isWifiEnabled).thenReturn(true) + + underTest.handleInput(QSTileInputTestKtx.toggleClick(InternetTileModel.Active())) + + verify(wifiStateWorker, times(1)).isWifiEnabled = eq(false) + } + + @Test + fun handleSecondaryClickWhenWifiOff() = + kosmos.testScope.runTest { + whenever(wifiStateWorker.isWifiEnabled).thenReturn(false) + + underTest.handleInput(QSTileInputTestKtx.toggleClick(InternetTileModel.Inactive())) + + verify(wifiStateWorker, times(1)).isWifiEnabled = eq(true) + } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileDataInteractorTest.kt index 69b8ee10107e..94fa9b9c631b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileDataInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileDataInteractorTest.kt @@ -16,19 +16,24 @@ package com.android.systemui.qs.tiles.impl.modes.domain.interactor +import android.app.AutomaticZenRule import android.app.Flags +import android.graphics.drawable.TestStubDrawable import android.os.UserHandle import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase +import com.android.systemui.common.shared.model.asIcon import com.android.systemui.coroutines.collectValues import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger import com.android.systemui.qs.tiles.impl.modes.domain.model.ModesTileModel +import com.android.systemui.shared.notifications.data.repository.NotificationSettingsRepository import com.android.systemui.statusbar.policy.data.repository.fakeZenModeRepository +import com.android.systemui.statusbar.policy.domain.interactor.ZenModeInteractor import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -36,8 +41,10 @@ import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.toCollection import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest +import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import org.mockito.kotlin.mock @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @@ -48,7 +55,20 @@ class ModesTileDataInteractorTest : SysuiTestCase() { private val dispatcher = kosmos.testDispatcher private val zenModeRepository = kosmos.fakeZenModeRepository - private val underTest = ModesTileDataInteractor(zenModeRepository, dispatcher) + private val underTest = + ModesTileDataInteractor( + context, + ZenModeInteractor(zenModeRepository, mock<NotificationSettingsRepository>()), + dispatcher + ) + + @Before + fun setUp() { + context.orCreateTestableResources.apply { + addOverride(com.android.internal.R.drawable.ic_zen_mode_type_bedtime, BEDTIME_DRAWABLE) + addOverride(com.android.internal.R.drawable.ic_zen_mode_type_driving, DRIVING_DRAWABLE) + } + } @EnableFlags(Flags.FLAG_MODES_UI) @Test @@ -110,8 +130,62 @@ class ModesTileDataInteractorTest : SysuiTestCase() { assertThat(dataList.map { it.activeModes }.last()).isEmpty() } - private companion object { + @Test + @EnableFlags(Flags.FLAG_MODES_UI, Flags.FLAG_MODES_UI_ICONS) + fun changesIconWhenActiveModesChange() = + testScope.runTest { + val dataList: List<ModesTileModel> by + collectValues( + underTest.tileData(TEST_USER, flowOf(DataUpdateTrigger.InitialRequest)) + ) + runCurrent() + assertThat(dataList.map { it.icon }).containsExactly(null).inOrder() + + // Add an inactive mode: state hasn't changed, so this shouldn't cause another emission + zenModeRepository.addMode(id = "Mode", active = false) + runCurrent() + assertThat(dataList.map { it.icon }).containsExactly(null).inOrder() + // Add an active mode: icon should be the mode icon + zenModeRepository.addMode( + id = "Bedtime", + type = AutomaticZenRule.TYPE_BEDTIME, + active = true + ) + runCurrent() + assertThat(dataList.map { it.icon }).containsExactly(null, BEDTIME_ICON).inOrder() + + // Add another, less-prioritized mode: icon should remain the first mode icon + zenModeRepository.addMode( + id = "Driving", + type = AutomaticZenRule.TYPE_DRIVING, + active = true + ) + runCurrent() + assertThat(dataList.map { it.icon }) + .containsExactly(null, BEDTIME_ICON, BEDTIME_ICON) + .inOrder() + + // Deactivate more important mode: icon should be the less important, still active mode. + zenModeRepository.deactivateMode("Bedtime") + runCurrent() + assertThat(dataList.map { it.icon }) + .containsExactly(null, BEDTIME_ICON, BEDTIME_ICON, DRIVING_ICON) + .inOrder() + + // Deactivate remaining mode: no icon + zenModeRepository.deactivateMode("Driving") + runCurrent() + assertThat(dataList.map { it.icon }) + .containsExactly(null, BEDTIME_ICON, BEDTIME_ICON, DRIVING_ICON, null) + .inOrder() + } + + private companion object { val TEST_USER = UserHandle.of(1)!! + val BEDTIME_DRAWABLE = TestStubDrawable("bedtime") + val DRIVING_DRAWABLE = TestStubDrawable("driving") + val BEDTIME_ICON = BEDTIME_DRAWABLE.asIcon() + val DRIVING_ICON = DRIVING_DRAWABLE.asIcon() } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapperTest.kt index dd9711e50779..a41f15d8ff82 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapperTest.kt @@ -16,10 +16,13 @@ package com.android.systemui.qs.tiles.impl.modes.ui +import android.app.Flags import android.graphics.drawable.TestStubDrawable +import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase +import com.android.systemui.common.shared.model.Icon import com.android.systemui.qs.tiles.impl.modes.domain.model.ModesTileModel import com.android.systemui.qs.tiles.viewmodel.QSTileConfigTestBuilder import com.android.systemui.qs.tiles.viewmodel.QSTileState @@ -31,6 +34,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) +@EnableFlags(Flags.FLAG_MODES_UI) class ModesTileMapperTest : SysuiTestCase() { val config = QSTileConfigTestBuilder.build { @@ -85,4 +89,16 @@ class ModesTileMapperTest : SysuiTestCase() { assertThat(state.iconRes).isEqualTo(R.drawable.qs_dnd_icon_on) assertThat(state.secondaryLabel).isEqualTo("3 modes are active") } + + @Test + @EnableFlags(Flags.FLAG_MODES_UI_ICONS) + fun activeState_withIcon() { + val icon = Icon.Resource(1234, contentDescription = null) + val model = ModesTileModel(isActivated = true, activeModes = listOf("DND"), icon = icon) + + val state = underTest.map(config, model) + + assertThat(state.iconRes).isNull() + assertThat(state.icon()).isEqualTo(icon) + } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt index 9122528e5c11..c15a4e5a7889 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt @@ -206,7 +206,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { .that(sceneContainerViewModel.currentScene.value) .isEqualTo(sceneContainerConfig.initialSceneKey) assertWithMessage("Initial scene container visibility mismatch!") - .that(sceneContainerViewModel.isVisible.value) + .that(sceneContainerViewModel.isVisible) .isTrue() } @@ -536,7 +536,6 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { private fun TestScope.emulatePendingTransitionProgress( expectedVisible: Boolean = true, ) { - val isVisible by collectLastValue(sceneContainerViewModel.isVisible) assertWithMessage("The FakeSceneDataSource has to be paused for this to do anything.") .that(fakeSceneDataSource.isPaused) .isTrue() @@ -574,7 +573,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { runCurrent() assertWithMessage("Visibility mismatch after scene transition from $from to $to!") - .that(isVisible) + .that(sceneContainerViewModel.isVisible) .isEqualTo(expectedVisible) assertThat(sceneContainerViewModel.currentScene.value).isEqualTo(to) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt index f85823ad7c33..b3157835ffe9 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt @@ -82,7 +82,10 @@ class SceneContainerViewModelTest : SysuiTestCase() { @Test fun activate_setsMotionEventHandler() = - testScope.runTest { assertThat(motionEventHandler).isNotNull() } + testScope.runTest { + runCurrent() + assertThat(motionEventHandler).isNotNull() + } @Test fun deactivate_clearsMotionEventHandler() = @@ -96,14 +99,15 @@ class SceneContainerViewModelTest : SysuiTestCase() { @Test fun isVisible() = testScope.runTest { - val isVisible by collectLastValue(underTest.isVisible) - assertThat(isVisible).isTrue() + assertThat(underTest.isVisible).isTrue() sceneInteractor.setVisible(false, "reason") - assertThat(isVisible).isFalse() + runCurrent() + assertThat(underTest.isVisible).isFalse() sceneInteractor.setVisible(true, "reason") - assertThat(isVisible).isTrue() + runCurrent() + assertThat(underTest.isVisible).isTrue() } @Test @@ -229,15 +233,17 @@ class SceneContainerViewModelTest : SysuiTestCase() { fun remoteUserInteraction_keepsContainerVisible() = testScope.runTest { sceneInteractor.setVisible(false, "reason") - val isVisible by collectLastValue(underTest.isVisible) - assertThat(isVisible).isFalse() + runCurrent() + assertThat(underTest.isVisible).isFalse() sceneInteractor.onRemoteUserInteractionStarted("reason") - assertThat(isVisible).isTrue() + runCurrent() + assertThat(underTest.isVisible).isTrue() underTest.onMotionEvent( mock { whenever(actionMasked).thenReturn(MotionEvent.ACTION_UP) } ) + runCurrent() - assertThat(isVisible).isFalse() + assertThat(underTest.isVisible).isFalse() } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt index 355669bd8a59..f72a2e861be5 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt @@ -43,6 +43,7 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.scene.data.repository.Idle import com.android.systemui.scene.data.repository.setTransition +import com.android.systemui.scene.domain.interactor.sceneBackInteractor import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Scenes @@ -112,6 +113,7 @@ class StatusBarStateControllerImplTest(flags: FlagsParameterization) : SysuiTest { kosmos.sceneInteractor }, { kosmos.sceneContainerOcclusionInteractor }, { kosmos.keyguardClockInteractor }, + { kosmos.sceneBackInteractor }, ) { override fun createDarkAnimator(): ObjectAnimator { return mockDarkAnimator @@ -320,12 +322,23 @@ class StatusBarStateControllerImplTest(flags: FlagsParameterization) : SysuiTest assertThat(deviceUnlockStatus!!.isUnlocked).isTrue() - kosmos.sceneInteractor.changeScene(toScene = Scenes.Gone, loggingReason = "reason") + kosmos.sceneInteractor.changeScene( + toScene = Scenes.Lockscreen, + loggingReason = "reason" + ) runCurrent() - assertThat(currentScene).isEqualTo(Scenes.Gone) + assertThat(currentScene).isEqualTo(Scenes.Lockscreen) // Call start to begin hydrating based on the scene framework: underTest.start() + runCurrent() + + assertThat(statusBarState).isEqualTo(StatusBarState.KEYGUARD) + + kosmos.sceneInteractor.changeScene(toScene = Scenes.Gone, loggingReason = "reason") + runCurrent() + assertThat(currentScene).isEqualTo(Scenes.Gone) + assertThat(statusBarState).isEqualTo(StatusBarState.SHADE) kosmos.sceneInteractor.changeScene(toScene = Scenes.Shade, loggingReason = "reason") runCurrent() diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java index d13c75082790..be44dee0aae6 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java @@ -169,6 +169,7 @@ public interface QSTile { public boolean isTransient = false; public String expandedAccessibilityClassName; public boolean handlesLongClick = true; + public boolean handlesSecondaryClick = false; @Nullable public Drawable sideViewCustomDrawable; public String spec; @@ -212,6 +213,7 @@ public interface QSTile { || !Objects.equals(other.isTransient, isTransient) || !Objects.equals(other.dualTarget, dualTarget) || !Objects.equals(other.handlesLongClick, handlesLongClick) + || !Objects.equals(other.handlesSecondaryClick, handlesSecondaryClick) || !Objects.equals(other.sideViewCustomDrawable, sideViewCustomDrawable); other.spec = spec; other.icon = icon; @@ -227,6 +229,7 @@ public interface QSTile { other.dualTarget = dualTarget; other.isTransient = isTransient; other.handlesLongClick = handlesLongClick; + other.handlesSecondaryClick = handlesSecondaryClick; other.sideViewCustomDrawable = sideViewCustomDrawable; return changed; } @@ -252,6 +255,7 @@ public interface QSTile { sb.append(",disabledByPolicy=").append(disabledByPolicy); sb.append(",dualTarget=").append(dualTarget); sb.append(",isTransient=").append(isTransient); + sb.append(",handlesSecondaryClick=").append(handlesSecondaryClick); sb.append(",state=").append(state); sb.append(",sideViewCustomDrawable=").append(sideViewCustomDrawable); return sb.append(']'); diff --git a/packages/SystemUI/res/values/ids.xml b/packages/SystemUI/res/values/ids.xml index 25bca25be732..20e70e0743ab 100644 --- a/packages/SystemUI/res/values/ids.xml +++ b/packages/SystemUI/res/values/ids.xml @@ -281,4 +281,9 @@ <!-- Ids for communal hub widgets --> <item type="id" name="communal_widget_disposable_tag"/> + + <!-- snapshot view-binding IDs --> + <item type="id" name="snapshot_view_binding" /> + <item type="id" name="snapshot_view_binding_root" /> + </resources> diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java index 723587e60df1..970fdeabcaf8 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java @@ -20,6 +20,7 @@ import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static com.android.internal.jank.InteractionJankMonitor.CUJ_BIOMETRIC_PROMPT_TRANSITION; +import static com.android.systemui.Flags.enableViewCaptureTracing; import android.animation.Animator; import android.annotation.IntDef; @@ -56,6 +57,8 @@ import android.window.OnBackInvokedDispatcher; import androidx.constraintlayout.widget.ConstraintLayout; import com.android.app.animation.Interpolators; +import com.android.app.viewcapture.ViewCapture; +import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.widget.LockPatternUtils; @@ -75,6 +78,8 @@ import com.android.systemui.res.R; import com.android.systemui.statusbar.VibratorHelper; import com.android.systemui.util.concurrency.DelayableExecutor; +import kotlin.Lazy; + import kotlinx.coroutines.CoroutineScope; import java.io.PrintWriter; @@ -124,7 +129,7 @@ public class AuthContainerView extends LinearLayout private final Config mConfig; private final int mEffectiveUserId; private final IBinder mWindowToken = new Binder(); - private final WindowManager mWindowManager; + private final ViewCaptureAwareWindowManager mWindowManager; private final Interpolator mLinearOutSlowIn; private final LockPatternUtils mLockPatternUtils; private final WakefulnessLifecycle mWakefulnessLifecycle; @@ -286,13 +291,16 @@ public class AuthContainerView extends LinearLayout @NonNull PromptViewModel promptViewModel, @NonNull Provider<CredentialViewModel> credentialViewModelProvider, @NonNull @Background DelayableExecutor bgExecutor, - @NonNull VibratorHelper vibratorHelper) { + @NonNull VibratorHelper vibratorHelper, + Lazy<ViewCapture> lazyViewCapture) { super(config.mContext); mConfig = config; mLockPatternUtils = lockPatternUtils; mEffectiveUserId = userManager.getCredentialOwnerProfile(mConfig.mUserId); - mWindowManager = mContext.getSystemService(WindowManager.class); + WindowManager wm = getContext().getSystemService(WindowManager.class); + mWindowManager = new ViewCaptureAwareWindowManager(wm, lazyViewCapture, + enableViewCaptureTracing()); mWakefulnessLifecycle = wakefulnessLifecycle; mApplicationCoroutineScope = applicationCoroutineScope; diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java index 037f5b72aff1..097ab72522d6 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java @@ -20,6 +20,8 @@ import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT; import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_REAR; +import static com.android.systemui.util.ConvenienceExtensionsKt.toKotlinLazy; + import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityTaskManager; @@ -61,6 +63,7 @@ import android.view.DisplayInfo; import android.view.MotionEvent; import android.view.WindowManager; +import com.android.app.viewcapture.ViewCapture; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.jank.InteractionJankMonitor; @@ -181,6 +184,8 @@ public class AuthController implements private final DisplayInfo mCachedDisplayInfo = new DisplayInfo(); @NonNull private final VibratorHelper mVibratorHelper; + private final kotlin.Lazy<ViewCapture> mLazyViewCapture; + @VisibleForTesting final TaskStackListener mTaskStackListener = new TaskStackListener() { @Override @@ -736,7 +741,8 @@ public class AuthController implements @Main Handler handler, @Background DelayableExecutor bgExecutor, @NonNull UdfpsUtils udfpsUtils, - @NonNull VibratorHelper vibratorHelper) { + @NonNull VibratorHelper vibratorHelper, + Lazy<ViewCapture> daggerLazyViewCapture) { mContext = context; mExecution = execution; mUserManager = userManager; @@ -785,6 +791,8 @@ public class AuthController implements filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); context.registerReceiver(mBroadcastReceiver, filter, Context.RECEIVER_EXPORTED_UNAUDITED); mSensorPrivacyManager = context.getSystemService(SensorPrivacyManager.class); + + mLazyViewCapture = toKotlinLazy(daggerLazyViewCapture); } // TODO(b/229290039): UDFPS controller should manage its dimensions on its own. Remove this. @@ -1318,7 +1326,8 @@ public class AuthController implements return new AuthContainerView(config, mApplicationCoroutineScope, mFpProps, mFaceProps, wakefulnessLifecycle, userManager, lockPatternUtils, mInteractionJankMonitor, mPromptSelectorInteractor, viewModel, - mCredentialViewModelProvider, bgExecutor, mVibratorHelper); + mCredentialViewModelProvider, bgExecutor, mVibratorHelper, + mLazyViewCapture); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/inputdevice/data/model/UserDeviceConnectionStatus.kt b/packages/SystemUI/src/com/android/systemui/inputdevice/data/model/UserDeviceConnectionStatus.kt new file mode 100644 index 000000000000..1a22d3c76a4f --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/inputdevice/data/model/UserDeviceConnectionStatus.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2024 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.systemui.inputdevice.data.model + +data class UserDeviceConnectionStatus(val isConnected: Boolean, val userId: Int) diff --git a/packages/SystemUI/src/com/android/systemui/inputdevice/data/repository/UserInputDeviceRepository.kt b/packages/SystemUI/src/com/android/systemui/inputdevice/data/repository/UserInputDeviceRepository.kt new file mode 100644 index 000000000000..b8e73a3a5927 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/inputdevice/data/repository/UserInputDeviceRepository.kt @@ -0,0 +1,64 @@ +/* + * Copyright 2024 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.systemui.inputdevice.data.repository + +import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.dagger.qualifiers.Background +import com.android.systemui.inputdevice.data.model.UserDeviceConnectionStatus +import com.android.systemui.keyboard.data.repository.KeyboardRepository +import com.android.systemui.touchpad.data.repository.TouchpadRepository +import com.android.systemui.user.data.model.SelectionStatus +import com.android.systemui.user.data.repository.UserRepository +import javax.inject.Inject +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.flow.map + +/** + * Allow listening keyboard and touchpad device connection changes for current user. It emits new + * value when user is changed. + */ +@SysUISingleton +class UserInputDeviceRepository +@Inject +constructor( + @Background private val backgroundDispatcher: CoroutineDispatcher, + keyboardRepository: KeyboardRepository, + touchpadRepository: TouchpadRepository, + userRepository: UserRepository, +) { + private val selectedUserId = + userRepository.selectedUser + .filter { it.selectionStatus == SelectionStatus.SELECTION_COMPLETE } + .map { it.userInfo.id } + + val isAnyKeyboardConnectedForUser = + keyboardRepository.isAnyKeyboardConnected + .combine(selectedUserId) { isAnyKeyboardConnected, userId -> + UserDeviceConnectionStatus(isAnyKeyboardConnected, userId) + } + .flowOn(backgroundDispatcher) + + val isAnyTouchpadConnectedForUser = + touchpadRepository.isAnyTouchpadConnected + .combine(selectedUserId) { isAnyTouchpadConnected, userId -> + UserDeviceConnectionStatus(isAnyTouchpadConnected, userId) + } + .flowOn(backgroundDispatcher) +} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerViewModel.kt index 7b0b23ffb2ff..3e3cbd0540a2 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerViewModel.kt @@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.viewmodel import android.graphics.Color import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor +import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor import com.android.systemui.keyguard.DismissCallbackRegistry import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState.ALTERNATE_BOUNCER @@ -41,6 +42,7 @@ constructor( keyguardTransitionInteractor: KeyguardTransitionInteractor, private val dismissCallbackRegistry: DismissCallbackRegistry, alternateBouncerInteractor: Lazy<AlternateBouncerInteractor>, + private val primaryBouncerInteractor: PrimaryBouncerInteractor, ) { // When we're fully transitioned to the AlternateBouncer, the alpha of the scrim should be: private val alternateBouncerScrimAlpha = .66f @@ -68,10 +70,13 @@ constructor( fun onRemovedFromWindow() { statusBarKeyguardViewManager.hideAlternateBouncer(false) + primaryBouncerInteractor.setDismissAction(null, null) + dismissCallbackRegistry.notifyDismissCancelled() } fun onBackRequested() { statusBarKeyguardViewManager.hideAlternateBouncer(false) + primaryBouncerInteractor.setDismissAction(null, null) dismissCallbackRegistry.notifyDismissCancelled() } } diff --git a/packages/SystemUI/src/com/android/systemui/lifecycle/SnapshotViewBinding.kt b/packages/SystemUI/src/com/android/systemui/lifecycle/SnapshotViewBinding.kt new file mode 100644 index 000000000000..91ba61430fb3 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/lifecycle/SnapshotViewBinding.kt @@ -0,0 +1,298 @@ +/* + * Copyright (C) 2024 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.systemui.lifecycle + +import android.os.Handler +import android.os.Looper +import android.view.Choreographer +import android.view.View +import androidx.collection.MutableScatterSet +import androidx.compose.runtime.snapshots.Snapshot +import androidx.compose.runtime.snapshots.SnapshotStateObserver +import androidx.core.os.HandlerCompat +import com.android.systemui.res.R + +/** + * [SnapshotViewBindingRoot] is installed on the root view of an attached view hierarchy and + * coordinates all [SnapshotViewBinding]s for the window. + * + * This class is not thread-safe. It should only be accessed from the thread corresponding to the UI + * thread referenced by the [handler] and [choreographer] constructor parameters. These two + * parameters must refer to the same UI thread. + * + * Lazily created and installed on a root attached view by [bindingRoot]. + */ +private class SnapshotViewBindingRoot( + private val handler: Handler, + private val choreographer: Choreographer +) { + /** Multiplexer for all snapshot state observations; see [start] and [stop] */ + private val observer = SnapshotStateObserver { task -> + if (Looper.myLooper() === handler.looper) task() else handler.post(task) + } + + /** `true` if a [Choreographer] frame is currently scheduled */ + private var isFrameScheduled = false + + /** + * Unordered set of [SnapshotViewBinding]s that have been invalidated and are awaiting handling + * by an upcoming frame. + */ + private val invalidatedBindings = MutableScatterSet<SnapshotViewBinding>() + + /** + * Callback for [SnapshotStateObserver.observeReads] allocated once for the life of the + * [SnapshotViewBindingRoot] and reused to avoid extra allocations during frame operations. + */ + private val onBindingChanged: (SnapshotViewBinding) -> Unit = { + invalidatedBindings += it + if (!isFrameScheduled) { + choreographer.postFrameCallback(frameCallback) + isFrameScheduled = true + } + } + + /** Callback for [Choreographer.postFrameCallback] */ + private val frameCallback = + Choreographer.FrameCallback { + try { + bindInvalidatedBindings() + } finally { + isFrameScheduled = false + } + } + + /** + * Perform binding of all [SnapshotViewBinding]s in [invalidatedBindings] within a single + * mutable snapshot. The snapshot will be committed if no exceptions are thrown from any + * binding's `onError` handler. + */ + private fun bindInvalidatedBindings() { + Snapshot.withMutableSnapshot { + // removeIf is used here to perform a forEach where each element is removed + // as the invalid bindings are traversed. If a performBindOf throws we want + // the rest of the unhandled invalidations to remain. + invalidatedBindings.removeIf { binding -> + performBindOf(binding) + true + } + } + } + + /** + * Perform the view binding for [binding] while observing its snapshot reads. Once this method + * is called for a [binding] this [SnapshotViewBindingRoot] may retain hard references back to + * [binding] via [observer], [invalidatedBindings] or both. Use [forgetBinding] to drop these + * references once a [SnapshotViewBinding] is no longer relevant. + * + * This method should only be called after [start] has been called and before [stop] has been + * called; failing to obey this constraint may result in lingering hard references to [binding] + * or missed invalidations in response to snapshot state that was changed prior to [start] being + * called. + */ + fun performBindOf(binding: SnapshotViewBinding) { + try { + observer.observeReads(binding, onBindingChanged, binding.performBind) + } catch (error: Throwable) { + // Note: it is valid (and the default) for this call to re-throw the error + binding.onError(error) + } + } + + /** + * Forget about [binding], dropping all observed tracking and invalidation state. After calling + * this method it is safe to abandon [binding] to the garbage collector. + */ + fun forgetBinding(binding: SnapshotViewBinding) { + observer.clear(binding) + invalidatedBindings.remove(binding) + } + + /** + * Start tracking snapshot commits that may affect [SnapshotViewBinding]s passed to + * [performBindOf] calls. Call this method before invoking [performBindOf]. + * + * Once this method has been called, [stop] must be called prior to abandoning this + * [SnapshotViewBindingRoot] to the garbage collector, as a hard reference to it will be + * retained by the snapshot system until [stop] is invoked. + */ + fun start() { + observer.start() + } + + /** + * Stop tracking snapshot commits that may affect [SnapshotViewBinding]s that have been passed + * to [performBindOf], cancel any pending [choreographer] frame callback, and forget all + * [invalidatedBindings]. + * + * Call [stop] prior to abandoning this [SnapshotViewBindingRoot] to the garbage collector. + * + * Calling [start] again after [stop] will begin tracking invalidations again, but any + * [SnapshotViewBinding]s must be re-bound using [performBindOf] after the [start] call returns. + */ + fun stop() { + observer.stop() + choreographer.removeFrameCallback(frameCallback) + isFrameScheduled = false + invalidatedBindings.clear() + } +} + +/** + * Return the [SnapshotViewBindingRoot] for this [View], lazily creating it if it does not yet + * exist. This [View] must be currently attached to a window and this property should only be + * accessed from this [View]'s UI thread. + * + * The [SnapshotViewBindingRoot] will be [started][SnapshotViewBindingRoot.start] before this + * property get returns, making it safe to call [SnapshotViewBindingRoot.performBindOf] for the + * [bindingRoot] of an attached [View]. + * + * When the [View] becomes attached to a window the [SnapshotViewBindingRoot] will automatically be + * [started][SnapshotViewBindingRoot.start]. When it becomes detached from its window it will + * automatically be [stopped][SnapshotViewBindingRoot.stop]. + * + * This should generally only be called on the [View] returned by [View.getRootView] for an attached + * [View]. + */ +private val View.bindingRoot: SnapshotViewBindingRoot + get() { + val tag = getTag(R.id.snapshot_view_binding_root) as? SnapshotViewBindingRoot + if (tag != null) return tag + val newRoot = + SnapshotViewBindingRoot( + // Use an async handler for processing invalidations; this ensures invalidations + // are tracked for the upcoming frame and not the next frame. + handler = + HandlerCompat.createAsync( + handler?.looper ?: error("$this is not attached to a window") + ), + choreographer = Choreographer.getInstance() + ) + setTag(R.id.snapshot_view_binding_root, newRoot) + addOnAttachStateChangeListener( + object : View.OnAttachStateChangeListener { + override fun onViewAttachedToWindow(view: View) { + newRoot.start() + } + + override fun onViewDetachedFromWindow(view: View) { + newRoot.stop() + } + } + ) + if (isAttachedToWindow) newRoot.start() + return newRoot + } + +/** + * A single [SnapshotViewBinding] set on a [View] by [setSnapshotBinding]. The [SnapshotViewBinding] + * is responsible for invoking [SnapshotViewBindingRoot.performBindOf] when the associated [View] + * becomes attached to a window in order to register it for invalidation tracking and rebinding as + * relevant snapshot state changes. When the [View] becomes detached the binding will invoke + * [SnapshotViewBindingRoot.forgetBinding] for itself. + */ +private class SnapshotViewBinding( + val performBind: () -> Unit, + val onError: (Throwable) -> Unit, +) : View.OnAttachStateChangeListener { + + override fun onViewAttachedToWindow(view: View) { + Snapshot.withMutableSnapshot { view.rootView.bindingRoot.performBindOf(this) } + } + + override fun onViewDetachedFromWindow(view: View) { + view.rootView.bindingRoot.forgetBinding(this) + } +} + +/** + * Set binding logic for this [View] that will be re-invoked for UI frames where relevant [Snapshot] + * state has changed. This can be especially useful for codebases with mixed usage of both Views and + * [Jetpack Compose](https://d.android.com/compose), enabling the same patterns of snapshot-backed + * state management when using either UI toolkit. + * + * In the following example the sender name and message text of a message item view will be kept up + * to date with the snapshot-backed `model.senderName` and `model.messageText` properties: + * ``` + * val view = layoutInflater.inflate(R.layout.single_message, parent, false) + * val senderNameView = view.findViewById<TextView>(R.id.sender_name) + * val messageTextView = view.findViewById<TextView>(R.id.message_text) + * view.setSnapshotBinding { + * senderNameView.text = model.senderName + * messageTextView.text = model.messageText + * } + * ``` + * + * Snapshot binding may also be used in concert with + * [View binding](https://developer.android.com/topic/libraries/view-binding): + * ``` + * val binding = SingleMessageBinding.inflate(layoutInflater) + * binding.root.setSnapshotBinding { + * binding.senderName.text = model.senderName + * binding.messageText.text = model.messageText + * } + * ``` + * + * When a snapshot binding is set [performBind] will be invoked immediately before + * [setSnapshotBinding] returns if this [View] is currently attached to a window. If the view is not + * currently attached, [performBind] will be invoked when the view becomes attached to a window. + * + * If a snapshot commit changes state accessed by [performBind] changes while the view remains + * attached to its window and the snapshot binding is not replaced or [cleared][clearBinding], the + * binding will be considered _invalidated,_ a rebinding will be scheduled for the upcoming UI + * frame, and [performBind] will be re-executed prior to the layout and draw phases for the frame. + * [performBind] will only be re-executed **once** for any given UI frame provided that + * [setSnapshotBinding] is not called again. + * + * [performBind] is always invoked from a [mutable snapshot][Snapshot.takeMutableSnapshot], ensuring + * atomic consistency of all snapshot state reads within it. **All** rebinding performed for + * invalidations of bindings within the same window for a given UI frame are performed within the + * **same** snapshot, ensuring that same atomic consistency of snapshot state for **all** snapshot + * bindings within the same window. + * + * As [performBind] is invoked for rebinding as part of the UI frame itself, [performBind] + * implementations should be both fast and idempotent to avoid delaying the UI frame. + * + * There are no mutual ordering guarantees between separate snapshot bindings; the [performBind] of + * separate snapshot bindings may be executed in any order. Similarly, no ordering guarantees exist + * between snapshot binding rebinding and Jetpack Compose recomposition. Snapshot bindings and + * Compose UIs both should obey + * [unidirectional data flow](https://developer.android.com/topic/architecture/ui-layer#udf) + * principles, consuming state from mutual single sources of truth and avoid consuming state + * produced by the rebinding or recomposition of other UI components. + */ +fun View.setSnapshotBinding(onError: (Throwable) -> Unit = { throw it }, performBind: () -> Unit) { + clearBinding() + val newBinding = SnapshotViewBinding(performBind, onError) + setTag(R.id.snapshot_view_binding, newBinding) + addOnAttachStateChangeListener(newBinding) + if (isAttachedToWindow) newBinding.onViewAttachedToWindow(this) +} + +/** + * Remove a snapshot binding that was set by [setSnapshotBinding]. It is not necessary to call this + * function before abandoning a [View] with a snapshot binding to the garbage collector. + */ +fun View.clearBinding() { + val oldBinding = getTag(R.id.snapshot_view_binding) as? SnapshotViewBinding + if (oldBinding != null) { + removeOnAttachStateChangeListener(oldBinding) + if (isAttachedToWindow) { + oldBinding.onViewDetachedFromWindow(this) + } + } +} diff --git a/packages/SystemUI/src/com/android/systemui/lifecycle/SysUiViewModel.kt b/packages/SystemUI/src/com/android/systemui/lifecycle/SysUiViewModel.kt index 32c476093774..979eaef30a23 100644 --- a/packages/SystemUI/src/com/android/systemui/lifecycle/SysUiViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/lifecycle/SysUiViewModel.kt @@ -30,6 +30,12 @@ import kotlinx.coroutines.launch /** Base class for all System UI view-models. */ abstract class SysUiViewModel : BaseActivatable() { + /** + * Returns a snapshot [State] that's kept up-to-date as long as the [SysUiViewModel] is active. + * + * @param source The upstream [StateFlow] to collect from; values emitted to it will be + * automatically set on the returned [State]. + */ @StateFactoryMarker fun <T> hydratedStateOf( source: StateFlow<T>, @@ -40,6 +46,13 @@ abstract class SysUiViewModel : BaseActivatable() { ) } + /** + * Returns a snapshot [State] that's kept up-to-date as long as the [SysUiViewModel] is active. + * + * @param initialValue The first value to place on the [State] + * @param source The upstream [Flow] to collect from; values emitted to it will be automatically + * set on the returned [State]. + */ @StateFactoryMarker fun <T> hydratedStateOf( initialValue: T, diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerImpl.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerImpl.java index 8e46fe4c98b7..5e8c2c9844ee 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerImpl.java @@ -16,10 +16,6 @@ package com.android.systemui.navigationbar; -import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU; -import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_GESTURE; -import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR; - import static com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler.DEBUG_MISSING_GESTURE_TAG; import static com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen; import static com.android.wm.shell.Flags.enableTaskbarNavbarUnification; @@ -32,8 +28,6 @@ import android.hardware.display.DisplayManager; import android.os.Bundle; import android.os.RemoteException; import android.os.Trace; -import android.os.UserHandle; -import android.provider.Settings; import android.util.Log; import android.util.SparseArray; import android.util.SparseBooleanArray; @@ -59,7 +53,6 @@ import com.android.systemui.navigationbar.views.NavigationBarView; import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.settings.DisplayTracker; import com.android.systemui.shared.statusbar.phone.BarTransitions.TransitionMode; -import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.TaskStackChangeListeners; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.phone.AutoHideController; @@ -192,7 +185,6 @@ public class NavigationBarControllerImpl implements } final int oldMode = mNavMode; mNavMode = mode; - updateAccessibilityButtonModeIfNeeded(); mExecutor.execute(() -> { // create/destroy nav bar based on nav mode only in unfolded state @@ -209,34 +201,6 @@ public class NavigationBarControllerImpl implements }); } - private void updateAccessibilityButtonModeIfNeeded() { - final int mode = mSecureSettings.getIntForUser( - Settings.Secure.ACCESSIBILITY_BUTTON_MODE, - ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR, UserHandle.USER_CURRENT); - - // ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU is compatible under gestural or non-gestural - // mode, so we don't need to update it. - if (mode == ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU) { - return; - } - - // ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR is incompatible under gestural mode. Need to - // force update to ACCESSIBILITY_BUTTON_MODE_GESTURE. - if (QuickStepContract.isGesturalMode(mNavMode) - && mode == ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR) { - mSecureSettings.putIntForUser( - Settings.Secure.ACCESSIBILITY_BUTTON_MODE, ACCESSIBILITY_BUTTON_MODE_GESTURE, - UserHandle.USER_CURRENT); - // ACCESSIBILITY_BUTTON_MODE_GESTURE is incompatible under non gestural mode. Need to - // force update to ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR. - } else if (!QuickStepContract.isGesturalMode(mNavMode) - && mode == ACCESSIBILITY_BUTTON_MODE_GESTURE) { - mSecureSettings.putIntForUser( - Settings.Secure.ACCESSIBILITY_BUTTON_MODE, - ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR, UserHandle.USER_CURRENT); - } - } - private boolean shouldCreateNavBarAndTaskBar(int displayId) { if (mHasNavBar.indexOfKey(displayId) > -1) { return mHasNavBar.get(displayId); @@ -353,8 +317,6 @@ public class NavigationBarControllerImpl implements @Override public void createNavigationBars(final boolean includeDefaultDisplay, RegisterStatusBarResult result) { - updateAccessibilityButtonModeIfNeeded(); - // Don't need to create nav bar on the default display if we initialize TaskBar. final boolean shouldCreateDefaultNavbar = includeDefaultDisplay && !initializeTaskbarIfNecessary(); diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileIcon.kt b/packages/SystemUI/src/com/android/systemui/qs/QSTileIcon.kt new file mode 100644 index 000000000000..ef7e7eb59898 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileIcon.kt @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2024 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.systemui.qs + +import com.android.systemui.common.shared.model.Icon +import com.android.systemui.plugins.qs.QSTile +import com.android.systemui.qs.tileimpl.QSTileImpl + +/** + * Creates a [QSTile.Icon] from an [Icon]. + * * [Icon.Loaded] -> [QSTileImpl.DrawableIcon] + * * [Icon.Resource] -> [QSTileImpl.ResourceIcon] + */ +fun Icon.asQSTileIcon(): QSTile.Icon { + return when (this) { + is Icon.Loaded -> { + QSTileImpl.DrawableIcon(this.drawable) + } + is Icon.Resource -> { + QSTileImpl.ResourceIcon.get(this.res) + } + } +} diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/Tile.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/Tile.kt index c06d6d2dc957..6eacb2ef9f14 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/Tile.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/Tile.kt @@ -109,6 +109,7 @@ import com.android.systemui.qs.panels.ui.model.GridCell import com.android.systemui.qs.panels.ui.model.SpacerGridCell import com.android.systemui.qs.panels.ui.model.TileGridCell import com.android.systemui.qs.panels.ui.viewmodel.EditTileViewModel +import com.android.systemui.qs.panels.ui.viewmodel.TileUiState import com.android.systemui.qs.panels.ui.viewmodel.TileViewModel import com.android.systemui.qs.panels.ui.viewmodel.toUiState import com.android.systemui.qs.pipeline.domain.interactor.CurrentTilesInteractor @@ -129,7 +130,7 @@ fun Tile( ) { val state by tile.state.collectAsStateWithLifecycle(tile.currentState) val uiState = remember(state) { state.toUiState() } - val colors = TileDefaults.getColorForState(uiState.state) + val colors = TileDefaults.getColorForState(uiState) TileContainer( colors = colors, @@ -150,9 +151,13 @@ fun Tile( secondaryLabel = uiState.secondaryLabel, icon = icon, colors = colors, - clickEnabled = true, - onClick = tile::onSecondaryClick, - onLongClick = tile::onLongClick, + toggleClickSupported = state.handlesSecondaryClick, + onClick = { + if (state.handlesSecondaryClick) { + tile.onSecondaryClick() + } + }, + onLongClick = { tile.onLongClick(it) }, ) } } @@ -168,7 +173,7 @@ private fun TileContainer( onClick: (Expandable) -> Unit = {}, onLongClick: (Expandable) -> Unit = {}, modifier: Modifier = Modifier, - content: @Composable BoxScope.() -> Unit, + content: @Composable BoxScope.(Expandable) -> Unit, ) { Column( horizontalAlignment = Alignment.CenterHorizontally, @@ -200,7 +205,7 @@ private fun TileContainer( } .tilePadding(), ) { - content() + content(it) } } @@ -222,36 +227,27 @@ private fun LargeTileContent( secondaryLabel: String?, icon: Icon, colors: TileColors, - clickEnabled: Boolean = false, - onClick: (Expandable) -> Unit = {}, - onLongClick: (Expandable) -> Unit = {}, + toggleClickSupported: Boolean = false, + onClick: () -> Unit = {}, + onLongClick: () -> Unit = {}, ) { Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = tileHorizontalArrangement() ) { - Expandable( - color = colors.iconBackground, - shape = TileDefaults.TileShape, - modifier = Modifier.fillMaxHeight().aspectRatio(1f) + // Icon + Box( + modifier = + Modifier.fillMaxHeight().aspectRatio(1f).thenIf(toggleClickSupported) { + Modifier.clip(TileDefaults.TileShape) + .background(colors.iconBackground, { 1f }) + .combinedClickable(onClick = onClick, onLongClick = onLongClick) + } ) { - Box( - modifier = - Modifier.fillMaxSize().clip(TileDefaults.TileShape).thenIf(clickEnabled) { - Modifier.combinedClickable( - onClick = { onClick(it) }, - onLongClick = { onLongClick(it) } - ) - } - ) { - TileIcon( - icon = icon, - color = colors.icon, - modifier = Modifier.align(Alignment.Center) - ) - } + TileIcon(icon = icon, color = colors.icon, modifier = Modifier.align(Alignment.Center)) } + // Labels Column(verticalArrangement = Arrangement.Center, modifier = Modifier.fillMaxHeight()) { Text( label, @@ -743,9 +739,21 @@ private object TileDefaults { val TileShape = CircleShape val IconTileWithLabelHeight = 140.dp + /** An active tile without dual target uses the active color as background */ @Composable fun activeTileColors(): TileColors = TileColors( + background = MaterialTheme.colorScheme.primary, + iconBackground = MaterialTheme.colorScheme.primary, + label = MaterialTheme.colorScheme.onPrimary, + secondaryLabel = MaterialTheme.colorScheme.onPrimary, + icon = MaterialTheme.colorScheme.onPrimary, + ) + + /** An active tile with dual target only show the active color on the icon */ + @Composable + fun activeDualTargetTileColors(): TileColors = + TileColors( background = MaterialTheme.colorScheme.surfaceVariant, iconBackground = MaterialTheme.colorScheme.primary, label = MaterialTheme.colorScheme.onSurfaceVariant, @@ -774,9 +782,15 @@ private object TileDefaults { ) @Composable - fun getColorForState(state: Int): TileColors { - return when (state) { - STATE_ACTIVE -> activeTileColors() + fun getColorForState(uiState: TileUiState): TileColors { + return when (uiState.state) { + STATE_ACTIVE -> { + if (uiState.handlesSecondaryClick) { + activeDualTargetTileColors() + } else { + activeTileColors() + } + } STATE_INACTIVE -> inactiveTileColors() else -> unavailableTileColors() } diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/TileUiState.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/TileUiState.kt index c83e3b2a0e06..45051fea76b6 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/TileUiState.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/TileUiState.kt @@ -25,6 +25,7 @@ data class TileUiState( val label: String, val secondaryLabel: String, val state: Int, + val handlesSecondaryClick: Boolean, val icon: Supplier<QSTile.Icon?>, ) @@ -33,6 +34,7 @@ fun QSTile.State.toUiState(): TileUiState { label?.toString() ?: "", secondaryLabel?.toString() ?: "", state, + handlesSecondaryClick, icon?.let { Supplier { icon } } ?: iconSupplier ?: Supplier { null }, ) } diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/TileViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/TileViewModel.kt index 8578bb0ef9a1..44dd801a8b9f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/TileViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/TileViewModel.kt @@ -50,8 +50,8 @@ class TileViewModel(private val tile: QSTile, val spec: TileSpec) { tile.longClick(expandable) } - fun onSecondaryClick(expandable: Expandable?) { - tile.secondaryClick(expandable) + fun onSecondaryClick() { + tile.secondaryClick(null) } fun startListening(token: Any) = tile.setListening(token, true) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java index 9f41d98b6969..7ceb78638f6c 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java @@ -114,7 +114,9 @@ public class BluetoothTile extends QSTileImpl<BooleanState> { @Override public BooleanState newTileState() { - return new BooleanState(); + BooleanState s = new BooleanState(); + s.handlesSecondaryClick = true; + return s; } @Override @@ -141,10 +143,7 @@ public class BluetoothTile extends QSTileImpl<BooleanState> { mDialogViewModel.showDialog(expandable); } else { // Secondary clicks are header clicks, just toggle. - final boolean isEnabled = mState.value; - // Immediately enter transient enabling state when turning bluetooth on. - refreshState(isEnabled ? null : ARG_SHOW_TRANSIENT_ENABLING); - mController.setBluetoothEnabled(!isEnabled); + toggleBluetooth(); } } @@ -160,9 +159,7 @@ public class BluetoothTile extends QSTileImpl<BooleanState> { new Intent(Settings.ACTION_BLUETOOTH_SETTINGS), 0); return; } - if (!mState.value) { - mController.setBluetoothEnabled(true); - } + toggleBluetooth(); } @Override @@ -228,6 +225,13 @@ public class BluetoothTile extends QSTileImpl<BooleanState> { state.forceExpandIcon = mFeatureFlags.isEnabled(Flags.BLUETOOTH_QS_TILE_DIALOG); } + private void toggleBluetooth() { + final boolean isEnabled = mState.value; + // Immediately enter transient enabling state when turning bluetooth on. + refreshState(isEnabled ? null : ARG_SHOW_TRANSIENT_ENABLING); + mController.setBluetoothEnabled(!isEnabled); + } + /** * Returns the secondary label to use for the given bluetooth connection in the form of the * battery level or bluetooth profile name. If the bluetooth is disabled, there's no connected diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTile.java index 6d98da4bac61..02f6f80d7282 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTile.java @@ -52,6 +52,7 @@ import com.android.systemui.qs.QsEventLogger; import com.android.systemui.qs.logging.QSLogger; import com.android.systemui.qs.tileimpl.QSTileImpl; import com.android.systemui.qs.tiles.dialog.InternetDialogManager; +import com.android.systemui.qs.tiles.dialog.WifiStateWorker; import com.android.systemui.res.R; import com.android.systemui.statusbar.connectivity.AccessPointController; import com.android.systemui.statusbar.connectivity.IconState; @@ -84,6 +85,7 @@ public class InternetTile extends QSTileImpl<QSTile.BooleanState> { protected final InternetSignalCallback mSignalCallback = new InternetSignalCallback(); private final InternetDialogManager mInternetDialogManager; + private final WifiStateWorker mWifiStateWorker; final Handler mHandler; @Inject @@ -99,11 +101,13 @@ public class InternetTile extends QSTileImpl<QSTile.BooleanState> { QSLogger qsLogger, NetworkController networkController, AccessPointController accessPointController, - InternetDialogManager internetDialogManager + InternetDialogManager internetDialogManager, + WifiStateWorker wifiStateWorker ) { super(host, uiEventLogger, backgroundLooper, mainHandler, falsingManager, metricsLogger, statusBarStateController, activityStarter, qsLogger); mInternetDialogManager = internetDialogManager; + mWifiStateWorker = wifiStateWorker; mHandler = mainHandler; mController = networkController; mAccessPointController = accessPointController; @@ -115,6 +119,7 @@ public class InternetTile extends QSTileImpl<QSTile.BooleanState> { public BooleanState newTileState() { BooleanState s = new BooleanState(); s.forceExpandIcon = true; + s.handlesSecondaryClick = true; return s; } @@ -131,6 +136,13 @@ public class InternetTile extends QSTileImpl<QSTile.BooleanState> { } @Override + public void secondaryClick(@Nullable Expandable expandable) { + // TODO(b/358352265): Figure out the correct action for the secondary click + // Toggle Wifi + mWifiStateWorker.setWifiEnabled(!mWifiStateWorker.isWifiEnabled()); + } + + @Override public CharSequence getTileLabel() { return mContext.getString(R.string.quick_settings_internet_label); } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTileNewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTileNewImpl.kt index 932dec5af950..42ef0cd3abb7 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTileNewImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTileNewImpl.kt @@ -34,6 +34,7 @@ import com.android.systemui.qs.QsEventLogger import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tileimpl.QSTileImpl import com.android.systemui.qs.tiles.dialog.InternetDialogManager +import com.android.systemui.qs.tiles.dialog.WifiStateWorker import com.android.systemui.res.R import com.android.systemui.statusbar.connectivity.AccessPointController import com.android.systemui.statusbar.pipeline.shared.ui.binder.InternetTileBinder @@ -55,6 +56,7 @@ constructor( qsLogger: QSLogger, viewModel: InternetTileViewModel, private val internetDialogManager: InternetDialogManager, + private val wifiStateWorker: WifiStateWorker, private val accessPointController: AccessPointController, ) : QSTileImpl<QSTile.BooleanState>( @@ -81,7 +83,10 @@ constructor( mContext.getString(R.string.quick_settings_internet_label) override fun newTileState(): QSTile.BooleanState { - return QSTile.BooleanState().also { it.forceExpandIcon = true } + return QSTile.BooleanState().also { + it.forceExpandIcon = true + it.handlesSecondaryClick = true + } } override fun handleClick(expandable: Expandable?) { @@ -95,6 +100,12 @@ constructor( } } + override fun secondaryClick(expandable: Expandable?) { + // TODO(b/358352265): Figure out the correct action for the secondary click + // Toggle wifi + wifiStateWorker.isWifiEnabled = !wifiStateWorker.isWifiEnabled + } + override fun handleUpdateState(state: QSTile.BooleanState, arg: Any?) { state.label = mContext.resources.getString(R.string.quick_settings_internet_label) state.expandedAccessibilityClassName = Switch::class.java.name diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ModesTile.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/ModesTile.kt index 5f10b385e23b..6d63d26d4300 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ModesTile.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ModesTile.kt @@ -24,7 +24,6 @@ import android.service.quicksettings.Tile import androidx.lifecycle.Lifecycle import androidx.lifecycle.coroutineScope import androidx.lifecycle.repeatOnLifecycle -import com.android.internal.R.attr.contentDescription import com.android.internal.logging.MetricsLogger import com.android.systemui.animation.Expandable import com.android.systemui.dagger.qualifiers.Background @@ -36,6 +35,7 @@ import com.android.systemui.plugins.qs.QSTile import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.qs.QSHost import com.android.systemui.qs.QsEventLogger +import com.android.systemui.qs.asQSTileIcon import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tileimpl.QSTileImpl import com.android.systemui.qs.tiles.impl.modes.domain.interactor.ModesTileDataInteractor @@ -115,7 +115,8 @@ constructor( state?.apply { this.state = tileState.activationState.legacyState - icon = ResourceIcon.get(tileState.iconRes ?: R.drawable.qs_dnd_icon_off) + val tileStateIcon = tileState.icon() + icon = tileStateIcon?.asQSTileIcon() ?: ResourceIcon.get(R.drawable.qs_dnd_icon_off) label = tileLabel secondaryLabel = tileState.secondaryLabel contentDescription = tileState.contentDescription diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/base/analytics/QSTileAnalytics.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/base/analytics/QSTileAnalytics.kt index 0d15a5b6b4d4..1d427775dad6 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/base/analytics/QSTileAnalytics.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/base/analytics/QSTileAnalytics.kt @@ -47,6 +47,7 @@ constructor( private fun QSTileUserAction.getQSEvent(): QSEvent = when (this) { is QSTileUserAction.Click -> QSEvent.QS_ACTION_CLICK + is QSTileUserAction.ToggleClick -> QSEvent.QS_ACTION_SECONDARY_CLICK is QSTileUserAction.LongClick -> QSEvent.QS_ACTION_LONG_PRESS } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/base/logging/QSTileLogger.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/base/logging/QSTileLogger.kt index f0d72065397d..8ec8a6d1e730 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/base/logging/QSTileLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/base/logging/QSTileLogger.kt @@ -222,6 +222,7 @@ constructor( private fun QSTileUserAction.toLogString(): String = when (this) { is QSTileUserAction.Click -> "click" + is QSTileUserAction.ToggleClick -> "toggle click" is QSTileUserAction.LongClick -> "long click" } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImpl.kt index 9e84f01c6bc4..d8c5af289048 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImpl.kt @@ -229,7 +229,8 @@ class QSTileViewModelImpl<DATA_TYPE>( filter { action -> val isFalseAction = when (action) { - is QSTileUserAction.Click -> + is QSTileUserAction.Click, + is QSTileUserAction.ToggleClick -> falsingManager.isFalseTap(FalsingManager.LOW_PENALTY) is QSTileUserAction.LongClick -> falsingManager.isFalseLongTap(FalsingManager.LOW_PENALTY) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/airplane/domain/interactor/AirplaneModeTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/airplane/domain/interactor/AirplaneModeTileUserActionInteractor.kt index bf0f8f6577de..50532918b170 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/airplane/domain/interactor/AirplaneModeTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/airplane/domain/interactor/AirplaneModeTileUserActionInteractor.kt @@ -57,6 +57,7 @@ constructor( Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS) ) } + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/alarm/domain/interactor/AlarmTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/alarm/domain/interactor/AlarmTileUserActionInteractor.kt index 14fc57c0f83f..79fcd3721877 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/alarm/domain/interactor/AlarmTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/alarm/domain/interactor/AlarmTileUserActionInteractor.kt @@ -49,6 +49,7 @@ constructor( } } is QSTileUserAction.LongClick -> {} + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/battery/domain/interactor/BatterySaverTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/battery/domain/interactor/BatterySaverTileUserActionInteractor.kt index d4b4fe06ded8..3bbb9aa8505c 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/battery/domain/interactor/BatterySaverTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/battery/domain/interactor/BatterySaverTileUserActionInteractor.kt @@ -48,6 +48,7 @@ constructor( Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS) ) } + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/interactor/ColorCorrectionUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/interactor/ColorCorrectionUserActionInteractor.kt index 534bd734f5bd..dfdec3b458a9 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/interactor/ColorCorrectionUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/interactor/ColorCorrectionUserActionInteractor.kt @@ -49,6 +49,7 @@ constructor( Intent(Settings.ACTION_COLOR_CORRECTION_SETTINGS) ) } + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/custom/domain/interactor/CustomTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/custom/domain/interactor/CustomTileUserActionInteractor.kt index 9bdf6316b069..af2bb9d0d2f7 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/custom/domain/interactor/CustomTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/custom/domain/interactor/CustomTileUserActionInteractor.kt @@ -74,6 +74,7 @@ constructor( click(action.expandable, data.tile.activityLaunchForClick) is QSTileUserAction.LongClick -> longClick(user, action.expandable, data.componentName, data.tile.state) + is QSTileUserAction.ToggleClick -> {} } qsTileLogger.logCustomTileUserActionDelivered(tileSpec) } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/flashlight/domain/interactor/FlashlightTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/flashlight/domain/interactor/FlashlightTileUserActionInteractor.kt index bedd65e0072f..13afc15d17ef 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/flashlight/domain/interactor/FlashlightTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/flashlight/domain/interactor/FlashlightTileUserActionInteractor.kt @@ -42,6 +42,7 @@ constructor( flashlightController.setFlashlight(!input.data.isEnabled) } } + is QSTileUserAction.ToggleClick -> {} else -> {} } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/interactor/FontScalingTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/interactor/FontScalingTileUserActionInteractor.kt index d308ec889136..6ab5796dceaa 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/interactor/FontScalingTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/interactor/FontScalingTileUserActionInteractor.kt @@ -66,8 +66,7 @@ constructor( INTERACTION_JANK_TAG ) ) - ?.let { dialogTransitionAnimator.show(dialog, it) } - ?: dialog.show() + ?.let { dialogTransitionAnimator.show(dialog, it) } ?: dialog.show() } else { dialog.show() } @@ -89,8 +88,10 @@ constructor( Intent(Settings.ACTION_TEXT_READING_SETTINGS) ) } + is QSTileUserAction.ToggleClick -> {} } } + companion object { private const val INTERACTION_JANK_TAG = "font_scaling" } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt index e543e4bdc930..8965ef2bc493 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt @@ -72,6 +72,10 @@ constructor( else QSTileState.ActivationState.INACTIVE supportedActions = - setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) + setOf( + QSTileState.UserAction.CLICK, + QSTileState.UserAction.TOGGLE_CLICK, + QSTileState.UserAction.LONG_CLICK + ) } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileUserActionInteractor.kt index c0b089d84dc8..a963b2875154 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileUserActionInteractor.kt @@ -23,6 +23,7 @@ import com.android.systemui.qs.tiles.base.actions.QSTileIntentUserInputHandler import com.android.systemui.qs.tiles.base.interactor.QSTileInput import com.android.systemui.qs.tiles.base.interactor.QSTileUserActionInteractor import com.android.systemui.qs.tiles.dialog.InternetDialogManager +import com.android.systemui.qs.tiles.dialog.WifiStateWorker import com.android.systemui.qs.tiles.impl.internet.domain.model.InternetTileModel import com.android.systemui.qs.tiles.viewmodel.QSTileUserAction import com.android.systemui.statusbar.connectivity.AccessPointController @@ -36,6 +37,7 @@ class InternetTileUserActionInteractor constructor( @Main private val mainContext: CoroutineContext, private val internetDialogManager: InternetDialogManager, + private val wifiStateWorker: WifiStateWorker, private val accessPointController: AccessPointController, private val qsTileIntentUserActionHandler: QSTileIntentUserInputHandler, ) : QSTileUserActionInteractor<InternetTileModel> { @@ -53,6 +55,11 @@ constructor( ) } } + is QSTileUserAction.ToggleClick -> { + // TODO(b/358352265): Figure out the correct action for the secondary click + // Toggle Wifi + wifiStateWorker.isWifiEnabled = !wifiStateWorker.isWifiEnabled + } is QSTileUserAction.LongClick -> { qsTileIntentUserActionHandler.handle( action.expandable, diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/inversion/domain/interactor/ColorInversionUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/inversion/domain/interactor/ColorInversionUserActionInteractor.kt index d64327333cb6..aa8387732160 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/inversion/domain/interactor/ColorInversionUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/inversion/domain/interactor/ColorInversionUserActionInteractor.kt @@ -49,6 +49,7 @@ constructor( Intent(Settings.ACTION_COLOR_INVERSION_SETTINGS) ) } + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/location/domain/interactor/LocationTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/location/domain/interactor/LocationTileUserActionInteractor.kt index 77404aa82606..cca947ff7e77 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/location/domain/interactor/LocationTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/location/domain/interactor/LocationTileUserActionInteractor.kt @@ -68,6 +68,7 @@ constructor( Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS) ) } + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileDataInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileDataInteractor.kt index 92efa40584e7..5f5b26514de8 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileDataInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileDataInteractor.kt @@ -17,30 +17,28 @@ package com.android.systemui.qs.tiles.impl.modes.domain.interactor import android.app.Flags +import android.content.Context import android.os.UserHandle -import com.android.settingslib.notification.data.repository.ZenModeRepository +import com.android.app.tracing.coroutines.flow.map import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger import com.android.systemui.qs.tiles.base.interactor.QSTileDataInteractor import com.android.systemui.qs.tiles.impl.modes.domain.model.ModesTileModel +import com.android.systemui.statusbar.policy.domain.interactor.ZenModeInteractor import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.flowOn -import kotlinx.coroutines.flow.map class ModesTileDataInteractor @Inject constructor( - val zenModeRepository: ZenModeRepository, + val context: Context, + val zenModeInteractor: ZenModeInteractor, @Background val bgDispatcher: CoroutineDispatcher, ) : QSTileDataInteractor<ModesTileModel> { - private val activeModes = - zenModeRepository.modes - .map { modes -> modes.filter { mode -> mode.isActive }.map { it.name } } - .distinctUntilChanged() override fun tileData( user: UserHandle, @@ -53,9 +51,19 @@ constructor( * TODO(b/299909989): Remove after the transition. */ fun tileData() = - activeModes - .map { ModesTileModel(isActivated = it.isNotEmpty(), activeModes = it) } + zenModeInteractor.activeModes + .map { modes -> + ModesTileModel( + isActivated = modes.isNotEmpty(), + icon = + if (Flags.modesApi() && Flags.modesUi() && Flags.modesUiIcons()) + zenModeInteractor.getActiveModeIcon(context, modes) + else null, + activeModes = modes.map { it.name } + ) + } .flowOn(bgDispatcher) + .distinctUntilChanged() override fun availability(user: UserHandle): Flow<Boolean> = flowOf(Flags.modesUi()) } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileUserActionInteractor.kt index 083bf05d213b..eb8b23c2505a 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileUserActionInteractor.kt @@ -41,7 +41,8 @@ constructor( override suspend fun handleInput(input: QSTileInput<ModesTileModel>) { with(input) { when (action) { - is QSTileUserAction.Click -> { + is QSTileUserAction.Click, + is QSTileUserAction.ToggleClick -> { handleClick(action.expandable) } is QSTileUserAction.LongClick -> { diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/model/ModesTileModel.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/model/ModesTileModel.kt index cc509ead3031..904ff3aaad26 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/model/ModesTileModel.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/domain/model/ModesTileModel.kt @@ -15,4 +15,11 @@ */ package com.android.systemui.qs.tiles.impl.modes.domain.model -data class ModesTileModel(val isActivated: Boolean, val activeModes: List<String>) + +import com.android.systemui.common.shared.model.Icon + +data class ModesTileModel( + val isActivated: Boolean, + val activeModes: List<String>, + val icon: Icon? = null +) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapper.kt index 7afdb75b6dba..0e127e3f6bb4 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapper.kt @@ -16,10 +16,11 @@ package com.android.systemui.qs.tiles.impl.modes.ui +import android.app.Flags import android.content.res.Resources import android.icu.text.MessageFormat import android.widget.Button -import com.android.systemui.common.shared.model.Icon +import com.android.systemui.common.shared.model.asIcon import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.qs.tiles.base.interactor.QSTileDataToStateMapper import com.android.systemui.qs.tiles.impl.modes.domain.model.ModesTileModel @@ -37,18 +38,14 @@ constructor( ) : QSTileDataToStateMapper<ModesTileModel> { override fun map(config: QSTileConfig, data: ModesTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { - iconRes = - if (data.isActivated) { - R.drawable.qs_dnd_icon_on - } else { - R.drawable.qs_dnd_icon_off - } - val icon = - Icon.Loaded( - resources.getDrawable(iconRes!!, theme), - contentDescription = null, - ) - this.icon = { icon } + if (Flags.modesApi() && Flags.modesUi() && Flags.modesUiIcons() && data.icon != null) { + icon = { data.icon } + } else { + val defaultIconRes = + if (data.isActivated) R.drawable.qs_dnd_icon_on else R.drawable.qs_dnd_icon_off + iconRes = defaultIconRes + icon = { resources.getDrawable(defaultIconRes, theme).asIcon() } + } activationState = if (data.isActivated) { QSTileState.ActivationState.ACTIVE diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/night/domain/interactor/NightDisplayTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/night/domain/interactor/NightDisplayTileUserActionInteractor.kt index 5cee8c49527d..7076a8f757fe 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/night/domain/interactor/NightDisplayTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/night/domain/interactor/NightDisplayTileUserActionInteractor.kt @@ -55,6 +55,7 @@ constructor( Intent(Settings.ACTION_NIGHT_DISPLAY_SETTINGS) ) } + is QSTileUserAction.ToggleClick -> {} } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/onehanded/domain/OneHandedModeTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/onehanded/domain/OneHandedModeTileUserActionInteractor.kt index 5cb0e181378b..0a0f0a668079 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/onehanded/domain/OneHandedModeTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/onehanded/domain/OneHandedModeTileUserActionInteractor.kt @@ -49,6 +49,7 @@ constructor( Intent(Settings.ACTION_ONE_HANDED_SETTINGS) ) } + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/qr/domain/interactor/QRCodeScannerTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/qr/domain/interactor/QRCodeScannerTileUserActionInteractor.kt index 7c0c41eca4bc..bb5df022dd1b 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/qr/domain/interactor/QRCodeScannerTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/qr/domain/interactor/QRCodeScannerTileUserActionInteractor.kt @@ -45,6 +45,7 @@ constructor( } } is QSTileUserAction.LongClick -> {} // no-op + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/reducebrightness/domain/interactor/ReduceBrightColorsTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/reducebrightness/domain/interactor/ReduceBrightColorsTileUserActionInteractor.kt index ed5e4fe74962..de49e70587ca 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/reducebrightness/domain/interactor/ReduceBrightColorsTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/reducebrightness/domain/interactor/ReduceBrightColorsTileUserActionInteractor.kt @@ -71,6 +71,7 @@ constructor( Intent(Settings.ACTION_REDUCE_BRIGHT_COLORS_SETTINGS) ) } + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/rotation/domain/interactor/RotationLockTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/rotation/domain/interactor/RotationLockTileUserActionInteractor.kt index 34385ea815eb..65712c75516f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/rotation/domain/interactor/RotationLockTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/rotation/domain/interactor/RotationLockTileUserActionInteractor.kt @@ -46,6 +46,7 @@ constructor( Intent(Settings.ACTION_AUTO_ROTATE_SETTINGS) ) } + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/saver/domain/interactor/DataSaverTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/saver/domain/interactor/DataSaverTileUserActionInteractor.kt index a5dc66c901f1..252e3f84df6c 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/saver/domain/interactor/DataSaverTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/saver/domain/interactor/DataSaverTileUserActionInteractor.kt @@ -94,8 +94,7 @@ constructor( ) ?.let { controller -> dialogTransitionAnimator.show(dialog, controller) - } - ?: dialog.show() + } ?: dialog.show() } } is QSTileUserAction.LongClick -> { @@ -104,6 +103,7 @@ constructor( Intent(Settings.ACTION_DATA_SAVER_SETTINGS) ) } + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractor.kt index 5637115cd6da..48b39ed25750 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractor.kt @@ -75,6 +75,7 @@ constructor( } } is QSTileUserAction.LongClick -> {} // no-op + is QSTileUserAction.ToggleClick -> {} } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/sensorprivacy/domain/SensorPrivacyToggleTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/sensorprivacy/domain/SensorPrivacyToggleTileUserActionInteractor.kt index f22a4269b3f5..d7f64d11a4fd 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/sensorprivacy/domain/SensorPrivacyToggleTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/sensorprivacy/domain/SensorPrivacyToggleTileUserActionInteractor.kt @@ -82,6 +82,7 @@ constructor( } qsTileIntentUserActionHandler.handle(action.expandable, longClickIntent) } + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/interactor/UiModeNightTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/interactor/UiModeNightTileUserActionInteractor.kt index f8dd1730cc10..889782831b70 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/interactor/UiModeNightTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/interactor/UiModeNightTileUserActionInteractor.kt @@ -54,6 +54,7 @@ constructor( Intent(Settings.ACTION_DARK_THEME_SETTINGS) ) } + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/work/domain/interactor/WorkModeTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/work/domain/interactor/WorkModeTileUserActionInteractor.kt index 031e4d978739..45ae09eaef92 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/work/domain/interactor/WorkModeTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/work/domain/interactor/WorkModeTileUserActionInteractor.kt @@ -49,6 +49,7 @@ constructor( ) } } + is QSTileUserAction.ToggleClick -> {} } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileState.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileState.kt index 30247c41200f..549f0a73908d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileState.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileState.kt @@ -105,6 +105,7 @@ data class QSTileState( enum class UserAction { CLICK, + TOGGLE_CLICK, LONG_CLICK, } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileUserAction.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileUserAction.kt index acb29362681b..bf3bc73cf72e 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileUserAction.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileUserAction.kt @@ -23,5 +23,8 @@ sealed interface QSTileUserAction { val expandable: Expandable? class Click(override val expandable: Expandable?) : QSTileUserAction + + class ToggleClick(override val expandable: Expandable?) : QSTileUserAction + class LongClick(override val expandable: Expandable?) : QSTileUserAction } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt index 9bcf9272c5d6..8077c67bbba6 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt @@ -131,8 +131,8 @@ constructor( } override fun secondaryClick(expandable: Expandable?) { - if (isActionSupported(QSTileState.UserAction.CLICK)) { - qsTileViewModel.onActionPerformed(QSTileUserAction.Click(expandable)) + if (isActionSupported(QSTileState.UserAction.TOGGLE_CLICK)) { + qsTileViewModel.onActionPerformed(QSTileUserAction.ToggleClick(expandable)) } } @@ -184,8 +184,7 @@ constructor( } } - override fun isListening(): Boolean = - listeningClients.isNotEmpty() + override fun isListening(): Boolean = listeningClients.isNotEmpty() override fun setDetailListening(show: Boolean) { // do nothing like QSTileImpl @@ -238,6 +237,8 @@ constructor( secondaryLabel = viewModelState.secondaryLabel handlesLongClick = viewModelState.supportedActions.contains(QSTileState.UserAction.LONG_CLICK) + handlesSecondaryClick = + viewModelState.supportedActions.contains(QSTileState.UserAction.TOGGLE_CLICK) icon = when (val stateIcon = viewModelState.icon()) { diff --git a/packages/SystemUI/src/com/android/systemui/scene/data/model/SceneStack.kt b/packages/SystemUI/src/com/android/systemui/scene/data/model/SceneStack.kt index d3e529c9035b..323bb3ddd63a 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/data/model/SceneStack.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/data/model/SceneStack.kt @@ -55,6 +55,9 @@ fun SceneStack.asIterable(): Iterable<SceneKey> = Iterable { } } +/** Does this stack contain the given [sceneKey]? O(N) */ +fun SceneStack.contains(sceneKey: SceneKey): Boolean = asIterable().any { it == sceneKey } + /** * Returns a new [SceneStack] containing the given [scenes], ordered such that the first argument is * the head returned from [peek], then the second, and so forth. diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt index ad68f17720c5..0f05af65187d 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt @@ -39,6 +39,7 @@ import com.android.systemui.keyguard.ui.composable.AlternateBouncer import com.android.systemui.keyguard.ui.viewmodel.AlternateBouncerDependencies import com.android.systemui.lifecycle.WindowLifecycleState import com.android.systemui.lifecycle.repeatWhenAttached +import com.android.systemui.lifecycle.setSnapshotBinding import com.android.systemui.lifecycle.viewModel import com.android.systemui.res.R import com.android.systemui.scene.shared.flag.SceneContainerFlag @@ -56,7 +57,6 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn -import kotlinx.coroutines.launch @ExperimentalCoroutinesApi object SceneWindowRootViewBinder { @@ -140,11 +140,7 @@ object SceneWindowRootViewBinder { ) } - launch { - viewModel.isVisible.collect { isVisible -> - onVisibilityChangedInternal(isVisible) - } - } + view.setSnapshotBinding { onVisibilityChangedInternal(viewModel.isVisible) } awaitCancellation() } finally { // Here when destroyed. diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt index 0b4fb32eaf5b..7f7f0f163bcd 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt @@ -17,6 +17,7 @@ package com.android.systemui.scene.ui.viewmodel import android.view.MotionEvent +import androidx.compose.runtime.getValue import com.android.compose.animation.scene.ObservableTransitionState import com.android.compose.animation.scene.SceneKey import com.android.compose.animation.scene.UserAction @@ -55,7 +56,7 @@ constructor( val currentScene: StateFlow<SceneKey> = sceneInteractor.currentScene /** Whether the container is visible. */ - val isVisible: StateFlow<Boolean> = sceneInteractor.isVisible + val isVisible: Boolean by hydratedStateOf(sceneInteractor.isVisible) override suspend fun onActivated(): Nothing { try { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java index 0957e5a5df35..3422c67d50bd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java @@ -54,6 +54,9 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInterac import com.android.systemui.keyguard.shared.model.KeyguardState; import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; import com.android.systemui.res.R; +import com.android.systemui.scene.data.model.SceneStack; +import com.android.systemui.scene.data.model.SceneStackKt; +import com.android.systemui.scene.domain.interactor.SceneBackInteractor; import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor; import com.android.systemui.scene.domain.interactor.SceneInteractor; import com.android.systemui.scene.shared.flag.SceneContainerFlag; @@ -118,6 +121,7 @@ public class StatusBarStateControllerImpl implements private final Lazy<SceneInteractor> mSceneInteractorLazy; private final Lazy<SceneContainerOcclusionInteractor> mSceneContainerOcclusionInteractorLazy; private final Lazy<KeyguardClockInteractor> mKeyguardClockInteractorLazy; + private final Lazy<SceneBackInteractor> mSceneBackInteractorLazy; private int mState; private int mLastState; private int mUpcomingState; @@ -186,7 +190,8 @@ public class StatusBarStateControllerImpl implements Lazy<DeviceUnlockedInteractor> deviceUnlockedInteractorLazy, Lazy<SceneInteractor> sceneInteractorLazy, Lazy<SceneContainerOcclusionInteractor> sceneContainerOcclusionInteractor, - Lazy<KeyguardClockInteractor> keyguardClockInteractorLazy) { + Lazy<KeyguardClockInteractor> keyguardClockInteractorLazy, + Lazy<SceneBackInteractor> sceneBackInteractorLazy) { mUiEventLogger = uiEventLogger; mInteractionJankMonitorLazy = interactionJankMonitorLazy; mJavaAdapter = javaAdapter; @@ -196,6 +201,7 @@ public class StatusBarStateControllerImpl implements mSceneInteractorLazy = sceneInteractorLazy; mSceneContainerOcclusionInteractorLazy = sceneContainerOcclusionInteractor; mKeyguardClockInteractorLazy = keyguardClockInteractorLazy; + mSceneBackInteractorLazy = sceneBackInteractorLazy; for (int i = 0; i < HISTORY_SIZE; i++) { mHistoricalRecords[i] = new HistoricalState(); } @@ -221,6 +227,7 @@ public class StatusBarStateControllerImpl implements combineFlows( mDeviceUnlockedInteractorLazy.get().getDeviceUnlockStatus(), mSceneInteractorLazy.get().getCurrentScene(), + mSceneBackInteractorLazy.get().getBackStack(), mSceneContainerOcclusionInteractorLazy.get().getInvisibleDueToOcclusion(), this::calculateStateFromSceneFramework), this::onStatusBarStateChanged); @@ -677,10 +684,15 @@ public class StatusBarStateControllerImpl implements private int calculateStateFromSceneFramework( DeviceUnlockStatus deviceUnlockStatus, SceneKey currentScene, + SceneStack backStack, boolean isOccluded) { SceneContainerFlag.isUnexpectedlyInLegacyMode(); - - if (deviceUnlockStatus.isUnlocked() || isOccluded) { + if (currentScene.equals(Scenes.Lockscreen)) { + return StatusBarState.KEYGUARD; + } else if (currentScene.equals(Scenes.Shade) + && SceneStackKt.contains(backStack, Scenes.Lockscreen)) { + return StatusBarState.SHADE_LOCKED; + } else if (deviceUnlockStatus.isUnlocked() || isOccluded) { return StatusBarState.SHADE; } else { return Preconditions.checkNotNull(sStatusBarStateByLockedSceneKey.get(currentScene)); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index cf2c7c963138..07b0b830cf6c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -1487,7 +1487,14 @@ public class NotificationStackScrollLayout private float updateStackEndHeight() { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return 0f; - float height = Math.max(0f, mAmbientState.getStackCutoff() - mAmbientState.getStackTop()); + final float height; + if (mMaxDisplayedNotifications != -1) { + // The stack intrinsic height already contains the correct value when there is a limit + // in the max number of notifications (e.g. as in keyguard). + height = mIntrinsicContentHeight; + } else { + height = Math.max(0f, mAmbientState.getStackCutoff() - mAmbientState.getStackTop()); + } mAmbientState.setStackEndHeight(height); return height; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt index 6b95e9820a02..ed69e6f1acef 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt @@ -64,6 +64,37 @@ constructor( activateFlowDumper() } + private fun expandFractionForScene(scene: SceneKey, shadeExpansion: Float): Float = + when (scene) { + Scenes.Lockscreen, + Scenes.QuickSettings -> 1f + else -> shadeExpansion + } + + private fun expandFractionForTransition( + state: ObservableTransitionState.Transition, + shadeExpansion: Float, + shadeMode: ShadeMode, + qsExpansion: Float, + quickSettingsScene: SceneKey + ): Float = + if ( + state.isBetween({ it == Scenes.Lockscreen }, { it in SceneFamilies.NotifShade }) || + state.isBetween({ it in SceneFamilies.NotifShade }, { it == quickSettingsScene }) + ) { + 1f + } else if ( + shadeMode != ShadeMode.Split && + state.isBetween({ it in SceneFamilies.Home }, { it == quickSettingsScene }) + ) { + // during QS expansion, increase fraction at same rate as scrim alpha, + // but start when scrim alpha is at EXPANSION_FOR_DELAYED_STACK_FADE_IN. + (qsExpansion / EXPANSION_FOR_MAX_SCRIM_ALPHA - EXPANSION_FOR_DELAYED_STACK_FADE_IN) + .coerceIn(0f, 1f) + } else { + shadeExpansion + } + /** * The expansion fraction of the notification stack. It should go from 0 to 1 when transitioning * from Gone to Shade scenes, and remain at 1 when in Lockscreen or Shade scenes and while @@ -78,41 +109,16 @@ constructor( sceneInteractor.resolveSceneFamily(SceneFamilies.QuickSettings), ) { shadeExpansion, shadeMode, qsExpansion, transitionState, quickSettingsScene -> when (transitionState) { - is ObservableTransitionState.Idle -> { - when (transitionState.currentScene) { - Scenes.Lockscreen, - Scenes.QuickSettings -> 1f - else -> shadeExpansion - } - } - is ObservableTransitionState.Transition -> { - if ( - (transitionState.fromScene in SceneFamilies.NotifShade && - transitionState.toScene == quickSettingsScene) || - (transitionState.fromScene in quickSettingsScene && - transitionState.toScene in SceneFamilies.NotifShade) || - (transitionState.fromScene == Scenes.Lockscreen && - transitionState.toScene in SceneFamilies.NotifShade) || - (transitionState.fromScene in SceneFamilies.NotifShade && - transitionState.toScene == Scenes.Lockscreen) - ) { - 1f - } else if ( - shadeMode != ShadeMode.Split && - (transitionState.fromScene in SceneFamilies.Home && - transitionState.toScene == quickSettingsScene) || - (transitionState.fromScene == quickSettingsScene && - transitionState.toScene in SceneFamilies.Home) - ) { - // during QS expansion, increase fraction at same rate as scrim alpha, - // but start when scrim alpha is at EXPANSION_FOR_DELAYED_STACK_FADE_IN. - (qsExpansion / EXPANSION_FOR_MAX_SCRIM_ALPHA - - EXPANSION_FOR_DELAYED_STACK_FADE_IN) - .coerceIn(0f, 1f) - } else { - shadeExpansion - } - } + is ObservableTransitionState.Idle -> + expandFractionForScene(transitionState.currentScene, shadeExpansion) + is ObservableTransitionState.Transition -> + expandFractionForTransition( + transitionState, + shadeExpansion, + shadeMode, + qsExpansion, + quickSettingsScene + ) } } .distinctUntilChanged() @@ -209,3 +215,8 @@ constructor( fun create(): NotificationScrollViewModel } } + +private fun ObservableTransitionState.Transition.isBetween( + a: (SceneKey) -> Boolean, + b: (SceneKey) -> Boolean +): Boolean = (a(fromScene) && b(toScene)) || (b(fromScene) && a(toScene)) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java index 720b257e4006..0ea28a75094c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java @@ -636,6 +636,7 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements mOnReorderingAllowedListener); } else if (mTrackingHeadsUp) { mEntriesToRemoveAfterExpand.add(entry); + mLogger.logRemoveEntryAfterExpand(entry); } else if (mVisualStabilityProvider.isReorderingAllowed() || entry.showingPulsing()) { removeEntry(entry.getKey(), "createRemoveRunnable"); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManagerLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManagerLogger.kt index c6fc54748cbd..600270c7189a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManagerLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManagerLogger.kt @@ -293,6 +293,14 @@ constructor(@NotificationHeadsUpLog private val buffer: LogBuffer) { { "has pinned notification changed to $bool1" } ) } + + fun logRemoveEntryAfterExpand(entry: NotificationEntry) { + buffer.log(TAG, VERBOSE, { + str1 = entry.logKey + }, { + "remove entry after expand: $str1" + }) + } } private const val TAG = "HeadsUpManager" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/domain/interactor/ZenModeInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/domain/interactor/ZenModeInteractor.kt index efd60f632804..75861331d932 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/domain/interactor/ZenModeInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/domain/interactor/ZenModeInteractor.kt @@ -26,6 +26,7 @@ import com.android.settingslib.notification.data.repository.ZenModeRepository import com.android.settingslib.notification.modes.ZenIconLoader import com.android.settingslib.notification.modes.ZenMode import com.android.systemui.common.shared.model.Icon +import com.android.systemui.common.shared.model.asIcon import com.android.systemui.shared.notifications.data.repository.NotificationSettingsRepository import java.time.Duration import javax.inject.Inject @@ -74,8 +75,27 @@ constructor( val modes: Flow<List<ZenMode>> = zenModeRepository.modes - suspend fun getModeIcon(mode: ZenMode, context: Context): Icon { - return Icon.Loaded(mode.getIcon(context, iconLoader).await(), contentDescription = null) + val activeModes: Flow<List<ZenMode>> = + modes.map { modes -> modes.filter { mode -> mode.isActive } }.distinctUntilChanged() + + /** + * Given the list of modes (which may include zero or more currently active modes), returns an + * icon representing the active mode, if any (or, if multiple modes are active, to the most + * prioritized one). This icon is suitable for use in the status bar or lockscreen (uses the + * standard DND icon for implicit modes, instead of the launcher icon of the associated + * package). + */ + suspend fun getActiveModeIcon(context: Context, modes: List<ZenMode>): Icon? { + return modes + .sortedWith(ZenMode.PRIORITIZING_COMPARATOR) + .firstOrNull { it.isActive } + ?.getLockscreenIcon(context, iconLoader) + ?.await() + ?.asIcon() + } + + suspend fun getModeIcon(context: Context, mode: ZenMode): Icon { + return mode.getIcon(context, iconLoader).await().asIcon() } fun activateMode(zenMode: ZenMode) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModel.kt index 16c18dd8c4b8..02b5e491047a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModel.kt @@ -88,8 +88,8 @@ constructor( modesList.map { mode -> ModeTileViewModel( id = mode.id, - icon = zenModeInteractor.getModeIcon(mode, context), - text = mode.rule.name, + icon = zenModeInteractor.getModeIcon(context, mode), + text = mode.name, subtext = getTileSubtext(mode), enabled = mode.isActive, onClick = { diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt index f94a6f24a106..1e2369034bf7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt @@ -41,6 +41,7 @@ import android.widget.ScrollView import androidx.constraintlayout.widget.ConstraintLayout import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.app.viewcapture.ViewCapture import com.android.internal.jank.InteractionJankMonitor import com.android.internal.widget.LockPatternUtils import com.android.launcher3.icons.IconProvider @@ -111,6 +112,7 @@ open class AuthContainerViewTest : SysuiTestCase() { @Mock lateinit var selectedUserInteractor: SelectedUserInteractor @Mock private lateinit var packageManager: PackageManager @Mock private lateinit var activityTaskManager: ActivityTaskManager + @Mock private lateinit var lazyViewCapture: Lazy<ViewCapture> private lateinit var displayRepository: FakeDisplayRepository private lateinit var displayStateInteractor: DisplayStateInteractor @@ -665,7 +667,8 @@ open class AuthContainerViewTest : SysuiTestCase() { ), { credentialViewModel }, fakeExecutor, - vibrator + vibrator, + lazyViewCapture ) { override fun postOnAnimation(runnable: Runnable) { runnable.run() diff --git a/packages/SystemUI/tests/src/com/android/systemui/inputdevice/data/repository/UserInputDeviceRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/inputdevice/data/repository/UserInputDeviceRepositoryTest.kt new file mode 100644 index 000000000000..f2e43fcb8e2c --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/inputdevice/data/repository/UserInputDeviceRepositoryTest.kt @@ -0,0 +1,106 @@ +/* + * Copyright 2024 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.systemui.inputdevice.data.repository + +import android.content.pm.UserInfo +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.SmallTest +import com.android.systemui.SysuiTestCase +import com.android.systemui.coroutines.collectValues +import com.android.systemui.inputdevice.data.model.UserDeviceConnectionStatus +import com.android.systemui.keyboard.data.repository.keyboardRepository +import com.android.systemui.kosmos.Kosmos +import com.android.systemui.kosmos.testDispatcher +import com.android.systemui.kosmos.testScope +import com.android.systemui.touchpad.data.repository.touchpadRepository +import com.android.systemui.user.data.repository.fakeUserRepository +import com.android.systemui.user.data.repository.userRepository +import com.google.common.truth.Truth.assertThat +import kotlinx.coroutines.test.runCurrent +import kotlinx.coroutines.test.runTest +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith + +@SmallTest +@RunWith(AndroidJUnit4::class) +@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) +class UserInputDeviceRepositoryTest : SysuiTestCase() { + + private lateinit var underTest: UserInputDeviceRepository + private val kosmos = Kosmos() + private val testScope = kosmos.testScope + private val keyboardRepository = kosmos.keyboardRepository + private val touchpadRepository = kosmos.touchpadRepository + private val userRepository = kosmos.fakeUserRepository + + @Before + fun setup() { + underTest = + UserInputDeviceRepository( + kosmos.testDispatcher, + keyboardRepository, + touchpadRepository, + kosmos.userRepository + ) + userRepository.setUserInfos(USER_INFOS) + } + + @Test + fun emitsNewKeyboardConnectedValueOnUserChanged() = + testScope.runTest { + val isAnyKeyboardConnected by collectValues(underTest.isAnyKeyboardConnectedForUser) + userRepository.setSelectedUserInfo(USER_INFOS[0]) + keyboardRepository.setIsAnyKeyboardConnected(true) + runCurrent() + + userRepository.setSelectedUserInfo(USER_INFOS[1]) + + assertThat(isAnyKeyboardConnected) + .containsExactly( + UserDeviceConnectionStatus(isConnected = true, USER_INFOS[0].id), + UserDeviceConnectionStatus(isConnected = true, USER_INFOS[1].id) + ) + .inOrder() + } + + @Test + fun emitsNewTouchpadConnectedValueOnUserChanged() = + testScope.runTest { + val isAnyTouchpadConnected by collectValues(underTest.isAnyTouchpadConnectedForUser) + userRepository.setSelectedUserInfo(USER_INFOS[0]) + touchpadRepository.setIsAnyTouchpadConnected(true) + runCurrent() + + userRepository.setSelectedUserInfo(USER_INFOS[1]) + + assertThat(isAnyTouchpadConnected) + .containsExactly( + UserDeviceConnectionStatus(isConnected = true, USER_INFOS[0].id), + UserDeviceConnectionStatus(isConnected = true, USER_INFOS[1].id) + ) + .inOrder() + } + + companion object { + private val USER_INFOS = + listOf( + UserInfo(100, "First User", 0), + UserInfo(101, "Second User", 0), + ) + } +} diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerViewModelTest.kt index 664a0bdedec4..2021400b326a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerViewModelTest.kt @@ -21,6 +21,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.policy.IKeyguardDismissCallback import com.android.systemui.SysuiTestCase +import com.android.systemui.bouncer.domain.interactor.primaryBouncerInteractor import com.android.systemui.concurrency.fakeExecutor import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues @@ -30,6 +31,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.testScope +import com.android.systemui.plugins.ActivityStarter import com.android.systemui.statusbar.phone.statusBarKeyguardViewManager import com.android.systemui.testKosmos import com.android.systemui.util.mockito.any @@ -62,13 +64,31 @@ class AlternateBouncerViewModelTest : SysuiTestCase() { @Test fun onRemovedFromWindow() = testScope.runTest { + kosmos.primaryBouncerInteractor.setDismissAction( + mock(ActivityStarter.OnDismissAction::class.java), + {}, + ) + assertThat(kosmos.primaryBouncerInteractor.bouncerDismissAction).isNotNull() + + val dismissCallback = mock(IKeyguardDismissCallback::class.java) + kosmos.dismissCallbackRegistry.addCallback(dismissCallback) underTest.onRemovedFromWindow() + + kosmos.fakeExecutor.runAllReady() verify(statusBarKeyguardViewManager).hideAlternateBouncer(any()) + verify(dismissCallback).onDismissCancelled() + assertThat(kosmos.primaryBouncerInteractor.bouncerDismissAction).isNull() } @Test fun onBackRequested() = testScope.runTest { + kosmos.primaryBouncerInteractor.setDismissAction( + mock(ActivityStarter.OnDismissAction::class.java), + {}, + ) + assertThat(kosmos.primaryBouncerInteractor.bouncerDismissAction).isNotNull() + val dismissCallback = mock(IKeyguardDismissCallback::class.java) kosmos.dismissCallbackRegistry.addCallback(dismissCallback) @@ -76,6 +96,7 @@ class AlternateBouncerViewModelTest : SysuiTestCase() { kosmos.fakeExecutor.runAllReady() verify(statusBarKeyguardViewManager).hideAlternateBouncer(any()) verify(dismissCallback).onDismissCancelled() + assertThat(kosmos.primaryBouncerInteractor.bouncerDismissAction).isNull() } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileNewImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileNewImplTest.kt index 79cb51ab3e10..828c7b2dbc69 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileNewImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileNewImplTest.kt @@ -23,7 +23,6 @@ import android.testing.TestableLooper.RunWithLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.logging.MetricsLogger -import com.android.systemui.res.R import com.android.systemui.SysuiTestCase import com.android.systemui.classifier.FalsingManagerFake import com.android.systemui.plugins.ActivityStarter @@ -32,6 +31,8 @@ import com.android.systemui.qs.QSHost import com.android.systemui.qs.QsEventLogger import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tiles.dialog.InternetDialogManager +import com.android.systemui.qs.tiles.dialog.WifiStateWorker +import com.android.systemui.res.R import com.android.systemui.statusbar.connectivity.AccessPointController import com.android.systemui.statusbar.pipeline.airplane.data.repository.FakeAirplaneModeRepository import com.android.systemui.statusbar.pipeline.ethernet.domain.EthernetInteractor @@ -46,7 +47,6 @@ import com.android.systemui.statusbar.pipeline.wifi.domain.interactor.WifiIntera import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiScanEntry import com.android.systemui.util.mockito.mock -import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.StandardTestDispatcher @@ -58,6 +58,10 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.MockitoAnnotations +import org.mockito.kotlin.eq +import org.mockito.kotlin.times +import org.mockito.kotlin.verify +import org.mockito.kotlin.whenever @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @@ -87,6 +91,7 @@ class InternetTileNewImplTest : SysuiTestCase() { @Mock private lateinit var activityStarter: ActivityStarter @Mock private lateinit var logger: QSLogger @Mock private lateinit var dialogManager: InternetDialogManager + @Mock private lateinit var wifiStateWorker: WifiStateWorker @Mock private lateinit var accessPointController: AccessPointController @Before @@ -122,6 +127,7 @@ class InternetTileNewImplTest : SysuiTestCase() { logger, viewModel, dialogManager, + wifiStateWorker, accessPointController ) @@ -231,6 +237,24 @@ class InternetTileNewImplTest : SysuiTestCase() { assertThat(underTest.state.secondaryLabel).isEqualTo(WIFI_SSID) } + @Test + fun secondaryClick_turnsWifiOff() { + whenever(wifiStateWorker.isWifiEnabled).thenReturn(true) + + underTest.secondaryClick(null) + + verify(wifiStateWorker, times(1)).isWifiEnabled = eq(false) + } + + @Test + fun secondaryClick_turnsWifiOn() { + whenever(wifiStateWorker.isWifiEnabled).thenReturn(false) + + underTest.secondaryClick(null) + + verify(wifiStateWorker, times(1)).isWifiEnabled = eq(true) + } + companion object { const val WIFI_SSID = "test ssid" val ACTIVE_WIFI = diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileTest.java index 8ea79d7cc230..0cf96047fcc0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileTest.java @@ -18,7 +18,10 @@ package com.android.systemui.qs.tiles; import static com.google.common.truth.Truth.assertThat; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.os.Handler; @@ -38,6 +41,7 @@ import com.android.systemui.qs.QsEventLogger; import com.android.systemui.qs.logging.QSLogger; import com.android.systemui.qs.tileimpl.QSTileImpl; import com.android.systemui.qs.tiles.dialog.InternetDialogManager; +import com.android.systemui.qs.tiles.dialog.WifiStateWorker; import com.android.systemui.res.R; import com.android.systemui.statusbar.connectivity.AccessPointController; import com.android.systemui.statusbar.connectivity.IconState; @@ -65,6 +69,8 @@ public class InternetTileTest extends SysuiTestCase { @Mock private InternetDialogManager mInternetDialogManager; @Mock + private WifiStateWorker mWifiStateWorker; + @Mock private QsEventLogger mUiEventLogger; private TestableLooper mTestableLooper; @@ -89,7 +95,8 @@ public class InternetTileTest extends SysuiTestCase { mock(QSLogger.class), mNetworkController, mAccessPointController, - mInternetDialogManager + mInternetDialogManager, + mWifiStateWorker ); mTile.initialize(); @@ -167,4 +174,22 @@ public class InternetTileTest extends SysuiTestCase { assertThat(mTile.getState().icon).isEqualTo( QSTileImpl.ResourceIcon.get(R.drawable.ic_qs_no_internet_unavailable)); } + + @Test + public void secondaryClick_turnsWifiOff() { + when(mWifiStateWorker.isWifiEnabled()).thenReturn(true); + + mTile.secondaryClick(null); + + verify(mWifiStateWorker, times(1)).setWifiEnabled(eq(false)); + } + + @Test + public void secondaryClick_turnsWifiOn() { + when(mWifiStateWorker.isWifiEnabled()).thenReturn(false); + + mTile.secondaryClick(null); + + verify(mWifiStateWorker, times(1)).setWifiEnabled(eq(true)); + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ModesTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ModesTileTest.kt index a5de7cd0b4db..c2f035f1c241 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ModesTileTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ModesTileTest.kt @@ -41,6 +41,8 @@ import com.android.systemui.qs.tiles.viewmodel.QSTileConfigProvider import com.android.systemui.qs.tiles.viewmodel.QSTileConfigTestBuilder import com.android.systemui.qs.tiles.viewmodel.QSTileUIConfig import com.android.systemui.res.R +import com.android.systemui.shared.notifications.data.repository.NotificationSettingsRepository +import com.android.systemui.statusbar.policy.domain.interactor.ZenModeInteractor import com.android.systemui.statusbar.policy.ui.dialog.ModesDialogDelegate import com.android.systemui.util.mockito.any import com.android.systemui.util.settings.FakeSettings @@ -57,6 +59,7 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.MockitoAnnotations +import org.mockito.kotlin.mock import org.mockito.kotlin.whenever @OptIn(ExperimentalCoroutinesApi::class) @@ -87,7 +90,12 @@ class ModesTileTest : SysuiTestCase() { private val inputHandler = FakeQSTileIntentUserInputHandler() private val zenModeRepository = FakeZenModeRepository() - private val tileDataInteractor = ModesTileDataInteractor(zenModeRepository, testDispatcher) + private val tileDataInteractor = + ModesTileDataInteractor( + context, + ZenModeInteractor(zenModeRepository, mock<NotificationSettingsRepository>()), + testDispatcher + ) private val mapper = ModesTileMapper( context.orCreateTestableResources diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java index 8125ef55f4af..523d15c7548f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java @@ -468,7 +468,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { () -> mKosmos.getDeviceUnlockedInteractor(), () -> mKosmos.getSceneInteractor(), () -> mKosmos.getSceneContainerOcclusionInteractor(), - () -> mKosmos.getKeyguardClockInteractor()); + () -> mKosmos.getKeyguardClockInteractor(), + () -> mKosmos.getSceneBackInteractor()); KeyguardStatusView keyguardStatusView = new KeyguardStatusView(mContext); keyguardStatusView.setId(R.id.keyguard_status_view); @@ -625,7 +626,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { () -> mKosmos.getDeviceUnlockedInteractor(), () -> mKosmos.getSceneInteractor(), () -> mKosmos.getSceneContainerOcclusionInteractor(), - () -> mKosmos.getKeyguardClockInteractor()), + () -> mKosmos.getKeyguardClockInteractor(), + () -> mKosmos.getSceneBackInteractor()), mKeyguardBypassController, mDozeParameters, mScreenOffAnimationController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index 22b98874c7ef..1717f4c069f4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -354,6 +354,20 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { } @Test + @EnableSceneContainer + public void updateStackEndHeightAndStackHeight_maxNotificationsSet_withSceneContainer() { + float stackHeight = 300f; + when(mStackSizeCalculator.computeHeight(eq(mStackScroller), anyInt(), anyFloat())) + .thenReturn(stackHeight); + mStackScroller.setMaxDisplayedNotifications(3); // any non-zero amount + + clearInvocations(mAmbientState); + mStackScroller.updateStackEndHeightAndStackHeight(1f); + + verify(mAmbientState).setStackHeight(eq(300f)); + } + + @Test public void updateStackEndHeightAndStackHeight_onlyUpdatesStackHeightDuringSwipeUp() { final float expansionFraction = 0.5f; mAmbientState.setStatusBarState(StatusBarState.KEYGUARD); diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerViewModelKosmos.kt index 29583153ccc6..f1d87fe3abb7 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerViewModelKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerViewModelKosmos.kt @@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.viewmodel import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor +import com.android.systemui.bouncer.domain.interactor.primaryBouncerInteractor import com.android.systemui.keyguard.dismissCallbackRegistry import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.kosmos.Kosmos @@ -32,5 +33,6 @@ val Kosmos.alternateBouncerViewModel by Fixture { keyguardTransitionInteractor = keyguardTransitionInteractor, dismissCallbackRegistry = dismissCallbackRegistry, alternateBouncerInteractor = { alternateBouncerInteractor }, + primaryBouncerInteractor = primaryBouncerInteractor, ) } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt index e6bd24b6b99a..9fe66eb77feb 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt @@ -50,6 +50,7 @@ import com.android.systemui.model.sceneContainerPlugin import com.android.systemui.plugins.statusbar.statusBarStateController import com.android.systemui.power.data.repository.fakePowerRepository import com.android.systemui.power.domain.interactor.powerInteractor +import com.android.systemui.scene.domain.interactor.sceneBackInteractor import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.domain.startable.scrimStartable @@ -115,6 +116,7 @@ class KosmosJavaAdapter() { val interactionJankMonitor by lazy { kosmos.interactionJankMonitor } val fakeSceneContainerConfig by lazy { kosmos.sceneContainerConfig } val sceneInteractor by lazy { kosmos.sceneInteractor } + val sceneBackInteractor by lazy { kosmos.sceneBackInteractor } val falsingCollector by lazy { kosmos.falsingCollector } val powerInteractor by lazy { kosmos.powerInteractor } val deviceEntryInteractor by lazy { kosmos.deviceEntryInteractor } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt index f9f8d232611e..2deeb253e925 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt @@ -22,6 +22,7 @@ import com.android.systemui.jank.interactionJankMonitor import com.android.systemui.keyguard.domain.interactor.keyguardClockInteractor import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.kosmos.Kosmos +import com.android.systemui.scene.domain.interactor.sceneBackInteractor import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.shade.domain.interactor.shadeInteractor @@ -41,5 +42,6 @@ var Kosmos.statusBarStateController: SysuiStatusBarStateController by { sceneInteractor }, { sceneContainerOcclusionInteractor }, { keyguardClockInteractor }, + { sceneBackInteractor }, ) } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/base/interactor/QSTileInputTestKtx.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/base/interactor/QSTileInputTestKtx.kt index 9cb76bb412f9..3943d1d7ec01 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/base/interactor/QSTileInputTestKtx.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/base/interactor/QSTileInputTestKtx.kt @@ -28,6 +28,12 @@ object QSTileInputTestKtx { expandable: Expandable? = null, ): QSTileInput<T> = QSTileInput(user, QSTileUserAction.Click(expandable), data) + fun <T> toggleClick( + data: T, + user: UserHandle = UserHandle.CURRENT, + expandable: Expandable? = null, + ): QSTileInput<T> = QSTileInput(user, QSTileUserAction.ToggleClick(expandable), data) + fun <T> longClick( data: T, user: UserHandle = UserHandle.CURRENT, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/touchpad/data/repository/TouchpadRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/touchpad/data/repository/TouchpadRepositoryKosmos.kt new file mode 100644 index 000000000000..91e239602b23 --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/touchpad/data/repository/TouchpadRepositoryKosmos.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2024 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.systemui.touchpad.data.repository + +import com.android.systemui.kosmos.Kosmos + +val Kosmos.touchpadRepository by Kosmos.Fixture { FakeTouchpadRepository() } diff --git a/services/accessibility/TEST_MAPPING b/services/accessibility/TEST_MAPPING index 454a3299af68..3f85a9005582 100644 --- a/services/accessibility/TEST_MAPPING +++ b/services/accessibility/TEST_MAPPING @@ -53,18 +53,7 @@ ] }, { - "name": "FrameworksCoreTests", - "options": [ - { - "include-filter": "android.accessibilityservice" - }, - { - "include-filter": "android.view.accessibility" - }, - { - "include-filter": "com.android.internal.accessibility" - } - ] + "name": "FrameworksCoreTests_accessibility" } ] } diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java index 45fcf6b756cf..0aa750e84a22 100644 --- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -38,7 +38,11 @@ import static android.accessibilityservice.AccessibilityTrace.FLAGS_WINDOW_MANAG import static android.companion.virtual.VirtualDeviceManager.ACTION_VIRTUAL_DEVICE_REMOVED; import static android.companion.virtual.VirtualDeviceManager.EXTRA_VIRTUAL_DEVICE_ID; import static android.content.Context.DEVICE_ID_DEFAULT; +import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU; +import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_GESTURE; +import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR; import static android.provider.Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED; +import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL; import static android.view.accessibility.AccessibilityManager.FlashNotificationReason; import static com.android.hardware.input.Flags.keyboardA11yMouseKeys; @@ -55,6 +59,7 @@ import static com.android.internal.accessibility.common.ShortcutConstants.UserSh import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TRIPLETAP; import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TWOFINGER_DOUBLETAP; import static com.android.internal.accessibility.util.AccessibilityStatsLogUtils.logAccessibilityShortcutActivated; +import static com.android.internal.accessibility.util.AccessibilityUtils.isUserSetupCompleted; import static com.android.internal.util.FunctionalUtils.ignoreRemoteException; import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage; import static com.android.server.accessibility.AccessibilityUserState.doesShortcutTargetsStringContain; @@ -937,8 +942,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub } } case Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, - Settings.Secure.ACCESSIBILITY_QS_TARGETS, - Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE -> + Settings.Secure.ACCESSIBILITY_GESTURE_TARGETS, + Settings.Secure.ACCESSIBILITY_QS_TARGETS, + Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE -> restoreShortcutTargets(newValue, ShortcutUtils.convertToType(which)); } @@ -1995,6 +2001,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub // Accessibility Menu component disabled. disableAccessibilityMenuToMigrateIfNeeded(); + // As an initialization step, update the shortcuts for the current user. + updateShortcutsForCurrentNavigationMode(); + if (announceNewUser) { // Schedule announcement of the current user if needed. mMainHandler.sendMessageDelayed( @@ -2216,6 +2225,69 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub mProxyManager.clearCacheLocked(); } + @VisibleForTesting + void updateShortcutsForCurrentNavigationMode() { + synchronized (mLock) { + AccessibilityUserState userState = getCurrentUserStateLocked(); + if (!isUserSetupCompleted(mContext)) { + return; + } + final boolean isInGesturalNavigation = Settings.Secure.getIntForUser( + mContext.getContentResolver(), Settings.Secure.NAVIGATION_MODE, + -1, userState.mUserId) == NAV_BAR_MODE_GESTURAL; + + Set<String> gestureTargets = userState.getShortcutTargetsLocked(GESTURE); + Set<String> softwareTargets = userState.getShortcutTargetsLocked(SOFTWARE); + int buttonMode = ShortcutUtils.getButtonMode(mContext, userState.mUserId); + + if (android.provider.Flags.a11yStandaloneGestureEnabled()) { + if (isInGesturalNavigation) { + if (buttonMode == ACCESSIBILITY_BUTTON_MODE_GESTURE) { + // GESTURE button mode indicates migrating from old version + // User was using gesture, so move all targets into gesture + gestureTargets.addAll(softwareTargets); + softwareTargets.clear(); + } + buttonMode = ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU; + } else { + // Only change the current button mode if there are gesture targets + // (indicating the user came from gesture mode or is migrating) + if (!gestureTargets.isEmpty()) { + buttonMode = softwareTargets.isEmpty() + ? ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR + : ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU; + + softwareTargets.addAll(gestureTargets); + gestureTargets.clear(); + } + } + } else { + if (!gestureTargets.isEmpty()) { + // Adjust button mode before clearing out gesture targets + if (!softwareTargets.isEmpty()) { + buttonMode = ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU; + } else if (isInGesturalNavigation) { + buttonMode = ACCESSIBILITY_BUTTON_MODE_GESTURE; + } else { + buttonMode = ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR; + } + softwareTargets.addAll(gestureTargets); + gestureTargets.clear(); + } else if (buttonMode != ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU) { + buttonMode = isInGesturalNavigation + ? ACCESSIBILITY_BUTTON_MODE_GESTURE + : ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR; + } + } + + updateShortcutTargetSets(userState, Set.of( + Pair.create(gestureTargets, GESTURE), + Pair.create(softwareTargets, SOFTWARE) + )); + ShortcutUtils.setButtonMode(mContext, buttonMode, userState.mUserId); + } + } + private void notifyMagnificationChangedLocked(int displayId, @NonNull Region region, @NonNull MagnificationConfig config) { final AccessibilityUserState state = getCurrentUserStateLocked(); @@ -3646,6 +3718,23 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub scheduleNotifyClientsOfServicesStateChangeLocked(userState); } + private void updateShortcutTargetSets(AccessibilityUserState userState, + Set<Pair<Set<String>, Integer>> targetSets) { + boolean somethingChanged = false; + for (Pair<Set<String>, Integer> pair : targetSets) { + Set<String> targets = pair.first; + int type = pair.second; + if (userState.updateShortcutTargetsLocked(targets, type)) { + somethingChanged = true; + persistColonDelimitedSetToSettingLocked(ShortcutUtils.convertToKey(type), + userState.mUserId, targets, str -> str); + } + } + if (somethingChanged) { + scheduleNotifyClientsOfServicesStateChangeLocked(userState); + } + } + /** * 1) Check if the service assigned to accessibility button target sdk version > Q. * If it isn't, remove it from the list and associated setting. @@ -5505,6 +5594,12 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub private final Uri mMouseKeysUri = Settings.Secure.getUriFor( Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_ENABLED); + private final Uri mNavigationModeUri = Settings.Secure.getUriFor( + Settings.Secure.NAVIGATION_MODE); + + private final Uri mUserSetupCompleteUri = Settings.Secure.getUriFor( + Settings.Secure.USER_SETUP_COMPLETE); + public AccessibilityContentObserver(Handler handler) { super(handler); } @@ -5555,6 +5650,10 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub mAlwaysOnMagnificationUri, false, this, UserHandle.USER_ALL); contentResolver.registerContentObserver( mMouseKeysUri, false, this, UserHandle.USER_ALL); + contentResolver.registerContentObserver( + mNavigationModeUri, false, this, UserHandle.USER_ALL); + contentResolver.registerContentObserver( + mUserSetupCompleteUri, false, this, UserHandle.USER_ALL); } @Override @@ -5639,6 +5738,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub if (readMouseKeysEnabledLocked(userState)) { onUserStateChangedLocked(userState); } + } else if (mNavigationModeUri.equals(uri) || mUserSetupCompleteUri.equals(uri)) { + updateShortcutsForCurrentNavigationMode(); } } } diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java index 3706dccbb717..b18e6ba8444d 100644 --- a/services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java +++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java @@ -57,6 +57,7 @@ import android.view.accessibility.IAccessibilityManagerClient; import com.android.internal.R; import com.android.internal.accessibility.AccessibilityShortcutController; +import com.android.internal.accessibility.util.ShortcutUtils; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -579,6 +580,9 @@ class AccessibilityUserState { .append(String.valueOf(mAlwaysOnMagnificationEnabled)); pw.append("}"); pw.println(); + pw.append(" button mode: "); + pw.append(String.valueOf(ShortcutUtils.getButtonMode(mContext, mUserId))); + pw.println(); dumpShortcutTargets(pw, HARDWARE, "shortcut key"); dumpShortcutTargets(pw, SOFTWARE, "button"); pw.append(" button target:{").append(mTargetAssignedToAccessibilityButton); diff --git a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java index 6b8e8c74a4e4..9c6bcdf8a67c 100644 --- a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java +++ b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java @@ -43,9 +43,12 @@ import java.util.concurrent.TimeUnit; */ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { private static final String TAG = AppFunctionManagerServiceImpl.class.getSimpleName(); + private final RemoteServiceCaller<IAppFunctionService> mRemoteServiceCaller; private final CallerValidator mCallerValidator; private final ServiceHelper mInternalServiceHelper; + private final ServiceConfig mServiceConfig; + public AppFunctionManagerServiceImpl(@NonNull Context context) { this(new RemoteServiceCallerImpl<>( @@ -57,17 +60,20 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { /*unit=*/ TimeUnit.SECONDS, /*workQueue=*/ new LinkedBlockingQueue<>())), new CallerValidatorImpl(context), - new ServiceHelperImpl(context)); + new ServiceHelperImpl(context), + new ServiceConfigImpl()); } @VisibleForTesting AppFunctionManagerServiceImpl(RemoteServiceCaller<IAppFunctionService> remoteServiceCaller, CallerValidator callerValidator, - ServiceHelper appFunctionInternalServiceHelper) { + ServiceHelper appFunctionInternalServiceHelper, + ServiceConfig serviceConfig) { mRemoteServiceCaller = Objects.requireNonNull(remoteServiceCaller); mCallerValidator = Objects.requireNonNull(callerValidator); mInternalServiceHelper = Objects.requireNonNull(appFunctionInternalServiceHelper); + mServiceConfig = serviceConfig; } @Override @@ -131,12 +137,10 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { ).build()); return; } - bindAppFunctionServiceUnchecked(requestInternal, serviceIntent, targetUser, safeExecuteAppFunctionCallback, /*bindFlags=*/ Context.BIND_AUTO_CREATE, - // TODO(b/357551503): Make timeout configurable. - /*timeoutInMillis=*/ 30_000L); + /*timeoutInMillis=*/ mServiceConfig.getExecutionTimeoutConfig()); } private void bindAppFunctionServiceUnchecked( diff --git a/services/appfunctions/java/com/android/server/appfunctions/ServiceConfig.java b/services/appfunctions/java/com/android/server/appfunctions/ServiceConfig.java new file mode 100644 index 000000000000..35c6c783ab43 --- /dev/null +++ b/services/appfunctions/java/com/android/server/appfunctions/ServiceConfig.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 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.server.appfunctions; + +/** + * This interface is used to expose configs to the AppFunctionManagerService. + */ +public interface ServiceConfig { + // TODO(b/357551503): Obtain namespace from DeviceConfig. + String NAMESPACE_APP_FUNCTIONS = "appfunctions"; + + /** + * Returns the maximum time to wait for an app function execution to be complete. + */ + long getExecutionTimeoutConfig(); +} diff --git a/services/appfunctions/java/com/android/server/appfunctions/ServiceConfigImpl.java b/services/appfunctions/java/com/android/server/appfunctions/ServiceConfigImpl.java new file mode 100644 index 000000000000..b203ead81121 --- /dev/null +++ b/services/appfunctions/java/com/android/server/appfunctions/ServiceConfigImpl.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2024 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.server.appfunctions; + +import android.provider.DeviceConfig; + +/** + * Implementation of {@link ServiceConfig} + */ +public class ServiceConfigImpl implements ServiceConfig { + static final String DEVICE_CONFIG_PROPERTY_EXECUTION_TIMEOUT = "execution_timeout"; + static final long DEFAULT_EXECUTION_TIMEOUT_MS = 5000L; + + + @Override + public long getExecutionTimeoutConfig() { + return DeviceConfig.getLong( + NAMESPACE_APP_FUNCTIONS, + DEVICE_CONFIG_PROPERTY_EXECUTION_TIMEOUT, + DEFAULT_EXECUTION_TIMEOUT_MS + ); + } +} diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java index 9f7fb5710bcc..259ea148f163 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java +++ b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java @@ -423,27 +423,22 @@ public final class AutofillManagerService @Nullable private AutofillManagerServiceImpl getServiceForUserWithLocalBinderIdentityLocked(int userId) { final long token = Binder.clearCallingIdentity(); - AutofillManagerServiceImpl managerService = null; try { - managerService = getServiceForUserLocked(userId); + return getServiceForUserLocked(userId); } finally { Binder.restoreCallingIdentity(token); } - return managerService; } @GuardedBy("mLock") @Nullable private AutofillManagerServiceImpl peekServiceForUserWithLocalBinderIdentityLocked(int userId) { final long token = Binder.clearCallingIdentity(); - AutofillManagerServiceImpl managerService = null; try { - managerService = peekServiceForUserLocked(userId); + return peekServiceForUserLocked(userId); } finally { Binder.restoreCallingIdentity(token); } - - return managerService; } @Override // from AbstractMasterSystemService diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index c75fd0b7e025..b109472a2a1e 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -4664,6 +4664,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // event as concluded. if (!wasPreviouslyFillDialog && (!isSameViewEntered || maybeNewRequestId.isPresent())) { + mPresentationStatsEventLogger.logAndEndEvent("new view entered"); startNewEventForPresentationStatsEventLogger(); if (maybeNewRequestId.isPresent()) { mPresentationStatsEventLogger.maybeSetRequestId(maybeNewRequestId.get()); diff --git a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java index 9000e9b87261..5d48d09adfbc 100644 --- a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java +++ b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java @@ -201,6 +201,7 @@ public class SettingsToPropertiesMapper { "pixel_watch", "platform_compat", "platform_security", + "pixel_watch_debug_trace", "pmw", "power", "preload_safety", diff --git a/services/core/java/com/android/server/power/stats/BatteryStatsImpl.java b/services/core/java/com/android/server/power/stats/BatteryStatsImpl.java index c878f14a5ff4..1d3de574991e 100644 --- a/services/core/java/com/android/server/power/stats/BatteryStatsImpl.java +++ b/services/core/java/com/android/server/power/stats/BatteryStatsImpl.java @@ -2131,13 +2131,13 @@ public class BatteryStatsImpl extends BatteryStats { @Override public LongSupplier getCallDurationSupplier() { return () -> mPhoneOnTimer.getTotalTimeLocked(mClock.elapsedRealtime() * 1000, - STATS_SINCE_CHARGED); + STATS_SINCE_CHARGED) / 1000; } @Override public LongSupplier getPhoneSignalScanDurationSupplier() { return () -> mPhoneSignalScanningTimer.getTotalTimeLocked( - mClock.elapsedRealtime() * 1000, STATS_SINCE_CHARGED); + mClock.elapsedRealtime() * 1000, STATS_SINCE_CHARGED) / 1000; } } diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 129931e92822..9bf255529768 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -951,6 +951,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp w.updateLastFrames(); mWmService.mFrameChangingWindows.remove(w); } + w.updateSurfacePositionNonOrganized(); w.onResizeHandled(); } diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index efa9c5345f77..92813a802a63 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -3330,6 +3330,7 @@ class Task extends TaskFragment { info.userId = isLeafTask() ? mUserId : mCurrentUser; info.taskId = mTaskId; + info.effectiveUid = effectiveUid; info.displayId = getDisplayId(); info.displayAreaFeatureId = tda != null ? tda.mFeatureId : FEATURE_UNDEFINED; final Intent baseIntent = getBaseIntent(); diff --git a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java index 8332b8b468c5..105147fe212d 100644 --- a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java +++ b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java @@ -275,26 +275,15 @@ public final class ProfcollectForwardingService extends SystemService { launchObserverRegistry.registerLaunchObserver(mAppLaunchObserver); } - private void traceOnAppStart(String packageName) { - if (mIProfcollect == null) { - return; - } - - if (Utils.withFrequency("applaunch_trace_freq", 2)) { - BackgroundThread.get().getThreadHandler().post(() -> { - try { - mIProfcollect.trace_system("applaunch"); - } catch (RemoteException e) { - Log.e(LOG_TAG, "Failed to initiate trace: " + e.getMessage()); - } - }); - } - } - private class AppLaunchObserver extends ActivityMetricsLaunchObserver { @Override public void onIntentStarted(Intent intent, long timestampNanos) { - traceOnAppStart(intent.getPackage()); + if (mIProfcollect == null) { + return; + } + if (Utils.withFrequency("applaunch_trace_freq", 5)) { + Utils.traceSystem(mIProfcollect, "applaunch"); + } } } @@ -316,13 +305,7 @@ public final class ProfcollectForwardingService extends SystemService { } if (Utils.withFrequency("dex2oat_trace_freq", 25)) { // Dex2oat could take a while before it starts. Add a short delay before start tracing. - BackgroundThread.get().getThreadHandler().postDelayed(() -> { - try { - mIProfcollect.trace_system("dex2oat"); - } catch (RemoteException e) { - Log.e(LOG_TAG, "Failed to initiate trace: " + e.getMessage()); - } - }, 1000); + Utils.traceSystem(mIProfcollect, "dex2oat", /* delayMs */ 1000); } } @@ -385,20 +368,10 @@ public final class ProfcollectForwardingService extends SystemService { return; } if (Utils.withFrequency("camera_trace_freq", 10)) { - final int traceDuration = 5000; - final String traceTag = "camera"; - BackgroundThread.get().getThreadHandler().post(() -> { - if (mIProfcollect == null) { - return; - } - try { - mIProfcollect.trace_process(traceTag, - "android.hardware.camera.provider", - traceDuration); - } catch (RemoteException e) { - Log.e(LOG_TAG, "Failed to initiate trace: " + e.getMessage()); - } - }); + Utils.traceProcess(mIProfcollect, + "camera", + "android.hardware.camera.provider", + /* durationMs */ 5000); } } }, null); diff --git a/services/profcollect/src/com/android/server/profcollect/Utils.java b/services/profcollect/src/com/android/server/profcollect/Utils.java index d5ef14c57b4c..850880256cfa 100644 --- a/services/profcollect/src/com/android/server/profcollect/Utils.java +++ b/services/profcollect/src/com/android/server/profcollect/Utils.java @@ -16,17 +16,67 @@ package com.android.server.profcollect; +import static com.android.server.profcollect.ProfcollectForwardingService.LOG_TAG; + +import android.os.RemoteException; import android.provider.DeviceConfig; +import android.util.Log; + +import com.android.internal.os.BackgroundThread; import java.util.concurrent.ThreadLocalRandom; public final class Utils { - public static boolean withFrequency(String configName, int defaultFrequency) { + public static boolean withFrequency(String configName, int defaultFrequency) { int threshold = DeviceConfig.getInt( DeviceConfig.NAMESPACE_PROFCOLLECT_NATIVE_BOOT, configName, defaultFrequency); int randomNum = ThreadLocalRandom.current().nextInt(100); return randomNum < threshold; } + public static boolean traceSystem(IProfCollectd mIProfcollect, String eventName) { + if (mIProfcollect == null) { + return false; + } + BackgroundThread.get().getThreadHandler().post(() -> { + try { + mIProfcollect.trace_system(eventName); + } catch (RemoteException e) { + Log.e(LOG_TAG, "Failed to initiate trace: " + e.getMessage()); + } + }); + return true; + } + + public static boolean traceSystem(IProfCollectd mIProfcollect, String eventName, int delayMs) { + if (mIProfcollect == null) { + return false; + } + BackgroundThread.get().getThreadHandler().postDelayed(() -> { + try { + mIProfcollect.trace_system(eventName); + } catch (RemoteException e) { + Log.e(LOG_TAG, "Failed to initiate trace: " + e.getMessage()); + } + }, delayMs); + return true; + } + + public static boolean traceProcess(IProfCollectd mIProfcollect, + String eventName, String processName, int durationMs) { + if (mIProfcollect == null) { + return false; + } + BackgroundThread.get().getThreadHandler().post(() -> { + try { + mIProfcollect.trace_process(eventName, + processName, + durationMs); + } catch (RemoteException e) { + Log.e(LOG_TAG, "Failed to initiate trace: " + e.getMessage()); + } + }); + return true; + } }
\ No newline at end of file diff --git a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityManagerServiceTest.java index 1afe12fc6927..c8cbbb5957ec 100644 --- a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityManagerServiceTest.java @@ -17,14 +17,21 @@ package com.android.server.accessibility; import static android.accessibilityservice.AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON; +import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU; +import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_GESTURE; +import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR; import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL; import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN; import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_NONE; import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW; +import static android.provider.Settings.Secure.NAVIGATION_MODE; +import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON; +import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL; import static android.view.accessibility.Flags.FLAG_SKIP_ACCESSIBILITY_WARNING_DIALOG_FOR_TRUSTED_SERVICES; import static com.android.internal.accessibility.AccessibilityShortcutController.ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME; import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME; +import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.GESTURE; import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.HARDWARE; import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS; import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE; @@ -121,7 +128,6 @@ import com.android.server.wm.ActivityTaskManagerInternal; import com.android.server.wm.WindowManagerInternal; import org.junit.After; -import org.junit.Assume; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -130,7 +136,6 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.internal.util.reflection.FieldReader; import org.mockito.internal.util.reflection.FieldSetter; @@ -178,6 +183,8 @@ public class AccessibilityManagerServiceTest { private static final String TARGET_ALWAYS_ON_A11Y_SERVICE_TILE_CLASS = "TileService"; private static final ComponentName TARGET_STANDARD_A11Y_SERVICE = new ComponentName("FakePackage", "StandardA11yService"); + private static final String TARGET_STANDARD_A11Y_SERVICE_NAME = + TARGET_STANDARD_A11Y_SERVICE.flattenToString(); static final ComponentName COMPONENT_NAME = new ComponentName( "com.android.server.accessibility", "AccessibilityManagerServiceTest"); @@ -229,7 +236,7 @@ public class AccessibilityManagerServiceTest { LocalServices.addService( UserManagerInternal.class, mMockUserManagerInternal); LocalServices.addService(StatusBarManagerInternal.class, mStatusBarManagerInternal); - mInputFilter = Mockito.mock(FakeInputFilter.class); + mInputFilter = mock(FakeInputFilter.class); when(mMockMagnificationController.getMagnificationConnectionManager()).thenReturn( mMockMagnificationConnectionManager); @@ -602,7 +609,7 @@ public class AccessibilityManagerServiceTest { mA11yms.getCurrentUserIdLocked()); userState.updateShortcutTargetsLocked(Set.of(MAGNIFICATION_CONTROLLER_NAME), HARDWARE); userState.setMagnificationCapabilitiesLocked( - Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL); + ACCESSIBILITY_MAGNIFICATION_MODE_ALL); // Invokes client change to trigger onUserStateChanged. mA11yms.onClientChangeLocked(/* serviceInfoChanged= */false); @@ -618,7 +625,7 @@ public class AccessibilityManagerServiceTest { final AccessibilityUserState userState = mA11yms.mUserStates.get( mA11yms.getCurrentUserIdLocked()); userState.setMagnificationCapabilitiesLocked( - Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL); + ACCESSIBILITY_MAGNIFICATION_MODE_ALL); userState.setMagnificationSingleFingerTripleTapEnabledLocked(true); // Invokes client change to trigger onUserStateChanged. @@ -635,7 +642,7 @@ public class AccessibilityManagerServiceTest { final AccessibilityUserState userState = mA11yms.mUserStates.get( mA11yms.getCurrentUserIdLocked()); userState.setMagnificationCapabilitiesLocked( - Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL); + ACCESSIBILITY_MAGNIFICATION_MODE_ALL); //userState.setMagnificationSingleFingerTripleTapEnabledLocked(false); userState.setMagnificationSingleFingerTripleTapEnabledLocked(false); @@ -654,7 +661,7 @@ public class AccessibilityManagerServiceTest { final AccessibilityUserState userState = mA11yms.mUserStates.get( mA11yms.getCurrentUserIdLocked()); userState.setMagnificationCapabilitiesLocked( - Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL); + ACCESSIBILITY_MAGNIFICATION_MODE_ALL); userState.setMagnificationTwoFingerTripleTapEnabledLocked(true); // Invokes client change to trigger onUserStateChanged. @@ -672,7 +679,7 @@ public class AccessibilityManagerServiceTest { final AccessibilityUserState userState = mA11yms.mUserStates.get( mA11yms.getCurrentUserIdLocked()); userState.setMagnificationCapabilitiesLocked( - Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL); + ACCESSIBILITY_MAGNIFICATION_MODE_ALL); //userState.setMagnificationSingleFingerTripleTapEnabledLocked(false); userState.setMagnificationTwoFingerTripleTapEnabledLocked(false); @@ -1090,7 +1097,7 @@ public class AccessibilityManagerServiceTest { assertThrows(SecurityException.class, () -> mA11yms.enableShortcutsForTargets( /* enable= */true, - UserShortcutType.SOFTWARE, + SOFTWARE, List.of(TARGET_MAGNIFICATION), mA11yms.getCurrentUserIdLocked())); } @@ -1099,7 +1106,7 @@ public class AccessibilityManagerServiceTest { public void enableShortcutsForTargets_enableSoftwareShortcut_shortcutTurnedOn() throws Exception { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); mFakePermissionEnforcer.grant(Manifest.permission.MANAGE_ACCESSIBILITY); setupShortcutTargetServices(); @@ -1107,13 +1114,13 @@ public class AccessibilityManagerServiceTest { mA11yms.enableShortcutsForTargets( /* enable= */ true, - UserShortcutType.SOFTWARE, + SOFTWARE, List.of(target), mA11yms.getCurrentUserIdLocked()); mTestableLooper.processAllMessages(); assertThat(ShortcutUtils.isComponentIdExistingInSettings( - mTestableContext, UserShortcutType.SOFTWARE, target + mTestableContext, SOFTWARE, target )).isTrue(); } @@ -1121,7 +1128,7 @@ public class AccessibilityManagerServiceTest { @EnableFlags(Flags.FLAG_ENABLE_HARDWARE_SHORTCUT_DISABLES_WARNING) public void enableHardwareShortcutsForTargets_shortcutDialogSetting_isShown() { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); Settings.Secure.putInt( mTestableContext.getContentResolver(), @@ -1151,33 +1158,33 @@ public class AccessibilityManagerServiceTest { public void enableShortcutsForTargets_disableSoftwareShortcut_shortcutTurnedOff() throws Exception { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString(); enableShortcutsForTargets_enableSoftwareShortcut_shortcutTurnedOn(); mA11yms.enableShortcutsForTargets( /* enable= */ false, - UserShortcutType.SOFTWARE, + SOFTWARE, List.of(target), mA11yms.getCurrentUserIdLocked()); mTestableLooper.processAllMessages(); assertThat(ShortcutUtils.isComponentIdExistingInSettings( - mTestableContext, UserShortcutType.SOFTWARE, target + mTestableContext, SOFTWARE, target )).isFalse(); } @Test public void enableShortcutsForTargets_enableSoftwareShortcutWithMagnification_menuSizeIncreased() { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); mFakePermissionEnforcer.grant(Manifest.permission.MANAGE_ACCESSIBILITY); mA11yms.enableShortcutsForTargets( /* enable= */ true, - UserShortcutType.SOFTWARE, + SOFTWARE, List.of(MAGNIFICATION_CONTROLLER_NAME), mA11yms.getCurrentUserIdLocked()); mTestableLooper.processAllMessages(); @@ -1200,7 +1207,7 @@ public class AccessibilityManagerServiceTest { mA11yms.enableShortcutsForTargets( /* enable= */ true, - UserShortcutType.SOFTWARE, + SOFTWARE, List.of(MAGNIFICATION_CONTROLLER_NAME), mA11yms.getCurrentUserIdLocked()); mTestableLooper.processAllMessages(); @@ -1217,14 +1224,14 @@ public class AccessibilityManagerServiceTest { public void enableShortcutsForTargets_enableAlwaysOnServiceSoftwareShortcut_turnsOnAlwaysOnService() throws Exception { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); mFakePermissionEnforcer.grant(Manifest.permission.MANAGE_ACCESSIBILITY); setupShortcutTargetServices(); mA11yms.enableShortcutsForTargets( /* enable= */ true, - UserShortcutType.SOFTWARE, + SOFTWARE, List.of(TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString()), mA11yms.getCurrentUserIdLocked()); mTestableLooper.processAllMessages(); @@ -1240,13 +1247,13 @@ public class AccessibilityManagerServiceTest { public void enableShortcutsForTargets_disableAlwaysOnServiceSoftwareShortcut_turnsOffAlwaysOnService() throws Exception { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); enableShortcutsForTargets_enableAlwaysOnServiceSoftwareShortcut_turnsOnAlwaysOnService(); mA11yms.enableShortcutsForTargets( /* enable= */ false, - UserShortcutType.SOFTWARE, + SOFTWARE, List.of(TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString()), mA11yms.getCurrentUserIdLocked()); mTestableLooper.processAllMessages(); @@ -1266,8 +1273,8 @@ public class AccessibilityManagerServiceTest { mA11yms.enableShortcutsForTargets( /* enable= */ true, - UserShortcutType.SOFTWARE, - List.of(TARGET_STANDARD_A11Y_SERVICE.flattenToString()), + SOFTWARE, + List.of(TARGET_STANDARD_A11Y_SERVICE_NAME), mA11yms.getCurrentUserIdLocked()); mTestableLooper.processAllMessages(); @@ -1282,7 +1289,7 @@ public class AccessibilityManagerServiceTest { public void enableShortcutsForTargets_disableStandardServiceSoftwareShortcutWithServiceOn_wontTurnOffService() throws Exception { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); enableShortcutsForTargets_enableStandardServiceSoftwareShortcut_wontTurnOnService(); AccessibilityUtils.setAccessibilityServiceState( @@ -1290,8 +1297,8 @@ public class AccessibilityManagerServiceTest { mA11yms.enableShortcutsForTargets( /* enable= */ false, - UserShortcutType.SOFTWARE, - List.of(TARGET_STANDARD_A11Y_SERVICE.flattenToString()), + SOFTWARE, + List.of(TARGET_STANDARD_A11Y_SERVICE_NAME), mA11yms.getCurrentUserIdLocked()); mTestableLooper.processAllMessages(); @@ -1305,7 +1312,7 @@ public class AccessibilityManagerServiceTest { @Test public void enableShortcutsForTargets_enableTripleTapShortcut_settingUpdated() { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); mFakePermissionEnforcer.grant(Manifest.permission.MANAGE_ACCESSIBILITY); @@ -1327,7 +1334,7 @@ public class AccessibilityManagerServiceTest { @Test public void enableShortcutsForTargets_disableTripleTapShortcut_settingUpdated() { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); enableShortcutsForTargets_enableTripleTapShortcut_settingUpdated(); @@ -1348,7 +1355,7 @@ public class AccessibilityManagerServiceTest { @Test public void enableShortcutsForTargets_enableMultiFingerMultiTapsShortcut_settingUpdated() { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); mFakePermissionEnforcer.grant(Manifest.permission.MANAGE_ACCESSIBILITY); @@ -1370,7 +1377,7 @@ public class AccessibilityManagerServiceTest { @Test public void enableShortcutsForTargets_disableMultiFingerMultiTapsShortcut_settingUpdated() { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); enableShortcutsForTargets_enableMultiFingerMultiTapsShortcut_settingUpdated(); @@ -1392,7 +1399,7 @@ public class AccessibilityManagerServiceTest { @Test public void enableShortcutsForTargets_enableVolumeKeysShortcut_shortcutSet() { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); mFakePermissionEnforcer.grant(Manifest.permission.MANAGE_ACCESSIBILITY); setupShortcutTargetServices(); @@ -1400,28 +1407,28 @@ public class AccessibilityManagerServiceTest { mA11yms.enableShortcutsForTargets( /* enable= */ true, HARDWARE, - List.of(TARGET_STANDARD_A11Y_SERVICE.flattenToString()), + List.of(TARGET_STANDARD_A11Y_SERVICE_NAME), mA11yms.getCurrentUserIdLocked()); mTestableLooper.processAllMessages(); assertThat( ShortcutUtils.isComponentIdExistingInSettings( mTestableContext, HARDWARE, - TARGET_STANDARD_A11Y_SERVICE.flattenToString()) + TARGET_STANDARD_A11Y_SERVICE_NAME) ).isTrue(); } @Test public void enableShortcutsForTargets_disableVolumeKeysShortcut_shortcutNotSet() { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); enableShortcutsForTargets_enableVolumeKeysShortcut_shortcutSet(); mA11yms.enableShortcutsForTargets( /* enable= */ false, HARDWARE, - List.of(TARGET_STANDARD_A11Y_SERVICE.flattenToString()), + List.of(TARGET_STANDARD_A11Y_SERVICE_NAME), mA11yms.getCurrentUserIdLocked()); mTestableLooper.processAllMessages(); @@ -1429,14 +1436,14 @@ public class AccessibilityManagerServiceTest { ShortcutUtils.isComponentIdExistingInSettings( mTestableContext, HARDWARE, - TARGET_STANDARD_A11Y_SERVICE.flattenToString())) + TARGET_STANDARD_A11Y_SERVICE_NAME)) .isFalse(); } @Test public void enableShortcutsForTargets_enableQuickSettings_shortcutSet() { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); mFakePermissionEnforcer.grant(Manifest.permission.MANAGE_ACCESSIBILITY); setupShortcutTargetServices(); @@ -1464,7 +1471,7 @@ public class AccessibilityManagerServiceTest { @Test public void enableShortcutsForTargets_disableQuickSettings_shortcutNotSet() { // TODO(b/111889696): Remove the user 0 assumption once we support multi-user - Assume.assumeTrue("The test is setup to run as a user 0", + assumeTrue("The test is setup to run as a user 0", isSameCurrentUser(mA11yms, mTestableContext)); enableShortcutsForTargets_enableQuickSettings_shortcutSet(); @@ -1779,7 +1786,7 @@ public class AccessibilityManagerServiceTest { mFakePermissionEnforcer.grant(Manifest.permission.MANAGE_ACCESSIBILITY); final String servicePrevious = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString(); final String otherPrevious = TARGET_MAGNIFICATION; - final String serviceRestored = TARGET_STANDARD_A11Y_SERVICE.flattenToString(); + final String serviceRestored = TARGET_STANDARD_A11Y_SERVICE_NAME; final AccessibilityUserState userState = new AccessibilityUserState( UserHandle.USER_SYSTEM, mTestableContext, mA11yms); mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState); @@ -1803,7 +1810,7 @@ public class AccessibilityManagerServiceTest { android.view.accessibility.Flags.FLAG_RESTORE_A11Y_SHORTCUT_TARGET_SERVICE, Flags.FLAG_CLEAR_DEFAULT_FROM_A11Y_SHORTCUT_TARGET_SERVICE_RESTORE}) public void restoreShortcutTargets_hardware_alreadyHadDefaultService_doesNotClear() { - final String serviceDefault = TARGET_STANDARD_A11Y_SERVICE.flattenToString(); + final String serviceDefault = TARGET_STANDARD_A11Y_SERVICE_NAME; mTestableContext.getOrCreateTestableResources().addOverride( R.string.config_defaultAccessibilityService, serviceDefault); final AccessibilityUserState userState = new AccessibilityUserState( @@ -1831,7 +1838,7 @@ public class AccessibilityManagerServiceTest { android.view.accessibility.Flags.FLAG_RESTORE_A11Y_SHORTCUT_TARGET_SERVICE, Flags.FLAG_CLEAR_DEFAULT_FROM_A11Y_SHORTCUT_TARGET_SERVICE_RESTORE}) public void restoreShortcutTargets_hardware_didNotHaveDefaultService_clearsDefaultService() { - final String serviceDefault = TARGET_STANDARD_A11Y_SERVICE.flattenToString(); + final String serviceDefault = TARGET_STANDARD_A11Y_SERVICE_NAME; final String serviceRestored = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString(); // Restored value from the broadcast contains both default and non-default service. final String combinedRestored = String.join(":", serviceDefault, serviceRestored); @@ -1858,7 +1865,7 @@ public class AccessibilityManagerServiceTest { android.view.accessibility.Flags.FLAG_RESTORE_A11Y_SHORTCUT_TARGET_SERVICE, Flags.FLAG_CLEAR_DEFAULT_FROM_A11Y_SHORTCUT_TARGET_SERVICE_RESTORE}) public void restoreShortcutTargets_hardware_nullSetting_clearsDefaultService() { - final String serviceDefault = TARGET_STANDARD_A11Y_SERVICE.flattenToString(); + final String serviceDefault = TARGET_STANDARD_A11Y_SERVICE_NAME; final String serviceRestored = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString(); // Restored value from the broadcast contains both default and non-default service. final String combinedRestored = String.join(":", serviceDefault, serviceRestored); @@ -1884,6 +1891,157 @@ public class AccessibilityManagerServiceTest { .containsExactlyElementsIn(expected); } + @Test + @EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED) + public void onNavButtonNavigation_migratesGestureTargets() { + mFakePermissionEnforcer.grant(Manifest.permission.STATUS_BAR_SERVICE); + final AccessibilityUserState userState = new AccessibilityUserState( + UserHandle.USER_SYSTEM, mTestableContext, mA11yms); + mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState); + setupShortcutTargetServices(userState); + userState.updateShortcutTargetsLocked( + Set.of(TARGET_STANDARD_A11Y_SERVICE_NAME), SOFTWARE); + userState.updateShortcutTargetsLocked( + Set.of(TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString()), GESTURE); + + Settings.Secure.putIntForUser(mTestableContext.getContentResolver(), + NAVIGATION_MODE, NAV_BAR_MODE_3BUTTON, userState.mUserId); + mA11yms.updateShortcutsForCurrentNavigationMode(); + + assertShortcutUserStateAndSetting(userState, GESTURE, Set.of()); + assertShortcutUserStateAndSetting(userState, SOFTWARE, Set.of( + TARGET_STANDARD_A11Y_SERVICE_NAME, + TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString() + )); + } + + @Test + @EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED) + public void onNavButtonNavigation_gestureTargets_noButtonTargets_navBarButtonMode() { + mFakePermissionEnforcer.grant(Manifest.permission.STATUS_BAR_SERVICE); + final AccessibilityUserState userState = new AccessibilityUserState( + UserHandle.USER_SYSTEM, mTestableContext, mA11yms); + mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState); + setupShortcutTargetServices(userState); + userState.updateShortcutTargetsLocked(Set.of(), SOFTWARE); + userState.updateShortcutTargetsLocked( + Set.of(TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString()), GESTURE); + ShortcutUtils.setButtonMode( + mTestableContext, ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU, UserHandle.USER_SYSTEM); + + Settings.Secure.putIntForUser(mTestableContext.getContentResolver(), + NAVIGATION_MODE, NAV_BAR_MODE_3BUTTON, userState.mUserId); + mA11yms.updateShortcutsForCurrentNavigationMode(); + + assertThat(ShortcutUtils.getButtonMode(mTestableContext, UserHandle.USER_SYSTEM)) + .isEqualTo(ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR); + } + + @Test + @EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED) + public void onGestureNavigation_floatingMenuMode() { + mFakePermissionEnforcer.grant(Manifest.permission.STATUS_BAR_SERVICE); + final AccessibilityUserState userState = new AccessibilityUserState( + UserHandle.USER_SYSTEM, mTestableContext, mA11yms); + mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState); + setupShortcutTargetServices(userState); + ShortcutUtils.setButtonMode( + mTestableContext, ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR, UserHandle.USER_SYSTEM); + + Settings.Secure.putIntForUser(mTestableContext.getContentResolver(), + NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, userState.mUserId); + mA11yms.updateShortcutsForCurrentNavigationMode(); + + assertThat(ShortcutUtils.getButtonMode(mTestableContext, userState.mUserId)) + .isEqualTo(ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU); + } + + @Test + @DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED) + public void onNavigation_revertGestureTargets() { + mFakePermissionEnforcer.grant(Manifest.permission.STATUS_BAR_SERVICE); + final AccessibilityUserState userState = new AccessibilityUserState( + UserHandle.USER_SYSTEM, mTestableContext, mA11yms); + mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState); + setupShortcutTargetServices(userState); + userState.updateShortcutTargetsLocked( + Set.of(TARGET_STANDARD_A11Y_SERVICE_NAME), SOFTWARE); + userState.updateShortcutTargetsLocked( + Set.of(TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString()), GESTURE); + + Settings.Secure.putIntForUser(mTestableContext.getContentResolver(), + NAVIGATION_MODE, NAV_BAR_MODE_3BUTTON, userState.mUserId); + mA11yms.updateShortcutsForCurrentNavigationMode(); + + assertShortcutUserStateAndSetting(userState, GESTURE, Set.of()); + assertShortcutUserStateAndSetting(userState, SOFTWARE, Set.of( + TARGET_STANDARD_A11Y_SERVICE_NAME, + TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString() + )); + } + + @Test + @EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED) + public void onNavigation_gestureNavigation_gestureButtonMode_migratesTargetsToGesture() { + mFakePermissionEnforcer.grant(Manifest.permission.STATUS_BAR_SERVICE); + final AccessibilityUserState userState = new AccessibilityUserState( + UserHandle.USER_SYSTEM, mTestableContext, mA11yms); + mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState); + setupShortcutTargetServices(userState); + userState.updateShortcutTargetsLocked(Set.of( + TARGET_STANDARD_A11Y_SERVICE_NAME, + TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString()), SOFTWARE); + userState.updateShortcutTargetsLocked(Set.of(), GESTURE); + + ShortcutUtils.setButtonMode( + mTestableContext, ACCESSIBILITY_BUTTON_MODE_GESTURE, UserHandle.USER_SYSTEM); + Settings.Secure.putIntForUser(mTestableContext.getContentResolver(), + NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, userState.mUserId); + mA11yms.updateShortcutsForCurrentNavigationMode(); + + assertShortcutUserStateAndSetting(userState, SOFTWARE, Set.of()); + assertShortcutUserStateAndSetting(userState, GESTURE, Set.of( + TARGET_STANDARD_A11Y_SERVICE_NAME, + TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString() + )); + } + + @Test + @DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED) + public void onNavigation_gestureNavigation_correctsButtonMode() { + final AccessibilityUserState userState = new AccessibilityUserState( + UserHandle.USER_SYSTEM, mTestableContext, mA11yms); + mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState); + setupShortcutTargetServices(userState); + ShortcutUtils.setButtonMode( + mTestableContext, ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR, UserHandle.USER_SYSTEM); + + Settings.Secure.putIntForUser(mTestableContext.getContentResolver(), + NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, userState.mUserId); + mA11yms.updateShortcutsForCurrentNavigationMode(); + + assertThat(ShortcutUtils.getButtonMode(mTestableContext, userState.mUserId)) + .isEqualTo(ACCESSIBILITY_BUTTON_MODE_GESTURE); + } + + @Test + @DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED) + public void onNavigation_navBarNavigation_correctsButtonMode() { + final AccessibilityUserState userState = new AccessibilityUserState( + UserHandle.USER_SYSTEM, mTestableContext, mA11yms); + mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState); + setupShortcutTargetServices(userState); + ShortcutUtils.setButtonMode( + mTestableContext, ACCESSIBILITY_BUTTON_MODE_GESTURE, UserHandle.USER_SYSTEM); + + Settings.Secure.putIntForUser(mTestableContext.getContentResolver(), + NAVIGATION_MODE, NAV_BAR_MODE_3BUTTON, userState.mUserId); + mA11yms.updateShortcutsForCurrentNavigationMode(); + + assertThat(ShortcutUtils.getButtonMode(mTestableContext, userState.mUserId)) + .isEqualTo(ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR); + } + private Set<String> readStringsFromSetting(String setting) { final Set<String> result = new ArraySet<>(); mA11yms.readColonDelimitedSettingToSet( @@ -1917,16 +2075,16 @@ public class AccessibilityManagerServiceTest { AccessibilityServiceInfo accessibilityServiceInfo = spy(new AccessibilityServiceInfo()); accessibilityServiceInfo.setComponentName(componentName); - ResolveInfo mockResolveInfo = Mockito.mock(ResolveInfo.class); + ResolveInfo mockResolveInfo = mock(ResolveInfo.class); when(accessibilityServiceInfo.getResolveInfo()).thenReturn(mockResolveInfo); - mockResolveInfo.serviceInfo = Mockito.mock(ServiceInfo.class); - mockResolveInfo.serviceInfo.applicationInfo = Mockito.mock(ApplicationInfo.class); + mockResolveInfo.serviceInfo = mock(ServiceInfo.class); + mockResolveInfo.serviceInfo.applicationInfo = mock(ApplicationInfo.class); mockResolveInfo.serviceInfo.packageName = componentName.getPackageName(); mockResolveInfo.serviceInfo.name = componentName.getClassName(); when(mockResolveInfo.serviceInfo.applicationInfo.isSystemApp()).thenReturn(isSystemApp); if (isAlwaysOnService) { accessibilityServiceInfo.flags |= - AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON; + FLAG_REQUEST_ACCESSIBILITY_BUTTON; mockResolveInfo.serviceInfo.applicationInfo.targetSdkVersion = Build.VERSION_CODES.R; } @@ -1999,7 +2157,7 @@ public class AccessibilityManagerServiceTest { A11yTestableContext(Context base) { super(base); - mMockContext = Mockito.mock(Context.class); + mMockContext = mock(Context.class); } @Override @@ -2050,4 +2208,12 @@ public class AccessibilityManagerServiceTest { shortcutValue, userId); } + + private void assertShortcutUserStateAndSetting(AccessibilityUserState userState, + @UserShortcutType int shortcutType, Set<String> value) { + assertThat(userState.getShortcutTargetsLocked(shortcutType)) + .containsExactlyElementsIn(value); + Set<String> setting = readStringsFromSetting(ShortcutUtils.convertToKey(shortcutType)); + assertThat(setting).containsExactlyElementsIn(value); + } } diff --git a/services/tests/servicestests/src/com/android/server/appfunctions/OWNERS b/services/tests/servicestests/src/com/android/server/appfunctions/OWNERS new file mode 100644 index 000000000000..7fa891736efe --- /dev/null +++ b/services/tests/servicestests/src/com/android/server/appfunctions/OWNERS @@ -0,0 +1,2 @@ +# Bug component: 1627156 +include platform/frameworks/base:/core/java/android/app/appfunctions/OWNERS diff --git a/services/usage/OWNERS b/services/usage/OWNERS index 26d9b10c7907..f825f559d30d 100644 --- a/services/usage/OWNERS +++ b/services/usage/OWNERS @@ -1,7 +1,10 @@ +# Bug component: 532296 +set noparent + mwachens@google.com varunshah@google.com -huiyu@google.com yamasani@google.com +guanxin@google.com per-file *StorageStats* = file:/core/java/android/os/storage/OWNERS per-file *Broadcast* = sudheersai@google.com
\ No newline at end of file diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index dbe4f2782616..3e8b3268ae4c 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -13928,7 +13928,10 @@ public class TelephonyManager { * {@link PackageManager#FEATURE_TELEPHONY_SUBSCRIPTION}. */ @RequiresFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION) - @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) + @RequiresPermission(anyOf = { + android.Manifest.permission.READ_BASIC_PHONE_STATE, + android.Manifest.permission.READ_PHONE_STATE + }) public void getCarrierRestrictionStatus(@NonNull Executor executor, @NonNull @CarrierRestrictionStatus Consumer<Integer> resultListener) { diff --git a/telephony/java/android/telephony/satellite/stub/ISatellite.aidl b/telephony/java/android/telephony/satellite/stub/ISatellite.aidl index e66a0824f545..51154e5baee1 100644 --- a/telephony/java/android/telephony/satellite/stub/ISatellite.aidl +++ b/telephony/java/android/telephony/satellite/stub/ISatellite.aidl @@ -24,6 +24,7 @@ import android.telephony.satellite.stub.ISatelliteCapabilitiesConsumer; import android.telephony.satellite.stub.ISatelliteListener; import android.telephony.satellite.stub.SatelliteDatagram; import android.telephony.satellite.stub.SystemSelectionSpecifier; +import android.telephony.satellite.stub.SatelliteModemEnableRequestAttributes; /** * {@hide} @@ -82,12 +83,7 @@ oneway interface ISatellite { * is enabled, this may also disable the cellular modem, and if the satellite modem is disabled, * this may also re-enable the cellular modem. * - * @param enableSatellite True to enable the satellite modem and false to disable. - * @param enableDemoMode True to enable demo mode and false to disable. - * @param isEmergency To specify the satellite is enabled for emergency session and false for - * non emergency session. Note: it is possible that a emergency session started get converted - * to a non emergency session and vice versa. - * @param resultCallback The callback to receive the error code result of the operation. + * @param enableAttributes The enable parameters that will be applied to the satellite session * * Valid result codes returned: * SatelliteResult:SATELLITE_RESULT_SUCCESS @@ -99,8 +95,8 @@ oneway interface ISatellite { * SatelliteResult:SATELLITE_RESULT_REQUEST_NOT_SUPPORTED * SatelliteResult:SATELLITE_RESULT_NO_RESOURCES */ - void requestSatelliteEnabled(in boolean enableSatellite, in boolean enableDemoMode, - in boolean isEmergency, in IIntegerConsumer resultCallback); + void requestSatelliteEnabled(in SatelliteModemEnableRequestAttributes enableAttributes, + in IIntegerConsumer resultCallback); /** * Request to get whether the satellite modem is enabled. diff --git a/telephony/java/android/telephony/satellite/stub/SatelliteImplBase.java b/telephony/java/android/telephony/satellite/stub/SatelliteImplBase.java index c50e469e83cb..4f472106a329 100644 --- a/telephony/java/android/telephony/satellite/stub/SatelliteImplBase.java +++ b/telephony/java/android/telephony/satellite/stub/SatelliteImplBase.java @@ -89,12 +89,11 @@ public class SatelliteImplBase extends SatelliteService { } @Override - public void requestSatelliteEnabled(boolean enableSatellite, boolean enableDemoMode, - boolean isEmergency, IIntegerConsumer resultCallback) throws RemoteException { + public void requestSatelliteEnabled(SatelliteModemEnableRequestAttributes enableAttributes, + IIntegerConsumer resultCallback) throws RemoteException { executeMethodAsync( () -> SatelliteImplBase.this - .requestSatelliteEnabled( - enableSatellite, enableDemoMode, isEmergency, resultCallback), + .requestSatelliteEnabled(enableAttributes, resultCallback), "requestSatelliteEnabled"); } @@ -325,11 +324,7 @@ public class SatelliteImplBase extends SatelliteService { * enabled, this may also disable the cellular modem, and if the satellite modem is disabled, * this may also re-enable the cellular modem. * - * @param enableSatellite True to enable the satellite modem and false to disable. - * @param enableDemoMode True to enable demo mode and false to disable. - * @param isEmergency To specify the satellite is enabled for emergency session and false for - * non emergency session. Note: it is possible that a emergency session started get converted - * to a non emergency session and vice versa. + * @param enableAttributes The enable parameters that will be applied to the satellite session * @param resultCallback The callback to receive the error code result of the operation. * * Valid result codes returned: @@ -342,8 +337,8 @@ public class SatelliteImplBase extends SatelliteService { * SatelliteResult:SATELLITE_RESULT_REQUEST_NOT_SUPPORTED * SatelliteResult:SATELLITE_RESULT_NO_RESOURCES */ - public void requestSatelliteEnabled(boolean enableSatellite, boolean enableDemoMode, - boolean isEmergency, @NonNull IIntegerConsumer resultCallback) { + public void requestSatelliteEnabled(SatelliteModemEnableRequestAttributes enableAttributes, + @NonNull IIntegerConsumer resultCallback) { // stub implementation } diff --git a/tests/Internal/src/com/android/internal/protolog/PerfettoProtoLogImplTest.java b/tests/Internal/src/com/android/internal/protolog/PerfettoProtoLogImplTest.java index 4826f4241e2b..05a68e9649d4 100644 --- a/tests/Internal/src/com/android/internal/protolog/PerfettoProtoLogImplTest.java +++ b/tests/Internal/src/com/android/internal/protolog/PerfettoProtoLogImplTest.java @@ -756,6 +756,48 @@ public class PerfettoProtoLogImplTest { .isEqualTo("My null args: 0, 0, false"); } + @Test + public void handlesConcurrentTracingSessions() throws IOException { + PerfettoTraceMonitor traceMonitor1 = + PerfettoTraceMonitor.newBuilder().enableProtoLog(true) + .build(); + + PerfettoTraceMonitor traceMonitor2 = + PerfettoTraceMonitor.newBuilder().enableProtoLog(true) + .build(); + + final ResultWriter writer2 = new ResultWriter() + .forScenario(new ScenarioBuilder() + .forClass(createTempFile("temp", "").getName()).build()) + .withOutputDir(mTracingDirectory) + .setRunComplete(); + + try { + traceMonitor1.start(); + traceMonitor2.start(); + + mProtoLog.log(LogLevel.DEBUG, TestProtoLogGroup.TEST_GROUP, 1, + LogDataType.BOOLEAN, new Object[]{true}); + } finally { + traceMonitor1.stop(mWriter); + traceMonitor2.stop(writer2); + } + + final ResultReader reader = new ResultReader(mWriter.write(), mTraceConfig); + final ProtoLogTrace protologFromMonitor1 = reader.readProtoLogTrace(); + + final ResultReader reader2 = new ResultReader(writer2.write(), mTraceConfig); + final ProtoLogTrace protologFromMonitor2 = reader2.readProtoLogTrace(); + + Truth.assertThat(protologFromMonitor1.messages).hasSize(1); + Truth.assertThat(protologFromMonitor1.messages.get(0).getMessage()) + .isEqualTo("My Test Debug Log Message true"); + + Truth.assertThat(protologFromMonitor2.messages).hasSize(1); + Truth.assertThat(protologFromMonitor2.messages.get(0).getMessage()) + .isEqualTo("My Test Debug Log Message true"); + } + private enum TestProtoLogGroup implements IProtoLogGroup { TEST_GROUP(true, true, false, "TEST_TAG"); diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp index be63f82b30cf..498e431097ad 100644 --- a/tools/aapt2/cmd/Link.cpp +++ b/tools/aapt2/cmd/Link.cpp @@ -306,6 +306,7 @@ struct ResourceFileFlattenerOptions { OutputFormat output_format = OutputFormat::kApk; std::unordered_set<std::string> extensions_to_not_compress; std::optional<std::regex> regex_to_not_compress; + FeatureFlagValues feature_flag_values; }; // A sampling of public framework resource IDs. @@ -672,6 +673,13 @@ bool ResourceFileFlattener::Flatten(ResourceTable* table, IArchiveWriter* archiv } } + FeatureFlagsFilterOptions flags_filter_options; + flags_filter_options.flags_must_be_readonly = true; + FeatureFlagsFilter flags_filter(options_.feature_flag_values, flags_filter_options); + if (!flags_filter.Consume(context_, doc.get())) { + return 1; + } + error |= !FlattenXml(context_, *doc, dst_path, options_.keep_raw_values, false /*utf16*/, options_.output_format, archive_writer); } @@ -1926,6 +1934,7 @@ class Linker { static_cast<bool>(options_.generate_proguard_rules_path); file_flattener_options.output_format = options_.output_format; file_flattener_options.do_not_fail_on_missing_resources = options_.merge_only; + file_flattener_options.feature_flag_values = options_.feature_flag_values; ResourceFileFlattener file_flattener(file_flattener_options, context_, keep_set); if (!file_flattener.Flatten(table, writer)) { diff --git a/tools/aapt2/integration-tests/FlaggedResourcesTest/Android.bp b/tools/aapt2/integration-tests/FlaggedResourcesTest/Android.bp index 4866d2c83c71..c456e5c296d2 100644 --- a/tools/aapt2/integration-tests/FlaggedResourcesTest/Android.bp +++ b/tools/aapt2/integration-tests/FlaggedResourcesTest/Android.bp @@ -30,12 +30,14 @@ genrule { "res/values/bools2.xml", "res/values/ints.xml", "res/values/strings.xml", + "res/layout/layout1.xml", ], out: [ "values_bools.arsc.flat", "values_bools2.arsc.flat", "values_ints.arsc.flat", "values_strings.arsc.flat", + "layout_layout1.xml.flat", ], cmd: "$(location aapt2) compile $(in) -o $(genDir) " + "--feature-flags test.package.falseFlag:ro=false,test.package.trueFlag:ro=true", @@ -52,7 +54,10 @@ genrule { out: [ "resapp.apk", ], - cmd: "$(location aapt2) link -o $(out) --manifest $(in)", + cmd: "$(location aapt2) link -o $(out) --manifest $(in) " + + "-I $(location :current_android_jar) " + + "--feature-flags test.package.falseFlag:ro=false,test.package.trueFlag:ro=true", + tool_files: [":current_android_jar"], } genrule { @@ -66,7 +71,10 @@ genrule { out: [ "resource-flagging-java/com/android/intenal/flaggedresources/R.java", ], - cmd: "$(location aapt2) link -o $(genDir)/resapp.apk --java $(genDir)/resource-flagging-java --manifest $(in)", + cmd: "$(location aapt2) link -o $(genDir)/resapp.apk --java $(genDir)/resource-flagging-java --manifest $(in) " + + "-I $(location :current_android_jar) " + + "--feature-flags test.package.falseFlag:ro=false,test.package.trueFlag:ro=true", + tool_files: [":current_android_jar"], } java_genrule { diff --git a/tools/aapt2/integration-tests/FlaggedResourcesTest/res/layout/layout1.xml b/tools/aapt2/integration-tests/FlaggedResourcesTest/res/layout/layout1.xml new file mode 100644 index 000000000000..8b9ce134a9de --- /dev/null +++ b/tools/aapt2/integration-tests/FlaggedResourcesTest/res/layout/layout1.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <TextView android:id="@+id/text1" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + <TextView android:id="@+id/disabled_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:featureFlag="test.package.falseFlag" /> + <TextView android:id="@+id/text2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:featureFlag="test.package.trueFlag" /> +</LinearLayout>
\ No newline at end of file diff --git a/tools/aapt2/integration-tests/FlaggedResourcesTest/res/values/bools.xml b/tools/aapt2/integration-tests/FlaggedResourcesTest/res/values/bools.xml index 3e094fbd669c..1ed0c8a5f1e6 100644 --- a/tools/aapt2/integration-tests/FlaggedResourcesTest/res/values/bools.xml +++ b/tools/aapt2/integration-tests/FlaggedResourcesTest/res/values/bools.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> - <bool name="res1">true</bool> - <bool name="res1" android:featureFlag="test.package.falseFlag">false</bool> + <bool name="bool1">true</bool> + <bool name="bool1" android:featureFlag="test.package.falseFlag">false</bool> - <bool name="res2">false</bool> - <bool name="res2" android:featureFlag="test.package.trueFlag">true</bool> + <bool name="bool2">false</bool> + <bool name="bool2" android:featureFlag="test.package.trueFlag">true</bool> - <bool name="res3">false</bool> + <bool name="bool3">false</bool> - <bool name="res4" android:featureFlag="test.package.falseFlag">true</bool> + <bool name="bool4" android:featureFlag="test.package.falseFlag">true</bool> </resources>
\ No newline at end of file diff --git a/tools/aapt2/integration-tests/FlaggedResourcesTest/res/values/bools2.xml b/tools/aapt2/integration-tests/FlaggedResourcesTest/res/values/bools2.xml index e7563aa0fbdd..248c45f7fad1 100644 --- a/tools/aapt2/integration-tests/FlaggedResourcesTest/res/values/bools2.xml +++ b/tools/aapt2/integration-tests/FlaggedResourcesTest/res/values/bools2.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> - <bool name="res3" android:featureFlag="test.package.trueFlag">true</bool> + <bool name="bool3" android:featureFlag="test.package.trueFlag">true</bool> </resources>
\ No newline at end of file diff --git a/tools/aapt2/link/FeatureFlagsFilter.cpp b/tools/aapt2/link/FeatureFlagsFilter.cpp index 9d40db521e13..4e7c1b4d8e54 100644 --- a/tools/aapt2/link/FeatureFlagsFilter.cpp +++ b/tools/aapt2/link/FeatureFlagsFilter.cpp @@ -65,6 +65,13 @@ class FlagsVisitor : public xml::Visitor { if (auto it = feature_flag_values_.find(flag_name); it != feature_flag_values_.end()) { if (it->second.enabled.has_value()) { + if (options_.flags_must_be_readonly && !it->second.read_only) { + diagnostics_->Error(android::DiagMessage(node->line_number) + << "attribute 'android:featureFlag' has flag '" << flag_name + << "' which must be readonly but is not"); + has_error_ = true; + return false; + } if (options_.remove_disabled_elements) { // Remove if flag==true && attr=="!flag" (negated) OR flag==false && attr=="flag" return *it->second.enabled == negated; diff --git a/tools/aapt2/link/FeatureFlagsFilter.h b/tools/aapt2/link/FeatureFlagsFilter.h index 1d342a71b996..61e4c8015f0e 100644 --- a/tools/aapt2/link/FeatureFlagsFilter.h +++ b/tools/aapt2/link/FeatureFlagsFilter.h @@ -38,6 +38,10 @@ struct FeatureFlagsFilterOptions { // If true, `Consume()` will return false (error) if a flag was found whose value in // `feature_flag_values` is not defined (std::nullopt). bool flags_must_have_value = true; + + // If true, `Consume()` will return false (error) if a flag was found whose value in + // `feature_flag_values` is not readonly. + bool flags_must_be_readonly = false; }; // Looks for the `android:featureFlag` attribute in each XML element, validates the flag names and diff --git a/tools/aapt2/link/FlaggedResources_test.cpp b/tools/aapt2/link/FlaggedResources_test.cpp index c901b5866279..3db37c2fa6f8 100644 --- a/tools/aapt2/link/FlaggedResources_test.cpp +++ b/tools/aapt2/link/FlaggedResources_test.cpp @@ -84,7 +84,7 @@ TEST_F(FlaggedResourcesTest, DisabledResourcesRemovedFromTableChunks) { std::string output; DumpChunksToString(loaded_apk.get(), &output); - ASSERT_EQ(output.find("res4"), std::string::npos); + ASSERT_EQ(output.find("bool4"), std::string::npos); ASSERT_EQ(output.find("str1"), std::string::npos); } @@ -94,7 +94,7 @@ TEST_F(FlaggedResourcesTest, DisabledResourcesInRJava) { std::string r_contents; ::android::base::ReadFileToString(r_path, &r_contents); - ASSERT_NE(r_contents.find("public static final int res4"), std::string::npos); + ASSERT_NE(r_contents.find("public static final int bool4"), std::string::npos); ASSERT_NE(r_contents.find("public static final int str1"), std::string::npos); } |