diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-09-30 00:07:33 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-09-30 00:07:33 +0000 |
commit | 56403c3bca5dfcd5804f55035ed5bd26c3060a51 (patch) | |
tree | 9ed63641bb93c4e002e2807ab3c352aadb3f2681 | |
parent | f6c04b8664d3af7d5278e0f82c02e270db686434 (diff) | |
parent | 2c34f295204ad23d29b83ec79b127914d36147fb (diff) | |
download | cts-android11-d1-s6-release.tar.gz |
Merge cherrypicks of [12730462, 12730463, 12729574, 12730525, 12730638, 12730639, 12730640, 12730641, 12730642, 12730643, 12730564, 12730542, 12730526, 12730527, 12730543, 12729545, 12729634, 12730565, 12730531, 12730645, 12730545, 12730406] into rvc-d1-releaseandroid-11.0.0_r15android-11.0.0_r14android-11.0.0_r13android-11.0.0_r12android11-d1-s7-releaseandroid11-d1-s6-releaseandroid11-d1-s5-releaseandroid11-d1-release
Change-Id: I0562103cc98433cb89a5d08017e34d66a651b12b
3 files changed, 45 insertions, 7 deletions
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/EphemeralTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/EphemeralTest.java index 7472748d6cb..fbc01dfa51c 100644 --- a/hostsidetests/appsecurity/src/android/appsecurity/cts/EphemeralTest.java +++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/EphemeralTest.java @@ -378,6 +378,24 @@ public class EphemeralTest extends BaseAppSecurityTest { "testInstallPermissionGranted"); } + @Test + public void testInstallPermissionNotGrantedInPackageInfo() throws Exception { + if (mIsUnsupportedDevice) { + return; + } + Utils.runDeviceTestsAsCurrentUser(getDevice(), EPHEMERAL_1_PKG, TEST_CLASS, + "testInstallPermissionNotGrantedInPackageInfo"); + } + + @Test + public void testInstallPermissionGrantedInPackageInfo() throws Exception { + if (mIsUnsupportedDevice) { + return; + } + Utils.runDeviceTestsAsCurrentUser(getDevice(), EPHEMERAL_1_PKG, TEST_CLASS, + "testInstallPermissionGrantedInPackageInfo"); + } + /** Test for android.permission.INSTANT_APP_FOREGROUND_SERVICE */ @Test public void testStartForegroundService() throws Exception { diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/src/com/android/cts/ephemeralapp1/ClientTest.java b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/src/com/android/cts/ephemeralapp1/ClientTest.java index 5930840a96f..23593b0746f 100644 --- a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/src/com/android/cts/ephemeralapp1/ClientTest.java +++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/src/com/android/cts/ephemeralapp1/ClientTest.java @@ -23,6 +23,7 @@ import static android.media.MediaRecorder.AudioSource.MIC; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; import static org.junit.Assert.assertSame; @@ -78,6 +79,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import java.io.IOException; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -1169,6 +1171,28 @@ public class ClientTest { } @Test + public void testInstallPermissionNotGrantedInPackageInfo() throws Exception { + assertThat(isPermissionGrantedInPackageInfo(Manifest.permission.SET_ALARM), is(false)); + } + + @Test + public void testInstallPermissionGrantedInPackageInfo() throws Exception { + assertThat(isPermissionGrantedInPackageInfo(Manifest.permission.INTERNET), is(true)); + } + + private static boolean isPermissionGrantedInPackageInfo(String permissionName) + throws Exception { + final Context context = InstrumentationRegistry.getContext(); + final PackageInfo packageInfo = context.getPackageManager().getPackageInfo( + context.getPackageName(), PackageManager.GET_PERMISSIONS); + final int permissionIndex = Arrays.asList(packageInfo.requestedPermissions).indexOf( + permissionName); + assertThat(permissionIndex, is(not(-1))); + return (packageInfo.requestedPermissionsFlags[permissionIndex] + & PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0; + } + + @Test public void testExposedActivity() throws Exception { final Bundle testArgs = InstrumentationRegistry.getArguments(); assertThat(testArgs, is(notNullValue())); diff --git a/tests/tests/os/src/android/os/cts/LocaleListTest.java b/tests/tests/os/src/android/os/cts/LocaleListTest.java index 8eee8c6d54e..3d053321e2b 100644 --- a/tests/tests/os/src/android/os/cts/LocaleListTest.java +++ b/tests/tests/os/src/android/os/cts/LocaleListTest.java @@ -93,13 +93,9 @@ public class LocaleListTest extends AndroidTestCase { public void testRepeatedArguments() { final Locale[] la = {Locale.US, Locale.US}; - LocaleList ll = null; - try { - ll = new LocaleList(la); - fail("Initializing a LocaleList with an array containing duplicates should throw."); - } catch (Throwable e) { - assertEquals(IllegalArgumentException.class, e.getClass()); - } + LocaleList ll = new LocaleList(la); + assertEquals(1, ll.size()); + assertEquals(Locale.US, ll.get(0)); } public void testIndexOf() { |