Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d85b9132 authored by Joonhun Shin's avatar Joonhun Shin Committed by Android (Google) Code Review
Browse files

Merge "Update unit test including vendor API level" into main

parents f201a246 88c1cfae
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -230,7 +230,12 @@ public class PhoneSubInfoControllerTest extends TelephonyTest {
    @Test
    @SmallTest
    @EnableCompatChanges({TelephonyManager.ENABLE_FEATURE_MAPPING})
    public void testGetNai_EnabledEnforceTelephonyFeatureMappingForPublicApis() {
    public void testGetNai_EnabledEnforceTelephonyFeatureMappingForPublicApis() throws Exception {
        // Replace field to set SDK version of vendor partition to Android V
        int vendorApiLevel = Build.VERSION_CODES.VANILLA_ICE_CREAM;
        replaceInstance(PhoneSubInfoController.class, "mVendorApiLevel",
                mPhoneSubInfoControllerUT, vendorApiLevel);

        // FeatureFlags enabled, System has required feature
        doReturn(true).when(mFeatureFlags).enforceTelephonyFeatureMappingForPublicApis();
        doReturn(true).when(mPm).hasSystemFeature(
+6 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.verify;

import android.compat.testing.PlatformCompatChangeRule;
import android.content.pm.PackageManager;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
@@ -295,11 +296,15 @@ public class SmsControllerTest extends TelephonyTest {

    @Test
    @EnableCompatChanges({TelephonyManager.ENABLE_FEATURE_MAPPING})
    public void sendTextForSubscriberTestEnabledTelephonyFeature() {
    public void sendTextForSubscriberTestEnabledTelephonyFeature() throws Exception {
        int subId = 1;
        doReturn(true).when(mSubscriptionManager)
                .isSubscriptionAssociatedWithUser(eq(subId), any());

        // Replace field to set SDK version of vendor partition to Android V
        int vendorApiLevel = Build.VERSION_CODES.VANILLA_ICE_CREAM;
        replaceInstance(SmsController.class, "mVendorApiLevel", mSmsControllerUT, vendorApiLevel);

        // Feature enabled, device does not have required telephony feature.
        doReturn(true).when(mFeatureFlags).enforceTelephonyFeatureMappingForPublicApis();
        doReturn(false).when(mPackageManager).hasSystemFeature(
+7 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.os.Build;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.UserManager;
@@ -1682,7 +1683,12 @@ public class EuiccControllerTest extends TelephonyTest {
    @Test
    @EnableCompatChanges({EuiccManager.INACTIVE_PORT_AVAILABILITY_CHECK,
            TelephonyManager.ENABLE_FEATURE_MAPPING})
    public void testIsSimPortAvailable_WithTelephonyFeatureMapping() {
    public void testIsSimPortAvailable_WithTelephonyFeatureMapping() throws Exception {
        // Replace field to set SDK version of vendor partition to Android V
        int vendorApiLevel = Build.VERSION_CODES.VANILLA_ICE_CREAM;
        replaceInstance(EuiccController.class, "mVendorApiLevel", (EuiccController) mController,
                vendorApiLevel);

        // Feature flag enabled, device has required telephony feature.
        doReturn(true).when(mFeatureFlags).enforceTelephonyFeatureMappingForPublicApis();
        doReturn(true).when(mPackageManager).hasSystemFeature(
+7 −1
Original line number Diff line number Diff line
@@ -497,7 +497,8 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {

    @Test
    @EnableCompatChanges({TelephonyManager.ENABLE_FEATURE_MAPPING})
    public void testSetPhoneNumber_EnabledEnforceTelephonyFeatureMappingForPublicApis() {
    public void testSetPhoneNumber_EnabledEnforceTelephonyFeatureMappingForPublicApis()
            throws Exception {
        mContextFixture.addCallingOrSelfPermission(Manifest.permission.MODIFY_PHONE_STATE);
        mSubscriptionManagerServiceUT.addSubInfo(FAKE_ICCID1, FAKE_CARRIER_NAME1,
                0, SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
@@ -509,6 +510,11 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
        // Grant carrier privilege
        setCarrierPrivilegesForSubId(true, 1);

        // Replace field to set SDK version of vendor partition to Android V
        int vendorApiLevel = Build.VERSION_CODES.VANILLA_ICE_CREAM;
        replaceInstance(SubscriptionManagerService.class, "mVendorApiLevel",
                mSubscriptionManagerServiceUT, vendorApiLevel);

        // Enabled FeatureFlags and ENABLE_FEATURE_MAPPING, telephony features are defined
        doReturn(true).when(mFlags).enforceTelephonyFeatureMappingForPublicApis();
        doReturn(true).when(mPackageManager).hasSystemFeature(