Fix Wi-Fi details crash in secondary users
- When Wi-Fi details are restricted for secondary users, UI components will be removed to prevent user interaction - The UI update function may not obtain the expected resources, causing NPE issues Bug: 362151753 Flag: EXEMPT bugfix Test: Manual testing atest -c WifiNetworkDetailsFragmentTest Change-Id: Ia97b4e202faff85ced0b6eaf2e4b4f0dc04b5cef
This commit is contained in:
@@ -400,6 +400,9 @@ public class WifiNetworkDetailsFragment extends RestrictedDashboardFragment impl
|
||||
|
||||
@VisibleForTesting
|
||||
void onHotspotNetworkChanged(WifiNetworkDetailsViewModel.HotspotNetworkData data) {
|
||||
if (mIsUiRestricted) {
|
||||
return;
|
||||
}
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
if (screen == null) {
|
||||
return;
|
||||
|
@@ -32,6 +32,7 @@ import static com.android.wifitrackerlib.WifiEntry.WIFI_LEVEL_MAX;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -246,6 +247,15 @@ public class WifiNetworkDetailsFragmentTest {
|
||||
.setSignalStrengthTitle(R.string.hotspot_connection_strength);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onHotspotNetworkChanged_uiRestricted_doNothing() {
|
||||
mFragment.mIsUiRestricted = true;
|
||||
|
||||
mFragment.onHotspotNetworkChanged(null /* HotspotNetworkData */);
|
||||
|
||||
verify(mScreen, never()).findPreference(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateInternetSource_networkTypeWifi_setWifiResource() {
|
||||
doReturn(mDrawable).when(mContext)
|
||||
|
Reference in New Issue
Block a user