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

Commit e548fc63 authored by Antony Sargent's avatar Antony Sargent
Browse files

Remove on/off toggle for physical SIMs

Our original design for mobile network subscription management included
having an on/off toggle for both eSIMs and physical SIMs. However, it
turns out that our current telephony stack has some problems with
disabling physical SIMs, so for now we're removing the on/off
toggle. Because of this, we've added a footer to the SIM details page
for physical SIMS letting users know that to disable them you need to
remove them from the device.

Even though we're removing the on/off toggle for pSIMs, there are still
a few edge cases where you could end up with a disabled one (eg having
two SIMs in single-SIM mode where the eSIM is active and then you erased
the eSIM). In order to have a way to re-enable the pSIM in these cases,
this CL changes the relevant pref's summary to "Tap to activate <name>"
and makes the tap action begin the re-enabling. This can affect either
the Mobile network pref on the Network & internet main page (if this
disabled pSIM is the only SIM), or an entry in the Mobile networks list
page (if there are still multiple SIMs present).

Finally, this also fixes a problem where we weren't showing the on/off
toggle for eSIMs if you only had one SIM total; we actually always want
to show it for eSIMs.

Bug: 132921553
Test: make RunSettingsRoboTests
Change-Id: Id0750ebd5bed46dc2450b65b53cc81847ef09b82
parent 102d43b5
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -203,4 +203,14 @@
        android:title="@string/mobile_network_erase_sim"
        settings:controller="com.android.settings.network.telephony.DeleteSimProfilePreferenceController" />

    <PreferenceCategory
        android:key="footer_container"
        android:title="@string/summary_placeholder"
        android:layout="@layout/preference_category_no_label"
        settings:controller="com.android.settings.network.telephony.DisableSimFooterPreferenceController">
        <com.android.settingslib.widget.FooterPreference
            android:key="disable_sim_explanation"
            android:title="@string/mobile_network_disable_sim_explanation" />
    </PreferenceCategory>

</PreferenceScreen>
+9 −4
Original line number Diff line number Diff line
@@ -118,14 +118,19 @@ public class MobileNetworkListController extends AbstractPreferenceController im
                if (mSubscriptionManager.isActiveSubscriptionId(subId)) {
                    pref.setSummary(R.string.mobile_network_active_sim);
                } else {
                    pref.setSummary(R.string.mobile_network_inactive_sim);
                    pref.setSummary(mContext.getString(R.string.mobile_network_tap_to_activate,
                            SubscriptionUtil.getDisplayName(info)));
                }
            }

            pref.setOnPreferenceClickListener(clickedPref -> {
                if (!info.isEmbedded() && !mSubscriptionManager.isActiveSubscriptionId(subId)) {
                    mSubscriptionManager.setSubscriptionEnabled(subId, true);
                } else {
                    final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
                    intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
                    mContext.startActivity(intent);
                }
                return true;
            });
            mPreferences.put(subId, pref);
+17 −4
Original line number Diff line number Diff line
@@ -108,7 +108,14 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
            }
            return null;
        } else if (subs.size() == 1) {
            final SubscriptionInfo info = subs.get(0);
            final int subId = info.getSubscriptionId();
            if (!info.isEmbedded() && !mSubscriptionManager.isActiveSubscriptionId(subId)) {
                return mContext.getString(R.string.mobile_network_tap_to_activate,
                        SubscriptionUtil.getDisplayName(info));
            } else {
                return subs.get(0).getDisplayName();
            }
        } else {
            final int count = subs.size();
            return mContext.getResources().getQuantityString(R.plurals.mobile_network_summary_count,
@@ -154,9 +161,15 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController

            if (subs.size() == 1) {
                mPreference.setOnPreferenceClickListener((Preference pref) -> {
                    final SubscriptionInfo info = subs.get(0);
                    final int subId = info.getSubscriptionId();
                    if (!info.isEmbedded() && !mSubscriptionManager.isActiveSubscriptionId(subId)) {
                        mSubscriptionManager.setSubscriptionEnabled(subId, true);
                    } else {
                        final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
                        intent.putExtra(Settings.EXTRA_SUB_ID, subs.get(0).getSubscriptionId());
                        mContext.startActivity(intent);
                    }
                    return true;
                });
            } else {
+8 −2
Original line number Diff line number Diff line
@@ -25,12 +25,10 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.UiccSlotInfo;
import android.text.TextUtils;

import androidx.annotation.VisibleForTesting;

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

public class SubscriptionUtil {
@@ -107,4 +105,12 @@ public class SubscriptionUtil {
        }
        return subscriptions;
    }

    public static String getDisplayName(SubscriptionInfo info) {
        final CharSequence name = info.getDisplayName();
        if (name != null) {
            return name.toString();
        }
        return "";
    }
}
+54 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.network.telephony;

import android.content.Context;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;

import com.android.settings.core.BasePreferenceController;
import com.android.settings.network.SubscriptionUtil;

public class DisableSimFooterPreferenceController extends BasePreferenceController {
    private int mSubId;

    public DisableSimFooterPreferenceController(Context context, String preferenceKey) {
        super(context, preferenceKey);
        mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    }

    public void init(int subId) {
        mSubId = subId;
    }

    @Override
    public int getAvailabilityStatus() {
        if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
            return CONDITIONALLY_UNAVAILABLE;
        }
        for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mContext)) {
            if (info.getSubscriptionId() == mSubId) {
                if (info.isEmbedded()) {
                    return CONDITIONALLY_UNAVAILABLE;
                }
                break;
            }
        }
        return AVAILABLE;
    }
}
Loading