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

Commit d58d0be2 authored by Aleksander Morgado's avatar Aleksander Morgado
Browse files

Return UNSUPPORTED_ON_DEVICE in deviceinfo/simstatus when no telephony

If the device does not have any telephony support (either via the
build-time config_show_sim_info=false boolean flag, or when not
declaring the PackageManager.FEATURE_TELEPHONY_DATA feature flag),
returning UNSUPPORTED_ON_DEVICE makes more sense than
CONDITIONALLY_UNAVAILABLE, as there is no runtime change that would
make it available.

Bug: 395714454
Flag: EXEMPT bugfix
Test: atest SimStatusPreferenceControllerTest
Change-Id: I0735c949a590190cdc177cbca835444691c50faa
parent 4cc14d65
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import com.android.settings.network.SubscriptionUtil;
import com.android.settingslib.Utils;
import com.android.settingslib.search.SearchIndexableRaw;

import java.util.ArrayList;
import java.util.List;

public class SimStatusPreferenceController extends BasePreferenceController {
@@ -74,13 +73,15 @@ public class SimStatusPreferenceController extends BasePreferenceController {

    @Override
    public int getAvailabilityStatus() {
        if (getSimSlotIndex() == SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
        if (!SubscriptionUtil.isSimHardwareVisible(mContext)
                || Utils.isWifiOnly(mContext)
                || getSimSlotIndex() == SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
            return UNSUPPORTED_ON_DEVICE;
        }
        boolean isAvailable = SubscriptionUtil.isSimHardwareVisible(mContext) &&
                mContext.getSystemService(UserManager.class).isAdminUser() &&
                !Utils.isWifiOnly(mContext);
        return isAvailable ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
        if (!mContext.getSystemService(UserManager.class).isAdminUser()) {
            return CONDITIONALLY_UNAVAILABLE;
        }
        return AVAILABLE;
    }

    @Override
+2 −2
Original line number Diff line number Diff line
@@ -231,7 +231,7 @@ public class SimStatusPreferenceControllerTest {

        when(mResources.getBoolean(R.bool.config_show_sim_info)).thenReturn(false);
        assertThat(mController.getAvailabilityStatus()).isEqualTo(
                BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
                BasePreferenceController.UNSUPPORTED_ON_DEVICE);
    }

    @Test
@@ -241,7 +241,7 @@ public class SimStatusPreferenceControllerTest {

        when(mTelephonyManager.isDataCapable()).thenReturn(false);
        assertThat(mController.getAvailabilityStatus()).isEqualTo(
                BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
                BasePreferenceController.UNSUPPORTED_ON_DEVICE);
    }

    @Test