mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2024-12-18 20:40:11 +00:00
commit
e50ae6da96
@ -377,6 +377,9 @@ public:
|
||||
* @return ErrCode - operation result
|
||||
*/
|
||||
virtual ErrCode StartPortalCertification() = 0;
|
||||
|
||||
virtual ErrCode GetChangeDeviceConfig(ConfigChange& value, WifiDeviceConfig &config) = 0;
|
||||
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.wifi.IWifiDeviceService");
|
||||
|
@ -69,6 +69,7 @@ enum class DevInterfaceCode {
|
||||
WIFI_CBK_CMD_STREAM_DIRECTION = 0x3003, /* traffic up/down state event */
|
||||
WIFI_CBK_CMD_WPS_STATE_CHANGE = 0x3004, /* wps state change event */
|
||||
WIFI_CBK_CMD_DEVICE_CONFIG_CHANGE = 0x3005, /* device config change event */
|
||||
WIFI_SVR_CMD_GET_DEVICE_CONFIG_CHANGE = 0x3006, /* device config change event */
|
||||
};
|
||||
|
||||
/* SAID: 1121 */
|
||||
|
@ -448,5 +448,12 @@ bool WifiDeviceImpl::IsRemoteDied(void)
|
||||
{
|
||||
return (client_ == nullptr) ? true : client_->IsRemoteDied();
|
||||
}
|
||||
|
||||
ErrCode WifiDeviceImpl::GetChangeDeviceConfig(ConfigChange& value, WifiDeviceConfig &config)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
RETURN_IF_FAIL(GetWifiDeviceProxy());
|
||||
return client_->GetChangeDeviceConfig(value, config);
|
||||
}
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
@ -402,6 +402,13 @@ public:
|
||||
*/
|
||||
bool IsRemoteDied(void);
|
||||
|
||||
/**
|
||||
* @Description get last Change devicecConfig
|
||||
*
|
||||
* @return ErrCode - operation result
|
||||
*/
|
||||
ErrCode GetChangeDeviceConfig(ConfigChange &value, WifiDeviceConfig &config) override;
|
||||
|
||||
private:
|
||||
bool GetWifiDeviceProxy();
|
||||
int systemAbilityId_;
|
||||
|
@ -1607,5 +1607,42 @@ ErrCode WifiDeviceProxy::StartPortalCertification()
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
ErrCode WifiDeviceProxy::GetChangeDeviceConfig(ConfigChange &value, WifiDeviceConfig &config)
|
||||
{
|
||||
if (mRemoteDied) {
|
||||
WIFI_LOGE("failed to `%{public}s`,remote service is died!", __func__);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
MessageOption option;
|
||||
MessageParcel data, reply;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WIFI_LOGE("Write interface token error: %{public}s", __func__);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
data.WriteInt32(0);
|
||||
int error = Remote()->SendRequest(static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_DEVICE_CONFIG_CHANGE),
|
||||
data, reply, option);
|
||||
if (error != ERR_NONE) {
|
||||
WIFI_LOGE("GetChangeDeviceConfig (%{public}d) failed,error code is %{public}d",
|
||||
static_cast<int32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_DEVICE_CONFIG_CHANGE), error);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
|
||||
int exception = reply.ReadInt32();
|
||||
if (exception) {
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
value = (ConfigChange)reply.ReadInt32();
|
||||
config.networkId = reply.ReadInt32();
|
||||
config.ssid = reply.ReadString();
|
||||
config.bssid = reply.ReadString();
|
||||
config.callProcessName = reply.ReadString();
|
||||
config.ancoCallProcessName = reply.ReadString();
|
||||
int ret = reply.ReadInt32();
|
||||
if (ret != WIFI_OPT_SUCCESS) {
|
||||
return ErrCode(ret);
|
||||
}
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
@ -382,6 +382,8 @@ public:
|
||||
* @return ErrCode - operation result
|
||||
*/
|
||||
ErrCode StartPortalCertification() override;
|
||||
|
||||
ErrCode GetChangeDeviceConfig(ConfigChange& value, WifiDeviceConfig &config) override;
|
||||
#ifdef OHOS_ARCH_LITE
|
||||
/**
|
||||
* @Description Handle remote object died event.
|
||||
|
@ -375,6 +375,8 @@ public:
|
||||
* @return ErrCode - operation result
|
||||
*/
|
||||
virtual ErrCode ResetAllFrozenApp() = 0;
|
||||
|
||||
virtual ErrCode GetChangeDeviceConfig(ConfigChange& value, WifiDeviceConfig &config) = 0;
|
||||
};
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
@ -536,5 +536,19 @@ int WifiConfigCenter::GetDeviceProvisionState() const
|
||||
return WifiSettings::GetInstance().GetDeviceProvisionState();
|
||||
}
|
||||
|
||||
int WifiConfigCenter::SetChangeDeviceConfig(ConfigChange value, const WifiDeviceConfig &config)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mScanMutex);
|
||||
mLastRemoveDeviceConfig = std::make_pair((int)value, config);
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
bool WifiConfigCenter::GetChangeDeviceConfig(ConfigChange& value, WifiDeviceConfig &config)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mScanMutex);
|
||||
value = (ConfigChange)mLastRemoveDeviceConfig.first;
|
||||
config = mLastRemoveDeviceConfig.second;
|
||||
return true;
|
||||
}
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
@ -644,6 +644,9 @@ public:
|
||||
*/
|
||||
int GetDeviceProvisionState() const;
|
||||
|
||||
int SetChangeDeviceConfig(ConfigChange value, const WifiDeviceConfig &config);
|
||||
|
||||
bool GetChangeDeviceConfig(ConfigChange& value, WifiDeviceConfig &config);
|
||||
private:
|
||||
std::mutex mStaMutex;
|
||||
std::mutex mScanMutex;
|
||||
@ -657,6 +660,7 @@ private:
|
||||
std::map<int, std::chrono::steady_clock::time_point> mWifiCloseTime;
|
||||
std::atomic<bool> mWifiOpenedWhenAirplane;
|
||||
std::map<int, std::atomic<bool>> mIsAncoConnected;
|
||||
std::pair<int, WifiDeviceConfig> mLastRemoveDeviceConfig;
|
||||
};
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
@ -1460,6 +1460,16 @@ void WifiDeviceServiceImpl::SaBasicDump(std::string& result)
|
||||
result += "\n";
|
||||
}
|
||||
|
||||
ErrCode WifiDeviceServiceImpl::GetChangeDeviceConfig(ConfigChange& value, WifiDeviceConfig &config)
|
||||
{
|
||||
bool result = WifiConfigCenter::GetInstance().GetChangeDeviceConfig(value, config);
|
||||
if (!result) {
|
||||
WIFI_LOGE("WifiDeviceServiceImpl::GetChangeDeviceConfig failed!");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
bool WifiDeviceServiceImpl::IsRemoteDied(void)
|
||||
{
|
||||
return false;
|
||||
|
@ -156,6 +156,7 @@ public:
|
||||
|
||||
ErrCode StartPortalCertification() override;
|
||||
|
||||
ErrCode GetChangeDeviceConfig(ConfigChange& value, WifiDeviceConfig &config) override;
|
||||
private:
|
||||
bool Init();
|
||||
ErrCode CheckCanEnableWifi(void);
|
||||
|
@ -70,6 +70,8 @@ void WifiDeviceStub::InitHandleMapEx()
|
||||
&WifiDeviceStub::OnResetAllFrozenApp;
|
||||
handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_START_PORTAL_CERTIF)] =
|
||||
&WifiDeviceStub::OnStartPortalCertification;
|
||||
handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_DEVICE_CONFIG_CHANGE)] =
|
||||
&WifiDeviceStub::OnGetChangeDeviceConfig;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -504,6 +506,23 @@ void WifiDeviceStub::OnDisableDeviceConfig(uint32_t code, MessageParcel &data, M
|
||||
return;
|
||||
}
|
||||
|
||||
void WifiDeviceStub::OnGetChangeDeviceConfig(uint32_t code, MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
|
||||
Wifi::ConfigChange value;
|
||||
Wifi::WifiDeviceConfig config;
|
||||
ErrCode ret = GetChangeDeviceConfig(value, config);
|
||||
reply.WriteInt32(0);
|
||||
reply.WriteInt32((int)value);
|
||||
reply.WriteInt32(config.networkId);
|
||||
reply.WriteString(config.ssid);
|
||||
reply.WriteString(config.bssid);
|
||||
reply.WriteString(config.callProcessName);
|
||||
reply.WriteString(config.ancoCallProcessName);
|
||||
reply.WriteInt32(ret);
|
||||
return;
|
||||
}
|
||||
|
||||
void WifiDeviceStub::OnConnectTo(uint32_t code, MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
|
||||
|
@ -50,6 +50,7 @@ private:
|
||||
void OnRemoveDevice(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
void OnRemoveAllDevice(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
void OnGetDeviceConfigs(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
void OnGetChangeDeviceConfig(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
void OnEnableDeviceConfig(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
void OnDisableDeviceConfig(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
void OnConnectTo(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
|
@ -35,6 +35,7 @@ namespace OHOS {
|
||||
namespace Wifi {
|
||||
|
||||
constexpr const char *ANCO_SERVICE_BROKER = "anco_service_broker";
|
||||
constexpr const int REMOVE_ALL_DEVICECONFIG = 0x7FFFFFFF;
|
||||
|
||||
StaService::StaService(int instId)
|
||||
: pStaStateMachine(nullptr), pStaMonitor(nullptr), pStaAutoConnectService(nullptr), m_instId(instId)
|
||||
@ -180,8 +181,17 @@ ErrCode StaService::AddCandidateConfig(const int uid, const WifiDeviceConfig &co
|
||||
}
|
||||
|
||||
if (config.keyMgmt == KEY_MGMT_NONE || config.keyMgmt == KEY_MGMT_WEP) {
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
const std::string wifiBrokerFrameProcessName = ANCO_SERVICE_BROKER;
|
||||
std::string ancoBrokerFrameProcessName = GetRunningProcessNameByPid(GetCallingUid(), GetCallingPid());
|
||||
if (ancoBrokerFrameProcessName != wifiBrokerFrameProcessName) {
|
||||
LOGE("AddCandidateConfig unsupport open or wep key!");
|
||||
return WIFI_OPT_NOT_SUPPORTED;
|
||||
}
|
||||
#else
|
||||
LOGE("AddCandidateConfig unsupport open or wep key!");
|
||||
return WIFI_OPT_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
WifiDeviceConfig tempDeviceConfig = config;
|
||||
tempDeviceConfig.uid = uid;
|
||||
@ -330,6 +340,16 @@ ErrCode StaService::RemoveDevice(int networkId) const
|
||||
WifiSettings::GetInstance().RemoveDevice(networkId);
|
||||
WifiSettings::GetInstance().SyncDeviceConfig();
|
||||
NotifyDeviceConfigChange(ConfigChange::CONFIG_REMOVE);
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
const std::string wifiBrokerFrameProcessName = ANCO_SERVICE_BROKER;
|
||||
std::string ancoBrokerFrameProcessName = GetRunningProcessNameByPid(GetCallingUid(), GetCallingPid());
|
||||
if (ancoBrokerFrameProcessName == wifiBrokerFrameProcessName) {
|
||||
config.callProcessName = wifiBrokerFrameProcessName;
|
||||
} else {
|
||||
config.callProcessName = "";
|
||||
}
|
||||
WifiConfigCenter::GetInstance().SetChangeDeviceConfig(ConfigChange::CONFIG_REMOVE, config);
|
||||
#endif
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
@ -352,6 +372,18 @@ ErrCode StaService::RemoveAllDevice() const
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
NotifyDeviceConfigChange(ConfigChange::CONFIG_REMOVE);
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
WifiDeviceConfig config;
|
||||
config.networkId = REMOVE_ALL_DEVICECONFIG;
|
||||
const std::string wifiBrokerFrameProcessName = ANCO_SERVICE_BROKER;
|
||||
std::string ancoBrokerFrameProcessName = GetRunningProcessNameByPid(GetCallingUid(), GetCallingPid());
|
||||
if (ancoBrokerFrameProcessName == wifiBrokerFrameProcessName) {
|
||||
config.callProcessName = wifiBrokerFrameProcessName;
|
||||
} else {
|
||||
config.callProcessName = "";
|
||||
}
|
||||
WifiConfigCenter::GetInstance().SetChangeDeviceConfig(ConfigChange::CONFIG_REMOVE, config);
|
||||
#endif
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user