STS test fix for Android Security CVE-2021-0339
Test: sts-tradefed run sts-engbuild-no-spl-lock -m CtsSecurityTestCases -t android.security.cts.CVE_2021_0339
Bug: 175817167
Change-Id: I2a917ea3cdaa787d124d8500d8c0cb93a8d4850f
Merged-In: I2a917ea3cdaa787d124d8500d8c0cb93a8d4850f
diff --git a/tests/tests/security/res/anim/translate1.xml b/tests/tests/security/res/anim/translate1.xml
index e8c562e..da2ee56 100644
--- a/tests/tests/security/res/anim/translate1.xml
+++ b/tests/tests/security/res/anim/translate1.xml
@@ -4,4 +4,4 @@
android:fromYDelta="0%"
android:toYDelta="-100%"
android:interpolator="@android:anim/linear_interpolator"
- android:duration="6000" />
+ android:duration="10000" />
diff --git a/tests/tests/security/res/anim/translate2.xml b/tests/tests/security/res/anim/translate2.xml
index 7156c56..d4bc6d9 100644
--- a/tests/tests/security/res/anim/translate2.xml
+++ b/tests/tests/security/res/anim/translate2.xml
@@ -4,4 +4,4 @@
android:fromYDelta="100%"
android:toYDelta="0%"
android:interpolator="@android:anim/linear_interpolator"
- android:duration="6000" />
+ android:duration="10000" />
diff --git a/tests/tests/security/src/android/security/cts/CVE_2021_0339.java b/tests/tests/security/src/android/security/cts/CVE_2021_0339.java
index c9866e5..41c4bdb 100644
--- a/tests/tests/security/src/android/security/cts/CVE_2021_0339.java
+++ b/tests/tests/security/src/android/security/cts/CVE_2021_0339.java
@@ -16,7 +16,9 @@
package android.security.cts;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertThat;
+import static org.hamcrest.Matchers.lessThan;
+
import android.test.AndroidTestCase;
import android.app.Activity;
import android.content.Context;
@@ -35,8 +37,8 @@
static final String TAG = CVE_2021_0339.class.getSimpleName();
private static final String SECURITY_CTS_PACKAGE_NAME = "android.security.cts";
- static final int MAX_TRANSITION_DURATION_MS = 3000;
- static final int TIME_MEASUREMENT_DELAY_MS = 150;
+ static final int MAX_TRANSITION_DURATION_MS = 3000; // internal max
+ static final int TIME_MEASUREMENT_DELAY_MS = 5000; // tolerance for lag.
public static boolean testCompleted;
public FirstActivity fActivity;
@@ -69,11 +71,12 @@
Log.d(TAG, "test completed");
//A duration of a transition from "FirstActivity" to "Second Activity"
- //is set in this test to 6000 ms
+ //is set in this test to 10 seconds
// (res/anim/translate1.xml and res/anim/translate2.xml)
- //The fix is supposed to limit the duration to 3000 ms
- assertTrue(SecondActivity.duration < MAX_TRANSITION_DURATION_MS +
- TIME_MEASUREMENT_DELAY_MS);
+ //The fix is supposed to limit the duration to 3000 ms.
+ // testing for > 8s
+ assertThat(SecondActivity.duration,
+ lessThan(MAX_TRANSITION_DURATION_MS + TIME_MEASUREMENT_DELAY_MS));
}
public static class FirstActivity extends Activity {