Merge "Update mobile data off dialog." into pi-dev

am: 372719cb35

Change-Id: I5a6683df112df1672bd943d7bc21e387336a0668
This commit is contained in:
Amin Shaikh
2018-03-19 17:53:45 +00:00
committed by android-build-merger
6 changed files with 36 additions and 7 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -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;
@@ -108,7 +110,11 @@ public class CellularTile extends QSTileImpl<SignalState> {
if (mKeyguardMonitor.isSecure() && !mKeyguardMonitor.canSkipBouncer()) {
mActivityStarter.postQSRunnableDismissingKeyguard(this::showDisableDialog);
} else {
mUiHandler.post(this::showDisableDialog);
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);

View File

@@ -36,6 +36,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
AccessPointController getAccessPointController();
DataUsageController getMobileDataController();
DataSaverController getDataSaverController();
String getMobileDataNetworkName();
boolean hasVoiceCallingFeature();

View File

@@ -308,6 +308,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
return mDefaultSignalController;
}
@Override
public String getMobileDataNetworkName() {
MobileSignalController controller = getDataController();
return controller != null ? controller.getState().networkNameData : "";

View File

@@ -88,4 +88,9 @@ public class FakeNetworkController extends BaseLeakChecker<SignalCallback>
public void dispatchDemoCommand(String command, Bundle args) {
}
@Override
public String getMobileDataNetworkName() {
return "";
}
}