mirror of https://github.com/grpc/grpc-java.git
roboelectric: Remove references to kitkat (#10953)
In addition to removing a test that only applies to KitKat, switch tests that require 19 to not specifying the SDK version as we only support min sdk version 21, which has the required API. Also removes the SDK version check from isProfileOwner, to trigger a runtime exception when too low of an SDK version is used.
This commit is contained in:
parent
ce2adcca93
commit
e697eccc51
|
|
@ -203,12 +203,13 @@ public final class SecurityPolicies {
|
|||
* Creates {@link SecurityPolicy} which checks if the app is a profile owner app. See
|
||||
* {@link DevicePolicyManager}.
|
||||
*/
|
||||
@androidx.annotation.RequiresApi(21)
|
||||
public static SecurityPolicy isProfileOwner(Context applicationContext) {
|
||||
DevicePolicyManager devicePolicyManager =
|
||||
(DevicePolicyManager) applicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
return anyPackageWithUidSatisfies(
|
||||
applicationContext,
|
||||
pkg -> VERSION.SDK_INT >= 21 && devicePolicyManager.isProfileOwnerApp(pkg),
|
||||
pkg -> devicePolicyManager.isProfileOwnerApp(pkg),
|
||||
"Rejected by profile owner policy. No packages found for UID.",
|
||||
"Rejected by profile owner policy");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -330,7 +330,6 @@ public final class SecurityPoliciesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Config(sdk = 19)
|
||||
public void testIsDeviceOwner_succeedsForDeviceOwner() throws Exception {
|
||||
PackageInfo info =
|
||||
newBuilder().setPackageName(OTHER_UID_PACKAGE_NAME).setSignatures(SIG2).build();
|
||||
|
|
@ -345,7 +344,6 @@ public final class SecurityPoliciesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Config(sdk = 19)
|
||||
public void testIsDeviceOwner_failsForNotDeviceOwner() throws Exception {
|
||||
PackageInfo info =
|
||||
newBuilder().setPackageName(OTHER_UID_PACKAGE_NAME).setSignatures(SIG2).build();
|
||||
|
|
@ -358,7 +356,6 @@ public final class SecurityPoliciesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Config(sdk = 19)
|
||||
public void testIsDeviceOwner_failsWhenNoPackagesForUid() throws Exception {
|
||||
policy = SecurityPolicies.isDeviceOwner(appContext);
|
||||
|
||||
|
|
@ -402,19 +399,6 @@ public final class SecurityPoliciesTest {
|
|||
assertThat(policy.checkAuthorization(OTHER_UID).getCode()).isEqualTo(Status.UNAUTHENTICATED.getCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(sdk = 19)
|
||||
public void testIsProfileOwner_failsForSdkLevelTooLow() throws Exception {
|
||||
PackageInfo info =
|
||||
newBuilder().setPackageName(OTHER_UID_PACKAGE_NAME).setSignatures(SIG2).build();
|
||||
|
||||
installPackages(OTHER_UID, info);
|
||||
|
||||
policy = SecurityPolicies.isProfileOwner(appContext);
|
||||
|
||||
assertThat(policy.checkAuthorization(OTHER_UID).getCode()).isEqualTo(Status.PERMISSION_DENIED.getCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(sdk = 30)
|
||||
public void testIsProfileOwnerOnOrgOwned_succeedsForProfileOwnerOnOrgOwned() throws Exception {
|
||||
|
|
|
|||
Loading…
Reference in New Issue