智能客服
你问我答,随时在线为你解决问题
如果厂商车机ROM是Android 10.0版本,在进行无线连接之前,应进行蓝牙和Wi-Fi适配修改。其中蓝牙适配修改可参考蓝牙,Wi-Fi适配可参考以下操作进行。
以下修改方案参考及代码供厂商参考,具体修改内容还需厂商根据自身系统情况独立完成适配。
修改framework下的文件:
“/service/java/com/android/server/wifi/SoftApManager.java”
“/service/java/com/android/server/wifi/WifiNative.java”
“/service/java/com/android/server/wifi/WificondControl.java”
- diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
- index b92dab7..f88c98c 100644
- --- a/service/java/com/android/server/wifi/SoftApManager.java
- +++ b/service/java/com/android/server/wifi/SoftApManager.java
- @@ -64,6 +64,9 @@ public class SoftApManager implements ActiveModeManager {
- public static final String SOFT_AP_SEND_MESSAGE_TIMEOUT_TAG = TAG
- + " Soft AP Send Message Timeout";
-
- + private static final String ACTION_WIFI_AP_STA_JOIN = "android.net.wifi.WIFI_AP_STA_JOIN";
- + private static final String ACTION_WIFI_AP_STA_LEAVE = "android.net.wifi.WIFI_AP_STA_LEAVE";
- +
- private final Context mContext;
- private final FrameworkFacade mFrameworkFacade;
- private final WifiNative mWifiNative;
- @@ -112,6 +115,18 @@ public class SoftApManager implements ActiveModeManager {
- }
-
- @Override
- + public void onStationAssociated(String macAddress) {
- + Log.i(TAG, "onStationAssociated macAddress: " + macAddress);
- + mStateMachine.sendMessage(SoftApStateMachine.CMD_NOTIFY_STATION_ASSOCIATED, macAddress);
- + }
- +
- + @Override
- + public void onStationDisassociated(String macAddress) {
- + Log.i(TAG, "onStationDisassociated macAddress: " + macAddress);
- + mStateMachine.sendMessage(SoftApStateMachine.CMD_NOTIFY_STATION_DISASSOCIATED, macAddress);
- + }
- +
- + @Override
- public void onSoftApChannelSwitched(int frequency, int bandwidth) {
- mStateMachine.sendMessage(
- SoftApStateMachine.CMD_SOFT_AP_CHANNEL_SWITCHED, frequency, bandwidth);
- @@ -237,6 +252,15 @@ public class SoftApManager implements ActiveModeManager {
- mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
- }
-
- + private void notifyStationChanged(String action, String macAddress) {
- + if (action != null && mContext != null) {
- + Intent apStaChangedIt = new Intent(action);
- + apStaChangedIt.putExtra("macInfo", macAddress);
- + Log.i(TAG, "notifyStationChanged macAddress=" + macAddress);
- + mContext.sendBroadcastAsUser(apStaChangedIt, UserHandle.ALL, android.Manifest.permission.ACCESS_WIFI_STATE);
- + }
- + }
- +
- /**
- * Start a soft AP instance with the given configuration.
- * @param config AP configuration
- @@ -312,6 +336,8 @@ public class SoftApManager implements ActiveModeManager {
- public static final int CMD_INTERFACE_DESTROYED = 7;
- public static final int CMD_INTERFACE_DOWN = 8;
- public static final int CMD_SOFT_AP_CHANNEL_SWITCHED = 9;
- + public static final int CMD_NOTIFY_STATION_ASSOCIATED = 10;
- + public static final int CMD_NOTIFY_STATION_DISASSOCIATED = 11;
-
- private final State mIdleState = new IdleState();
- private final State mStartedState = new StartedState();
- @@ -645,6 +671,12 @@ public class SoftApManager implements ActiveModeManager {
- WifiManager.WIFI_AP_STATE_FAILED, 0);
- transitionTo(mIdleState);
- break;
- + case CMD_NOTIFY_STATION_ASSOCIATED:
- + notifyStationChanged(ACTION_WIFI_AP_STA_JOIN, (String) message.obj);
- + break;
- + case CMD_NOTIFY_STATION_DISASSOCIATED:
- + notifyStationChanged(ACTION_WIFI_AP_STA_LEAVE, (String) message.obj);
- + break;
- default:
- return NOT_HANDLED;
- }
- diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
- index 3e5dc3c..44f9c42 100644
- --- a/service/java/com/android/server/wifi/WifiNative.java
- +++ b/service/java/com/android/server/wifi/WifiNative.java
- @@ -1527,6 +1527,16 @@ public class WifiNative {
- void onNumAssociatedStationsChanged(int numStations);
-
- /**
- + * Notify station associated
- + */
- + void onStationAssociated(String macAddress);
- +
- + /**
- + * Notify station disassociated
- + */
- + void onStationDisassociated(String macAddress);
- +
- + /**
- * Invoked when the channel switch event happens.
- */
- void onSoftApChannelSwitched(int frequency, int bandwidth);
- diff --git a/service/java/com/android/server/wifi/WificondControl.java b/service/java/com/android/server/wifi/WificondControl.java
- index bd756f6..4cd8975 100644
- --- a/service/java/com/android/server/wifi/WificondControl.java
- +++ b/service/java/com/android/server/wifi/WificondControl.java
- @@ -188,6 +188,16 @@ public class WificondControl implements IBinder.DeathRecipient {
- }
-
- @Override
- + public void onStationAssociated(String macAddress) {
- + mSoftApListener.onStationAssociated(macAddress);
- + }
- +
- + @Override
- + public void onStationDisassociated(String macAddress) {
- + mSoftApListener.onStationDisassociated(macAddress);
- + }
- +
- + @Override
- public void onSoftApChannelSwitched(int frequency, int bandwidth) {
- mSoftApListener.onSoftApChannelSwitched(frequency, bandwidth);
- }
- --
- 2.7.4
-
修改如下文件:
“system/connectivity/wificond/aidl/android/net/wifi/IApInterfaceEventCallback.aidl”
“system/connectivity/wificond/ap_interface_binder.cpp”
“system/connectivity/wificond/ap_interface_binder.h”
“system/connectivity/wificond/ap_interface_impl.cpp”
- diff --git a/aidl/android/net/wifi/IApInterfaceEventCallback.aidl b/aidl/android/net/wifi/IApInterfaceEventCallback.aidl
- index d23da91..f2b4b60 100644
- --- a/aidl/android/net/wifi/IApInterfaceEventCallback.aidl
- +++ b/aidl/android/net/wifi/IApInterfaceEventCallback.aidl
- @@ -33,6 +33,16 @@ interface IApInterfaceEventCallback {
- // @param numStations Number of associated stations after change
- oneway void onNumAssociatedStationsChanged(int numStations);
-
- + // Notify station associated
- + //
- + // @param macAddress mac address of this station
- + oneway void onStationAssociated(String macAddress);
- +
- + // Notify station disassociated
- + //
- + // @param macAddress mac address of this station
- + oneway void onStationDisassociated(String macAddress);
- +
- // Signals a channel switch event for this soft Ap.
- //
- // @param frequency Represents the frequency of the channel in MHz
- diff --git a/ap_interface_binder.cpp b/ap_interface_binder.cpp
- index 56e779f..b59f67e 100644
- --- a/ap_interface_binder.cpp
- +++ b/ap_interface_binder.cpp
- @@ -37,6 +37,18 @@ void ApInterfaceBinder::NotifyNumAssociatedStationsChanged(int num_stations) {
- }
- }
-
- + void ApInterfaceBinder::NotifyStationAssociated(const String16& mac_address) {
- + if (ap_interface_event_callback_ != nullptr) {
- + ap_interface_event_callback_->onStationAssociated(mac_address);
- + }
- +}
- +
- + void ApInterfaceBinder::NotifyStationDisassociated(const String16& mac_address) {
- + if (ap_interface_event_callback_ != nullptr) {
- + ap_interface_event_callback_->onStationDisassociated(mac_address);
- + }
- +}
- +
- void ApInterfaceBinder::NotifySoftApChannelSwitched(
- int frequency, ChannelBandwidth channel_bandwidth) {
- if (ap_interface_event_callback_ == nullptr) {
- diff --git a/ap_interface_binder.h b/ap_interface_binder.h
- index 7e332f5..0b5fae1 100644
- --- a/ap_interface_binder.h
- +++ b/ap_interface_binder.h
- @@ -41,6 +41,8 @@ class ApInterfaceBinder : public android::net::wifi::BnApInterface {
-
- // Called by |impl_| everytime number of associated stations changes.
- void NotifyNumAssociatedStationsChanged(int num_stations);
- + void NotifyStationAssociated(const String16& mac_address);
- + void NotifyStationDisassociated(const String16& mac_address);
-
- // Called by |impl_| on every channel switch event.
- void NotifySoftApChannelSwitched(int frequency,
- diff --git a/ap_interface_impl.cpp b/ap_interface_impl.cpp
- index f39e9c1..80a8d42 100644
- --- a/ap_interface_impl.cpp
- +++ b/ap_interface_impl.cpp
- @@ -88,6 +88,8 @@ void ApInterfaceImpl::OnStationEvent(
- << LoggingUtils::GetMacString(mac_address)
- << " associated with hotspot";
- number_of_associated_stations_++;
- + binder_->NotifyStationAssociated(String16(LoggingUtils::GetMacString(mac_address).c_str()));
- + binder_->NotifyNumAssociatedStationsChanged(number_of_associated_stations_);
- } else if (event == DEL_STATION) {
- LOG(INFO) << "Station "
- << LoggingUtils::GetMacString(mac_address)
- @@ -99,9 +101,8 @@ void ApInterfaceImpl::OnStationEvent(
- } else {
- number_of_associated_stations_--;
- }
- - }
-
- - if (event == NEW_STATION || event == DEL_STATION) {
- + binder_->NotifyStationDisassociated(String16(LoggingUtils::GetMacString(mac_address).c_str()));
- binder_->NotifyNumAssociatedStationsChanged(number_of_associated_stations_);
- }
- }
-
修改如下文件:
“core/res/AndroidManifest.xml”
- diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
- index 825d198..1c9c9d9 100644
- --- a/core/res/AndroidManifest.xml
- +++ b/core/res/AndroidManifest.xml
- @@ -635,6 +635,10 @@
- <!-- For tether entitlement recheck-->
- <protected-broadcast
- android:name="com.android.server.connectivity.tethering.PROVISIONING_RECHECK_ALARM" />
- +
- + <!-- For HiCar SDK OS -->
- + <protected-broadcast android:name="android.net.wifi.WIFI_AP_STA_JOIN" />
- + <protected-broadcast android:name="android.net.wifi.WIFI_AP_STA_LEAVE" />
- <!-- ====================================================================== -->
- <!-- RUNTIME PERMISSIONS -->
- <!-- ====================================================================== -->