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

Unverified Commit 270debda authored by Bruno Martins's avatar Bruno Martins Committed by Michael Bestas
Browse files

Settings: Move SIM restrictions currently applied to per-app data usage

When Google introduced commit d3b35f24, all the custom addons for
per-app network isolation became hidden on devices that set the
overlay config_show_sim_info to "false".

Expose only the toggles that really make sense, i.e. for the mentioned
usecase, leave the main toggle (restrict all), WiFi and VPN data
toggles.

Change-Id: I4720483d98ae69fbb6eec8fa749e8d071e91c629
parent f485f780
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@

    <PreferenceCategory
        android:key="app_data_usage_settings_category"
        settings:isPreferenceVisible="@bool/config_show_sim_info"
        android:layout="@layout/preference_category_no_label">

        <Preference
@@ -51,12 +50,14 @@
        <com.android.settingslib.RestrictedSwitchPreference
            android:key="restrict_cellular"
            android:title="@string/data_usage_app_restrict_mobile"
            android:summary="@string/data_usage_app_restrict_mobile_summary" />
            android:summary="@string/data_usage_app_restrict_mobile_summary"
            settings:isPreferenceVisible="@bool/config_show_sim_info" />

        <com.android.settingslib.RestrictedSwitchPreference
            android:key="restrict_background"
            android:title="@string/data_usage_app_restrict_background"
            android:summary="@string/data_usage_app_restrict_background_summary"
            settings:isPreferenceVisible="@bool/config_show_sim_info"
            settings:useAdditionalSummary="true"
            settings:restrictedSwitchSummary="@string/disabled_by_admin" />

@@ -69,6 +70,7 @@
            android:key="unrestricted_data_saver"
            android:title="@string/unrestricted_app_title"
            android:summary="@string/unrestricted_app_summary"
            settings:isPreferenceVisible="@bool/config_show_sim_info"
            settings:useAdditionalSummary="true"
            settings:restrictedSwitchSummary="@string/disabled_by_admin" />

+1 −8
Original line number Diff line number Diff line
@@ -107,10 +107,6 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
    private long mSelectedCycle;
    private boolean mIsLoading;

    public boolean isSimHardwareVisible(Context context) {
        return SubscriptionUtil.isSimHardwareVisible(context);
    }

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
@@ -153,7 +149,7 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
        final UidDetailProvider uidDetailProvider = getUidDetailProvider();

        if (mAppItem.key > 0) {
            if ((!isSimHardwareVisible(mContext)) || !UserHandle.isApp(mAppItem.key)) {
            if (!UserHandle.isApp(mAppItem.key)) {
                final UidDetail uidDetail = uidDetailProvider.getUidDetail(mAppItem.key, true);
                mIcon = uidDetail.icon;
                mLabel = uidDetail.label;
@@ -334,9 +330,6 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
    private void updatePrefs(boolean restrictBackground, boolean unrestrictData,
            boolean restrictAll, boolean restrictCellular, boolean restrictVpn,
            boolean restrictWifi, boolean hasInternetPermission) {
        if (!isSimHardwareVisible(mContext)) {
            return;
        }
        setBackPreferenceListAnimatorIfLoaded();
        final EnforcedAdmin admin = RestrictedLockUtilsInternal
                .checkIfMeteredDataUsageUserControlDisabled(mContext, mPackageName,