Disable Moblie Data Slice in AP mode
When airplane mode is enabled, users should not be able to change the value of mobile data. Thus, when airplane mode is enabled, replace the Slice with a no-op slice explaining why it cannot be changed. Fixes: 119411534 Fixes: 126726036 Test: robotests Change-Id: I991fe05ad8f18004f77fbf1c87403de602d3a267
This commit is contained in:
@@ -74,8 +74,27 @@ public class MobileDataSlice implements CustomSliceable {
|
||||
final IconCompat icon = IconCompat.createWithResource(mContext,
|
||||
R.drawable.ic_network_cell);
|
||||
final String title = mContext.getText(R.string.mobile_data_settings_title).toString();
|
||||
final CharSequence summary = getSummary();
|
||||
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
|
||||
|
||||
// Return a Slice without the mobile data toggle when airplane mode is on.
|
||||
if (isAirplaneModeEnabled()) {
|
||||
final CharSequence summary = mContext.getText(R.string.mobile_data_ap_mode_disabled);
|
||||
// Intent does nothing, but we have to pass an intent to the Row.
|
||||
final PendingIntent intent = PendingIntent.getActivity(mContext, 0 /* requestCode */,
|
||||
new Intent(), 0 /* flags */);
|
||||
final SliceAction deadAction =
|
||||
SliceAction.create(intent, icon, ListBuilder.ICON_IMAGE, title);
|
||||
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(),
|
||||
ListBuilder.INFINITY)
|
||||
.setAccentColor(color)
|
||||
.addRow(new ListBuilder.RowBuilder()
|
||||
.setTitle(title)
|
||||
.setSubtitle(summary)
|
||||
.setPrimaryAction(deadAction));
|
||||
return listBuilder.build();
|
||||
}
|
||||
|
||||
final CharSequence summary = getSummary();
|
||||
final PendingIntent toggleAction = getBroadcastIntent(mContext);
|
||||
final PendingIntent primaryAction = getPrimaryAction();
|
||||
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon,
|
||||
@@ -101,11 +120,6 @@ public class MobileDataSlice implements CustomSliceable {
|
||||
|
||||
@Override
|
||||
public void onNotifyChange(Intent intent) {
|
||||
// Don't make a change if we are in Airplane Mode.
|
||||
if (isAirplaneModeEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean newState = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
|
||||
isMobileDataEnabled());
|
||||
|
||||
|
Reference in New Issue
Block a user