From 751eba205b50bf0a70ba30a1e99aa59f23206ad0 Mon Sep 17 00:00:00 2001 From: Arc Wang Date: Tue, 11 Jun 2019 11:40:59 +0800 Subject: [PATCH 1/5] [Wi-Fi DPP] Support WPA2/WPA3 transition mode This change shows buttons of QR code scnanner and QR code generator for a connected Wi-Fi network. Bug: 134706055 Test: Generate QR code for a WPA2/WPA3 personal transition mode Wi-Fi AP and check if the security type is WPA2 personal. Generate QR code for open network. Generate QR code for OWE network. Scan a QR code of open network, verify connection. Scan a QR code of OWE network, verify connection. Scan a QR code of WPA3 network, verify connection. Scan a QR code of WPA3 network, verify transition mode connection. Change-Id: I60f2c38585f85745f992fa63a5ea85312f08c5e5 --- src/com/android/settings/wifi/dpp/WifiDppUtils.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java index 4644f125017..7e15064b251 100644 --- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java +++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java @@ -205,6 +205,11 @@ public class WifiDppUtils { final WifiConfiguration wifiConfiguration = accessPoint.getConfig(); setConfiguratorIntentExtra(intent, wifiManager, wifiConfiguration); + // For a transition mode Wi-Fi AP, creates a QR code that's compatible with more devices + if (accessPoint.getSecurity() == AccessPoint.SECURITY_PSK_SAE_TRANSITION) { + intent.putExtra(EXTRA_WIFI_SECURITY, WifiQrCode.SECURITY_WPA_PSK); + } + return intent; } @@ -400,6 +405,7 @@ public class WifiDppUtils { } break; case AccessPoint.SECURITY_PSK: + case AccessPoint.SECURITY_PSK_SAE_TRANSITION: return true; default: } @@ -412,6 +418,8 @@ public class WifiDppUtils { case AccessPoint.SECURITY_PSK: case AccessPoint.SECURITY_WEP: case AccessPoint.SECURITY_NONE: + case AccessPoint.SECURITY_PSK_SAE_TRANSITION: + case AccessPoint.SECURITY_OWE_TRANSITION: return true; case AccessPoint.SECURITY_SAE: if (wifiManager.isWpa3SaeSupported()) { From 63bc6a10904a77b365895f6a056fda841ec711e5 Mon Sep 17 00:00:00 2001 From: Matthew Fritze Date: Wed, 12 Jun 2019 15:00:55 -0700 Subject: [PATCH 2/5] MobileData slice should be null if not-actionable In cases where MobileData should not be changed: - Airplane mode - No data subscriptions we will return a null slice, rather than a slice with a no-op intent attached as a primary action. The problem with the no-op intent is that Slices assumes all actions are by definition, actionable, and the the TalkBack description announces that the item is clickable, which it really isn't. We will in the future investigate disabled actions on Slices, but this is the short-term fix. Fixes: 132924748 Test: Robolectric Test: Panel tester app Change-Id: I1d62af32fe2dd985f0b52ea4188651e76f9c90ec --- .../network/telephony/MobileDataSlice.java | 26 ++-------- .../telephony/MobileDataSliceTest.java | 48 ++----------------- 2 files changed, 7 insertions(+), 67 deletions(-) diff --git a/src/com/android/settings/network/telephony/MobileDataSlice.java b/src/com/android/settings/network/telephony/MobileDataSlice.java index e497a9e442e..65eaf8708b5 100644 --- a/src/com/android/settings/network/telephony/MobileDataSlice.java +++ b/src/com/android/settings/network/telephony/MobileDataSlice.java @@ -78,16 +78,14 @@ public class MobileDataSlice implements CustomSliceable { 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. + // Return null until we can show a disabled-action Slice, blaming Airplane mode. if (isAirplaneModeEnabled()) { - return buildUnavailableMobileDataSlice(title, - mContext.getText(R.string.mobile_data_ap_mode_disabled), icon, color); + return null; } - // Return a Slice without the mobile data toggle when mobile data disabled. + // Return null until we can show a disabled-action Slice. if (!isMobileDataAvailable()) { - return buildUnavailableMobileDataSlice(title, - mContext.getText(R.string.sim_cellular_data_unavailable), icon, color); + return null; } final CharSequence summary = getSummary(); @@ -201,22 +199,6 @@ public class MobileDataSlice implements CustomSliceable { return mTelephonyManager.isDataEnabled(); } - private Slice buildUnavailableMobileDataSlice(String title, CharSequence summary, - IconCompat icon, int color) { - 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(); - } - /** * Listener for mobile data state changes. * diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java index ae6f5687445..c66f75f02a6 100644 --- a/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java +++ b/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java @@ -174,21 +174,7 @@ public class MobileDataSliceTest { doReturn(new ArrayList<>()).when(mSubscriptionManager).getSelectableSubscriptionInfoList(); 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.sim_cellular_data_unavailable)); - - final List toggles = metadata.getToggles(); - assertThat(toggles).hasSize(0); - - final SliceAction primaryAction = metadata.getPrimaryAction(); - final PendingIntent pendingIntent = primaryAction.getAction(); - final Intent actionIntent = pendingIntent.getIntent(); - - assertThat(actionIntent).isNull(); + assertThat(mobileData).isNull(); } @Test @@ -196,21 +182,7 @@ public class MobileDataSliceTest { doReturn(null).when(mSubscriptionManager).getSelectableSubscriptionInfoList(); 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.sim_cellular_data_unavailable)); - - final List toggles = metadata.getToggles(); - assertThat(toggles).hasSize(0); - - final SliceAction primaryAction = metadata.getPrimaryAction(); - final PendingIntent pendingIntent = primaryAction.getAction(); - final Intent actionIntent = pendingIntent.getIntent(); - - assertThat(actionIntent).isNull(); + assertThat(mobileData).isNull(); } @Test @@ -219,20 +191,6 @@ public class MobileDataSliceTest { 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 toggles = metadata.getToggles(); - assertThat(toggles).hasSize(0); - - final SliceAction primaryAction = metadata.getPrimaryAction(); - final PendingIntent pendingIntent = primaryAction.getAction(); - final Intent actionIntent = pendingIntent.getIntent(); - - assertThat(actionIntent).isNull(); + assertThat(mobileData).isNull(); } } From dd0b2fc380c15e510bd2c75bef7047b7782a04c5 Mon Sep 17 00:00:00 2001 From: Malcolm Chen Date: Tue, 18 Jun 2019 14:01:45 -0700 Subject: [PATCH 3/5] Replace isSubscriptionEnabled with isActiveSubId. As we don't allow pSIM modem disablment, we should simply use isActiveSubId to decide whether a subscription's preferences is changable. This will avoid potential modem bugs that reports wrong modem status that result in Setting's UX error. Bug: 135222940 Test: manual and robo Change-Id: I7cccf2fdab7c89d26dac4daad51cd5d6f3a90eba --- .../telephony/DisabledSubscriptionController.java | 3 ++- .../telephony/MobileNetworkSwitchController.java | 8 ++++++-- .../DisabledSubscriptionControllerTest.java | 12 ++++++------ .../MobileNetworkSwitchControllerTest.java | 14 +++++++------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/com/android/settings/network/telephony/DisabledSubscriptionController.java b/src/com/android/settings/network/telephony/DisabledSubscriptionController.java index 22cbb138c37..cd517359227 100644 --- a/src/com/android/settings/network/telephony/DisabledSubscriptionController.java +++ b/src/com/android/settings/network/telephony/DisabledSubscriptionController.java @@ -72,7 +72,8 @@ public class DisabledSubscriptionController extends BasePreferenceController imp if (mCategory == null || mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { return; } - mCategory.setVisible(mSubscriptionManager.isSubscriptionEnabled(mSubId)); + // TODO b/135222940: re-evaluate whether to use mSubscriptionManager#isSubscriptionEnabled + mCategory.setVisible(mSubscriptionManager.isActiveSubId(mSubId)); } @Override diff --git a/src/com/android/settings/network/telephony/MobileNetworkSwitchController.java b/src/com/android/settings/network/telephony/MobileNetworkSwitchController.java index e6422f00d60..02396ddef70 100644 --- a/src/com/android/settings/network/telephony/MobileNetworkSwitchController.java +++ b/src/com/android/settings/network/telephony/MobileNetworkSwitchController.java @@ -81,7 +81,9 @@ public class MobileNetworkSwitchController extends BasePreferenceController impl R.string.mobile_network_use_sim_off); mSwitchBar.addOnSwitchChangeListener((switchView, isChecked) -> { - if (mSubscriptionManager.isSubscriptionEnabled(mSubId) != isChecked + // TODO b/135222940: re-evaluate whether to use + // mSubscriptionManager#isSubscriptionEnabled + if (mSubscriptionManager.isActiveSubId(mSubId) != isChecked && (!mSubscriptionManager.setSubscriptionEnabled(mSubId, isChecked))) { mSwitchBar.setChecked(!isChecked); } @@ -108,7 +110,9 @@ public class MobileNetworkSwitchController extends BasePreferenceController impl mSwitchBar.hide(); } else { mSwitchBar.show(); - mSwitchBar.setChecked(mSubscriptionManager.isSubscriptionEnabled(mSubId)); + // TODO b/135222940: re-evaluate whether to use + // mSubscriptionManager#isSubscriptionEnabled + mSwitchBar.setChecked(mSubscriptionManager.isActiveSubId(mSubId)); } } diff --git a/tests/robotests/src/com/android/settings/network/telephony/DisabledSubscriptionControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/DisabledSubscriptionControllerTest.java index c1004faf572..f25ffa4532a 100644 --- a/tests/robotests/src/com/android/settings/network/telephony/DisabledSubscriptionControllerTest.java +++ b/tests/robotests/src/com/android/settings/network/telephony/DisabledSubscriptionControllerTest.java @@ -69,32 +69,32 @@ public class DisabledSubscriptionControllerTest { @Test public void displayPreference_subscriptionEnabled_categoryIsVisible() { - doReturn(true).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID); + doReturn(true).when(mSubscriptionManager).isActiveSubId(SUB_ID); mController.displayPreference(mScreen); assertThat(mCategory.isVisible()).isTrue(); } @Test public void displayPreference_subscriptionDisabled_categoryIsNotVisible() { - doReturn(false).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID); + doReturn(false).when(mSubscriptionManager).isActiveSubId(SUB_ID); mController.displayPreference(mScreen); assertThat(mCategory.isVisible()).isFalse(); } @Test public void onSubscriptionsChanged_subscriptionBecomesDisabled_categoryIsNotVisible() { - doReturn(true).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID); + doReturn(true).when(mSubscriptionManager).isActiveSubId(SUB_ID); mController.displayPreference(mScreen); - doReturn(false).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID); + doReturn(false).when(mSubscriptionManager).isActiveSubId(SUB_ID); mController.onSubscriptionsChanged(); assertThat(mCategory.isVisible()).isFalse(); } @Test public void onSubscriptionsChanged_subscriptionBecomesEnabled_categoryIsVisible() { - doReturn(false).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID); + doReturn(false).when(mSubscriptionManager).isActiveSubId(SUB_ID); mController.displayPreference(mScreen); - doReturn(true).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID); + doReturn(true).when(mSubscriptionManager).isActiveSubId(SUB_ID); mController.onSubscriptionsChanged(); assertThat(mCategory.isVisible()).isTrue(); } diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSwitchControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSwitchControllerTest.java index 86c380e006b..ccf345f8bdd 100644 --- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSwitchControllerTest.java +++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSwitchControllerTest.java @@ -109,7 +109,7 @@ public class MobileNetworkSwitchControllerTest { @Test public void displayPreference_oneEnabledSubscription_switchBarNotHidden() { - doReturn(true).when(mSubscriptionManager).isSubscriptionEnabled(mSubId); + doReturn(true).when(mSubscriptionManager).isActiveSubId(mSubId); SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSubscription)); mController.displayPreference(mScreen); assertThat(mSwitchBar.isShowing()).isTrue(); @@ -117,7 +117,7 @@ public class MobileNetworkSwitchControllerTest { @Test public void displayPreference_oneDisabledSubscription_switchBarNotHidden() { - doReturn(false).when(mSubscriptionManager).isSubscriptionEnabled(mSubId); + doReturn(false).when(mSubscriptionManager).isActiveSubId(mSubId); SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSubscription)); mController.displayPreference(mScreen); assertThat(mSwitchBar.isShowing()).isTrue(); @@ -125,7 +125,7 @@ public class MobileNetworkSwitchControllerTest { @Test public void displayPreference_subscriptionEnabled_switchIsOn() { - when(mSubscriptionManager.isSubscriptionEnabled(mSubId)).thenReturn(true); + when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true); mController.displayPreference(mScreen); assertThat(mSwitchBar.isShowing()).isTrue(); assertThat(mSwitchBar.isChecked()).isTrue(); @@ -133,7 +133,7 @@ public class MobileNetworkSwitchControllerTest { @Test public void displayPreference_subscriptionDisabled_switchIsOff() { - when(mSubscriptionManager.isSubscriptionEnabled(mSubId)).thenReturn(false); + when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(false); mController.displayPreference(mScreen); assertThat(mSwitchBar.isShowing()).isTrue(); assertThat(mSwitchBar.isChecked()).isFalse(); @@ -141,7 +141,7 @@ public class MobileNetworkSwitchControllerTest { @Test public void switchChangeListener_fromEnabledToDisabled_setSubscriptionEnabledCalledCorrectly() { - when(mSubscriptionManager.isSubscriptionEnabled(mSubId)).thenReturn(true); + when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true); mController.displayPreference(mScreen); assertThat(mSwitchBar.isShowing()).isTrue(); assertThat(mSwitchBar.isChecked()).isTrue(); @@ -153,7 +153,7 @@ public class MobileNetworkSwitchControllerTest { public void switchChangeListener_fromEnabledToDisabled_setSubscriptionEnabledFailed() { when(mSubscriptionManager.setSubscriptionEnabled(eq(mSubId), anyBoolean())) .thenReturn(false); - when(mSubscriptionManager.isSubscriptionEnabled(mSubId)).thenReturn(true); + when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true); mController.displayPreference(mScreen); assertThat(mSwitchBar.isShowing()).isTrue(); assertThat(mSwitchBar.isChecked()).isTrue(); @@ -164,7 +164,7 @@ public class MobileNetworkSwitchControllerTest { @Test public void switchChangeListener_fromDisabledToEnabled_setSubscriptionEnabledCalledCorrectly() { - when(mSubscriptionManager.isSubscriptionEnabled(mSubId)).thenReturn(false); + when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(false); mController.displayPreference(mScreen); assertThat(mSwitchBar.isShowing()).isTrue(); assertThat(mSwitchBar.isChecked()).isFalse(); From 06f22da547da156a02918a87967e377168c0d0bf Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Tue, 18 Jun 2019 18:55:20 -0700 Subject: [PATCH 4/5] Lockscreen bypass should be searchable Fixes: 135566785 Test: Searchable now Change-Id: Idae804f77ea5b7680c2dbe585bfec5078bb56c8f --- res/xml/security_settings_face.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/xml/security_settings_face.xml b/res/xml/security_settings_face.xml index 862c1a555ba..7d59f30c5ad 100644 --- a/res/xml/security_settings_face.xml +++ b/res/xml/security_settings_face.xml @@ -44,7 +44,7 @@ android:key="security_lockscreen_bypass" android:title="@string/lockscreen_bypass_title" android:summary="@string/lockscreen_bypass_summary" - settings:searchable="false" + settings:keywords="@string/keywords_lockscreen_bypass" settings:controller="com.android.settings.biometrics.face.FaceSettingsLockscreenBypassPreferenceController" /> From 6a1d7e60ac3593ce46c12dab0066a10149ca4aac Mon Sep 17 00:00:00 2001 From: Antony Sargent Date: Wed, 19 Jun 2019 11:30:33 -0700 Subject: [PATCH 5/5] Add a listener for subscription changes to SimDialogFragment For some kinds of telephony changes that might happen while we're already showing one of these dialogs, we already get sent a new intent for the dialog which we internally convert into a refresh of the dialog contents instead of stacking a new copy on top of the old one. But it turns out there are some other cases where the telephony stack doesn't send a new intent for the dialog but *does* send a change event through the SubscriptionManager, and we want to respond to those as well. This CL adds a listener for those events. Fixes: 135276696 Test: make RunSettingsRoboTests Change-Id: Ifb93ae95f45fda5831e112306dd9361ccaa5119c --- .../settings/sim/SimDialogFragment.java | 34 ++++++++++++++++++- .../sim/SimListDialogFragmentTest.java | 17 ++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/sim/SimDialogFragment.java b/src/com/android/settings/sim/SimDialogFragment.java index de991ec14f8..362fccc75ab 100644 --- a/src/com/android/settings/sim/SimDialogFragment.java +++ b/src/com/android/settings/sim/SimDialogFragment.java @@ -16,20 +16,25 @@ package com.android.settings.sim; +import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import androidx.annotation.NonNull; import com.android.settings.core.instrumentation.InstrumentedDialogFragment; +import com.android.settings.network.SubscriptionsChangeListener; /** Common functionality for showing a dialog in SimDialogActivity. */ -public abstract class SimDialogFragment extends InstrumentedDialogFragment { +public abstract class SimDialogFragment extends InstrumentedDialogFragment implements + SubscriptionsChangeListener.SubscriptionsChangeListenerClient { private static final String TAG = "SimDialogFragment"; private static final String KEY_TITLE_ID = "title_id"; private static final String KEY_DIALOG_TYPE = "dialog_type"; + private SubscriptionsChangeListener mChangeListener; + protected static Bundle initArguments(int dialogType, int titleResId) { final Bundle args = new Bundle(); args.putInt(KEY_DIALOG_TYPE, dialogType); @@ -45,6 +50,24 @@ public abstract class SimDialogFragment extends InstrumentedDialogFragment { return getArguments().getInt(KEY_TITLE_ID); } + @Override + public void onAttach(Context context) { + super.onAttach(context); + mChangeListener = new SubscriptionsChangeListener(context, this); + } + + @Override + public void onPause() { + super.onPause(); + mChangeListener.stop(); + } + + @Override + public void onResume() { + super.onResume(); + mChangeListener.start(); + } + @Override public void onDismiss(@NonNull DialogInterface dialog) { super.onDismiss(dialog); @@ -55,4 +78,13 @@ public abstract class SimDialogFragment extends InstrumentedDialogFragment { } public abstract void updateDialog(); + + @Override + public void onAirplaneModeChanged(boolean airplaneModeEnabled) { + } + + @Override + public void onSubscriptionsChanged() { + updateDialog(); + } } diff --git a/tests/robotests/src/com/android/settings/sim/SimListDialogFragmentTest.java b/tests/robotests/src/com/android/settings/sim/SimListDialogFragmentTest.java index 2b33ebe6c20..6a9590be3e0 100644 --- a/tests/robotests/src/com/android/settings/sim/SimListDialogFragmentTest.java +++ b/tests/robotests/src/com/android/settings/sim/SimListDialogFragmentTest.java @@ -26,6 +26,7 @@ import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import android.telephony.SubscriptionManager; @@ -77,6 +78,22 @@ public class SimListDialogFragmentTest extends SimDialogFragmentTestBase