Merge "Allow disabling specific auto-bugreport triggers" into main
diff --git a/flags/wifi_flags.aconfig b/flags/wifi_flags.aconfig
index d02996c..42e165c 100644
--- a/flags/wifi_flags.aconfig
+++ b/flags/wifi_flags.aconfig
@@ -63,6 +63,14 @@
 }
 
 flag {
+    name: "get_channel_width_api"
+    namespace: "wifi"
+    description: "Add new API to get channel width"
+    bug: "335358378"
+    is_fixed_read_only: true
+}
+
+flag {
     name: "voip_detection"
     namespace: "wifi"
     description: "Detect VoIP over Wifi and execute optimization"
diff --git a/framework/api/current.txt b/framework/api/current.txt
index f48cfe8..a277bca 100644
--- a/framework/api/current.txt
+++ b/framework/api/current.txt
@@ -145,6 +145,7 @@
   public final class WifiAvailableChannel implements android.os.Parcelable {
     ctor public WifiAvailableChannel(int, int);
     method public int describeContents();
+    method @FlaggedApi("com.android.wifi.flags.get_channel_width_api") public int getChannelWidth();
     method public int getFrequencyMhz();
     method public int getOperationalModes();
     method public void writeToParcel(@NonNull android.os.Parcel, int);
diff --git a/framework/java/android/net/wifi/WifiAvailableChannel.java b/framework/java/android/net/wifi/WifiAvailableChannel.java
index 11a4054..4f3596d 100644
--- a/framework/java/android/net/wifi/WifiAvailableChannel.java
+++ b/framework/java/android/net/wifi/WifiAvailableChannel.java
@@ -15,12 +15,15 @@
  */
 package android.net.wifi;
 
+import android.annotation.FlaggedApi;
 import android.annotation.IntDef;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.os.Parcel;
 import android.os.Parcelable;
 
+import com.android.wifi.flags.Flags;
+
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.util.Objects;
@@ -124,9 +127,23 @@
      */
     private @OpMode int mOpModes;
 
+    /**
+     * Wifi channel bandwidth.
+     */
+    private @WifiAnnotations.ChannelWidth int mChannelWidth;
+
     public WifiAvailableChannel(int freq, @OpMode int opModes) {
+        this(freq, opModes, ScanResult.CHANNEL_WIDTH_20MHZ);
+    }
+
+    /**
+     * @hide
+     */
+    public WifiAvailableChannel(int freq, @OpMode int opModes,
+            @WifiAnnotations.ChannelWidth int channelWidth) {
         mFrequency = freq;
         mOpModes = opModes;
+        mChannelWidth = channelWidth;
     }
 
     private WifiAvailableChannel(@NonNull Parcel in) {
@@ -136,6 +153,7 @@
     private void readFromParcel(@NonNull Parcel in) {
         mFrequency = in.readInt();
         mOpModes = in.readInt();
+        mChannelWidth = in.readInt();
     }
 
     /**
@@ -164,6 +182,20 @@
                 | FILTER_CELLULAR_COEXISTENCE;
     }
 
+    /**
+     * Get the channel bandwidth, which indicates the amount of frequency spectrum allocated for
+     * data transmission within a channel.
+     *
+     * @return the bandwidth representation of the Wi-Fi channel from
+     * {@link ScanResult#CHANNEL_WIDTH_20MHZ}, {@link ScanResult#CHANNEL_WIDTH_40MHZ},
+     * {@link ScanResult#CHANNEL_WIDTH_80MHZ}, {@link ScanResult#CHANNEL_WIDTH_160MHZ},
+     * {@link ScanResult#CHANNEL_WIDTH_80MHZ_PLUS_MHZ} or {@link ScanResult#CHANNEL_WIDTH_320MHZ}.
+     */
+    @FlaggedApi(Flags.FLAG_GET_CHANNEL_WIDTH_API)
+    public @WifiAnnotations.ChannelWidth int getChannelWidth() {
+        return mChannelWidth;
+    }
+
     @Override
     public int describeContents() {
         return 0;
@@ -175,12 +207,13 @@
         if (o == null || getClass() != o.getClass()) return false;
         WifiAvailableChannel that = (WifiAvailableChannel) o;
         return mFrequency == that.mFrequency
-                && mOpModes == that.mOpModes;
+                && mOpModes == that.mOpModes
+                && mChannelWidth == that.mChannelWidth;
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(mFrequency, mOpModes);
+        return Objects.hash(mFrequency, mOpModes, mChannelWidth);
     }
 
     @Override
@@ -188,6 +221,8 @@
         StringBuilder sbuf = new StringBuilder();
         sbuf.append("mFrequency = ")
             .append(mFrequency)
+            .append(", mChannelWidth = ")
+            .append(mChannelWidth)
             .append(", mOpModes = ")
             .append(String.format("%x", mOpModes));
         return sbuf.toString();
@@ -197,6 +232,7 @@
     public void writeToParcel(@NonNull Parcel dest, int flags) {
         dest.writeInt(mFrequency);
         dest.writeInt(mOpModes);
+        dest.writeInt(mChannelWidth);
     }
 
     public static final @android.annotation.NonNull Creator<WifiAvailableChannel> CREATOR =
diff --git a/framework/java/android/net/wifi/WifiManager.java b/framework/java/android/net/wifi/WifiManager.java
index aa6ff1f..a28d898 100644
--- a/framework/java/android/net/wifi/WifiManager.java
+++ b/framework/java/android/net/wifi/WifiManager.java
@@ -11595,10 +11595,6 @@
     })
     public void addCustomDhcpOptions(@NonNull WifiSsid ssid, @NonNull byte[] oui,
             @NonNull List<DhcpOption> options) {
-        if (mVerboseLoggingEnabled) {
-            Log.v(TAG, "addCustomDhcpOptions: ssid="
-                    + ssid + ", oui=" + Arrays.toString(oui) + ", options=" + options);
-        }
         try {
             mService.addCustomDhcpOptions(ssid, oui, options);
         } catch (RemoteException e) {
@@ -11621,9 +11617,6 @@
             android.Manifest.permission.OVERRIDE_WIFI_CONFIG
     })
     public void removeCustomDhcpOptions(@NonNull WifiSsid ssid, @NonNull byte[] oui) {
-        if (mVerboseLoggingEnabled) {
-            Log.v(TAG, "removeCustomDhcpOptions: ssid=" + ssid + ", oui=" + Arrays.toString(oui));
-        }
         try {
             mService.removeCustomDhcpOptions(ssid, oui);
         } catch (RemoteException e) {
diff --git a/service/ServiceWifiResources/res/values-ky/strings.xml b/service/ServiceWifiResources/res/values-ky/strings.xml
index 1dac1db..e8c22b7 100644
--- a/service/ServiceWifiResources/res/values-ky/strings.xml
+++ b/service/ServiceWifiResources/res/values-ky/strings.xml
@@ -155,9 +155,9 @@
     <string name="wifi_ca_cert_notification_preT_message" msgid="4565553176090475724">"Тармактын <xliff:g id="SSID">%1$s</xliff:g> тастыктамасы жок. Тастыктамаларды кошконду үйрөнүп алыңыз."</string>
     <string name="wifi_ca_cert_notification_preT_continue_text" msgid="1525418430746943670">"Баары бир туташуу"</string>
     <string name="wifi_ca_cert_notification_preT_abort_text" msgid="8307996031461071854">"Туташпасын"</string>
-    <string name="wifi_enable_request_dialog_title" msgid="3577459145316177148">"<xliff:g id="APP_NAME">%1$s</xliff:g> колдонмосуна Wi‑Fi\'ды күйгүзүүгө уруксат берилсинби?"</string>
+    <string name="wifi_enable_request_dialog_title" msgid="3577459145316177148">"<xliff:g id="APP_NAME">%1$s</xliff:g> колдонмосуна Wi‑Fi\'ды күйгүзүүгө уруксат бересизби?"</string>
     <string name="wifi_enable_request_dialog_message" msgid="6395169178524938278">"Wi‑Fi\'ды Ыкчам жөндөөлөрдөн өчүрсөңүз болот"</string>
-    <string name="wifi_enable_request_dialog_positive_button" msgid="6050832555821470466">"Уруксат берүү"</string>
+    <string name="wifi_enable_request_dialog_positive_button" msgid="6050832555821470466">"Ооба"</string>
     <string name="wifi_enable_request_dialog_negative_button" msgid="4754219902374918882">"Тыюу салуу"</string>
     <string name="wifi_enabled_apm_first_time_title" msgid="4814302384637588804">"Wi‑Fi учак режиминде күйгүзүлөт"</string>
     <string name="wifi_enabled_apm_first_time_message" msgid="6416193199042203037">"Эгер Wi-Fi күйүк бойдон калса, кийинки жолу учак режимине өткөнүңүздө түзмөгүңүз аны эстеп калат"</string>
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 5adb0a7..c331d55 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -3513,6 +3513,10 @@
                 mWakeupController.setLastDisconnectInfo(matchInfo);
             }
             mRssiMonitor.reset();
+            // On disconnect, restore roaming mode to normal
+            if (!newConnectionInProgress) {
+                enableRoaming(true);
+            }
         }
 
         clearTargetBssid("handleNetworkDisconnect");
diff --git a/service/java/com/android/server/wifi/DppManager.java b/service/java/com/android/server/wifi/DppManager.java
index 76a8f63..c8bf111 100644
--- a/service/java/com/android/server/wifi/DppManager.java
+++ b/service/java/com/android/server/wifi/DppManager.java
@@ -1094,8 +1094,13 @@
                 logd("binderDied: uid=" + dppRequestInfo.uid);
 
                 mHandler.post(() -> {
-                    dppRequestInfo.isGeneratingSelfConfiguration = false;
                     // Clean up supplicant resource
+                    if (mDppRequestInfo == null) {
+                        Log.e(TAG, "binderDied event without a request information object");
+                        return;
+                    }
+                    mDppRequestInfo.isGeneratingSelfConfiguration = false;
+
                     if (mDppRequestInfo.authRole == DPP_AUTH_ROLE_INITIATOR) {
                         if (!mWifiNative.stopDppInitiator(mClientIfaceName)) {
                             Log.e(TAG, "Failed to stop DPP Initiator");
diff --git a/service/java/com/android/server/wifi/RunnerState.java b/service/java/com/android/server/wifi/RunnerState.java
index 5dbe65c..e6a8573 100644
--- a/service/java/com/android/server/wifi/RunnerState.java
+++ b/service/java/com/android/server/wifi/RunnerState.java
@@ -62,7 +62,10 @@
     public boolean processMessage(Message message) {
         long startTime = System.currentTimeMillis();
 
-        String signatureToLog = getMessageLogRec(message.what);
+        String signatureToLog = getMessageLogRec(message);
+        if (signatureToLog == null) {
+            signatureToLog = getMessageLogRec(message.what);
+        }
         Trace.traceBegin(Trace.TRACE_TAG_NETWORK, signatureToLog);
         boolean ret = processMessageImpl(message);
         Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
@@ -128,5 +131,15 @@
      * @param what message 'what' field
      * @return Readable string
      */
-    public abstract String getMessageLogRec(int what);
+    public String getMessageLogRec(int what) {
+        return null;
+    };
+
+    /**
+     * Implement this to translate a message into a readable String
+     * @return Readable string
+     */
+    public String getMessageLogRec(Message message) {
+        return null;
+    };
 }
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
index 5f271e1..619be54 100644
--- a/service/java/com/android/server/wifi/SoftApManager.java
+++ b/service/java/com/android/server/wifi/SoftApManager.java
@@ -1335,8 +1335,7 @@
                                     mWifiNative.getDeviceWiphyCapabilities(
                                             mApInterfaceName, isBridgeRequired());
                             if (!ApConfigUtil.is11beAllowedForThisConfiguration(capabilities,
-                                    mContext.getResources(),
-                                    mCurrentSoftApConfiguration, isBridgedMode())) {
+                                    mContext, mCurrentSoftApConfiguration, isBridgedMode())) {
                                 Log.d(getTag(), "11BE is not allowed,"
                                         + " removing from configuration");
                                 mCurrentSoftApConfiguration = new SoftApConfiguration.Builder(
diff --git a/service/java/com/android/server/wifi/WifiCarrierInfoManager.java b/service/java/com/android/server/wifi/WifiCarrierInfoManager.java
index cdfb0cc..1936abb 100644
--- a/service/java/com/android/server/wifi/WifiCarrierInfoManager.java
+++ b/service/java/com/android/server/wifi/WifiCarrierInfoManager.java
@@ -54,6 +54,10 @@
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyCallback;
 import android.telephony.TelephonyManager;
+import android.telephony.ims.ImsManager;
+import android.telephony.ims.ImsMmTelManager;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
 import android.text.TextUtils;
 import android.util.ArraySet;
 import android.util.Base64;
@@ -188,6 +192,9 @@
     private final WifiMetrics mWifiMetrics;
     private final Clock mClock;
     private final WifiPseudonymManager mWifiPseudonymManager;
+
+    private ImsManager mImsManager;
+    private Map<Integer, ImsMmTelManager> mImsMmTelManagerMap = new HashMap<>();
     /**
      * Cached Map of <subscription ID, CarrierConfig PersistableBundle> since retrieving the
      * PersistableBundle from CarrierConfigManager is somewhat expensive as it has hundreds of
@@ -526,6 +533,7 @@
         @Override
         public void onSubscriptionsChanged() {
             mActiveSubInfos = mSubscriptionManager.getCompleteActiveSubscriptionInfoList();
+            mImsMmTelManagerMap.clear();
             updateSubIdsInNetworkFactoryFilters(mActiveSubInfos);
             mSubIdToSimInfoSparseArray.clear();
             mSubscriptionGroupMap.clear();
@@ -2333,6 +2341,40 @@
         return ret;
     }
 
+    /**
+     * Check if wifi calling is being available.
+     */
+    public boolean isWifiCallingAvailable() {
+        if (mActiveSubInfos == null || mActiveSubInfos.isEmpty()) {
+            return false;
+        }
+        if (mImsManager == null) {
+            mImsManager = mContext.getSystemService(ImsManager.class);
+        }
+        for (SubscriptionInfo subInfo : mActiveSubInfos) {
+            int subscriptionId = subInfo.getSubscriptionId();
+            try {
+                if (mImsManager != null) {
+                    ImsMmTelManager imsMmTelManager = mImsMmTelManagerMap.get(subscriptionId);
+                    if (imsMmTelManager == null) {
+                        imsMmTelManager = mImsManager.getImsMmTelManager(subscriptionId);
+                        mImsMmTelManagerMap.put(subscriptionId, imsMmTelManager);
+                    }
+                    if (imsMmTelManager != null
+                            && imsMmTelManager.isAvailable(
+                                    MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
+                                    ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN)) {
+                        Log.d(TAG, "WifiCalling is available on subId " + subscriptionId);
+                        return true;
+                    }
+                }
+            } catch (RuntimeException e) {
+                Log.d(TAG, "RuntimeException while checking if wifi calling is available: " + e);
+            }
+        }
+        return false;
+    }
+
     private boolean isOobPseudonymFeatureEnabledInResource(int carrierId) {
         WifiStringResourceWrapper wifiStringResourceWrapper =
                 mContext.getStringResourceWrapper(getMatchingSubId(carrierId), carrierId);
diff --git a/service/java/com/android/server/wifi/WifiCountryCode.java b/service/java/com/android/server/wifi/WifiCountryCode.java
index 46c2393..4d4bc0b 100644
--- a/service/java/com/android/server/wifi/WifiCountryCode.java
+++ b/service/java/com/android/server/wifi/WifiCountryCode.java
@@ -23,12 +23,7 @@
 import android.content.Context;
 import android.net.wifi.WifiInfo;
 import android.os.SystemProperties;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
-import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
 import android.text.TextUtils;
 import android.util.ArrayMap;
 import android.util.Log;
@@ -78,6 +73,7 @@
     private final WifiSettingsConfigStore mSettingsConfigStore;
     private final Clock mClock;
     private final WifiPermissionsUtil mWifiPermissionsUtil;
+    private final WifiCarrierInfoManager mWifiCarrierInfoManager;
     private List<ChangeListener> mListeners = new ArrayList<>();
     private boolean mVerboseLoggingEnabled = false;
     private boolean mIsCountryCodePendingToUpdateToCmm = true; // default to true for first update.
@@ -210,7 +206,8 @@
             WifiNative wifiNative,
             @NonNull WifiSettingsConfigStore settingsConfigStore,
             Clock clock,
-            WifiPermissionsUtil wifiPermissionsUtil) {
+            WifiPermissionsUtil wifiPermissionsUtil,
+            @NonNull WifiCarrierInfoManager wifiCarrierInfoManager) {
         mContext = context;
         mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
         mActiveModeWarden = activeModeWarden;
@@ -219,6 +216,7 @@
         mSettingsConfigStore = settingsConfigStore;
         mClock = clock;
         mWifiPermissionsUtil = wifiPermissionsUtil;
+        mWifiCarrierInfoManager = wifiCarrierInfoManager;
 
         mActiveModeWarden.registerModeChangeCallback(new ModeChangeCallbackInternal());
         clientModeImplMonitor.registerListener(new ClientModeListenerInternal());
@@ -309,41 +307,6 @@
         return mContext.getPackageManager().hasSystemFeature(FEATURE_TELEPHONY_CALLING);
     }
 
-    /**
-     * Check if Wi-Fi calling is available.
-     *
-     * This method can only be called if device has calling feature (see hasCalling()).
-     */
-    private boolean isWifiCallingAvailable() {
-        SubscriptionManager subscriptionManager =
-                mContext.getSystemService(SubscriptionManager.class);
-        if (subscriptionManager == null) {
-            Log.d(TAG, "SubscriptionManager not found");
-            return false;
-        }
-
-        List<SubscriptionInfo> subInfoList = subscriptionManager
-                .getCompleteActiveSubscriptionInfoList();
-        if (subInfoList == null) {
-            Log.d(TAG, "Active SubscriptionInfo list not found");
-            return false;
-        }
-        for (SubscriptionInfo subInfo : subInfoList) {
-            int subscriptionId = subInfo.getSubscriptionId();
-            try {
-                if (ImsMmTelManager.createForSubscriptionId(subscriptionId).isAvailable(
-                        MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
-                        ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN)) {
-                    Log.d(TAG, "WifiCalling is available on subId " + subscriptionId);
-                    return true;
-                }
-            } catch (RuntimeException e) {
-                Log.d(TAG, "RuntimeException while checking if wifi calling is available: " + e);
-            }
-        }
-        return false;
-    }
-
     private void initializeTelephonyCountryCodeIfNeeded() {
         // If we don't have telephony country code set yet, poll it.
         if (mTelephonyCountryCode == null) {
@@ -547,7 +510,7 @@
     }
 
     private boolean shouldDisconnectWifiToForceUpdate() {
-        if (!hasCalling() || isWifiCallingAvailable()) {
+        if (!hasCalling() || mWifiCarrierInfoManager.isWifiCallingAvailable()) {
             return false;
         }
 
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index 85af0a5..9553434 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -527,7 +527,8 @@
                 mContext, mCmiMonitor, mSettingsStore, wifiHandler, mClock);
         mExternalPnoScanRequestManager = new ExternalPnoScanRequestManager(wifiHandler, mContext);
         mCountryCode = new WifiCountryCode(mContext, mActiveModeWarden, mWifiP2pMetrics,
-                mCmiMonitor, mWifiNative, mSettingsConfigStore, mClock, mWifiPermissionsUtil);
+                mCmiMonitor, mWifiNative, mSettingsConfigStore, mClock, mWifiPermissionsUtil,
+                mWifiCarrierInfoManager);
         mWifiConnectivityManager = new WifiConnectivityManager(
                 mContext, mScoringParams, mWifiConfigManager,
                 mWifiNetworkSuggestionsManager, mWifiNetworkSelector,
@@ -623,7 +624,8 @@
                 WifiTwtSession.MAX_TWT_SESSIONS, 1);
         mBackupRestoreController = new BackupRestoreController(mWifiSettingsBackupRestore, mClock);
         if (mFeatureFlags.voipDetection() && SdkLevel.isAtLeastV()) {
-            mWifiVoipDetector = new WifiVoipDetector(mContext, wifiHandler, this);
+            mWifiVoipDetector = new WifiVoipDetector(mContext, wifiHandler, this,
+                    mWifiCarrierInfoManager);
         } else {
             mWifiVoipDetector = null;
         }
diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java
index ff6c066..358593d 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSelector.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java
@@ -1453,9 +1453,11 @@
     private void updateSecurityParamsForTransitionModeIfNecessary(
             ScanResult scanResult, SecurityParams params) {
         if (params.isSecurityType(WifiConfiguration.SECURITY_TYPE_SAE)
+                && params.isAddedByAutoUpgrade()
                 && ScanResultUtil.isScanResultForPskSaeTransitionNetwork(scanResult)) {
             params.setRequirePmf(false);
         } else if (params.isSecurityType(WifiConfiguration.SECURITY_TYPE_EAP_WPA3_ENTERPRISE)
+                && params.isAddedByAutoUpgrade()
                 && ScanResultUtil.isScanResultForWpa3EnterpriseTransitionNetwork(scanResult)) {
             params.setRequirePmf(false);
         }
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 89a23b7..7914f15 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -1020,6 +1020,9 @@
     }
 
     private void handleShutDown() {
+        if (mVerboseLoggingEnabled) {
+            Log.v(TAG, "handleShutDown");
+        }
         // Direct call to notify ActiveModeWarden as soon as possible with the assumption that
         // notifyShuttingDown() doesn't have codes that may cause concurrentModificationException,
         // e.g., access to a collection.
@@ -7455,7 +7458,10 @@
             if ((band & ScanResult.toBand(freq)) == 0) {
                 continue;
             }
-            channels.add(new WifiAvailableChannel(freq, WifiAvailableChannel.OP_MODE_SAP));
+            // TODO b/340956906: Save and retrieve channel width in config store along with
+            //  frequency.
+            channels.add(new WifiAvailableChannel(freq, WifiAvailableChannel.OP_MODE_SAP,
+                    ScanResult.CHANNEL_WIDTH_20MHZ));
         }
         return channels;
     }
@@ -7779,6 +7785,10 @@
             @NonNull List<DhcpOption> options) {
         enforceAnyPermissionOf(android.Manifest.permission.NETWORK_SETTINGS,
                 android.Manifest.permission.OVERRIDE_WIFI_CONFIG);
+        if (mVerboseLoggingEnabled) {
+            Log.v(TAG, "addCustomDhcpOptions: ssid="
+                    + ssid + ", oui=" + Arrays.toString(oui) + ", options=" + options);
+        }
         mWifiThreadRunner.post(() -> mWifiConfigManager.addCustomDhcpOptions(ssid, oui, options),
                 TAG + "#addCustomDhcpOptions");
     }
@@ -7790,6 +7800,9 @@
     public void removeCustomDhcpOptions(@NonNull WifiSsid ssid, @NonNull byte[] oui) {
         enforceAnyPermissionOf(android.Manifest.permission.NETWORK_SETTINGS,
                 android.Manifest.permission.OVERRIDE_WIFI_CONFIG);
+        if (mVerboseLoggingEnabled) {
+            Log.v(TAG, "removeCustomDhcpOptions: ssid=" + ssid + ", oui=" + Arrays.toString(oui));
+        }
         mWifiThreadRunner.post(() -> mWifiConfigManager.removeCustomDhcpOptions(ssid, oui),
                 TAG + "#removeCustomDhcpOptions");
     }
diff --git a/service/java/com/android/server/wifi/WifiThreadRunner.java b/service/java/com/android/server/wifi/WifiThreadRunner.java
index add1bb2..a7200ff 100644
--- a/service/java/com/android/server/wifi/WifiThreadRunner.java
+++ b/service/java/com/android/server/wifi/WifiThreadRunner.java
@@ -102,6 +102,13 @@
     }
 
     /**
+     * TODO(b/342976570): remove when we are sure no more usage
+     */
+    public <T> T call(@NonNull Supplier<T> supplier, T valueToReturnOnTimeout) {
+        return call(supplier, valueToReturnOnTimeout, null);
+    }
+
+    /**
      * Runs a Runnable on the main Wifi thread and <b>blocks</b> the calling thread until the
      * Runnable completes execution on the main Wifi thread.
      *
@@ -126,6 +133,13 @@
     }
 
     /**
+     * TODO(b/342976570): remove when we are sure no more usage
+     */
+    public boolean run(@NonNull Runnable runnable) {
+        return run(runnable, null);
+    }
+
+    /**
      * Runs a Runnable on the main Wifi thread on the next iteration and <b>blocks</b> the calling
      * thread until the Runnable completes execution on the main Wifi thread.
      *
@@ -188,13 +202,20 @@
      * @param runnable The Runnable that will be executed.
      * @param taskName The task name for performance logging
      */
-    public boolean post(@NonNull Runnable runnable, String taskName) {
+    public boolean post(@NonNull Runnable runnable, @Nullable String taskName) {
         Message m = Message.obtain(mHandler, runnable);
         m.getData().putString(KEY_SIGNATURE, taskName);
         return mHandler.sendMessage(m);
     }
 
     /**
+     * TODO(b/342976570): remove when we are sure no more usage
+     */
+    public boolean post(@NonNull Runnable runnable) {
+        return post(runnable, null);
+    }
+
+    /**
      * Asynchronously runs a Runnable on the main Wifi thread with delay.
      *
      * @param runnable    The Runnable that will be executed.
diff --git a/service/java/com/android/server/wifi/WifiVoipDetector.java b/service/java/com/android/server/wifi/WifiVoipDetector.java
index 1b7e3cb..5754bc3 100644
--- a/service/java/com/android/server/wifi/WifiVoipDetector.java
+++ b/service/java/com/android/server/wifi/WifiVoipDetector.java
@@ -25,13 +25,8 @@
 import android.os.Build;
 import android.os.Handler;
 import android.telephony.CallAttributes;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyCallback;
 import android.telephony.TelephonyManager;
-import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
 import android.util.LocalLog;
 import android.util.Log;
 
@@ -44,7 +39,6 @@
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -60,6 +54,7 @@
     private final WifiInjector mWifiInjector;
     private final LocalLog mLocalLog;
 
+    private final WifiCarrierInfoManager mWifiCarrierInfoManager;
 
     private AudioManager mAudioManager;
     private TelephonyManager mTelephonyManager;
@@ -77,11 +72,13 @@
     private Map<String, Boolean> mConnectedWifiIfaceMap = new HashMap<>();
 
     public WifiVoipDetector(@NonNull Context context, @NonNull Handler handler,
-            @NonNull WifiInjector wifiInjector) {
+            @NonNull WifiInjector wifiInjector,
+            @NonNull WifiCarrierInfoManager wifiCarrierInfoManager) {
         mContext = context;
         mHandler = handler;
         mHandlerExecutor = new HandlerExecutor(mHandler);
         mWifiInjector = wifiInjector;
+        mWifiCarrierInfoManager = wifiCarrierInfoManager;
         mLocalLog = new LocalLog(32);
     }
 
@@ -210,7 +207,7 @@
             mAudioModeListener = new AudioModeListener();
         }
         if (mTelephonyManager != null) {
-            mIsVoWifiOn = isWifiCallingAvailable();
+            mIsVoWifiOn = mWifiCarrierInfoManager.isWifiCallingAvailable();
             mTelephonyManager.registerTelephonyCallback(
                      mHandlerExecutor, mWifiCallingStateListener);
         }
@@ -253,35 +250,4 @@
         pw.println("mIsWifiConnected = " + mIsWifiConnected);
         pw.println("mCurrentMode = " + mCurrentMode);
     }
-
-    // TODO: Public this API and update all caller to use one place to detect VoWifi call
-    private boolean isWifiCallingAvailable() {
-        SubscriptionManager subscriptionManager =
-                mContext.getSystemService(SubscriptionManager.class);
-        if (subscriptionManager == null) {
-            Log.d(TAG, "SubscriptionManager not found");
-            return false;
-        }
-
-        List<SubscriptionInfo> subInfoList = subscriptionManager
-                .getCompleteActiveSubscriptionInfoList();
-        if (subInfoList == null) {
-            Log.d(TAG, "Active SubscriptionInfo list not found");
-            return false;
-        }
-        for (SubscriptionInfo subInfo : subInfoList) {
-            int subscriptionId = subInfo.getSubscriptionId();
-            try {
-                if (ImsMmTelManager.createForSubscriptionId(subscriptionId).isAvailable(
-                        MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
-                        ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN)) {
-                    Log.d(TAG, "WifiCalling is available on subId " + subscriptionId);
-                    return true;
-                }
-            } catch (RuntimeException e) {
-                Log.d(TAG, "RuntimeException while checking if wifi calling is available: " + e);
-            }
-        }
-        return false;
-    }
 }
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
index 9d42277..a4fd8ad 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
@@ -2377,6 +2377,31 @@
             };
         }
 
+        private String messageToString(Message msg) {
+            StringBuilder sb = new StringBuilder();
+
+            String s = getWhatToString(msg.what);
+            if (s == null) {
+                s = "<unknown>";
+            }
+            sb.append(s).append("/");
+
+            if (msg.what == MESSAGE_TYPE_NOTIFICATION || msg.what == MESSAGE_TYPE_COMMAND
+                    || msg.what == MESSAGE_TYPE_RESPONSE) {
+                s = getWhatToString(msg.arg1);
+                if (s == null) {
+                    s = "<unknown>";
+                }
+                sb.append(s);
+            }
+
+            if (msg.what == MESSAGE_TYPE_RESPONSE || msg.what == MESSAGE_TYPE_RESPONSE_TIMEOUT) {
+                sb.append(" (Transaction ID=").append(msg.arg2).append(")");
+            }
+
+            return sb.toString();
+        }
+
         public void onAwareDownCleanupSendQueueState() {
             mSendQueueBlocked = false;
             mHostQueuedSendMessages.clear();
@@ -2390,9 +2415,10 @@
             }
 
             @Override
-            public String getMessageLogRec(int what) {
+            public String getMessageLogRec(Message message) {
                 return WifiAwareStateManager.class.getSimpleName() + "."
-                        + DefaultState.class.getSimpleName() + "." + getWhatToString(what);
+                        + DefaultState.class.getSimpleName() + "." + getWhatToString(message.what)
+                        + "#" + getWhatToString(message.arg1);
             }
 
             @Override
@@ -2459,9 +2485,10 @@
             }
 
             @Override
-            public String getMessageLogRec(int what) {
+            public String getMessageLogRec(Message message) {
                 return WifiAwareStateManager.class.getSimpleName() + "."
-                        + WaitState.class.getSimpleName() + "." + getWhatToString(what);
+                        + WaitState.class.getSimpleName() + "." + getWhatToString(message.what)
+                        + "#" + getWhatToString(message.arg1);
             }
 
             @Override
@@ -2510,9 +2537,10 @@
             }
 
             @Override
-            public String getMessageLogRec(int what) {
+            public String getMessageLogRec(Message message) {
                 return WifiAwareStateManager.class.getSimpleName() + "."
-                        + WaitForResponseState.class.getSimpleName() + "." + getWhatToString(what);
+                        + WaitForResponseState.class.getSimpleName() + "."
+                        + getWhatToString(message.what) + "#" + getWhatToString(message.arg1);
             }
 
             @Override
@@ -3694,7 +3722,7 @@
 
         @Override
         protected String getLogRecString(Message msg) {
-            StringBuilder sb = new StringBuilder(WifiAwareStateManager.messageToString(msg));
+            StringBuilder sb = new StringBuilder(messageToString(msg));
 
             if (msg.what == MESSAGE_TYPE_COMMAND
                     && mCurrentTransactionId != TRANSACTION_ID_IGNORE) {
@@ -5645,31 +5673,6 @@
         return instantMode;
     }
 
-    private static String messageToString(Message msg) {
-        StringBuilder sb = new StringBuilder();
-
-        String s = sSmToString.get(msg.what);
-        if (s == null) {
-            s = "<unknown>";
-        }
-        sb.append(s).append("/");
-
-        if (msg.what == MESSAGE_TYPE_NOTIFICATION || msg.what == MESSAGE_TYPE_COMMAND
-                || msg.what == MESSAGE_TYPE_RESPONSE) {
-            s = sSmToString.get(msg.arg1);
-            if (s == null) {
-                s = "<unknown>";
-            }
-            sb.append(s);
-        }
-
-        if (msg.what == MESSAGE_TYPE_RESPONSE || msg.what == MESSAGE_TYPE_RESPONSE_TIMEOUT) {
-            sb.append(" (Transaction ID=").append(msg.arg2).append(")");
-        }
-
-        return sb.toString();
-    }
-
     /**
      * Just a proxy to call {@link WifiAwareDataPathStateManager#createAllInterfaces()} for test.
      */
diff --git a/service/java/com/android/server/wifi/hal/WifiChipAidlImpl.java b/service/java/com/android/server/wifi/hal/WifiChipAidlImpl.java
index 80e53ca..f9e4ce2 100644
--- a/service/java/com/android/server/wifi/hal/WifiChipAidlImpl.java
+++ b/service/java/com/android/server/wifi/hal/WifiChipAidlImpl.java
@@ -16,6 +16,11 @@
 
 package com.android.server.wifi.hal;
 
+import static android.hardware.wifi.WifiChannelWidthInMhz.WIDTH_160;
+import static android.hardware.wifi.WifiChannelWidthInMhz.WIDTH_320;
+import static android.hardware.wifi.WifiChannelWidthInMhz.WIDTH_40;
+import static android.hardware.wifi.WifiChannelWidthInMhz.WIDTH_80;
+import static android.hardware.wifi.WifiChannelWidthInMhz.WIDTH_80P80;
 import static android.net.wifi.CoexUnsafeChannel.POWER_CAP_NONE;
 
 import android.annotation.NonNull;
@@ -53,6 +58,8 @@
 import android.hardware.wifi.WifiUsableChannel;
 import android.net.wifi.CoexUnsafeChannel;
 import android.net.wifi.OuiKeyedData;
+import android.net.wifi.ScanResult;
+import android.net.wifi.WifiAnnotations;
 import android.net.wifi.WifiAvailableChannel;
 import android.net.wifi.WifiManager;
 import android.net.wifi.WifiScanner;
@@ -690,7 +697,8 @@
                 List<WifiAvailableChannel> frameworkChannels = new ArrayList<>();
                 for (WifiUsableChannel ch : halChannels) {
                     frameworkChannels.add(new WifiAvailableChannel(
-                            ch.channel, halToFrameworkIfaceMode(ch.ifaceModeMask)));
+                            ch.channel, halToFrameworkIfaceMode(ch.ifaceModeMask),
+                            halToFrameworkChannelWidth(ch.channelBandwidth)));
                 }
                 return frameworkChannels;
             } catch (RemoteException e) {
@@ -704,6 +712,23 @@
         }
     }
 
+    private @WifiAnnotations.ChannelWidth int halToFrameworkChannelWidth(int channelBandwidth) {
+        switch(channelBandwidth) {
+            case WIDTH_40:
+                return ScanResult.CHANNEL_WIDTH_40MHZ;
+            case WIDTH_80:
+                return ScanResult.CHANNEL_WIDTH_80MHZ;
+            case WIDTH_160:
+                return ScanResult.CHANNEL_WIDTH_160MHZ;
+            case WIDTH_80P80:
+                return ScanResult.CHANNEL_WIDTH_80MHZ_PLUS_MHZ;
+            case WIDTH_320:
+                return ScanResult.CHANNEL_WIDTH_320MHZ;
+            default:
+                return ScanResult.CHANNEL_WIDTH_20MHZ;
+        }
+    }
+
     /**
      * See comments for {@link IWifiChip#registerCallback(WifiChip.Callback)}
      */
diff --git a/service/java/com/android/server/wifi/hal/WifiChipHidlImpl.java b/service/java/com/android/server/wifi/hal/WifiChipHidlImpl.java
index 430f96a..31101ac 100644
--- a/service/java/com/android/server/wifi/hal/WifiChipHidlImpl.java
+++ b/service/java/com/android/server/wifi/hal/WifiChipHidlImpl.java
@@ -16,6 +16,11 @@
 
 package com.android.server.wifi.hal;
 
+import static android.hardware.wifi.V1_6.WifiChannelWidthInMhz.WIDTH_160;
+import static android.hardware.wifi.V1_6.WifiChannelWidthInMhz.WIDTH_320;
+import static android.hardware.wifi.V1_6.WifiChannelWidthInMhz.WIDTH_40;
+import static android.hardware.wifi.V1_6.WifiChannelWidthInMhz.WIDTH_80;
+import static android.hardware.wifi.V1_6.WifiChannelWidthInMhz.WIDTH_80P80;
 import static android.net.wifi.CoexUnsafeChannel.POWER_CAP_NONE;
 
 import android.annotation.NonNull;
@@ -37,6 +42,8 @@
 import android.hardware.wifi.V1_6.WifiRadioConfiguration;
 import android.net.wifi.CoexUnsafeChannel;
 import android.net.wifi.OuiKeyedData;
+import android.net.wifi.ScanResult;
+import android.net.wifi.WifiAnnotations;
 import android.net.wifi.WifiAvailableChannel;
 import android.net.wifi.WifiManager;
 import android.net.wifi.WifiScanner;
@@ -1042,7 +1049,8 @@
                                 channelResp.value = new ArrayList<>();
                                 for (android.hardware.wifi.V1_6.WifiUsableChannel ch : channels) {
                                     channelResp.value.add(new WifiAvailableChannel(ch.channel,
-                                            halToFrameworkIfaceMode(ch.ifaceModeMask)));
+                                            halToFrameworkIfaceMode(ch.ifaceModeMask),
+                                            halToFrameworkChannelWidth(ch.channelBandwidth)));
                                 }
                             }
                         });
@@ -1056,7 +1064,8 @@
                                 channelResp.value = new ArrayList<>();
                                 for (android.hardware.wifi.V1_5.WifiUsableChannel ch : channels) {
                                     channelResp.value.add(new WifiAvailableChannel(ch.channel,
-                                            halToFrameworkIfaceMode(ch.ifaceModeMask)));
+                                            halToFrameworkIfaceMode(ch.ifaceModeMask),
+                                            halToFrameworkChannelWidth(ch.channelBandwidth)));
                                 }
                             }
                         });
@@ -1067,6 +1076,23 @@
         return channelResp.value;
     }
 
+    private @WifiAnnotations.ChannelWidth int halToFrameworkChannelWidth(int channelBandwidth) {
+        switch (channelBandwidth) {
+            case WIDTH_40:
+                return ScanResult.CHANNEL_WIDTH_40MHZ;
+            case WIDTH_80:
+                return ScanResult.CHANNEL_WIDTH_80MHZ;
+            case WIDTH_160:
+                return ScanResult.CHANNEL_WIDTH_160MHZ;
+            case WIDTH_80P80:
+                return ScanResult.CHANNEL_WIDTH_80MHZ_PLUS_MHZ;
+            case WIDTH_320:
+                return ScanResult.CHANNEL_WIDTH_320MHZ;
+            default:
+                return ScanResult.CHANNEL_WIDTH_20MHZ;
+        }
+    }
+
     private boolean registerCallbackInternal(String methodStr, WifiChip.Callback callback) {
         if (mFrameworkCallback != null) {
             Log.e(TAG, "Framework callback is already registered");
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index 4945eb9..6989411 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -882,6 +882,7 @@
                             if (staticIpConfig != null) {
                                 config = new ProvisioningConfiguration.Builder()
                                         .withoutIpReachabilityMonitor()
+                                        .withRandomMacAddress()
                                         .withStaticConfiguration(staticIpConfig).build();
                             }
                         }
@@ -889,6 +890,7 @@
                             // start DHCP provisioning
                             config = new ProvisioningConfiguration.Builder()
                                     .withoutIpReachabilityMonitor()
+                                    .withRandomMacAddress()
                                     .withPreDhcpAction(30 * 1000)
                                     .withProvisioningTimeoutMs(36 * 1000)
                                     .build();
diff --git a/service/java/com/android/server/wifi/util/ApConfigUtil.java b/service/java/com/android/server/wifi/util/ApConfigUtil.java
index 2f63fc1..bbc8d4b 100644
--- a/service/java/com/android/server/wifi/util/ApConfigUtil.java
+++ b/service/java/com/android/server/wifi/util/ApConfigUtil.java
@@ -834,23 +834,26 @@
      * Check if IEEE80211BE is allowed for the given softAp configuration.
      *
      * @param capabilities capabilities of the device to check support for IEEE80211BE support.
-     * @param resources the resources to get the OEM configuration for support for single link MLO
-     *                  in bridged mode.
+     * @param context The caller context used to get the OEM configuration for support for
+     *                IEEE80211BE & single link MLO in bridged mode from the resource file.
      * @param config The current {@link SoftApConfiguration}.
      * @param isBridgedMode true if bridged mode is enabled, false otherwise.
      *
      * @return true if IEEE80211BE is allowed for the given configuration, false otherwise.
      */
     public static boolean is11beAllowedForThisConfiguration(DeviceWiphyCapabilities capabilities,
-            @NonNull Resources resources,
+            @NonNull Context context,
             SoftApConfiguration config,
             boolean isBridgedMode) {
+        if (!ApConfigUtil.isIeee80211beSupported(context)) {
+            return false;
+        }
         if (capabilities == null || !capabilities.isWifiStandardSupported(
                 ScanResult.WIFI_STANDARD_11BE)) {
             return false;
         }
         if (isBridgedMode
-                && !resources.getBoolean(
+                && !context.getResources().getBoolean(
                         R.bool.config_wifiSoftApSingleLinkMloInBridgedModeSupported)) {
             return false;
         }
diff --git a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
index c7d97cf..614b0df 100644
--- a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
+++ b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
@@ -180,6 +180,7 @@
         try {
             enforceNearbyDevicesPermission(attributionSource, checkForLocation, message);
         } catch (SecurityException e) {
+            Log.e(TAG, "checkNearbyDevicesPermission - " + e);
             return false;
         }
         return true;
diff --git a/service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index 723e2e1..fddabc7 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -7866,6 +7866,39 @@
         verifyNoMoreInteractions(mWifiNetworkAgent);
     }
 
+    /**
+     * Verify that roaming mode is enabled on disconnect for primary.
+     */
+    @Test
+    public void testRoamingModeOnDisconnectPrimary() throws Exception {
+        when(mClientModeManager.getRole()).thenReturn(ROLE_CLIENT_PRIMARY);
+        connect();
+        mCmi.disconnect();
+        mLooper.dispatchAll();
+        mCmi.sendMessage(WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT, 0, 0,
+                new StateChangeResult(0, WifiSsid.fromUtf8Text(mConnectedNetwork.SSID),
+                        TEST_BSSID_STR, sFreq, SupplicantState.DISCONNECTED));
+        mLooper.dispatchAll();
+        verify(mWifiNative).enableFirmwareRoaming(anyString(),
+                eq(WifiNative.ENABLE_FIRMWARE_ROAMING));
+    }
+
+    /**
+     * Verify that roaming mode doesn't change on disconnect for secondary.
+     */
+    @Test
+    public void testRoamingModeOnDisconnectSecondary() throws Exception {
+        when(mClientModeManager.getRole()).thenReturn(ROLE_CLIENT_SECONDARY_TRANSIENT);
+        connect();
+        mCmi.disconnect();
+        mLooper.dispatchAll();
+        mCmi.sendMessage(WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT, 0, 0,
+                new StateChangeResult(0, WifiSsid.fromUtf8Text(mConnectedNetwork.SSID),
+                        TEST_BSSID_STR, sFreq, SupplicantState.DISCONNECTED));
+        mLooper.dispatchAll();
+        verify(mWifiNative, never()).enableFirmwareRoaming(anyString(), anyInt());
+    }
+
     @Test
     public void testConnectionWhileDisconnecting() throws Exception {
         connect();
diff --git a/service/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
index 70e5942..aeb84c2 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
@@ -4038,17 +4038,46 @@
 
     /**
      * Tests that 11BE is set to disabled in the SoftApConfiguration if it isn't supported by
-     * SoftApCapability.
+     * device Capabilities.
      */
     @Test
-    public void testStartSoftApRemoves11BEIfNotSupported() throws Exception {
+    public void testStartSoftApRemoves11BEIfNotSupportedByDeviceCapabilities() throws Exception {
         assumeTrue(SdkLevel.isAtLeastT());
+        when(mResources.getBoolean(R.bool.config_wifiSoftapIeee80211beSupported))
+                .thenReturn(true);
         when(mDeviceWiphyCapabilities.isWifiStandardSupported(ScanResult.WIFI_STANDARD_11BE))
                 .thenReturn(false);
         Builder configBuilder = new SoftApConfiguration.Builder();
-        configBuilder.setBand(SoftApConfiguration.BAND_2GHZ);
+        configBuilder.setBand(SoftApConfiguration.BAND_5GHZ);
         configBuilder.setSsid(TEST_SSID);
         configBuilder.setIeee80211beEnabled(true);
+        configBuilder.setPassphrase("somepassword",
+                SoftApConfiguration.SECURITY_TYPE_WPA3_SAE);
+        SoftApModeConfiguration apConfig = new SoftApModeConfiguration(
+                WifiManager.IFACE_IP_MODE_TETHERED, configBuilder.build(),
+                mTestSoftApCapability, TEST_COUNTRY_CODE, TEST_TETHERING_REQUEST);
+        SoftApConfiguration expectedConfig = configBuilder.setIeee80211beEnabled(false).build();
+        startSoftApAndVerifyEnabled(apConfig, expectedConfig, false);
+    }
+
+    /**
+     * Tests that 11BE is set to disabled in the SoftApConfiguration if it isn't supported by
+     * overlay configuration.
+     */
+    @Test
+    public void testStartSoftApRemoves11BEIfNotSupportedByOverlay() throws Exception {
+        assumeTrue(SdkLevel.isAtLeastT());
+        when(mResources.getBoolean(R.bool.config_wifiSoftapIeee80211beSupported))
+                .thenReturn(false);
+        when(mDeviceWiphyCapabilities.isWifiStandardSupported(ScanResult.WIFI_STANDARD_11BE))
+                .thenReturn(true);
+        mDeviceWiphyCapabilitiesSupports11Be = true;
+        Builder configBuilder = new SoftApConfiguration.Builder();
+        configBuilder.setBand(SoftApConfiguration.BAND_5GHZ);
+        configBuilder.setSsid(TEST_SSID);
+        configBuilder.setIeee80211beEnabled(true);
+        configBuilder.setPassphrase("somepassword",
+                SoftApConfiguration.SECURITY_TYPE_WPA3_SAE);
         SoftApModeConfiguration apConfig = new SoftApModeConfiguration(
                 WifiManager.IFACE_IP_MODE_TETHERED, configBuilder.build(),
                 mTestSoftApCapability, TEST_COUNTRY_CODE, TEST_TETHERING_REQUEST);
@@ -4062,6 +4091,8 @@
     @Test
     public void testStartSoftApRemoves11BEInWpa2()throws Exception {
         assumeTrue(SdkLevel.isAtLeastT());
+        when(mResources.getBoolean(R.bool.config_wifiSoftapIeee80211beSupported))
+                .thenReturn(true);
         when(mDeviceWiphyCapabilities.isWifiStandardSupported(ScanResult.WIFI_STANDARD_11BE))
                 .thenReturn(true);
         mDeviceWiphyCapabilitiesSupports11Be = true;
@@ -4086,6 +4117,8 @@
     @Test
     public void testStartSoftApRemoves11BEInBridgedModeIfNotSupportedByOverlay()throws Exception {
         assumeTrue(SdkLevel.isAtLeastT());
+        when(mResources.getBoolean(R.bool.config_wifiSoftapIeee80211beSupported))
+                .thenReturn(true);
         when(mResources.getBoolean(R.bool.config_wifiSoftApSingleLinkMloInBridgedModeSupported))
                 .thenReturn(false);
         when(mDeviceWiphyCapabilities.isWifiStandardSupported(ScanResult.WIFI_STANDARD_11BE))
@@ -4113,6 +4146,8 @@
     @Test
     public void testStartSoftApInBridgedMode11BEConfiguration()throws Exception {
         assumeTrue(SdkLevel.isAtLeastT());
+        when(mResources.getBoolean(R.bool.config_wifiSoftapIeee80211beSupported))
+                .thenReturn(true);
         when(mResources.getBoolean(R.bool.config_wifiSoftApSingleLinkMloInBridgedModeSupported))
                 .thenReturn(true);
         when(mDeviceWiphyCapabilities.isWifiStandardSupported(ScanResult.WIFI_STANDARD_11BE))
@@ -4138,6 +4173,8 @@
     @Test
     public void testStartSoftApInSingleAp11BEConfiguration()throws Exception {
         assumeTrue(SdkLevel.isAtLeastT());
+        when(mResources.getBoolean(R.bool.config_wifiSoftapIeee80211beSupported))
+                .thenReturn(true);
         when(mDeviceWiphyCapabilities.isWifiStandardSupported(ScanResult.WIFI_STANDARD_11BE))
                 .thenReturn(true);
         mDeviceWiphyCapabilitiesSupports11Be = true;
diff --git a/service/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java b/service/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java
index e9ba8d3..dacf2cc 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java
@@ -16,7 +16,6 @@
 
 package com.android.server.wifi;
 
-import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
 import static com.android.server.wifi.ActiveModeManager.ROLE_CLIENT_PRIMARY;
 import static com.android.server.wifi.ActiveModeManager.ROLE_CLIENT_SECONDARY_LONG_LIVED;
 import static com.android.server.wifi.WifiSettingsConfigStore.WIFI_DEFAULT_COUNTRY_CODE;
@@ -25,14 +24,12 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.anyInt;
 import static org.mockito.Mockito.anyString;
 import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.lenient;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.times;
@@ -45,10 +42,7 @@
 import android.net.wifi.ScanResult;
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
-import android.telephony.ims.ImsMmTelManager;
 
 import androidx.test.filters.SmallTest;
 
@@ -58,7 +52,6 @@
 import com.android.server.wifi.util.WifiPermissionsUtil;
 import com.android.wifi.resources.R;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
@@ -110,15 +103,12 @@
     @Mock WifiInfo mWifiInfo;
     @Mock WifiCountryCode.ChangeListener mExternalChangeListener;
     @Mock SoftApModeConfiguration mSoftApModeConfiguration;
-    @Mock SubscriptionManager mSubscriptionManager;
-    @Mock SubscriptionInfo  mActiveSubscriptionInfo;
-    @Mock ImsMmTelManager mImsMmTelManager;
     @Mock Clock mClock;
     @Mock WifiPermissionsUtil mWifiPermissionsUtil;
     @Mock WifiP2pMetrics mWifiP2pMetrics;
+    @Mock WifiCarrierInfoManager mWifiCarrierInfoManager;
     private WifiCountryCode mWifiCountryCode;
     private List<ClientModeManager> mClientManagerList;
-    private List<SubscriptionInfo> mSubscriptionInfoList = new ArrayList<>();
     private MockitoSession mStaticMockSession = null;
 
     @Captor
@@ -171,19 +161,6 @@
         }).when(mSettingsConfigStore).put(eq(WIFI_DEFAULT_COUNTRY_CODE), any(String.class));
 
         when(mSettingsConfigStore.get(WIFI_DEFAULT_COUNTRY_CODE)).thenReturn(mDefaultCountryCode);
-        when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
-        mSubscriptionInfoList.add(mActiveSubscriptionInfo);
-
-        when(mSubscriptionManager.getCompleteActiveSubscriptionInfoList())
-            .thenReturn(mSubscriptionInfoList);
-        when(mActiveSubscriptionInfo.getSubscriptionId()).thenReturn(TEST_ACTIVE_SUBSCRIPTION_ID);
-        mStaticMockSession = mockitoSession()
-            .mockStatic(ImsMmTelManager.class)
-            .startMocking();
-
-        lenient().when(ImsMmTelManager.createForSubscriptionId(eq(TEST_ACTIVE_SUBSCRIPTION_ID)))
-                .thenReturn(mImsMmTelManager);
-        when(mImsMmTelManager.isAvailable(anyInt(), anyInt())).thenReturn(false);
 
         createWifiCountryCode();
         mScanDetails = setupScanDetails(TEST_COUNTRY_CODE);
@@ -194,11 +171,6 @@
         when(mPackageManager.hasSystemFeature(FEATURE_TELEPHONY_CALLING)).thenReturn(supported);
     }
 
-    @After
-    public void cleanUp() throws Exception {
-        mStaticMockSession.finishMocking();
-    }
-
     private void createWifiCountryCode() {
         mResources.setBoolean(R.bool.config_wifi_revert_country_code_on_cellular_loss,
                 mRevertCountryCodeOnCellularLoss);
@@ -231,7 +203,8 @@
                 mWifiNative,
                 mSettingsConfigStore,
                 mClock,
-                mWifiPermissionsUtil);
+                mWifiPermissionsUtil,
+                mWifiCarrierInfoManager);
         mWifiCountryCode.enableVerboseLogging(true);
         verify(mActiveModeWarden, atLeastOnce()).registerModeChangeCallback(
                     mModeChangeCallbackCaptor.capture());
@@ -361,7 +334,7 @@
         mClientModeImplListenerCaptor.getValue().onConnectionStart(mClientModeManager);
 
         // Wifi Calling is available
-        when(mImsMmTelManager.isAvailable(anyInt(), anyInt())).thenReturn(true);
+        when(mWifiCarrierInfoManager.isWifiCallingAvailable()).thenReturn(true);
         // Telephony country code arrives.
         mWifiCountryCode.setTelephonyCountryCodeAndUpdate(mTelephonyCountryCode);
         // Telephony country code won't be applied at this time.
@@ -371,7 +344,7 @@
         verify(mClientModeManager, times(0)).disconnect();
 
         // Wifi Calling is not available
-        when(mImsMmTelManager.isAvailable(anyInt(), anyInt())).thenReturn(false);
+        when(mWifiCarrierInfoManager.isWifiCallingAvailable()).thenReturn(false);
         // Wifi traffic is high
         when(mWifiInfo.getSuccessfulTxPacketsPerSecond()).thenReturn(20.0);
         // Telephony country code arrives.
@@ -466,21 +439,6 @@
     }
 
     /**
-     * Test that we don't crash when we try to set the country code if the TelephonyService
-     * cannot be found. This is really only the case when instrumentation tests that run on the
-     * phone process are cleaned up.
-     */
-    @Test
-    public void setCountryCodeDoesNotCrashWhenTelephonyServiceNotFound() throws Exception {
-        when(mImsMmTelManager.isAvailable(anyInt(), anyInt())).thenThrow(new RuntimeException());
-        try {
-            mWifiCountryCode.setTelephonyCountryCodeAndUpdate(mTelephonyCountryCode);
-        } catch (RuntimeException e) {
-            fail("Didn't catch RuntimeException from Telephony Service not being found!");
-        }
-    }
-
-    /**
      * Test if we can keep using the last known country code when phone is out of service, when
      * |config_wifi_revert_country_code_on_cellular_loss| is set to false;
      * Telephony service calls |setCountryCode| with an empty string when phone is out of service.
diff --git a/service/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java b/service/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
index 4927700..cff2525 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
@@ -1601,8 +1601,10 @@
     @Test
     public void testGetSupportedBandsFromHal() throws Exception {
         List<WifiAvailableChannel> usableChannelList = new ArrayList<>();
-        usableChannelList.add(new WifiAvailableChannel(2412, WifiAvailableChannel.OP_MODE_STA));
-        usableChannelList.add(new WifiAvailableChannel(5160, WifiAvailableChannel.OP_MODE_STA));
+        usableChannelList.add(new WifiAvailableChannel(2412, WifiAvailableChannel.OP_MODE_STA,
+                ScanResult.CHANNEL_WIDTH_20MHZ));
+        usableChannelList.add(new WifiAvailableChannel(5160, WifiAvailableChannel.OP_MODE_STA,
+                ScanResult.CHANNEL_WIDTH_40MHZ));
         when(mWifiVendorHal.getUsableChannels(WifiScanner.WIFI_BAND_24_5_WITH_DFS_6_60_GHZ,
                 WifiAvailableChannel.OP_MODE_STA,
                 WifiAvailableChannel.FILTER_REGULATORY)).thenReturn(usableChannelList);
diff --git a/service/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/service/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index 8c22ac2..18851ea 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -9981,10 +9981,14 @@
         mLooper.startAutoDispatch();
         assertThat(mWifiServiceImpl.getUsableChannels(WIFI_BAND_24_5_WITH_DFS_6_60_GHZ, OP_MODE_SAP,
                 FILTER_REGULATORY, TEST_PACKAGE_NAME, mExtras)).containsExactly(
-                new WifiAvailableChannel(2452, WifiAvailableChannel.OP_MODE_SAP),
-                new WifiAvailableChannel(5180, WifiAvailableChannel.OP_MODE_SAP),
-                new WifiAvailableChannel(5955, WifiAvailableChannel.OP_MODE_SAP),
-                new WifiAvailableChannel(58320, WifiAvailableChannel.OP_MODE_SAP));
+                        new WifiAvailableChannel(2452, WifiAvailableChannel.OP_MODE_SAP,
+                        ScanResult.CHANNEL_WIDTH_20MHZ),
+                        new WifiAvailableChannel(5180, WifiAvailableChannel.OP_MODE_SAP,
+                        ScanResult.CHANNEL_WIDTH_20MHZ),
+                        new WifiAvailableChannel(5955, WifiAvailableChannel.OP_MODE_SAP,
+                        ScanResult.CHANNEL_WIDTH_20MHZ),
+                        new WifiAvailableChannel(58320, WifiAvailableChannel.OP_MODE_SAP,
+                        ScanResult.CHANNEL_WIDTH_20MHZ));
         mLooper.stopAutoDispatchAndIgnoreExceptions();
     }
 
@@ -10006,13 +10010,16 @@
         when(mWifiNative.isHalStarted()).thenReturn(true);
         when(mWifiNative.getUsableChannels(eq(WIFI_BAND_24_GHZ), anyInt(), anyInt()))
                 .thenReturn(Arrays.asList(
-                        new WifiAvailableChannel(2452, WifiAvailableChannel.OP_MODE_SAP)));
+                        new WifiAvailableChannel(2452, WifiAvailableChannel.OP_MODE_SAP,
+                                ScanResult.CHANNEL_WIDTH_20MHZ)));
         when(mWifiNative.getUsableChannels(eq(WIFI_BAND_5_GHZ), anyInt(), anyInt()))
                 .thenReturn(Arrays.asList(
-                        new WifiAvailableChannel(5180, WifiAvailableChannel.OP_MODE_SAP)));
+                        new WifiAvailableChannel(5180, WifiAvailableChannel.OP_MODE_SAP,
+                                ScanResult.CHANNEL_WIDTH_20MHZ)));
         when(mWifiNative.getUsableChannels(eq(WIFI_BAND_6_GHZ), anyInt(), anyInt()))
                 .thenReturn(Arrays.asList(
-                        new WifiAvailableChannel(5955, WifiAvailableChannel.OP_MODE_SAP)));
+                        new WifiAvailableChannel(5955, WifiAvailableChannel.OP_MODE_SAP,
+                                ScanResult.CHANNEL_WIDTH_20MHZ)));
         when(mWifiNative.getUsableChannels(eq(WIFI_BAND_60_GHZ), anyInt(), anyInt()))
                 .thenReturn(null);
 
@@ -11427,7 +11434,7 @@
         when(mWifiNative.isHalStarted()).thenReturn(true);
         // Channel 9 - 2452Mhz
         WifiAvailableChannel channels2g = new WifiAvailableChannel(2452,
-                WifiAvailableChannel.OP_MODE_SAP);
+                WifiAvailableChannel.OP_MODE_SAP, ScanResult.CHANNEL_WIDTH_20MHZ);
         when(mWifiNative.isHalSupported()).thenReturn(true);
         when(mWifiNative.isHalStarted()).thenReturn(true);
         when(mWifiNative.getUsableChannels(eq(WifiScanner.WIFI_BAND_24_GHZ), anyInt(), anyInt()))
diff --git a/service/tests/wifitests/src/com/android/server/wifi/WifiVoipDetectorTest.java b/service/tests/wifitests/src/com/android/server/wifi/WifiVoipDetectorTest.java
index 5deb166..9741a2c 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/WifiVoipDetectorTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/WifiVoipDetectorTest.java
@@ -65,6 +65,7 @@
     @Mock private AudioManager mAudioManager;
     @Mock private TelephonyManager mTelephonyManager;
     @Mock private WifiNative mWifiNative;
+    @Mock private WifiCarrierInfoManager mWifiCarrierInfoManager;
 
     private WifiVoipDetector mWifiVoipDetector;
     private TestLooper mLooper;
@@ -85,7 +86,7 @@
         when(mWifiInjector.getWifiNative()).thenReturn(mWifiNative);
         when(mWifiNative.setVoipMode(anyInt())).thenReturn(true);
         mWifiVoipDetector = new WifiVoipDetector(mContext,
-                new Handler(mLooper.getLooper()), mWifiInjector);
+                new Handler(mLooper.getLooper()), mWifiInjector, mWifiCarrierInfoManager);
     }
 
     private void resetWifiNativeAndReSetupforMock() {
@@ -103,6 +104,17 @@
                 mAudioModeChangedListeneCaptor.capture());
         // Init should do nothing
         verify(mWifiNative, never()).setVoipMode(anyInt());
+        // deinit should do nothing
+        mWifiVoipDetector.notifyWifiConnected(false, true, TEST_PRIMARY_INTERFACE_NAME);
+        verify(mWifiNative, never()).setVoipMode(anyInt());
+        // Init again when VoIP call is on
+        when(mWifiCarrierInfoManager.isWifiCallingAvailable()).thenReturn(true);
+        mWifiVoipDetector.notifyWifiConnected(true, true, TEST_PRIMARY_INTERFACE_NAME);
+        verify(mWifiNative).setVoipMode(WifiChip.WIFI_VOIP_MODE_VOICE);
+        // Test VoWifi call off -> switch to VoLte
+        mTelephonyCallbackCaptor.getValue().onCallAttributesChanged(TEST_LTE_CALL_ATT);
+        verify(mWifiNative).setVoipMode(WifiChip.WIFI_VOIP_MODE_OFF);
+        resetWifiNativeAndReSetupforMock();
         // Test VoWifi Call
         mTelephonyCallbackCaptor.getValue().onCallAttributesChanged(TEST_VOWIFI_CALL_ATT);
         verify(mWifiNative).setVoipMode(WifiChip.WIFI_VOIP_MODE_VOICE);
diff --git a/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java
index f853050..51537dc 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java
@@ -68,6 +68,7 @@
 import android.net.ConnectivityManager;
 import android.net.wifi.IBooleanListener;
 import android.net.wifi.OuiKeyedData;
+import android.net.wifi.ScanResult;
 import android.net.wifi.WifiAvailableChannel;
 import android.net.wifi.WifiManager;
 import android.net.wifi.WifiScanner;
@@ -1133,8 +1134,10 @@
         when(mWifiNative.getUsableChannels(WifiScanner.WIFI_BAND_5_GHZ, OP_MODE_WIFI_AWARE,
                 WifiAvailableChannel.FILTER_NAN_INSTANT_MODE))
                 .thenReturn(List.of(new WifiAvailableChannel(5220,
-                                WifiAvailableChannel.OP_MODE_WIFI_AWARE),
-                        new WifiAvailableChannel(5745, WifiAvailableChannel.OP_MODE_WIFI_AWARE)));
+                                WifiAvailableChannel.OP_MODE_WIFI_AWARE,
+                                ScanResult.CHANNEL_WIDTH_80MHZ),
+                        new WifiAvailableChannel(5745, WifiAvailableChannel.OP_MODE_WIFI_AWARE,
+                                ScanResult.CHANNEL_WIDTH_80MHZ)));
         mActiveCountryCodeChangedCallback.onActiveCountryCodeChanged("US");
         mMockLooper.dispatchAll();
         inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
@@ -1220,7 +1223,7 @@
         when(mWifiNative.getUsableChannels(WifiScanner.WIFI_BAND_5_GHZ, OP_MODE_WIFI_AWARE,
                 WifiAvailableChannel.FILTER_NAN_INSTANT_MODE))
                 .thenReturn(List.of(new WifiAvailableChannel(5220,
-                        WifiAvailableChannel.OP_MODE_WIFI_AWARE)));
+                        WifiAvailableChannel.OP_MODE_WIFI_AWARE, ScanResult.CHANNEL_WIDTH_80MHZ)));
         mActiveCountryCodeChangedCallback.onActiveCountryCodeChanged("US");
         mMockLooper.dispatchAll();
         inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
diff --git a/service/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java b/service/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java
index 6a85ee8..5774278 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java
@@ -1455,21 +1455,23 @@
                 .thenReturn(false);
         /* 11be is disallowed when IEEE80211_BE feature is not supported */
         assertFalse(ApConfigUtil.is11beAllowedForThisConfiguration(mDeviceWiphyCapabilities,
-                mResources, config, true));
+                mContext, config, true));
 
+        when(mResources.getBoolean(R.bool.config_wifiSoftapIeee80211beSupported))
+                .thenReturn(true);
         when(mResources.getBoolean(R.bool.config_wifiSoftApSingleLinkMloInBridgedModeSupported))
                 .thenReturn(true);
         when(mDeviceWiphyCapabilities.isWifiStandardSupported(ScanResult.WIFI_STANDARD_11BE))
                 .thenReturn(true);
         /* 11be is allowed if chip supports single link MLO in bridged mode */
         assertTrue(ApConfigUtil.is11beAllowedForThisConfiguration(mDeviceWiphyCapabilities,
-                mResources, config, true));
+                mContext, config, true));
 
         /* 11be is not allowed if chip doesn't support single link MLO in bridged mode */
         when(mResources.getBoolean(R.bool.config_wifiSoftApSingleLinkMloInBridgedModeSupported))
                 .thenReturn(false);
         assertFalse(ApConfigUtil.is11beAllowedForThisConfiguration(mDeviceWiphyCapabilities,
-                mResources, config, true));
+                mContext, config, true));
     }
     @Test
     public void testIs11beDisabledForSecurityType() throws Exception {