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

Commit 04160909 authored by joonhunshin's avatar joonhunshin Committed by Cherrypicker Worker
Browse files

Update unit test including vendor API level

Bug: 335362916
Test: atest PhoneSubInfoControllerTest, SmsControllerTest, EuiccControllerTest, SubscriptionManagerServiceTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:88c1cfae051a3b3e85959daab418eb64c43d49ed)
Merged-In: Ic6dad52b385a5ee2e60606eb1833cf63ed2a654b
Change-Id: Ic6dad52b385a5ee2e60606eb1833cf63ed2a654b
parent d9dbd635
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;
@@ -1605,7 +1606,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
@@ -479,7 +479,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);
@@ -491,6 +492,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(