[Wi-Fi] Support WiFi detail page for OpenRoaming feature in AOSP setting.
Issue: Openroaming should have a specific detail page. Solution: Apply the mock design to only reserve two preference items: 1.Auto-connect 2.Scription details Bug: 146669261 Test: Add unit test case to test the new controller: WifiSubscriptionDetailPreferenceController2 Change-Id: Iba96500062f412f4cdcd1c8248544657770ab231
This commit is contained in:
@@ -2029,6 +2029,8 @@
|
|||||||
<string name="wifi_ip_settings">IP settings</string>
|
<string name="wifi_ip_settings">IP settings</string>
|
||||||
<!-- Label for the spinner to show Wifi MAC randomization [CHAR LIMIT=25] -->
|
<!-- Label for the spinner to show Wifi MAC randomization [CHAR LIMIT=25] -->
|
||||||
<string name="wifi_privacy_settings">Privacy</string>
|
<string name="wifi_privacy_settings">Privacy</string>
|
||||||
|
<!-- Label for the subscription detail preference. [CHAR LIMIT=32] -->
|
||||||
|
<string name="wifi_subscription_detail">Subscription details</string>
|
||||||
<!-- Summary for Wifi MAC randomization option when it is ephemeral network [CHAR LIMIT=50] -->
|
<!-- Summary for Wifi MAC randomization option when it is ephemeral network [CHAR LIMIT=50] -->
|
||||||
<string name="wifi_privacy_settings_ephemeral_summary">Randomized MAC</string>
|
<string name="wifi_privacy_settings_ephemeral_summary">Randomized MAC</string>
|
||||||
<!-- Title for the fragment to add a device into the wifi network [CHAR LIMIT=50] -->
|
<!-- Title for the fragment to add a device into the wifi network [CHAR LIMIT=50] -->
|
||||||
|
@@ -138,4 +138,10 @@
|
|||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
settings:enableCopying="true"/>
|
settings:enableCopying="true"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="subscription_detail"
|
||||||
|
android:title="@string/wifi_subscription_detail"
|
||||||
|
settings:allowDividerAbove="true"/>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -51,11 +51,11 @@ public class AddDevicePreferenceController2 extends BasePreferenceController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
if (WifiDppUtils.isSupportConfiguratorQrCodeScanner(mContext, mWifiEntry)) {
|
if (!WifiDppUtils.isSupportConfiguratorQrCodeScanner(mContext, mWifiEntry)
|
||||||
return AVAILABLE;
|
|| mWifiEntry.canManageSubscription()) {
|
||||||
} else {
|
|
||||||
return CONDITIONALLY_UNAVAILABLE;
|
return CONDITIONALLY_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
return AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -145,6 +145,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
|||||||
static final String KEY_IPV6_CATEGORY = "ipv6_category";
|
static final String KEY_IPV6_CATEGORY = "ipv6_category";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String KEY_IPV6_ADDRESSES_PREF = "ipv6_addresses";
|
static final String KEY_IPV6_ADDRESSES_PREF = "ipv6_addresses";
|
||||||
|
static final String KEY_IP_DETAILS_CATEGORY = "ip_details_category";
|
||||||
|
|
||||||
private final WifiEntry mWifiEntry;
|
private final WifiEntry mWifiEntry;
|
||||||
private final ConnectivityManager mConnectivityManager;
|
private final ConnectivityManager mConnectivityManager;
|
||||||
@@ -164,6 +165,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
|||||||
private ActionButtonsPreference mButtonsPref;
|
private ActionButtonsPreference mButtonsPref;
|
||||||
private EntityHeaderController mEntityHeaderController;
|
private EntityHeaderController mEntityHeaderController;
|
||||||
private Preference mSignalStrengthPref;
|
private Preference mSignalStrengthPref;
|
||||||
|
private PreferenceCategory mIpDetailsCategory;
|
||||||
private Preference mTxLinkSpeedPref;
|
private Preference mTxLinkSpeedPref;
|
||||||
private Preference mRxLinkSpeedPref;
|
private Preference mRxLinkSpeedPref;
|
||||||
private Preference mFrequencyPref;
|
private Preference mFrequencyPref;
|
||||||
@@ -194,7 +196,9 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
|||||||
mLinkProperties = lp;
|
mLinkProperties = lp;
|
||||||
refreshEntityHeader();
|
refreshEntityHeader();
|
||||||
refreshButtons();
|
refreshButtons();
|
||||||
refreshIpLayerInfo();
|
if (!mWifiEntry.canManageSubscription()) {
|
||||||
|
refreshIpLayerInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +238,9 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
|||||||
}
|
}
|
||||||
mNetworkCapabilities = nc;
|
mNetworkCapabilities = nc;
|
||||||
refreshButtons();
|
refreshButtons();
|
||||||
refreshIpLayerInfo();
|
if (!mWifiEntry.canManageSubscription()) {
|
||||||
|
refreshIpLayerInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,6 +335,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
|||||||
updateCaptivePortalButton();
|
updateCaptivePortalButton();
|
||||||
|
|
||||||
mSignalStrengthPref = screen.findPreference(KEY_SIGNAL_STRENGTH_PREF);
|
mSignalStrengthPref = screen.findPreference(KEY_SIGNAL_STRENGTH_PREF);
|
||||||
|
mIpDetailsCategory = screen.findPreference(KEY_IP_DETAILS_CATEGORY);
|
||||||
mTxLinkSpeedPref = screen.findPreference(KEY_TX_LINK_SPEED);
|
mTxLinkSpeedPref = screen.findPreference(KEY_TX_LINK_SPEED);
|
||||||
mRxLinkSpeedPref = screen.findPreference(KEY_RX_LINK_SPEED);
|
mRxLinkSpeedPref = screen.findPreference(KEY_RX_LINK_SPEED);
|
||||||
mFrequencyPref = screen.findPreference(KEY_FREQUENCY_PREF);
|
mFrequencyPref = screen.findPreference(KEY_FREQUENCY_PREF);
|
||||||
@@ -344,6 +351,13 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
|||||||
mIpv6Category = screen.findPreference(KEY_IPV6_CATEGORY);
|
mIpv6Category = screen.findPreference(KEY_IPV6_CATEGORY);
|
||||||
mIpv6AddressPref = screen.findPreference(KEY_IPV6_ADDRESSES_PREF);
|
mIpv6AddressPref = screen.findPreference(KEY_IPV6_ADDRESSES_PREF);
|
||||||
|
|
||||||
|
if (mWifiEntry.canManageSubscription()) {
|
||||||
|
mIpDetailsCategory.setVisible(false);
|
||||||
|
mIpv6Category.setVisible(false);
|
||||||
|
mSignalStrengthPref.setVisible(false);
|
||||||
|
mFrequencyPref.setVisible(false);
|
||||||
|
mSecurityPref.setVisible(false);
|
||||||
|
}
|
||||||
mSecurityPref.setSummary(mWifiEntry.getSecurityString(false /* concise */));
|
mSecurityPref.setSummary(mWifiEntry.getSecurityString(false /* concise */));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,10 +505,16 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
|||||||
|
|
||||||
// refresh header
|
// refresh header
|
||||||
refreshEntityHeader();
|
refreshEntityHeader();
|
||||||
|
refreshEntityHeaderIcon();
|
||||||
// refresh Buttons
|
// refresh Buttons
|
||||||
refreshButtons();
|
refreshButtons();
|
||||||
|
|
||||||
|
// When support manage subscription, there won't have any detail information, so don't
|
||||||
|
// need to update those detail UIs.
|
||||||
|
if (mWifiEntry.canManageSubscription()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Update Connection Header icon and Signal Strength Preference
|
// Update Connection Header icon and Signal Strength Preference
|
||||||
refreshRssiViews();
|
refreshRssiViews();
|
||||||
// Frequency Pref
|
// Frequency Pref
|
||||||
@@ -511,7 +531,11 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
|||||||
refreshMacAddress();
|
refreshMacAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshRssiViews() {
|
private void refreshEntityHeaderIcon() {
|
||||||
|
if (mEntityHeaderController == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int signalLevel = mWifiEntry.getLevel();
|
int signalLevel = mWifiEntry.getLevel();
|
||||||
|
|
||||||
// Disappears signal view if not in range. e.g. for saved networks.
|
// Disappears signal view if not in range. e.g. for saved networks.
|
||||||
@@ -526,13 +550,23 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
|||||||
}
|
}
|
||||||
mRssiSignalLevel = signalLevel;
|
mRssiSignalLevel = signalLevel;
|
||||||
Drawable wifiIcon = mIconInjector.getIcon(mRssiSignalLevel);
|
Drawable wifiIcon = mIconInjector.getIcon(mRssiSignalLevel);
|
||||||
|
mEntityHeaderController
|
||||||
|
.setIcon(redrawIconForHeader(wifiIcon)).done(mFragment.getActivity(),
|
||||||
|
true /* rebind */);
|
||||||
|
}
|
||||||
|
|
||||||
if (mEntityHeaderController != null) {
|
private void refreshRssiViews() {
|
||||||
mEntityHeaderController
|
int signalLevel = mWifiEntry.getLevel();
|
||||||
.setIcon(redrawIconForHeader(wifiIcon)).done(mFragment.getActivity(),
|
|
||||||
true /* rebind */);
|
// Disappears signal view if not in range. e.g. for saved networks.
|
||||||
|
if (signalLevel == WifiEntry.WIFI_LEVEL_UNREACHABLE) {
|
||||||
|
mSignalStrengthPref.setVisible(false);
|
||||||
|
mRssiSignalLevel = -1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mRssiSignalLevel = signalLevel;
|
||||||
|
Drawable wifiIcon = mIconInjector.getIcon(mRssiSignalLevel);
|
||||||
Drawable wifiIconDark = wifiIcon.getConstantState().newDrawable().mutate();
|
Drawable wifiIconDark = wifiIcon.getConstantState().newDrawable().mutate();
|
||||||
wifiIconDark.setTintList(Utils.getColorAttr(mContext, android.R.attr.colorControlNormal));
|
wifiIconDark.setTintList(Utils.getColorAttr(mContext, android.R.attr.colorControlNormal));
|
||||||
mSignalStrengthPref.setIcon(wifiIconDark);
|
mSignalStrengthPref.setIcon(wifiIconDark);
|
||||||
|
@@ -55,7 +55,7 @@ public class WifiMeteredPreferenceController2 extends BasePreferenceController i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AVAILABLE;
|
return mWifiEntry.canManageSubscription() ? CONDITIONALLY_UNAVAILABLE : AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -115,6 +115,10 @@ public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
if (mNetworkDetailsTracker.getWifiEntry().canManageSubscription()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MenuItem item = menu.add(0, Menu.FIRST, 0, R.string.wifi_modify);
|
MenuItem item = menu.add(0, Menu.FIRST, 0, R.string.wifi_modify);
|
||||||
item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
|
item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
|
||||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||||
@@ -174,6 +178,12 @@ public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
|
|||||||
privacyController2.setWifiEntry(wifiEntry);
|
privacyController2.setWifiEntry(wifiEntry);
|
||||||
controllers.add(privacyController2);
|
controllers.add(privacyController2);
|
||||||
|
|
||||||
|
final WifiSubscriptionDetailPreferenceController2
|
||||||
|
wifiSubscriptionDetailPreferenceController2 =
|
||||||
|
new WifiSubscriptionDetailPreferenceController2(context);
|
||||||
|
wifiSubscriptionDetailPreferenceController2.setWifiEntry(wifiEntry);
|
||||||
|
controllers.add(wifiSubscriptionDetailPreferenceController2);
|
||||||
|
|
||||||
// Sets callback listener for wifi dialog.
|
// Sets callback listener for wifi dialog.
|
||||||
mWifiDialogListeners.add(mWifiDetailPreferenceController2);
|
mWifiDialogListeners.add(mWifiDetailPreferenceController2);
|
||||||
mWifiDialogListeners.add(privacyController2);
|
mWifiDialogListeners.add(privacyController2);
|
||||||
|
@@ -55,8 +55,11 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return mWifiManager.isConnectedMacRandomizationSupported()
|
if (!mWifiManager.isConnectedMacRandomizationSupported()
|
||||||
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
|| mWifiEntry.canManageSubscription()) {
|
||||||
|
return CONDITIONALLY_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
return AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.android.settings.wifi.details2;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link BasePreferenceController} that controls show the subscription detail preference item.
|
||||||
|
* or not
|
||||||
|
*/
|
||||||
|
public class WifiSubscriptionDetailPreferenceController2 extends BasePreferenceController {
|
||||||
|
|
||||||
|
private static final String KEY_WIFI_SUBSCRIPTION_DETAIL = "subscription_detail";
|
||||||
|
private WifiEntry mWifiEntry;
|
||||||
|
|
||||||
|
public WifiSubscriptionDetailPreferenceController2(Context context) {
|
||||||
|
super(context, KEY_WIFI_SUBSCRIPTION_DETAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWifiEntry(WifiEntry wifiEntry) {
|
||||||
|
mWifiEntry = wifiEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
if (mWifiEntry.canManageSubscription()) {
|
||||||
|
return AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CONDITIONALLY_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||||
|
if (KEY_WIFI_SUBSCRIPTION_DETAIL.equals(preference.getKey())) {
|
||||||
|
mWifiEntry.manageSubscription();
|
||||||
|
return true; /* click is handled */
|
||||||
|
}
|
||||||
|
|
||||||
|
return false; /* click is not handled */
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.wifi.details2;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class WifiSubscriptionDetailPreferenceController2Test {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private WifiEntry mMockWifiEntry;
|
||||||
|
|
||||||
|
private WifiSubscriptionDetailPreferenceController2 mPreferenceController;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
|
|
||||||
|
mMockWifiEntry = mock(WifiEntry.class);
|
||||||
|
WifiSubscriptionDetailPreferenceController2 preferenceController =
|
||||||
|
new WifiSubscriptionDetailPreferenceController2(mContext);
|
||||||
|
preferenceController.setWifiEntry(mMockWifiEntry);
|
||||||
|
mPreferenceController = spy(preferenceController);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateState_canSetPrivacy_shouldBeSelectable() {
|
||||||
|
when(mMockWifiEntry.canManageSubscription()).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mPreferenceController.isAvailable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateState_canNotSetPrivacy_shouldNotSelectable() {
|
||||||
|
when(mMockWifiEntry.canManageSubscription()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mPreferenceController.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user