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

Commit 66850554 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "[Settings][port] configuration for hidding SIM related UI"

parents d1e0b46a b644c542
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -626,4 +626,8 @@
        <item>@string/config_settingsintelligence_package_name</item>
        <item>android.uid.system:1000</item>
    </string-array>

    <!-- Whether sim related information is visible to the end user. -->
    <bool name="config_show_sim_info">true</bool>

</resources>
+8 −0
Original line number Diff line number Diff line
@@ -86,6 +86,14 @@ public class SubscriptionUtil {
        return subscriptions;
    }

    /**
     * Check if SIM hardware is visible to the end user.
     */
    public static boolean isSimHardwareVisible(Context context) {
        return context.getResources()
            .getBoolean(R.bool.config_show_sim_info);
    }

    @VisibleForTesting
    static boolean isInactiveInsertedPSim(UiccSlotInfo slotInfo) {
        if (slotInfo == null)  {
+20 −0
Original line number Diff line number Diff line
@@ -25,11 +25,14 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

import android.content.Context;
import android.content.res.Resources;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

import com.android.settings.R;

import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;

@@ -58,12 +61,15 @@ public class SubscriptionUtilTest {
    private SubscriptionManager mSubMgr;
    @Mock
    private TelephonyManager mTelMgr;
    @Mock
    private Resources mResources;


    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        mContext = spy(ApplicationProvider.getApplicationContext());
        when(mContext.getResources()).thenReturn(mResources);
        when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubMgr);
        when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelMgr);
        when(mTelMgr.getUiccSlotsInfo()).thenReturn(null);
@@ -443,4 +449,18 @@ public class SubscriptionUtilTest {
    public void isInactiveInsertedPSim_nullSubInfo_doesNotCrash() {
        assertThat(SubscriptionUtil.isInactiveInsertedPSim(null)).isFalse();
    }

    @Test
    public void isSimHardwareVisible_configAsInvisible_returnFalse() {
        when(mResources.getBoolean(R.bool.config_show_sim_info)).thenReturn(false);

        assertThat(SubscriptionUtil.isSimHardwareVisible(mContext)).isFalse();
    }

    @Test
    public void isSimHardwareVisible_configAsVisible_returnTrue() {
        when(mResources.getBoolean(R.bool.config_show_sim_info)).thenReturn(true);

        assertTrue(SubscriptionUtil.isSimHardwareVisible(mContext));
    }
}