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

Commit ba576ffd authored by Hani Kazmi's avatar Hani Kazmi Committed by Android (Google) Code Review
Browse files

Merge "[AAPM] UX for disabling WEP" into main

parents fd070bf5 407465e0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ android_library {
    libs:[
        // This flag library has been added in frameworks jar
        "aconfig_settingslib_flags_java_lib",
        "wifi_framework_aconfig_flags_lib",
    ],
    plugins: ["androidx.room_room-compiler-plugin"],
    use_resource_processor: true,
+20 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.net.wifi.WifiManager
import android.net.wifi.sharedconnectivity.app.NetworkProviderInfo
import android.os.Bundle
import android.os.SystemClock
import android.security.advancedprotection.AdvancedProtectionManager
import android.util.Log
import android.view.WindowManager
import androidx.annotation.VisibleForTesting
@@ -498,7 +499,13 @@ open class WifiUtils {
        ): Job =
            coroutineScope.launch {
                val wifiManager = context.getSystemService(WifiManager::class.java) ?: return@launch
                if (wifiManager.isWepSupported == true && wifiManager.queryWepAllowed()) {
                val aapmManager = context.getSystemService(AdvancedProtectionManager::class.java)
                if (isAdvancedProtectionEnabled(aapmManager)) {
                    val intent = aapmManager.createSupportIntent(
                        AdvancedProtectionManager.FEATURE_ID_DISALLOW_WEP,
                        AdvancedProtectionManager.SUPPORT_DIALOG_TYPE_BLOCKED_INTERACTION)
                    onStartActivity(intent)
                } else if (wifiManager.isWepSupported == true && wifiManager.queryWepAllowed()) {
                    onAllowed()
                } else {
                    val intent = Intent(Intent.ACTION_MAIN).apply {
@@ -522,6 +529,18 @@ open class WifiUtils {
                }
            }

        private suspend fun isAdvancedProtectionEnabled(
            aapmManager: AdvancedProtectionManager?
        ): Boolean =
            if (android.security.Flags.aapmApi() &&
                    com.android.wifi.flags.Flags.wepDisabledInApm() &&
                    aapmManager != null
            ) {
                withContext(Dispatchers.Default) { aapmManager.isAdvancedProtectionEnabled() }
            } else {
                false
            }

        const val SSID = "ssid"
        const val DIALOG_WINDOW_TYPE = "dialog_window_type"
    }
+3 −0
Original line number Diff line number Diff line
@@ -322,6 +322,9 @@
    <!-- Query all packages on device on R+ -->
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />

    <!-- Query advanced protection state -->
    <uses-permission android:name="android.permission.QUERY_ADVANCED_PROTECTION_MODE" />

    <queries>
        <intent>
            <action android:name="android.intent.action.CREATE_NOTE" />