Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed450728 authored by Weng Su's avatar Weng Su
Browse files

Fixed Settings crashes issues in WEP Wi-Fi networks

- Use the main thread to launch the Settings dialog

Bug: 402158320
Flag: EXEMPT bugfix
Test: Manual testing
  atest com.android.settingslib.wifi.WifiUtilsTest
Change-Id: Idf728300d43dd3db60cdafa5ee649beccb0a317e
parent 2fb08245
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -510,9 +510,9 @@ open class WifiUtils {
                        AdvancedProtectionManager.FEATURE_ID_DISALLOW_WEP,
                        AdvancedProtectionManager.SUPPORT_DIALOG_TYPE_BLOCKED_INTERACTION)
                    intent.putExtra(DIALOG_WINDOW_TYPE, dialogWindowType)
                    onStartActivity(intent)
                    withContext(Dispatchers.Main) { onStartActivity(intent) }
                } else if (wifiManager.isWepSupported == true && wifiManager.queryWepAllowed()) {
                    onAllowed()
                    withContext(Dispatchers.Main) { onAllowed() }
                } else {
                    val intent = Intent(Intent.ACTION_MAIN).apply {
                        component = ComponentName(
@@ -522,7 +522,7 @@ open class WifiUtils {
                        putExtra(DIALOG_WINDOW_TYPE, dialogWindowType)
                        putExtra(SSID, ssid)
                    }.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                    onStartActivity(intent)
                    withContext(Dispatchers.Main) { onStartActivity(intent) }
                }
            }

+3 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;

@@ -211,10 +212,12 @@ public class WifiUtilsTest {
        WifiUtils.InternetIconInjector iconInjector = new WifiUtils.InternetIconInjector(mContext);

        for (int level = 0; level <= 4; level++) {
            Mockito.reset(mContext);
            iconInjector.getIcon(false /* noInternet */, level);
            verify(mContext).getDrawable(
                    WifiUtils.getInternetIconResource(level, false /* noInternet */));

            Mockito.reset(mContext);
            iconInjector.getIcon(true /* noInternet */, level);
            verify(mContext).getDrawable(
                    WifiUtils.getInternetIconResource(level, true /* noInternet */));