summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-12-02 03:41:54 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-12-02 03:41:54 +0000
commitb2bbdd3cdf13a263d85af9efb9c8d267e456e45c (patch)
tree292bb5ada6fcc50f9a08118ee62b862a810cb85c
parent73568f63bc998af84146a9202b13b57eb8e3e11d (diff)
parent7f16060ce7e7227c8d3fa9a6ebee5ae45add8922 (diff)
downloadcts-sparse-7961824-L72800000952228303.tar.gz
Merge "Merge cherrypicks of [1886548, 1888796, 1893654, 1895243, 1905451] into sparse-7907387-L00500000952137325." into sparse-7907387-L00500000952137325sparse-7961824-L72800000952228303
-rw-r--r--hostsidetests/security/src/android/security/cts/KernelConfigTest.java4
-rw-r--r--hostsidetests/security/src/android/security/cts/SELinuxHostTest.java5
-rw-r--r--tests/framework/base/windowmanager/src/android/server/wm/CompatChangeTests.java66
-rw-r--r--tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java6
-rw-r--r--tests/tests/permission2/res/raw/android_manifest.xml2
-rw-r--r--tests/tests/permission3/src/android/permission3/cts/PermissionTest30.kt22
6 files changed, 64 insertions, 41 deletions
diff --git a/hostsidetests/security/src/android/security/cts/KernelConfigTest.java b/hostsidetests/security/src/android/security/cts/KernelConfigTest.java
index e782dbf7ce9..ca5e889f144 100644
--- a/hostsidetests/security/src/android/security/cts/KernelConfigTest.java
+++ b/hostsidetests/security/src/android/security/cts/KernelConfigTest.java
@@ -59,11 +59,11 @@ public class KernelConfigTest extends BaseHostJUnit4Test {
@Before
public void setUp() throws Exception {
- // Assumes every test in this file asserts a requirement of CDD section 9.
- assumeSecurityModelCompat();
mDevice = getDevice();
mBuild = getBuild();
configSet = getDeviceConfig(mDevice, cachedConfigGzSet);
+ // Assumes every test in this file asserts a requirement of CDD section 9.
+ assumeSecurityModelCompat();
}
/*
diff --git a/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
index 15eaeaa3c9e..337750281b1 100644
--- a/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
+++ b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
@@ -155,11 +155,12 @@ public class SELinuxHostTest extends BaseHostJUnit4Test {
@Before
public void setUp() throws Exception {
+ mDevice = getDevice();
+ mBuild = getBuild();
+
// Assumes every test in this file asserts a requirement of CDD section 9.
assumeSecurityModelCompat();
- mDevice = getDevice();
- mBuild = getBuild();
CompatibilityBuildHelper buildHelper = new CompatibilityBuildHelper(mBuild);
sepolicyAnalyze = copyResourceToTempFile("/sepolicy-analyze");
sepolicyAnalyze.setExecutable(true);
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/CompatChangeTests.java b/tests/framework/base/windowmanager/src/android/server/wm/CompatChangeTests.java
index 4cd3719e00e..2524090fe97 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/CompatChangeTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/CompatChangeTests.java
@@ -18,6 +18,8 @@ package android.server.wm;
import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE;
import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE;
+import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
+import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.provider.DeviceConfig.NAMESPACE_CONSTRAIN_DISPLAY_APIS;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -82,6 +84,8 @@ public final class CompatChangeTests extends MultiDisplayTestBase {
private static final ComponentName SUPPORTS_SIZE_CHANGES_PORTRAIT_ACTIVITY =
component(SupportsSizeChangesPortraitActivity.class);
+ // Device aspect ratio (both portrait and landscape orientations) for min aspect ratio tests
+ private static final float SIZE_COMPAT_DISPLAY_ASPECT_RATIO = 1.4f;
// Fixed orientation min aspect ratio
private static final float FIXED_ORIENTATION_MIN_ASPECT_RATIO = 1.03f;
// The min aspect ratio of NON_RESIZEABLE_ASPECT_RATIO_ACTIVITY (as defined in the manifest).
@@ -326,7 +330,11 @@ public final class CompatChangeTests extends MultiDisplayTestBase {
@Test
@EnableCompatChanges({ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO})
public void testOverrideMinAspectRatioMissingSpecificOverride() {
- runMinAspectRatioTest(NON_RESIZEABLE_PORTRAIT_ACTIVITY, /* expected= */ 0);
+ // Note that we're using getBounds() in portrait, rather than getAppBounds() like other
+ // tests, because we're comparing to the display size and therefore need to consider insets.
+ runMinAspectRatioTest(NON_RESIZEABLE_PORTRAIT_ACTIVITY,
+ /* expected= */ SIZE_COMPAT_DISPLAY_ASPECT_RATIO,
+ /* useAppBoundsInPortrait= */false);
}
/**
@@ -336,7 +344,11 @@ public final class CompatChangeTests extends MultiDisplayTestBase {
@Test
@EnableCompatChanges({ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE})
public void testOverrideMinAspectRatioMissingGeneralOverride() {
- runMinAspectRatioTest(NON_RESIZEABLE_PORTRAIT_ACTIVITY, /* expected= */ 0);
+ // Note that we're using getBounds() in portrait, rather than getAppBounds() like other
+ // tests, because we're comparing to the display size and therefore need to consider insets.
+ runMinAspectRatioTest(NON_RESIZEABLE_PORTRAIT_ACTIVITY,
+ /* expected= */ SIZE_COMPAT_DISPLAY_ASPECT_RATIO,
+ /* useAppBoundsInPortrait= */false);
}
/**
@@ -545,18 +557,47 @@ public final class CompatChangeTests extends MultiDisplayTestBase {
}
/**
- * Launches the provided activity and verifies that its min aspect ratio is equal to {@code
- * expected}.
+ * Launches the provided activity twice. The first time, the display is resized to a portrait
+ * aspect ratio. The second time, the display is resized to a landscape aspect ratio.
*
* @param activity the activity under test.
- * @param expected the expected min aspect ratio in both portrait and landscape displays.
+ * @param expected the expected aspect ratio in both portrait and landscape displays.
*/
private void runMinAspectRatioTest(ComponentName activity, float expected) {
+ runMinAspectRatioTest(activity, expected, /* useAppBoundsInPortrait= */ true);
+ }
+
+ /**
+ * Launches the provided activity twice. The first time, the display is resized to a portrait
+ * aspect ratio. The second time, the display is resized to a landscape aspect ratio.
+ *
+ * @param activity the activity under test.
+ * @param expected the expected aspect ratio in both a portrait and a landscape
+ * display.
+ * @param useAppBoundsInPortrait whether to use {@code activity#getAppBounds} rather than
+ * {@code activity.getBounds} in portrait display.
+ */
+ private void runMinAspectRatioTest(ComponentName activity, float expected,
+ boolean useAppBoundsInPortrait) {
+ // Change the aspect ratio of the display to something that is smaller than all the aspect
+ // ratios used throughout those tests but still portrait. This ensures we're using
+ // enforcing aspect ratio behaviour within orientation.
+ // NOTE: using a smaller aspect ratio (e.g., 1.2) might cause activities to have a landscape
+ // window because of insets.
+ mDisplayMetricsSession.changeAspectRatio(SIZE_COMPAT_DISPLAY_ASPECT_RATIO,
+ ORIENTATION_PORTRAIT);
launchActivity(activity);
- WindowManagerState.Activity activityContainer = mWmState.getActivity(activity);
- assertNotNull(activityContainer);
assertEquals(expected,
- activityContainer.getMinAspectRatio(),
+ getActivityAspectRatio(activity, /* useAppBounds= */ useAppBoundsInPortrait),
+ FLOAT_EQUALITY_DELTA);
+
+ // Change the orientation of the display to landscape. In this case we should see
+ // fixed orientation letterboxing and the aspect ratio should be applied there.
+ mDisplayMetricsSession.changeAspectRatio(SIZE_COMPAT_DISPLAY_ASPECT_RATIO,
+ ORIENTATION_LANDSCAPE);
+ launchActivity(activity);
+ assertEquals(expected,
+ getActivityAspectRatio(activity, /* useAppBounds= */ true),
FLOAT_EQUALITY_DELTA);
}
@@ -597,6 +638,15 @@ public final class CompatChangeTests extends MultiDisplayTestBase {
}, "checking task bounds updated");
}
+ private float getActivityAspectRatio(ComponentName componentName, boolean useAppBounds) {
+ WindowManagerState.Activity activity = mWmState.getActivity(componentName);
+ assertNotNull(activity);
+ Rect bounds = useAppBounds ? activity.getAppBounds() : activity.getBounds();
+ assertNotNull(bounds);
+ return Math.max(bounds.height(), bounds.width())
+ / (float) (Math.min(bounds.height(), bounds.width()));
+ }
+
private float getInitialDisplayAspectRatio() {
Size size = mDisplayMetricsSession.getInitialDisplayMetrics().getSize();
return Math.max(size.getHeight(), size.getWidth())
diff --git a/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java b/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java
index 10cab2d2b0d..ba34d1785d9 100644
--- a/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java
+++ b/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java
@@ -1454,7 +1454,6 @@ public class WindowManagerState {
boolean visible;
boolean frontOfTask;
boolean inSizeCompatMode;
- float minAspectRatio;
int procId = -1;
public boolean translucent;
ActivityTask task;
@@ -1467,7 +1466,6 @@ public class WindowManagerState {
visible = proto.visible;
frontOfTask = proto.frontOfTask;
inSizeCompatMode = proto.inSizeCompatMode;
- minAspectRatio = proto.minAspectRatio;
if (proto.procId != 0) {
procId = proto.procId;
}
@@ -1486,10 +1484,6 @@ public class WindowManagerState {
return inSizeCompatMode;
}
- public float getMinAspectRatio() {
- return minAspectRatio;
- }
-
@Override
public Rect getBounds() {
if (mBounds == null) {
diff --git a/tests/tests/permission2/res/raw/android_manifest.xml b/tests/tests/permission2/res/raw/android_manifest.xml
index e6f0666e9a7..5ff702fb325 100644
--- a/tests/tests/permission2/res/raw/android_manifest.xml
+++ b/tests/tests/permission2/res/raw/android_manifest.xml
@@ -5024,7 +5024,7 @@
<!-- Allows access to keyguard secure storage. Only allowed for system processes.
@hide -->
<permission android:name="android.permission.ACCESS_KEYGUARD_SECURE_STORAGE"
- android:protectionLevel="signature" />
+ android:protectionLevel="signature|setup" />
<!-- Allows applications to set the initial lockscreen state.
<p>Not for use by third-party applications. @hide -->
diff --git a/tests/tests/permission3/src/android/permission3/cts/PermissionTest30.kt b/tests/tests/permission3/src/android/permission3/cts/PermissionTest30.kt
index ff261f6e9ca..614cdc6ca04 100644
--- a/tests/tests/permission3/src/android/permission3/cts/PermissionTest30.kt
+++ b/tests/tests/permission3/src/android/permission3/cts/PermissionTest30.kt
@@ -17,11 +17,8 @@
package android.permission3.cts
import android.Manifest.permission.ACCESS_BACKGROUND_LOCATION
-import android.Manifest.permission.ACCESS_COARSE_LOCATION
import android.Manifest.permission.ACCESS_FINE_LOCATION
-import android.support.test.uiautomator.By
import org.junit.Test
-import org.junit.Assert.assertNull
/**
* Runtime permission behavior apps targeting API 30
@@ -56,23 +53,4 @@ class PermissionTest30 : BaseUsePermissionTest() {
pressBack()
}
}
-
- @Test
- fun testRequestFgLocationAndNoAccuracyOptions() {
- installPackage(APP_APK_PATH_30)
- assertAppHasPermission(ACCESS_FINE_LOCATION, false)
- assertAppHasPermission(ACCESS_COARSE_LOCATION, false)
-
- requestAppPermissionsAndAssertResult(ACCESS_FINE_LOCATION to false,
- ACCESS_COARSE_LOCATION to false) {
- // Verify there's no location accuracy options
- val locationAccuracyOptions = waitFindObjectOrNull(By.res(
- "com.android.permissioncontroller:id/permission_location_accuracy"), 1000L)
- assertNull("For apps targetSDK < 31, location permission dialog shouldn't show " +
- "accuracy options. Please update the system with " +
- "the latest (at least Oct, 2021) mainline modules.",
- locationAccuracyOptions)
- return
- }
- }
}