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

Commit 01ed8e7b authored by Amin Shaikh's avatar Amin Shaikh Committed by android-build-merger
Browse files

Merge "Update mobile data off dialog." into pi-dev am: 372719cb

am: 54e1ca5f

Change-Id: I7a91f729c89cedea5c35ec4be7458b53f9b30094
parents 2d907e45 54e1ca5f
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -2152,8 +2152,14 @@
        been identified for them as running). [CHAR LIMIT=NONE] -->
    <string name="running_foreground_services_msg">Tap for details on battery and data usage</string>

    <!-- Prompt to turn off data usage [CHAR LIMIT=NONE] -->
    <string name="data_usage_disable_mobile" msgid="8656552431969276305">Turn off mobile data?</string>
    <!-- Title of the dialog to turn off data usage [CHAR LIMIT=NONE] -->
    <string name="mobile_data_disable_title">Turn off mobile data?</string>

    <!-- Message body of the dialog to turn off data usage [CHAR LIMIT=NONE] -->
    <string name="mobile_data_disable_message">You won\’t have access to data or the internet through <xliff:g id="carrier" example="T-Mobile">%s</xliff:g>. Internet will only be available via Wi-Fi.</string>

    <!-- Text used to refer to the user's current carrier in mobile_data_disable_message if the users's mobile network carrier name is not available [CHAR LIMIT=NONE] -->
    <string name="mobile_data_disable_message_default_carrier">your carrier</string>

    <!-- Warning shown when user input has been blocked due to another app overlaying screen
     content. Since we don't know what the app is showing on top of the input target, we
+3 −1
Original line number Diff line number Diff line
@@ -52,7 +52,8 @@ public final class Prefs {
            Key.SEEN_MULTI_USER,
            Key.NUM_APPS_LAUNCHED,
            Key.HAS_SEEN_RECENTS_ONBOARDING,
            Key.SEEN_RINGER_GUIDANCE_COUNT
            Key.SEEN_RINGER_GUIDANCE_COUNT,
            Key.QS_HAS_TURNED_OFF_MOBILE_DATA
    })
    public @interface Key {
        @Deprecated
@@ -89,6 +90,7 @@ public final class Prefs {
        String HAS_SEEN_RECENTS_ONBOARDING = "HasSeenRecentsOnboarding";
        String SEEN_RINGER_GUIDANCE_COUNT = "RingerGuidanceCount";
        String QS_TILE_SPECS_REVEALED = "QsTileSpecsRevealed";
        String QS_HAS_TURNED_OFF_MOBILE_DATA = "QsHasTurnedOffMobileData";
    }

    public static boolean getBoolean(Context context, @Key String key, boolean defaultValue) {
+18 −4
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.qs.tiles;

import static com.android.systemui.Prefs.Key.QS_HAS_TURNED_OFF_MOBILE_DATA;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
@@ -34,8 +36,8 @@ import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settingslib.net.DataUsageController;
import com.android.systemui.Dependency;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.R.string;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.qs.DetailAdapter;
import com.android.systemui.plugins.qs.QSIconView;
@@ -107,9 +109,13 @@ public class CellularTile extends QSTileImpl<SignalState> {
        if (mDataController.isMobileDataEnabled()) {
            if (mKeyguardMonitor.isSecure() && !mKeyguardMonitor.canSkipBouncer()) {
                mActivityStarter.postQSRunnableDismissingKeyguard(this::showDisableDialog);
            } else {
                if (Prefs.getBoolean(mContext, QS_HAS_TURNED_OFF_MOBILE_DATA, false)) {
                    mDataController.setMobileDataEnabled(false);
                } else {
                    mUiHandler.post(this::showDisableDialog);
                }
            }
        } else {
            mDataController.setMobileDataEnabled(true);
        }
@@ -117,12 +123,20 @@ public class CellularTile extends QSTileImpl<SignalState> {

    private void showDisableDialog() {
        mHost.collapsePanels();
        String carrierName = mController.getMobileDataNetworkName();
        if (TextUtils.isEmpty(carrierName)) {
            carrierName = mContext.getString(R.string.mobile_data_disable_message_default_carrier);
        }
        AlertDialog dialog = new Builder(mContext)
                .setMessage(string.data_usage_disable_mobile)
                .setTitle(R.string.mobile_data_disable_title)
                .setMessage(mContext.getString(R.string.mobile_data_disable_message, carrierName))
                .setNegativeButton(android.R.string.cancel, null)
                .setPositiveButton(
                        com.android.internal.R.string.alert_windows_notification_turn_off_action,
                        (d, w) -> mDataController.setMobileDataEnabled(false))
                        (d, w) -> {
                            mDataController.setMobileDataEnabled(false);
                            Prefs.putBoolean(mContext, QS_HAS_TURNED_OFF_MOBILE_DATA, true);
                        })
                .create();
        dialog.getWindow().setType(LayoutParams.TYPE_KEYGUARD_DIALOG);
        SystemUIDialog.setShowForAllUsers(dialog, true);
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
    AccessPointController getAccessPointController();
    DataUsageController getMobileDataController();
    DataSaverController getDataSaverController();
    String getMobileDataNetworkName();

    boolean hasVoiceCallingFeature();

+1 −0
Original line number Diff line number Diff line
@@ -308,6 +308,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
        return mDefaultSignalController;
    }

    @Override
    public String getMobileDataNetworkName() {
        MobileSignalController controller = getDataController();
        return controller != null ? controller.getState().networkNameData : "";
Loading