Merge "Revert "Disable Moblie Data Slice in AP mode""
This commit is contained in:
committed by
Android (Google) Code Review
commit
a07961a4bf
@@ -10678,9 +10678,6 @@
|
|||||||
<!-- Title for the Volume dialog (settings panel) with all volume streams[CHAR LIMIT=50] -->
|
<!-- Title for the Volume dialog (settings panel) with all volume streams[CHAR LIMIT=50] -->
|
||||||
<string name="volume_connectivity_panel_title">Volume</string>
|
<string name="volume_connectivity_panel_title">Volume</string>
|
||||||
|
|
||||||
<!-- Subtitle explaining that mobile data cannot be used while airplane mode is on [CHAR LIMIT=50] -->
|
|
||||||
<string name="mobile_data_ap_mode_disabled">Unavailable during airplane mode</string>
|
|
||||||
|
|
||||||
<!-- UI debug setting: force desktop mode [CHAR LIMIT=50] -->
|
<!-- UI debug setting: force desktop mode [CHAR LIMIT=50] -->
|
||||||
<string name="force_desktop_mode">Force desktop mode</string>
|
<string name="force_desktop_mode">Force desktop mode</string>
|
||||||
<!-- UI debug setting: force desktop mode summary [CHAR LIMIT=NONE] -->
|
<!-- UI debug setting: force desktop mode summary [CHAR LIMIT=NONE] -->
|
||||||
|
@@ -74,27 +74,8 @@ public class MobileDataSlice implements CustomSliceable {
|
|||||||
final IconCompat icon = IconCompat.createWithResource(mContext,
|
final IconCompat icon = IconCompat.createWithResource(mContext,
|
||||||
R.drawable.ic_network_cell);
|
R.drawable.ic_network_cell);
|
||||||
final String title = mContext.getText(R.string.mobile_data_settings_title).toString();
|
final String title = mContext.getText(R.string.mobile_data_settings_title).toString();
|
||||||
@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 CharSequence summary = getSummary();
|
||||||
|
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
|
||||||
final PendingIntent toggleAction = getBroadcastIntent(mContext);
|
final PendingIntent toggleAction = getBroadcastIntent(mContext);
|
||||||
final PendingIntent primaryAction = getPrimaryAction();
|
final PendingIntent primaryAction = getPrimaryAction();
|
||||||
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon,
|
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon,
|
||||||
@@ -120,6 +101,11 @@ public class MobileDataSlice implements CustomSliceable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotifyChange(Intent intent) {
|
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,
|
final boolean newState = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
|
||||||
isMobileDataEnabled());
|
isMobileDataEnabled());
|
||||||
|
|
||||||
|
@@ -24,7 +24,6 @@ import static org.mockito.Mockito.spy;
|
|||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -163,27 +162,4 @@ public class MobileDataSliceTest {
|
|||||||
|
|
||||||
assertThat(isMobileDataEnabled).isEqualTo(seed);
|
assertThat(isMobileDataEnabled).isEqualTo(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void airplaneModeEnabled_slicePrimaryActionIsEmpty() {
|
|
||||||
doReturn(true).when(mMobileDataSlice).isAirplaneModeEnabled();
|
|
||||||
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
|
|
||||||
final Slice mobileData = mMobileDataSlice.getSlice();
|
|
||||||
|
|
||||||
final SliceMetadata metadata = SliceMetadata.from(mContext, mobileData);
|
|
||||||
assertThat(metadata.getTitle())
|
|
||||||
.isEqualTo(mContext.getString(R.string.mobile_data_settings_title));
|
|
||||||
|
|
||||||
assertThat(metadata.getSubtitle())
|
|
||||||
.isEqualTo(mContext.getString(R.string.mobile_data_ap_mode_disabled));
|
|
||||||
|
|
||||||
final List<SliceAction> toggles = metadata.getToggles();
|
|
||||||
assertThat(toggles).hasSize(0);
|
|
||||||
|
|
||||||
final SliceAction primaryAction = metadata.getPrimaryAction();
|
|
||||||
final PendingIntent pendingIntent = primaryAction.getAction();
|
|
||||||
final Intent actionIntent = pendingIntent.getIntent();
|
|
||||||
|
|
||||||
assertThat(actionIntent.getAction()).isNull();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user