Merge "Change WepNetworkDialogActivity exported="true"." into main
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 927f38e..aed51f3 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -5127,8 +5127,9 @@
<activity
android:name="com.android.settings.network.WepNetworkDialogActivity"
- android:exported="false"
- android:theme="@style/Theme.SpaLib.Dialog">
+ android:exported="true"
+ android:theme="@style/Theme.SpaLib.Dialog"
+ android:permission="android.permission.NETWORK_SETTINGS">
</activity>
<!-- This is the longest AndroidManifest.xml ever. -->
diff --git a/src/com/android/settings/network/NetworkProviderSettings.java b/src/com/android/settings/network/NetworkProviderSettings.java
index bcf0d00..0bc426c 100644
--- a/src/com/android/settings/network/NetworkProviderSettings.java
+++ b/src/com/android/settings/network/NetworkProviderSettings.java
@@ -1263,7 +1263,7 @@
if (Flags.androidVWifiApi() && wifiEntry.getSecurityTypes()
.contains(WifiEntry.SECURITY_WEP)) {
- WepNetworkDialogActivity.checkWepAllowed(
+ WifiUtils.checkWepAllowed(
getContext(), getViewLifecycleOwner(), wifiEntry.getSsid(), () -> {
wifiEntry.connect(callback);
return null;
diff --git a/src/com/android/settings/network/WepNetworkDialogActivity.kt b/src/com/android/settings/network/WepNetworkDialogActivity.kt
index d69630f..fef93ef 100644
--- a/src/com/android/settings/network/WepNetworkDialogActivity.kt
+++ b/src/com/android/settings/network/WepNetworkDialogActivity.kt
@@ -17,8 +17,6 @@
package com.android.settings.network
import android.app.settings.SettingsEnums
-import android.content.Context
-import android.content.Intent
import android.net.wifi.WifiManager
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Text
@@ -26,20 +24,13 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextAlign
-import androidx.lifecycle.LifecycleOwner
-import androidx.lifecycle.lifecycleScope
import com.android.settings.R
import com.android.settings.core.SubSettingLauncher
import com.android.settings.wifi.ConfigureWifiSettings
import com.android.settingslib.spa.SpaBaseDialogActivity
import com.android.settingslib.spa.widget.dialog.AlertDialogButton
import com.android.settingslib.spa.widget.dialog.SettingsAlertDialogWithIcon
-import kotlin.coroutines.resume
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.asExecutor
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.suspendCancellableCoroutine
-import kotlinx.coroutines.withContext
+import com.android.settingslib.wifi.WifiUtils.Companion.SSID
class WepNetworkDialogActivity : SpaBaseDialogActivity() {
@Composable
@@ -76,37 +67,4 @@
)
})
}
-
- companion object {
- @JvmStatic
- fun checkWepAllowed(
- context: Context,
- lifecycleOwner: LifecycleOwner,
- ssid: String,
- onAllowed: () -> Unit,
- ) {
- lifecycleOwner.lifecycleScope.launch {
- val wifiManager = context.getSystemService(WifiManager::class.java) ?: return@launch
- if (wifiManager.queryWepAllowed()) {
- onAllowed()
- } else {
- val intent = Intent(context, WepNetworkDialogActivity::class.java).apply {
- putExtra(SSID, ssid)
- }
- context.startActivity(intent)
- }
- }
- }
-
- private suspend fun WifiManager.queryWepAllowed(): Boolean =
- withContext(Dispatchers.Default) {
- suspendCancellableCoroutine { continuation ->
- queryWepAllowed(Dispatchers.Default.asExecutor()) {
- continuation.resume(it)
- }
- }
- }
-
- const val SSID = "ssid"
- }
}
\ No newline at end of file