diff --git a/frameworks/js/napi/include/devicestatus_callback_stub.h b/frameworks/js/napi/include/devicestatus_callback_stub.h index e8f389931..d7c49f6d8 100644 --- a/frameworks/js/napi/include/devicestatus_callback_stub.h +++ b/frameworks/js/napi/include/devicestatus_callback_stub.h @@ -26,16 +26,16 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DevicestatusCallbackStub : public IRemoteStub { +class DeviceStatusCallbackStub : public IRemoteStub { public: - DISALLOW_COPY_AND_MOVE(DevicestatusCallbackStub); - DevicestatusCallbackStub() = default; - virtual ~DevicestatusCallbackStub() = default; + DISALLOW_COPY_AND_MOVE(DeviceStatusCallbackStub); + DeviceStatusCallbackStub() = default; + virtual ~DeviceStatusCallbackStub() = default; int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - void OnDevicestatusChanged(const DevicestatusDataUtils::DevicestatusData& __attribute__((unused))value) override {} + void OnDeviceStatusChanged(const DeviceStatusDataUtils::DeviceStatusData& __attribute__((unused))value) override {} private: - int32_t OnDevicestatusChangedStub(MessageParcel& data); + int32_t OnDeviceStatusChangedStub(MessageParcel& data); }; } // namespace DeviceStatus } // namespace Msdp diff --git a/frameworks/js/napi/include/devicestatus_napi.h b/frameworks/js/napi/include/devicestatus_napi.h index e7672340b..a58c50253 100644 --- a/frameworks/js/napi/include/devicestatus_napi.h +++ b/frameworks/js/napi/include/devicestatus_napi.h @@ -29,16 +29,16 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DeviceStatusCallback : public DevicestatusCallbackStub { +class DeviceStatusCallback : public DeviceStatusCallbackStub { public: explicit DeviceStatusCallback(napi_env env) : env_(env) {} virtual ~DeviceStatusCallback() {}; - void OnDevicestatusChanged(const DevicestatusDataUtils::DevicestatusData &devicestatusData) override; + void OnDeviceStatusChanged(const DeviceStatusDataUtils::DeviceStatusData &devicestatusData) override; static void EmitOnEvent(uv_work_t *work, int status); private: napi_env env_ = { nullptr }; std::mutex mutex_; - DevicestatusDataUtils::DevicestatusData data_; + DeviceStatusDataUtils::DeviceStatusData data_; }; class DeviceStatusNapi : public DeviceStatusEvent { diff --git a/frameworks/js/napi/src/devicestatus_callback_stub.cpp b/frameworks/js/napi/src/devicestatus_callback_stub.cpp index b9d8076ed..770897372 100644 --- a/frameworks/js/napi/src/devicestatus_callback_stub.cpp +++ b/frameworks/js/napi/src/devicestatus_callback_stub.cpp @@ -22,20 +22,20 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -int32_t DevicestatusCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, \ +int32_t DeviceStatusCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, \ MessageOption &option) { DEV_HILOGD(SERVICE, "cmd = %{public}u, flags= %{public}d", code, option.GetFlags()); - std::u16string descriptor = DevicestatusCallbackStub::GetDescriptor(); + std::u16string descriptor = DeviceStatusCallbackStub::GetDescriptor(); std::u16string remoteDescriptor = data.ReadInterfaceToken(); if (descriptor != remoteDescriptor) { - DEV_HILOGE(SERVICE, "DevicestatusCallbackStub::OnRemoteRequest failed, descriptor mismatch"); + DEV_HILOGE(SERVICE, "DeviceStatusCallbackStub::OnRemoteRequest failed, descriptor mismatch"); return E_DEVICESTATUS_GET_SERVICE_FAILED; } switch (code) { case static_cast(IdevicestatusCallback::DEVICESTATUS_CHANGE): { - return OnDevicestatusChangedStub(data); + return OnDeviceStatusChangedStub(data); } default: return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -43,18 +43,18 @@ int32_t DevicestatusCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel & return ERR_OK; } -int32_t DevicestatusCallbackStub::OnDevicestatusChangedStub(MessageParcel& data) +int32_t DeviceStatusCallbackStub::OnDeviceStatusChangedStub(MessageParcel& data) { DEV_HILOGD(SERVICE, "Enter"); int32_t type; int32_t value; READINT32(data, type, E_DEVICESTATUS_READ_PARCEL_ERROR); READINT32(data, value, E_DEVICESTATUS_READ_PARCEL_ERROR); - DevicestatusDataUtils::DevicestatusData devicestatusData = { - static_cast(type), - static_cast(value) + DeviceStatusDataUtils::DeviceStatusData devicestatusData = { + static_cast(type), + static_cast(value) }; - OnDevicestatusChanged(devicestatusData); + OnDeviceStatusChanged(devicestatusData); return ERR_OK; } } // namespace DeviceStatus diff --git a/frameworks/js/napi/src/devicestatus_event.cpp b/frameworks/js/napi/src/devicestatus_event.cpp index ff7b78878..45be6c0c7 100644 --- a/frameworks/js/napi/src/devicestatus_event.cpp +++ b/frameworks/js/napi/src/devicestatus_event.cpp @@ -201,8 +201,8 @@ void DeviceStatusEvent::SendRet(int32_t eventType, int32_t value, napi_value &re DEV_HILOGE(JS_NAPI, "Failed to set name"); return; } - if (value >= static_cast(DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID) - && value <= static_cast(DevicestatusDataUtils::DevicestatusValue::VALUE_EXIT)) { + if (value >= static_cast(DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID) + && value <= static_cast(DeviceStatusDataUtils::DeviceStatusValue::VALUE_EXIT)) { status = napi_create_int32(env_, value, &tmpValue); if (status != napi_ok) { DEV_HILOGE(JS_NAPI, "Failed to get int32"); diff --git a/frameworks/js/napi/src/devicestatus_napi.cpp b/frameworks/js/napi/src/devicestatus_napi.cpp index 7eef46b80..df60c5428 100644 --- a/frameworks/js/napi/src/devicestatus_napi.cpp +++ b/frameworks/js/napi/src/devicestatus_napi.cpp @@ -42,12 +42,12 @@ std::map> DeviceStatusNapi::callbackMap_; napi_ref DeviceStatusNapi::devicestatusValueRef_ = nullptr; struct ResponseEntity { - DevicestatusDataUtils::DevicestatusValue value; + DeviceStatusDataUtils::DeviceStatusValue value; }; -void DeviceStatusCallback::OnDevicestatusChanged(const DevicestatusDataUtils::DevicestatusData& devicestatusData) +void DeviceStatusCallback::OnDeviceStatusChanged(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) { - DEV_HILOGD(JS_NAPI, "OnDevicestatusChanged enter"); + DEV_HILOGD(JS_NAPI, "OnDeviceStatusChanged enter"); std::lock_guard guard(mutex_); uv_loop_s *loop = nullptr; napi_get_uv_event_loop(env_, &loop); @@ -72,7 +72,7 @@ void DeviceStatusCallback::OnDevicestatusChanged(const DevicestatusDataUtils::De void DeviceStatusCallback::EmitOnEvent(uv_work_t *work, int status) { - DevicestatusDataUtils::DevicestatusData* data = static_cast(work->data); + DeviceStatusDataUtils::DeviceStatusData* data = static_cast(work->data); delete work; if (data == nullptr) { DEV_HILOGE(JS_NAPI, "work->data is nullptr"); @@ -127,13 +127,13 @@ void DeviceStatusNapi::OnDeviceStatusChangedDone(int32_t type, int32_t value, bo int32_t DeviceStatusNapi::ConvertTypeToInt(const std::string &type) { if (type == "still") { - return DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL; + return DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL; } else if (type == "relativeStill") { - return DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL; + return DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL; } else if (type == "carBluetooth") { - return DevicestatusDataUtils::DevicestatusType::TYPE_CAR_BLUETOOTH; + return DeviceStatusDataUtils::DeviceStatusType::TYPE_CAR_BLUETOOTH; } else { - return DevicestatusDataUtils::DevicestatusType::TYPE_INVALID; + return DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID; } } @@ -259,7 +259,7 @@ napi_value DeviceStatusNapi::SubscribeDeviceStatusCallback(napi_env env, napi_ca DEV_HILOGE(JS_NAPI, "callback is nullptr"); return nullptr; } - DevicestatusClient::GetInstance().SubscribeCallback(DevicestatusDataUtils::DevicestatusType(type), callback); + DeviceStatusClient::GetInstance().SubscribeCallback(DeviceStatusDataUtils::DeviceStatusType(type), callback); auto ret = callbackMap_.insert(std::pair>(type, callback)); if (!ret.second) { DEV_HILOGE(JS_NAPI, "Failed to insert"); @@ -309,8 +309,8 @@ napi_value DeviceStatusNapi::SubscribeDeviceStatus(napi_env env, napi_callback_i int32_t event = eventMode; int32_t latency = latencyMode; DEV_HILOGD(JS_NAPI, "type:%{public}d, event:%{public}d, latency:%{public}d", type, event, latency); - NAPI_ASSERT(env, (type >= DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL) && - (type <= DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN), "type is illegal"); + NAPI_ASSERT(env, (type >= DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL) && + (type <= DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN), "type is illegal"); return SubscribeDeviceStatusCallback(env, info, args, type, event, latency); } @@ -338,8 +338,8 @@ napi_value DeviceStatusNapi::UnsubscribeDeviceStatus(napi_env env, napi_callback return nullptr; } int32_t type = ConvertTypeToInt(typeBuf.data()); - NAPI_ASSERT(env, (type >= DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL) && - (type <= DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN), "type is illegal"); + NAPI_ASSERT(env, (type >= DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL) && + (type <= DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN), "type is illegal"); int32_t eventMode = 0; status = napi_get_value_int32(env, args[ARG_1], &eventMode); if (status != napi_ok) { @@ -354,7 +354,7 @@ napi_value DeviceStatusNapi::UnsubscribeDeviceStatus(napi_env env, napi_callback } auto callbackIter = callbackMap_.find(type); if (callbackIter != callbackMap_.end()) { - DevicestatusClient::GetInstance().UnsubscribeCallback(DevicestatusDataUtils::DevicestatusType(type), + DeviceStatusClient::GetInstance().UnsubscribeCallback(DeviceStatusDataUtils::DeviceStatusType(type), callbackIter->second); callbackMap_.erase(type); } else { @@ -389,8 +389,8 @@ napi_value DeviceStatusNapi::GetDeviceStatus(napi_env env, napi_callback_info in return nullptr; } int32_t type = ConvertTypeToInt(typeBuf.data()); - NAPI_ASSERT(env, (type >= DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL) && - (type <= DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN), "type is illegal"); + NAPI_ASSERT(env, (type >= DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL) && + (type <= DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN), "type is illegal"); if (g_obj == nullptr) { g_obj = new (std::nothrow) DeviceStatusNapi(env); if (g_obj == nullptr) { @@ -410,8 +410,8 @@ napi_value DeviceStatusNapi::GetDeviceStatus(napi_env env, napi_callback_info in DEV_HILOGE(JS_NAPI, "type:%{public}d already exists", type); return nullptr; } - DevicestatusDataUtils::DevicestatusData devicestatusData = - DevicestatusClient::GetInstance().GetDevicestatusData(DevicestatusDataUtils::DevicestatusType(type)); + DeviceStatusDataUtils::DeviceStatusData devicestatusData = + DeviceStatusClient::GetInstance().GetDeviceStatusData(DeviceStatusDataUtils::DeviceStatusType(type)); g_obj->OnDeviceStatusChangedDone(devicestatusData.type, devicestatusData.value, true); g_obj->OffOnce(devicestatusData.type, args[ARG_1]); return nullptr; diff --git a/frameworks/native/interaction/src/coordination_manager_impl.cpp b/frameworks/native/interaction/src/coordination_manager_impl.cpp index 25d1f8bb5..eae498f73 100644 --- a/frameworks/native/interaction/src/coordination_manager_impl.cpp +++ b/frameworks/native/interaction/src/coordination_manager_impl.cpp @@ -51,7 +51,7 @@ int32_t CoordinationManagerImpl::RegisterCoordinationListener(CoordinationListen if (!isListeningProcess_) { FI_HILOGI("Start monitoring"); isListeningProcess_ = true; - return DevicestatusClient::GetInstance().RegisterCoordinationListener(); + return DeviceStatusClient::GetInstance().RegisterCoordinationListener(); } return RET_OK; } @@ -78,7 +78,7 @@ int32_t CoordinationManagerImpl::UnregisterCoordinationListener(CoordinationList listenerLabel: if (isListeningProcess_ && devCoordinationListener_.empty()) { isListeningProcess_ = false; - return DevicestatusClient::GetInstance().UnregisterCoordinationListener(); + return DeviceStatusClient::GetInstance().UnregisterCoordinationListener(); } return RET_OK; } @@ -98,7 +98,7 @@ int32_t CoordinationManagerImpl::EnableInputDeviceCoordination(bool enabled, Fun return RET_ERR; } devCoordinationEvent_[userData_] = event; - return DevicestatusClient::GetInstance().EnableInputDeviceCoordination(userData_++, enabled); + return DeviceStatusClient::GetInstance().EnableInputDeviceCoordination(userData_++, enabled); } int32_t CoordinationManagerImpl::StartInputDeviceCoordination(const std::string &sinkDeviceId, @@ -117,7 +117,7 @@ int32_t CoordinationManagerImpl::StartInputDeviceCoordination(const std::string return RET_ERR; } devCoordinationEvent_[userData_] = event; - return DevicestatusClient::GetInstance().StartInputDeviceCoordination( + return DeviceStatusClient::GetInstance().StartInputDeviceCoordination( userData_++, sinkDeviceId, srcInputDeviceId); } @@ -136,7 +136,7 @@ int32_t CoordinationManagerImpl::StopDeviceCoordination(FuncCoordinationMessage return RET_ERR; } devCoordinationEvent_[userData_] = event; - return DevicestatusClient::GetInstance().StopDeviceCoordination(userData_++); + return DeviceStatusClient::GetInstance().StopDeviceCoordination(userData_++); } int32_t CoordinationManagerImpl::GetInputDeviceCoordinationState( @@ -155,7 +155,7 @@ int32_t CoordinationManagerImpl::GetInputDeviceCoordinationState( return RET_ERR; } devCoordinationEvent_[userData_] = event; - return DevicestatusClient::GetInstance().GetInputDeviceCoordinationState(userData_++, deviceId); + return DeviceStatusClient::GetInstance().GetInputDeviceCoordinationState(userData_++, deviceId); } void CoordinationManagerImpl::OnDevCoordinationListener(const std::string deviceId, CoordinationMessage msg) diff --git a/frameworks/native/src/client.cpp b/frameworks/native/src/client.cpp index 4f7ce4c9c..300535677 100644 --- a/frameworks/native/src/client.cpp +++ b/frameworks/native/src/client.cpp @@ -256,12 +256,12 @@ void Client::OnConnected() int32_t Client::Socket() { CALL_DEBUG_ENTER; - int32_t ret = DevicestatusClient::GetInstance().AllocSocketPair(CONNECT_MODULE_TYPE_MMI_CLIENT); + int32_t ret = DeviceStatusClient::GetInstance().AllocSocketPair(CONNECT_MODULE_TYPE_MMI_CLIENT); if (ret != RET_OK) { FI_HILOGE("Call AllocSocketPair return %{public}d", ret); return RET_ERR; } - fd_ = DevicestatusClient::GetInstance().GetClientSocketFdOfAllocedSocketPair(); + fd_ = DeviceStatusClient::GetInstance().GetClientSocketFdOfAllocedSocketPair(); if (fd_ == -1) { FI_HILOGE("Call GetClientSocketFdOfAllocedSocketPair return invalid fd"); } diff --git a/frameworks/native/src/devicestatus_agent.cpp b/frameworks/native/src/devicestatus_agent.cpp index 91a052a78..6d047e2e9 100644 --- a/frameworks/native/src/devicestatus_agent.cpp +++ b/frameworks/native/src/devicestatus_agent.cpp @@ -23,12 +23,12 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -void DeviceStatusAgent::DeviceStatusAgentCallback::OnDevicestatusChanged( - const DevicestatusDataUtils::DevicestatusData& devicestatusData) +void DeviceStatusAgent::DeviceStatusAgentCallback::OnDeviceStatusChanged( + const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) { DEV_HILOGI(INNERKIT, "type=%{public}d, value=%{public}d", - static_cast(devicestatusData.type), - static_cast(devicestatusData.value)); + static_cast(devicestatusData.type), + static_cast(devicestatusData.value)); std::shared_ptr agent = agent_.lock(); if (agent == nullptr) { DEV_HILOGE(SERVICE, "agent is nullptr"); @@ -37,7 +37,7 @@ void DeviceStatusAgent::DeviceStatusAgentCallback::OnDevicestatusChanged( agent->agentEvent_->OnEventResult(devicestatusData); } -int32_t DeviceStatusAgent::SubscribeAgentEvent(const DevicestatusDataUtils::DevicestatusType& type, +int32_t DeviceStatusAgent::SubscribeAgentEvent(const DeviceStatusDataUtils::DeviceStatusType& type, const std::shared_ptr& agentEvent) { DEV_HILOGI(INNERKIT, "Enter"); @@ -45,8 +45,8 @@ int32_t DeviceStatusAgent::SubscribeAgentEvent(const DevicestatusDataUtils::Devi if (agentEvent == nullptr) { return ERR_INVALID_VALUE; } - if (type > DevicestatusDataUtils::DevicestatusType::TYPE_INVALID - && type <= DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN) { + if (type > DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID + && type <= DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN) { RegisterServiceEvent(type); agentEvent_ = agentEvent; } else { @@ -55,17 +55,17 @@ int32_t DeviceStatusAgent::SubscribeAgentEvent(const DevicestatusDataUtils::Devi return ERR_OK; } -int32_t DeviceStatusAgent::UnsubscribeAgentEvent(const DevicestatusDataUtils::DevicestatusType& type) +int32_t DeviceStatusAgent::UnsubscribeAgentEvent(const DeviceStatusDataUtils::DeviceStatusType& type) { - if (type > DevicestatusDataUtils::DevicestatusType::TYPE_INVALID - && type <= DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN) { + if (type > DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID + && type <= DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN) { UnRegisterServiceEvent(type); return ERR_OK; } return ERR_INVALID_VALUE; } -void DeviceStatusAgent::RegisterServiceEvent(const DevicestatusDataUtils::DevicestatusType& type) +void DeviceStatusAgent::RegisterServiceEvent(const DeviceStatusDataUtils::DeviceStatusType& type) { DEV_HILOGI(INNERKIT, "Enter"); callback_ = new (std::nothrow) DeviceStatusAgentCallback(shared_from_this()); @@ -73,13 +73,13 @@ void DeviceStatusAgent::RegisterServiceEvent(const DevicestatusDataUtils::Device DEV_HILOGE(INNERKIT, "callback_ is nullptr"); return; } - DevicestatusClient::GetInstance().SubscribeCallback(type, callback_); + DeviceStatusClient::GetInstance().SubscribeCallback(type, callback_); } -void DeviceStatusAgent::UnRegisterServiceEvent(const DevicestatusDataUtils::DevicestatusType& type) +void DeviceStatusAgent::UnRegisterServiceEvent(const DeviceStatusDataUtils::DeviceStatusType& type) { DEV_HILOGI(INNERKIT, "Enter"); - DevicestatusClient::GetInstance().UnsubscribeCallback(type, callback_); + DeviceStatusClient::GetInstance().UnsubscribeCallback(type, callback_); } } // namespace DeviceStatus } // namespace Msdp diff --git a/frameworks/native/src/devicestatus_callback_proxy.cpp b/frameworks/native/src/devicestatus_callback_proxy.cpp index d46214a54..76e0e2616 100644 --- a/frameworks/native/src/devicestatus_callback_proxy.cpp +++ b/frameworks/native/src/devicestatus_callback_proxy.cpp @@ -25,7 +25,7 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -void DeviceStatusCallbackProxy::OnDevicestatusChanged(const DevicestatusDataUtils::DevicestatusData& devicestatusData) +void DeviceStatusCallbackProxy::OnDeviceStatusChanged(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) { sptr remote = Remote(); DEVICESTATUS_RETURN_IF(remote == nullptr); diff --git a/frameworks/native/src/devicestatus_client.cpp b/frameworks/native/src/devicestatus_client.cpp index c539e1cb7..f22fc851f 100644 --- a/frameworks/native/src/devicestatus_client.cpp +++ b/frameworks/native/src/devicestatus_client.cpp @@ -33,11 +33,11 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { namespace { -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MSDP_DOMAIN_ID, "DevicestatusClient" }; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MSDP_DOMAIN_ID, "DeviceStatusClient" }; } // namespace -DevicestatusClient::DevicestatusClient() {} -DevicestatusClient::~DevicestatusClient() +DeviceStatusClient::DeviceStatusClient() {} +DeviceStatusClient::~DeviceStatusClient() { if (devicestatusProxy_ != nullptr) { auto remoteObject = devicestatusProxy_->AsObject(); @@ -47,7 +47,7 @@ DevicestatusClient::~DevicestatusClient() } } -ErrCode DevicestatusClient::Connect() +ErrCode DeviceStatusClient::Connect() { std::lock_guard lock(mutex_); if (devicestatusProxy_ != nullptr) { @@ -67,23 +67,23 @@ ErrCode DevicestatusClient::Connect() return E_DEVICESTATUS_GET_SERVICE_FAILED; } - deathRecipient_ = sptr(new DevicestatusDeathRecipient()); + deathRecipient_ = sptr(new DeviceStatusDeathRecipient()); if (deathRecipient_ == nullptr) { - DEV_HILOGE(INNERKIT, "Failed to create DevicestatusDeathRecipient"); + DEV_HILOGE(INNERKIT, "Failed to create DeviceStatusDeathRecipient"); return ERR_NO_MEMORY; } if ((remoteObject_->IsProxyObject()) && (!remoteObject_->AddDeathRecipient(deathRecipient_))) { - DEV_HILOGE(INNERKIT, "Add death recipient to Devicestatus service failed"); + DEV_HILOGE(INNERKIT, "Add death recipient to DeviceStatus service failed"); return E_DEVICESTATUS_ADD_DEATH_RECIPIENT_FAILED; } devicestatusProxy_ = iface_cast(remoteObject_); - DEV_HILOGD(INNERKIT, "Connecting DevicestatusService success"); + DEV_HILOGD(INNERKIT, "Connecting DeviceStatusService success"); return ERR_OK; } -void DevicestatusClient::ResetProxy(const wptr& remote) +void DeviceStatusClient::ResetProxy(const wptr& remote) { std::lock_guard lock(mutex_); DEVICESTATUS_RETURN_IF(devicestatusProxy_ == nullptr); @@ -95,18 +95,18 @@ void DevicestatusClient::ResetProxy(const wptr& remote) } } -void DevicestatusClient::DevicestatusDeathRecipient::OnRemoteDied(const wptr& remote) +void DeviceStatusClient::DeviceStatusDeathRecipient::OnRemoteDied(const wptr& remote) { if (remote == nullptr) { DEV_HILOGE(INNERKIT, "OnRemoteDied failed, remote is nullptr"); return; } - DevicestatusClient::GetInstance().ResetProxy(remote); + DeviceStatusClient::GetInstance().ResetProxy(remote); DEV_HILOGD(INNERKIT, "Recv death notice"); } -void DevicestatusClient::SubscribeCallback(const DevicestatusDataUtils::DevicestatusType& type, \ +void DeviceStatusClient::SubscribeCallback(const DeviceStatusDataUtils::DeviceStatusType& type, \ const sptr& callback) { DEV_HILOGD(INNERKIT, "Enter"); @@ -115,15 +115,15 @@ void DevicestatusClient::SubscribeCallback(const DevicestatusDataUtils::Devicest DEV_HILOGE(SERVICE, "devicestatusProxy_ is nullptr"); return; } - if (type > DevicestatusDataUtils::DevicestatusType::TYPE_INVALID - && type <= DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN) { + if (type > DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID + && type <= DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN) { devicestatusProxy_->Subscribe(type, callback); } return; DEV_HILOGD(INNERKIT, "Exit"); } -void DevicestatusClient::UnsubscribeCallback(const DevicestatusDataUtils::DevicestatusType& type, \ +void DeviceStatusClient::UnsubscribeCallback(const DeviceStatusDataUtils::DeviceStatusType& type, \ const sptr& callback) { DEV_HILOGD(INNERKIT, "Enter"); @@ -132,57 +132,57 @@ void DevicestatusClient::UnsubscribeCallback(const DevicestatusDataUtils::Device DEV_HILOGE(SERVICE, "devicestatusProxy_ is nullptr"); return; } - if (type > DevicestatusDataUtils::DevicestatusType::TYPE_INVALID - && type <= DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN) { + if (type > DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID + && type <= DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN) { devicestatusProxy_->Unsubscribe(type, callback); } return; DEV_HILOGD(INNERKIT, "Exit"); } -DevicestatusDataUtils::DevicestatusData DevicestatusClient::GetDevicestatusData(const \ - DevicestatusDataUtils::DevicestatusType& type) +DeviceStatusDataUtils::DeviceStatusData DeviceStatusClient::GetDeviceStatusData(const \ + DeviceStatusDataUtils::DeviceStatusType& type) { DEV_HILOGD(INNERKIT, "Enter"); - DevicestatusDataUtils::DevicestatusData devicestatusData; - devicestatusData.type = DevicestatusDataUtils::DevicestatusType::TYPE_INVALID; - devicestatusData.value = DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID; + DeviceStatusDataUtils::DeviceStatusData devicestatusData; + devicestatusData.type = DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID; + devicestatusData.value = DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID; DEVICESTATUS_RETURN_IF_WITH_RET((Connect() != ERR_OK), devicestatusData); if (devicestatusProxy_ == nullptr) { DEV_HILOGE(SERVICE, "devicestatusProxy_ is nullptr"); return devicestatusData; } - if (type > DevicestatusDataUtils::DevicestatusType::TYPE_INVALID - && type <= DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN) { + if (type > DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID + && type <= DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN) { devicestatusData = devicestatusProxy_->GetCache(type); } DEV_HILOGD(INNERKIT, "Exit"); return devicestatusData; } -int32_t DevicestatusClient::RegisterCoordinationListener() +int32_t DeviceStatusClient::RegisterCoordinationListener() { CALL_DEBUG_ENTER; DEVICESTATUS_RETURN_IF_WITH_RET((Connect() != ERR_OK), RET_ERR); return devicestatusProxy_->RegisterCoordinationListener(); } -int32_t DevicestatusClient::UnregisterCoordinationListener() +int32_t DeviceStatusClient::UnregisterCoordinationListener() { CALL_DEBUG_ENTER; DEVICESTATUS_RETURN_IF_WITH_RET((Connect() != ERR_OK), RET_ERR); return devicestatusProxy_->UnregisterCoordinationListener(); } -int32_t DevicestatusClient::EnableInputDeviceCoordination(int32_t userData, bool enabled) +int32_t DeviceStatusClient::EnableInputDeviceCoordination(int32_t userData, bool enabled) { CALL_DEBUG_ENTER; DEVICESTATUS_RETURN_IF_WITH_RET((Connect() != ERR_OK), RET_ERR); return devicestatusProxy_->EnableInputDeviceCoordination(userData, enabled); } -int32_t DevicestatusClient::StartInputDeviceCoordination(int32_t userData, +int32_t DeviceStatusClient::StartInputDeviceCoordination(int32_t userData, const std::string &sinkDeviceId, int32_t srcInputDeviceId) { CALL_DEBUG_ENTER; @@ -190,14 +190,14 @@ int32_t DevicestatusClient::StartInputDeviceCoordination(int32_t userData, return devicestatusProxy_->StartInputDeviceCoordination(userData, sinkDeviceId, srcInputDeviceId); } -int32_t DevicestatusClient::StopDeviceCoordination(int32_t userData) +int32_t DeviceStatusClient::StopDeviceCoordination(int32_t userData) { CALL_DEBUG_ENTER; DEVICESTATUS_RETURN_IF_WITH_RET((Connect() != ERR_OK), RET_ERR); return devicestatusProxy_->StopDeviceCoordination(userData); } -int32_t DevicestatusClient::GetInputDeviceCoordinationState(int32_t userData, const std::string &deviceId) +int32_t DeviceStatusClient::GetInputDeviceCoordinationState(int32_t userData, const std::string &deviceId) { CALL_DEBUG_ENTER; DEVICESTATUS_RETURN_IF_WITH_RET((Connect() != ERR_OK), RET_ERR); @@ -205,7 +205,7 @@ int32_t DevicestatusClient::GetInputDeviceCoordinationState(int32_t userData, co } -int32_t DevicestatusClient::AllocSocketPair(const int32_t moduleType) +int32_t DeviceStatusClient::AllocSocketPair(const int32_t moduleType) { CALL_DEBUG_ENTER; DEVICESTATUS_RETURN_IF_WITH_RET((Connect() != ERR_OK), RET_ERR); @@ -226,7 +226,7 @@ int32_t DevicestatusClient::AllocSocketPair(const int32_t moduleType) return RET_OK; } -int32_t DevicestatusClient::GetClientSocketFdOfAllocedSocketPair() const +int32_t DeviceStatusClient::GetClientSocketFdOfAllocedSocketPair() const { CALL_DEBUG_ENTER; return socketFd_; diff --git a/frameworks/native/src/devicestatus_srv_proxy.cpp b/frameworks/native/src/devicestatus_srv_proxy.cpp index 176d12e0e..14bfae64d 100644 --- a/frameworks/native/src/devicestatus_srv_proxy.cpp +++ b/frameworks/native/src/devicestatus_srv_proxy.cpp @@ -29,10 +29,10 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { namespace { -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MSDP_DOMAIN_ID, "DevicestatusSrvProxy" }; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MSDP_DOMAIN_ID, "DeviceStatusSrvProxy" }; } // namespace -void DevicestatusSrvProxy::Subscribe(const DevicestatusDataUtils::DevicestatusType& type, \ +void DeviceStatusSrvProxy::Subscribe(const DeviceStatusDataUtils::DeviceStatusType& type, \ const sptr& callback) { DEV_HILOGD(INNERKIT, "Enter"); @@ -44,7 +44,7 @@ void DevicestatusSrvProxy::Subscribe(const DevicestatusDataUtils::DevicestatusTy MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(DevicestatusSrvProxy::GetDescriptor())) { + if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) { DEV_HILOGE(INNERKIT, "Write descriptor failed"); return; } @@ -61,7 +61,7 @@ void DevicestatusSrvProxy::Subscribe(const DevicestatusDataUtils::DevicestatusTy DEV_HILOGD(INNERKIT, "Exit"); } -void DevicestatusSrvProxy::Unsubscribe(const DevicestatusDataUtils::DevicestatusType& type, +void DeviceStatusSrvProxy::Unsubscribe(const DeviceStatusDataUtils::DeviceStatusType& type, const sptr& callback) { DEV_HILOGD(INNERKIT, "Enter"); @@ -73,7 +73,7 @@ void DevicestatusSrvProxy::Unsubscribe(const DevicestatusDataUtils::Devicestatus MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(DevicestatusSrvProxy::GetDescriptor())) { + if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) { DEV_HILOGE(INNERKIT, "Write descriptor failed!"); return; } @@ -91,13 +91,13 @@ void DevicestatusSrvProxy::Unsubscribe(const DevicestatusDataUtils::Devicestatus DEV_HILOGD(INNERKIT, "Exit"); } -DevicestatusDataUtils::DevicestatusData DevicestatusSrvProxy::GetCache(const \ - DevicestatusDataUtils::DevicestatusType& type) +DeviceStatusDataUtils::DeviceStatusData DeviceStatusSrvProxy::GetCache(const \ + DeviceStatusDataUtils::DeviceStatusType& type) { DEV_HILOGD(INNERKIT, "Enter"); - DevicestatusDataUtils::DevicestatusData devicestatusData; - devicestatusData.type = DevicestatusDataUtils::DevicestatusType::TYPE_INVALID; - devicestatusData.value = DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID; + DeviceStatusDataUtils::DeviceStatusData devicestatusData; + devicestatusData.type = DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID; + devicestatusData.value = DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID; sptr remote = Remote(); DEVICESTATUS_RETURN_IF_WITH_RET((remote == nullptr), devicestatusData); @@ -106,7 +106,7 @@ DevicestatusDataUtils::DevicestatusData DevicestatusSrvProxy::GetCache(const \ MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(DevicestatusSrvProxy::GetDescriptor())) { + if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) { DEV_HILOGE(INNERKIT, "Write descriptor failed!"); return devicestatusData; } @@ -123,18 +123,18 @@ DevicestatusDataUtils::DevicestatusData DevicestatusSrvProxy::GetCache(const \ int32_t devicestatusValue = -1; READINT32(reply, devicestatusType, devicestatusData); READINT32(reply, devicestatusValue, devicestatusData); - devicestatusData.type = DevicestatusDataUtils::DevicestatusType(devicestatusType); - devicestatusData.value = DevicestatusDataUtils::DevicestatusValue(devicestatusValue); + devicestatusData.type = DeviceStatusDataUtils::DeviceStatusType(devicestatusType); + devicestatusData.value = DeviceStatusDataUtils::DeviceStatusValue(devicestatusValue); DEV_HILOGD(INNERKIT, "type: %{public}d, value: %{public}d", devicestatusData.type, devicestatusData.value); DEV_HILOGD(INNERKIT, "Exit"); return devicestatusData; } -int32_t DevicestatusSrvProxy::RegisterCoordinationListener() +int32_t DeviceStatusSrvProxy::RegisterCoordinationListener() { CALL_DEBUG_ENTER; MessageParcel data; - if (!data.WriteInterfaceToken(DevicestatusSrvProxy::GetDescriptor())) { + if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) { FI_HILOGE("Failed to write descriptor"); return ERR_INVALID_VALUE; } @@ -149,11 +149,11 @@ int32_t DevicestatusSrvProxy::RegisterCoordinationListener() return ret; } -int32_t DevicestatusSrvProxy::UnregisterCoordinationListener() +int32_t DeviceStatusSrvProxy::UnregisterCoordinationListener() { CALL_DEBUG_ENTER; MessageParcel data; - if (!data.WriteInterfaceToken(DevicestatusSrvProxy::GetDescriptor())) { + if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) { FI_HILOGE("Failed to write descriptor"); return ERR_INVALID_VALUE; } @@ -168,11 +168,11 @@ int32_t DevicestatusSrvProxy::UnregisterCoordinationListener() return ret; } -int32_t DevicestatusSrvProxy::EnableInputDeviceCoordination(int32_t userData, bool enabled) +int32_t DeviceStatusSrvProxy::EnableInputDeviceCoordination(int32_t userData, bool enabled) { CALL_DEBUG_ENTER; MessageParcel data; - if (!data.WriteInterfaceToken(DevicestatusSrvProxy::GetDescriptor())) { + if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) { FI_HILOGE("Failed to write descriptor"); return ERR_INVALID_VALUE; } @@ -189,12 +189,12 @@ int32_t DevicestatusSrvProxy::EnableInputDeviceCoordination(int32_t userData, bo return ret; } -int32_t DevicestatusSrvProxy::StartInputDeviceCoordination(int32_t userData, const std::string &sinkDeviceId, +int32_t DeviceStatusSrvProxy::StartInputDeviceCoordination(int32_t userData, const std::string &sinkDeviceId, int32_t srcInputDeviceId) { CALL_DEBUG_ENTER; MessageParcel data; - if (!data.WriteInterfaceToken(DevicestatusSrvProxy::GetDescriptor())) { + if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) { FI_HILOGE("Failed to write descriptor"); return ERR_INVALID_VALUE; } @@ -212,11 +212,11 @@ int32_t DevicestatusSrvProxy::StartInputDeviceCoordination(int32_t userData, con return ret; } -int32_t DevicestatusSrvProxy::StopDeviceCoordination(int32_t userData) +int32_t DeviceStatusSrvProxy::StopDeviceCoordination(int32_t userData) { CALL_DEBUG_ENTER; MessageParcel data; - if (!data.WriteInterfaceToken(DevicestatusSrvProxy::GetDescriptor())) { + if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) { FI_HILOGE("Failed to write descriptor"); return ERR_INVALID_VALUE; } @@ -232,11 +232,11 @@ int32_t DevicestatusSrvProxy::StopDeviceCoordination(int32_t userData) return ret; } -int32_t DevicestatusSrvProxy::GetInputDeviceCoordinationState(int32_t userData, const std::string &deviceId) +int32_t DeviceStatusSrvProxy::GetInputDeviceCoordinationState(int32_t userData, const std::string &deviceId) { CALL_DEBUG_ENTER; MessageParcel data; - if (!data.WriteInterfaceToken(DevicestatusSrvProxy::GetDescriptor())) { + if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) { FI_HILOGE("Failed to write descriptor"); return ERR_INVALID_VALUE; } @@ -253,12 +253,12 @@ int32_t DevicestatusSrvProxy::GetInputDeviceCoordinationState(int32_t userData, return ret; } -int32_t DevicestatusSrvProxy::AllocSocketFd(const std::string &programName, const int32_t moduleType, +int32_t DeviceStatusSrvProxy::AllocSocketFd(const std::string &programName, const int32_t moduleType, int32_t &socketFd, int32_t &tokenType) { CALL_DEBUG_ENTER; MessageParcel data; - if (!data.WriteInterfaceToken(DevicestatusSrvProxy::GetDescriptor())) { + if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) { FI_HILOGE("Failed to write descriptor"); return ERR_INVALID_VALUE; } diff --git a/interfaces/innerkits/include/devicestatus_agent.h b/interfaces/innerkits/include/devicestatus_agent.h index 0cd289ce6..1bc138ece 100644 --- a/interfaces/innerkits/include/devicestatus_agent.h +++ b/interfaces/innerkits/include/devicestatus_agent.h @@ -31,25 +31,25 @@ public: class DeviceStatusAgentEvent { public: virtual ~DeviceStatusAgentEvent() = default; - virtual bool OnEventResult(const DevicestatusDataUtils::DevicestatusData& devicestatusData) = 0; + virtual bool OnEventResult(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) = 0; }; - class DeviceStatusAgentCallback : public DevicestatusCallbackStub { + class DeviceStatusAgentCallback : public DeviceStatusCallbackStub { public: explicit DeviceStatusAgentCallback(std::shared_ptr agent) : agent_(agent) {}; virtual ~DeviceStatusAgentCallback() {}; - void OnDevicestatusChanged(const DevicestatusDataUtils::DevicestatusData& devicestatusData) override; + void OnDeviceStatusChanged(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) override; private: std::weak_ptr agent_; }; - int32_t SubscribeAgentEvent(const DevicestatusDataUtils::DevicestatusType& type, + int32_t SubscribeAgentEvent(const DeviceStatusDataUtils::DeviceStatusType& type, const std::shared_ptr& agentEvent); - int32_t UnsubscribeAgentEvent(const DevicestatusDataUtils::DevicestatusType& type); + int32_t UnsubscribeAgentEvent(const DeviceStatusDataUtils::DeviceStatusType& type); friend class DeviceStatusAgentCallback; private: - void RegisterServiceEvent(const DevicestatusDataUtils::DevicestatusType& type); - void UnRegisterServiceEvent(const DevicestatusDataUtils::DevicestatusType& type); + void RegisterServiceEvent(const DeviceStatusDataUtils::DeviceStatusType& type); + void UnRegisterServiceEvent(const DeviceStatusDataUtils::DeviceStatusType& type); sptr callback_; std::shared_ptr agentEvent_; }; diff --git a/interfaces/innerkits/include/devicestatus_callback_proxy.h b/interfaces/innerkits/include/devicestatus_callback_proxy.h index 105a7cf0e..eab1fa2d2 100644 --- a/interfaces/innerkits/include/devicestatus_callback_proxy.h +++ b/interfaces/innerkits/include/devicestatus_callback_proxy.h @@ -31,7 +31,7 @@ public: : IRemoteProxy(impl) {} ~DeviceStatusCallbackProxy() = default; DISALLOW_COPY_AND_MOVE(DeviceStatusCallbackProxy); - virtual void OnDevicestatusChanged(const DevicestatusDataUtils::DevicestatusData& devicestatusData) override; + virtual void OnDeviceStatusChanged(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) override; private: static inline BrokerDelegator delegator_; diff --git a/interfaces/innerkits/include/devicestatus_client.h b/interfaces/innerkits/include/devicestatus_client.h index f6326459a..cae84e7d3 100644 --- a/interfaces/innerkits/include/devicestatus_client.h +++ b/interfaces/innerkits/include/devicestatus_client.h @@ -27,17 +27,17 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DevicestatusClient final : public DelayedRefSingleton { - DECLARE_DELAYED_REF_SINGLETON(DevicestatusClient) +class DeviceStatusClient final : public DelayedRefSingleton { + DECLARE_DELAYED_REF_SINGLETON(DeviceStatusClient) public: - DISALLOW_COPY_AND_MOVE(DevicestatusClient); + DISALLOW_COPY_AND_MOVE(DeviceStatusClient); - void SubscribeCallback(const DevicestatusDataUtils::DevicestatusType& type, \ + void SubscribeCallback(const DeviceStatusDataUtils::DeviceStatusType& type, \ const sptr& callback); - void UnsubscribeCallback(const DevicestatusDataUtils::DevicestatusType& type, \ + void UnsubscribeCallback(const DeviceStatusDataUtils::DeviceStatusType& type, \ const sptr& callback); - DevicestatusDataUtils::DevicestatusData GetDevicestatusData(const DevicestatusDataUtils::DevicestatusType& type); + DeviceStatusDataUtils::DeviceStatusData GetDeviceStatusData(const DeviceStatusDataUtils::DeviceStatusType& type); int32_t RegisterCoordinationListener(); int32_t UnregisterCoordinationListener(); @@ -49,13 +49,13 @@ public: int32_t AllocSocketPair(const int32_t moduleType); int32_t GetClientSocketFdOfAllocedSocketPair() const; private: - class DevicestatusDeathRecipient : public IRemoteObject::DeathRecipient { + class DeviceStatusDeathRecipient : public IRemoteObject::DeathRecipient { public: - DevicestatusDeathRecipient() = default; - ~DevicestatusDeathRecipient() = default; + DeviceStatusDeathRecipient() = default; + ~DeviceStatusDeathRecipient() = default; void OnRemoteDied(const wptr& remote); private: - DISALLOW_COPY_AND_MOVE(DevicestatusDeathRecipient); + DISALLOW_COPY_AND_MOVE(DeviceStatusDeathRecipient); }; ErrCode Connect(); diff --git a/interfaces/innerkits/include/devicestatus_data_utils.h b/interfaces/innerkits/include/devicestatus_data_utils.h index dbadc4425..a5c9c533d 100644 --- a/interfaces/innerkits/include/devicestatus_data_utils.h +++ b/interfaces/innerkits/include/devicestatus_data_utils.h @@ -21,9 +21,9 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DevicestatusDataUtils { +class DeviceStatusDataUtils { public: - enum DevicestatusType { + enum DeviceStatusType { TYPE_INVALID = -1, TYPE_HIGH_STILL, TYPE_FINE_STILL, @@ -33,7 +33,7 @@ public: TYPE_MAX }; - enum DevicestatusValue { + enum DeviceStatusValue { VALUE_INVALID = -1, VALUE_ENTER, VALUE_EXIT @@ -44,9 +44,9 @@ public: VALID }; - struct DevicestatusData { - DevicestatusType type; - DevicestatusValue value; + struct DeviceStatusData { + DeviceStatusType type; + DeviceStatusValue value; }; }; @@ -56,11 +56,11 @@ typedef struct DeviceStatusJsonData { }DeviceStatusJsonD; static DeviceStatusJsonD DeviceStatusJson[] = { - {DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL, "TYPE_HIGH_STILL"}, - {DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL, "TYPE_FINE_STILL"}, - {DevicestatusDataUtils::DevicestatusType::TYPE_CAR_BLUETOOTH, "TYPE_CAR_BLUETOOTH"}, - {DevicestatusDataUtils::DevicestatusType::TYPE_STAND, "TYPE_STAND"}, - {DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, "TYPE_LID_OPEN"} + {DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL, "TYPE_HIGH_STILL"}, + {DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL, "TYPE_FINE_STILL"}, + {DeviceStatusDataUtils::DeviceStatusType::TYPE_CAR_BLUETOOTH, "TYPE_CAR_BLUETOOTH"}, + {DeviceStatusDataUtils::DeviceStatusType::TYPE_STAND, "TYPE_STAND"}, + {DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, "TYPE_LID_OPEN"} }; } // namespace DeviceStatus } // namespace Msdp diff --git a/interfaces/innerkits/include/devicestatus_srv_proxy.h b/interfaces/innerkits/include/devicestatus_srv_proxy.h index 9bf232026..d2cb3485f 100644 --- a/interfaces/innerkits/include/devicestatus_srv_proxy.h +++ b/interfaces/innerkits/include/devicestatus_srv_proxy.h @@ -24,19 +24,19 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DevicestatusSrvProxy : public IRemoteProxy { +class DeviceStatusSrvProxy : public IRemoteProxy { public: - explicit DevicestatusSrvProxy(const sptr& impl) + explicit DeviceStatusSrvProxy(const sptr& impl) : IRemoteProxy(impl) {} - ~DevicestatusSrvProxy() = default; - DISALLOW_COPY_AND_MOVE(DevicestatusSrvProxy); + ~DeviceStatusSrvProxy() = default; + DISALLOW_COPY_AND_MOVE(DeviceStatusSrvProxy); - virtual void Subscribe(const DevicestatusDataUtils::DevicestatusType& type, \ + virtual void Subscribe(const DeviceStatusDataUtils::DeviceStatusType& type, \ const sptr& callback) override; - virtual void Unsubscribe(const DevicestatusDataUtils::DevicestatusType& type, \ + virtual void Unsubscribe(const DeviceStatusDataUtils::DeviceStatusType& type, \ const sptr& callback) override; - virtual DevicestatusDataUtils::DevicestatusData GetCache(const \ - DevicestatusDataUtils::DevicestatusType& type) override; + virtual DeviceStatusDataUtils::DeviceStatusData GetCache(const \ + DeviceStatusDataUtils::DeviceStatusType& type) override; virtual int32_t RegisterCoordinationListener() override; virtual int32_t UnregisterCoordinationListener() override; @@ -50,7 +50,7 @@ public: int32_t &socketFd, int32_t &tokenType) override; private: - static inline BrokerDelegator delegator_; + static inline BrokerDelegator delegator_; }; } // namespace DeviceStatus } // namespace Msdp diff --git a/interfaces/innerkits/include/idevicestatus.h b/interfaces/innerkits/include/idevicestatus.h index fcb8422cc..8ea26a455 100644 --- a/interfaces/innerkits/include/idevicestatus.h +++ b/interfaces/innerkits/include/idevicestatus.h @@ -40,11 +40,11 @@ public: ALLOC_SOCKET_FD = 40 }; - virtual void Subscribe(const DevicestatusDataUtils::DevicestatusType& type, \ + virtual void Subscribe(const DeviceStatusDataUtils::DeviceStatusType& type, \ const sptr& callback) = 0; - virtual void Unsubscribe(const DevicestatusDataUtils::DevicestatusType& type, \ + virtual void Unsubscribe(const DeviceStatusDataUtils::DeviceStatusType& type, \ const sptr& callback) = 0; - virtual DevicestatusDataUtils::DevicestatusData GetCache(const DevicestatusDataUtils::DevicestatusType& type) = 0; + virtual DeviceStatusDataUtils::DeviceStatusData GetCache(const DeviceStatusDataUtils::DeviceStatusType& type) = 0; virtual int32_t RegisterCoordinationListener() = 0; virtual int32_t UnregisterCoordinationListener() = 0; diff --git a/interfaces/innerkits/include/idevicestatus_algorithm_callback.h b/interfaces/innerkits/include/idevicestatus_algorithm_callback.h index 9d278fba2..117e36d46 100644 --- a/interfaces/innerkits/include/idevicestatus_algorithm_callback.h +++ b/interfaces/innerkits/include/idevicestatus_algorithm_callback.h @@ -25,7 +25,7 @@ namespace Msdp { namespace DeviceStatus { class IdevicestatusAlgorithmCallback : public IRemoteBroker { public: - virtual void OnDevicestatusChanged(const DevicestatusDataUtils::DevicestatusData& data) = 0; + virtual void OnDeviceStatusChanged(const DeviceStatusDataUtils::DeviceStatusData& data) = 0; DECLARE_INTERFACE_DESCRIPTOR(u"ohos.msdp.IdevicestatusAlgorithmCallback"); }; diff --git a/interfaces/innerkits/include/idevicestatus_callback.h b/interfaces/innerkits/include/idevicestatus_callback.h index db02fbb4f..5da773e99 100644 --- a/interfaces/innerkits/include/idevicestatus_callback.h +++ b/interfaces/innerkits/include/idevicestatus_callback.h @@ -30,7 +30,7 @@ public: DEVICESTATUS_CHANGE = 0, }; - virtual void OnDevicestatusChanged(const DevicestatusDataUtils::DevicestatusData& devicestatusData) = 0; + virtual void OnDeviceStatusChanged(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) = 0; DECLARE_INTERFACE_DESCRIPTOR(u"ohos.msdp.IdevicestatusCallback"); }; diff --git a/interfaces/innerkits/include/idevicestatus_storage.h b/interfaces/innerkits/include/idevicestatus_storage.h index 5627951bd..3a6d5c3e1 100644 --- a/interfaces/innerkits/include/idevicestatus_storage.h +++ b/interfaces/innerkits/include/idevicestatus_storage.h @@ -25,14 +25,14 @@ namespace Msdp { namespace DeviceStatus { class IdevicestatusStorage : public IRemoteBroker { public: - struct DevicestatusRecord { - DevicestatusDataUtils::DevicestatusType type; - DevicestatusDataUtils::DevicestatusValue value; + struct DeviceStatusRecord { + DeviceStatusDataUtils::DeviceStatusType type; + DeviceStatusDataUtils::DeviceStatusValue value; std::string date; std::string time; }; - virtual bool Save(DevicestatusRecord record) = 0; + virtual bool Save(DeviceStatusRecord record) = 0; DECLARE_INTERFACE_DESCRIPTOR(u"ohos.msdp.IdevicestatusStorage"); }; diff --git a/libs/include/devicestatus_data_parse.h b/libs/include/devicestatus_data_parse.h index 1dc841f5b..6591e23c1 100644 --- a/libs/include/devicestatus_data_parse.h +++ b/libs/include/devicestatus_data_parse.h @@ -40,11 +40,11 @@ class DeviceStatusDataParse { public: DeviceStatusDataParse() = default; ~DeviceStatusDataParse() = default; - bool ParseDeviceStatusData(DevicestatusDataUtils::DevicestatusData& data, - DevicestatusDataUtils::DevicestatusType& type); - bool DisableCount(const DevicestatusDataUtils::DevicestatusType& type); - bool DataInit(const std::string& fileData, bool logStatus, DevicestatusDataUtils::DevicestatusType& type, - DevicestatusDataUtils::DevicestatusData& data); + bool ParseDeviceStatusData(DeviceStatusDataUtils::DeviceStatusData& data, + DeviceStatusDataUtils::DeviceStatusType& type); + bool DisableCount(const DeviceStatusDataUtils::DeviceStatusType& type); + bool DataInit(const std::string& fileData, bool logStatus, DeviceStatusDataUtils::DeviceStatusType& type, + DeviceStatusDataUtils::DeviceStatusData& data); int32_t CreateJsonFile(); private: diff --git a/libs/include/devicestatus_msdp_mock.h b/libs/include/devicestatus_msdp_mock.h index ac6cd5de7..7d028d48e 100644 --- a/libs/include/devicestatus_msdp_mock.h +++ b/libs/include/devicestatus_msdp_mock.h @@ -29,7 +29,7 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DeviceStatusMsdpMock final : public DevicestatusMsdpInterface { +class DeviceStatusMsdpMock final : public DeviceStatusMsdpInterface { public: DeviceStatusMsdpMock() = default; ~DeviceStatusMsdpMock() = default; @@ -47,12 +47,12 @@ public: int32_t RegisterTimerCallback(const int32_t fd, const EventType et); void StartThread(); void LoopingThreadEntry(); - void Enable(DevicestatusDataUtils::DevicestatusType type) override; - void Disable(DevicestatusDataUtils::DevicestatusType type) override; - void DisableCount(DevicestatusDataUtils::DevicestatusType type) override; + void Enable(DeviceStatusDataUtils::DeviceStatusType type) override; + void Disable(DeviceStatusDataUtils::DeviceStatusType type) override; + void DisableCount(DeviceStatusDataUtils::DeviceStatusType type) override; void RegisterCallback(std::shared_ptr callback) override; void UnregisterCallback() override; - ErrCode NotifyMsdpImpl(const DevicestatusDataUtils::DevicestatusData& data); + ErrCode NotifyMsdpImpl(const DeviceStatusDataUtils::DeviceStatusData& data); void GetDeviceStatusData(); std::shared_ptr GetCallbackImpl() { diff --git a/libs/interface/devicestatus_msdp_interface.h b/libs/interface/devicestatus_msdp_interface.h index a1550c81e..dc3af9e79 100644 --- a/libs/interface/devicestatus_msdp_interface.h +++ b/libs/interface/devicestatus_msdp_interface.h @@ -26,29 +26,29 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DevicestatusMsdpInterface { +class DeviceStatusMsdpInterface { public: - DevicestatusMsdpInterface() {} - virtual ~DevicestatusMsdpInterface() {} + DeviceStatusMsdpInterface() {} + virtual ~DeviceStatusMsdpInterface() {} class MsdpAlgorithmCallback { public: MsdpAlgorithmCallback() = default; virtual ~MsdpAlgorithmCallback() = default; - virtual void OnResult(const DevicestatusDataUtils::DevicestatusData& data) = 0; + virtual void OnResult(const DeviceStatusDataUtils::DeviceStatusData& data) = 0; }; virtual void RegisterCallback(std::shared_ptr callback) = 0; virtual void UnregisterCallback() = 0; - virtual void Enable(DevicestatusDataUtils::DevicestatusType type) = 0; - virtual void Disable(DevicestatusDataUtils::DevicestatusType type) = 0; - virtual void DisableCount(DevicestatusDataUtils::DevicestatusType type) = 0; + virtual void Enable(DeviceStatusDataUtils::DeviceStatusType type) = 0; + virtual void Disable(DeviceStatusDataUtils::DeviceStatusType type) = 0; + virtual void DisableCount(DeviceStatusDataUtils::DeviceStatusType type) = 0; }; struct MsdpAlgorithmHandle { void* handle; - DevicestatusMsdpInterface* (*create)(); - void* (*destroy)(DevicestatusMsdpInterface*); - DevicestatusMsdpInterface* pAlgorithm; + DeviceStatusMsdpInterface* (*create)(); + void* (*destroy)(DeviceStatusMsdpInterface*); + DeviceStatusMsdpInterface* pAlgorithm; MsdpAlgorithmHandle() : handle(nullptr), create(nullptr), destroy(nullptr), pAlgorithm(nullptr) {} ~MsdpAlgorithmHandle() {} void Clear() diff --git a/libs/src/devicestatus_data_parse.cpp b/libs/src/devicestatus_data_parse.cpp index 2bc742307..48439d550 100644 --- a/libs/src/devicestatus_data_parse.cpp +++ b/libs/src/devicestatus_data_parse.cpp @@ -27,11 +27,11 @@ const std::string MSDP_DATA_DIR = "/data/msdp"; } // namespace std::vector DeviceStatusDataParse::tempcount_ = - std::vector (static_cast(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN), - static_cast(DevicestatusDataUtils::Value::INVALID)); + std::vector (static_cast(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN), + static_cast(DeviceStatusDataUtils::Value::INVALID)); -bool DeviceStatusDataParse::ParseDeviceStatusData(DevicestatusDataUtils::DevicestatusData& data, - DevicestatusDataUtils::DevicestatusType& type) +bool DeviceStatusDataParse::ParseDeviceStatusData(DeviceStatusDataUtils::DeviceStatusData& data, + DeviceStatusDataUtils::DeviceStatusType& type) { std::string jsonBuf = ReadJsonFile(MSDP_DATA_PATH.c_str()); if (jsonBuf.empty()) { @@ -41,20 +41,20 @@ bool DeviceStatusDataParse::ParseDeviceStatusData(DevicestatusDataUtils::Devices } bool DeviceStatusDataParse::DataInit(const std::string& fileData, bool logStatus, - DevicestatusDataUtils::DevicestatusType& type, DevicestatusDataUtils::DevicestatusData& data) + DeviceStatusDataUtils::DeviceStatusType& type, DeviceStatusDataUtils::DeviceStatusData& data) { DEV_HILOGD(SERVICE, "Enter"); JsonParser parser; parser.json_ = cJSON_Parse(fileData.c_str()); data.type = type; - data.value = DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID; + data.value = DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID; if (cJSON_IsArray(parser.json_)) { DEV_HILOGE(SERVICE, "parser is array"); return false; } - if (type < DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL || - type >= DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN) { + if (type < DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL || + type >= DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN) { DEV_HILOGE(SERVICE, "Type error"); return false; } @@ -70,16 +70,16 @@ bool DeviceStatusDataParse::DataInit(const std::string& fileData, bool logStatus return false; } tempcount_[type]++; - data.value = static_cast(mockvalue->valueint); + data.value = static_cast(mockvalue->valueint); DEV_HILOGD(SERVICE, "type:%{public}d, status:%{public}d", data.type, data.value); return true; } -bool DeviceStatusDataParse::DisableCount(const DevicestatusDataUtils::DevicestatusType& type) +bool DeviceStatusDataParse::DisableCount(const DeviceStatusDataUtils::DeviceStatusType& type) { DEV_HILOGD(SERVICE, "Enter"); tempcount_[static_cast(type)] = - static_cast(DevicestatusDataUtils::DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID); + static_cast(DeviceStatusDataUtils::DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID); return true; } diff --git a/libs/src/devicestatus_msdp_mock.cpp b/libs/src/devicestatus_msdp_mock.cpp index 512887e2c..6ce8b45ff 100644 --- a/libs/src/devicestatus_msdp_mock.cpp +++ b/libs/src/devicestatus_msdp_mock.cpp @@ -37,8 +37,8 @@ DeviceStatusMsdpMock* g_msdpMock = nullptr; } // namespace std::vector DeviceStatusMsdpMock::enabledType_ = - std::vector (static_cast(DevicestatusDataUtils::DevicestatusType::TYPE_MAX), - static_cast(DevicestatusDataUtils::Value::INVALID)); + std::vector (static_cast(DeviceStatusDataUtils::DeviceStatusType::TYPE_MAX), + static_cast(DeviceStatusDataUtils::Value::INVALID)); bool DeviceStatusMsdpMock::Init() { @@ -67,19 +67,19 @@ void DeviceStatusMsdpMock::UnregisterCallback() callback_ = nullptr; } -void DeviceStatusMsdpMock::Enable(DevicestatusDataUtils::DevicestatusType type) +void DeviceStatusMsdpMock::Enable(DeviceStatusDataUtils::DeviceStatusType type) { DEV_HILOGD(SERVICE, "Enter"); - if (type < DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL || - type >= DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN) { + if (type < DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL || + type >= DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN) { DEV_HILOGE(SERVICE, "Type error"); } - enabledType_[type] = static_cast(DevicestatusDataUtils::Value::VALID); + enabledType_[type] = static_cast(DeviceStatusDataUtils::Value::VALID); Init(); DEV_HILOGD(SERVICE, "Exit"); } -void DeviceStatusMsdpMock::Disable(DevicestatusDataUtils::DevicestatusType type) +void DeviceStatusMsdpMock::Disable(DeviceStatusDataUtils::DeviceStatusType type) { DEV_HILOGD(SERVICE, "Enter"); scFlag_ = false; @@ -87,15 +87,15 @@ void DeviceStatusMsdpMock::Disable(DevicestatusDataUtils::DevicestatusType type) DEV_HILOGD(SERVICE, "Exit"); } -void DeviceStatusMsdpMock::DisableCount(DevicestatusDataUtils::DevicestatusType type) +void DeviceStatusMsdpMock::DisableCount(DeviceStatusDataUtils::DeviceStatusType type) { DEV_HILOGD(SERVICE, "Enter"); - enabledType_[type] = static_cast(DevicestatusDataUtils::Value::INVALID); + enabledType_[type] = static_cast(DeviceStatusDataUtils::Value::INVALID); dataParse_->DisableCount(type); DEV_HILOGD(SERVICE, "Exit"); } -ErrCode DeviceStatusMsdpMock::NotifyMsdpImpl(const DevicestatusDataUtils::DevicestatusData& data) +ErrCode DeviceStatusMsdpMock::NotifyMsdpImpl(const DeviceStatusDataUtils::DeviceStatusData& data) { DEV_HILOGD(SERVICE, "Enter"); if (g_msdpMock == nullptr) { @@ -177,11 +177,11 @@ void DeviceStatusMsdpMock::TimerCallback() void DeviceStatusMsdpMock::GetDeviceStatusData() { - DevicestatusDataUtils::DevicestatusData data; - for (int32_t i = int(DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL); - i <= DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN; ++i) { - if (enabledType_[i] == static_cast(DevicestatusDataUtils::Value::VALID)) { - DevicestatusDataUtils::DevicestatusType type = DevicestatusDataUtils::DevicestatusType(i); + DeviceStatusDataUtils::DeviceStatusData data; + for (int32_t i = int(DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL); + i <= DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN; ++i) { + if (enabledType_[i] == static_cast(DeviceStatusDataUtils::Value::VALID)) { + DeviceStatusDataUtils::DeviceStatusType type = DeviceStatusDataUtils::DeviceStatusType(i); DEV_HILOGE(SERVICE, "type:%{public}d", type); if (dataParse_ == nullptr) { DEV_HILOGE(SERVICE, "dataParse_ is nullptr"); @@ -240,14 +240,14 @@ void DeviceStatusMsdpMock::LoopingThreadEntry() } } -extern "C" DevicestatusMsdpInterface *Create(void) +extern "C" DeviceStatusMsdpInterface *Create(void) { DEV_HILOGI(SERVICE, "Enter"); g_msdpMock = new DeviceStatusMsdpMock(); return g_msdpMock; } -extern "C" void Destroy(const DevicestatusMsdpInterface* algorithm) +extern "C" void Destroy(const DeviceStatusMsdpInterface* algorithm) { DEV_HILOGI(SERVICE, "Enter"); delete algorithm; diff --git a/services/native/include/devicestatus_dumper.h b/services/native/include/devicestatus_dumper.h index a4dcf2de8..a712d27d6 100644 --- a/services/native/include/devicestatus_dumper.h +++ b/services/native/include/devicestatus_dumper.h @@ -46,34 +46,34 @@ struct AppInfo { int32_t pid = 0; Security::AccessToken::AccessTokenID tokenId; std::string packageName; - DevicestatusDataUtils::DevicestatusType type; + DeviceStatusDataUtils::DeviceStatusType type; sptr callback; }; struct DeviceStatusRecord { std::string startTime; - DevicestatusDataUtils::DevicestatusData data; + DeviceStatusDataUtils::DeviceStatusData data; }; -class DevicestatusDumper final : public RefBase, - public Singleton { +class DeviceStatusDumper final : public RefBase, + public Singleton { public: - DevicestatusDumper() = default; - ~DevicestatusDumper() = default; + DeviceStatusDumper() = default; + ~DeviceStatusDumper() = default; void ParseCommand(int32_t fd, const std::vector &args, - const std::vector &datas); + const std::vector &datas); void DumpHelpInfo(int32_t fd) const; - void DumpDevicestatusSubscriber(int32_t fd); - void DumpDevicestatusChanges(int32_t fd); - void DumpDevicestatusCurrentStatus(int32_t fd, - const std::vector &datas) const; + void DumpDeviceStatusSubscriber(int32_t fd); + void DumpDeviceStatusChanges(int32_t fd); + void DumpDeviceStatusCurrentStatus(int32_t fd, + const std::vector &datas) const; void SaveAppInfo(std::shared_ptr appInfo); void RemoveAppInfo(std::shared_ptr appInfo); - void pushDeviceStatus(const DevicestatusDataUtils::DevicestatusData& data); + void pushDeviceStatus(const DeviceStatusDataUtils::DeviceStatusData& data); private: - DISALLOW_COPY_AND_MOVE(DevicestatusDumper); + DISALLOW_COPY_AND_MOVE(DeviceStatusDumper); void DumpCurrentTime(std::string &startTime) const; - std::string GetStatusType(const DevicestatusDataUtils::DevicestatusType &type) const; - std::string GetDeviceState(const DevicestatusDataUtils::DevicestatusValue &type) const; - std::map>> \ + std::string GetStatusType(const DeviceStatusDataUtils::DeviceStatusType &type) const; + std::string GetDeviceState(const DeviceStatusDataUtils::DeviceStatusValue &type) const; + std::map>> \ appInfoMap_; std::queue> deviceStatusQueue_; std::mutex mutex_; diff --git a/services/native/include/devicestatus_manager.h b/services/native/include/devicestatus_manager.h index 0320bdb4f..823e113f2 100644 --- a/services/native/include/devicestatus_manager.h +++ b/services/native/include/devicestatus_manager.h @@ -31,33 +31,33 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { using namespace Security::AccessToken; -class DevicestatusService; -class DevicestatusManager { +class DeviceStatusService; +class DeviceStatusManager { public: - explicit DevicestatusManager(const wptr& ms) : ms_(ms) + explicit DeviceStatusManager(const wptr& ms) : ms_(ms) { - DEV_HILOGI(SERVICE, "DevicestatusManager instance is created."); + DEV_HILOGI(SERVICE, "DeviceStatusManager instance is created."); } - ~DevicestatusManager() = default; + ~DeviceStatusManager() = default; - class DevicestatusCallbackDeathRecipient : public IRemoteObject::DeathRecipient { + class DeviceStatusCallbackDeathRecipient : public IRemoteObject::DeathRecipient { public: - DevicestatusCallbackDeathRecipient() = default; + DeviceStatusCallbackDeathRecipient() = default; virtual void OnRemoteDied(const wptr &remote); - virtual ~DevicestatusCallbackDeathRecipient() = default; + virtual ~DeviceStatusCallbackDeathRecipient() = default; }; bool Init(); - bool EnableMock(DevicestatusDataUtils::DevicestatusType type); - bool InitInterface(DevicestatusDataUtils::DevicestatusType type); - bool DisableMock(DevicestatusDataUtils::DevicestatusType type); + bool EnableMock(DeviceStatusDataUtils::DeviceStatusType type); + bool InitInterface(DeviceStatusDataUtils::DeviceStatusType type); + bool DisableMock(DeviceStatusDataUtils::DeviceStatusType type); bool InitDataCallback(); - void NotifyDevicestatusChange(const DevicestatusDataUtils::DevicestatusData& devicestatusData); - void Subscribe(const DevicestatusDataUtils::DevicestatusType& type, const sptr& callback); - void Unsubscribe(const DevicestatusDataUtils::DevicestatusType& type, const sptr& callback); - DevicestatusDataUtils::DevicestatusData GetLatestDevicestatusData(const \ - DevicestatusDataUtils::DevicestatusType& type); - int32_t MsdpDataCallback(const DevicestatusDataUtils::DevicestatusData& data); + void NotifyDeviceStatusChange(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData); + void Subscribe(const DeviceStatusDataUtils::DeviceStatusType& type, const sptr& callback); + void Unsubscribe(const DeviceStatusDataUtils::DeviceStatusType& type, const sptr& callback); + DeviceStatusDataUtils::DeviceStatusData GetLatestDeviceStatusData(const \ + DeviceStatusDataUtils::DeviceStatusType& type); + int32_t MsdpDataCallback(const DeviceStatusDataUtils::DeviceStatusData& data); int32_t LoadAlgorithm(bool bCreate); int32_t UnloadAlgorithm(bool bCreate); void GetPackageName(AccessTokenID tokenId, std::string &packageName); @@ -69,12 +69,12 @@ private: return l->AsObject() < r->AsObject(); } }; - const wptr ms_; + const wptr ms_; std::mutex mutex_; sptr devicestatusCBDeathRecipient_; - std::unique_ptr msdpImpl_; - std::map msdpData_; - std::map, classcomp>> \ + std::unique_ptr msdpImpl_; + std::map msdpData_; + std::map, classcomp>> \ listenerMap_; }; } // namespace DeviceStatus diff --git a/services/native/include/devicestatus_msdp_client_impl.h b/services/native/include/devicestatus_msdp_client_impl.h index 427a8e0ed..a395898d3 100644 --- a/services/native/include/devicestatus_msdp_client_impl.h +++ b/services/native/include/devicestatus_msdp_client_impl.h @@ -38,28 +38,28 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DevicestatusMsdpClientImpl : public DevicestatusMsdpInterface::MsdpAlgorithmCallback { +class DeviceStatusMsdpClientImpl : public DeviceStatusMsdpInterface::MsdpAlgorithmCallback { public: - using CallbackManager = std::function; + using CallbackManager = std::function; - ErrCode InitMsdpImpl(DevicestatusDataUtils::DevicestatusType type); - ErrCode DisableMsdpImpl(DevicestatusDataUtils::DevicestatusType type); + ErrCode InitMsdpImpl(DeviceStatusDataUtils::DeviceStatusType type); + ErrCode DisableMsdpImpl(DeviceStatusDataUtils::DeviceStatusType type); ErrCode RegisterImpl(const CallbackManager& callback); ErrCode UnregisterImpl(); - int32_t MsdpCallback(const DevicestatusDataUtils::DevicestatusData& data); + int32_t MsdpCallback(const DeviceStatusDataUtils::DeviceStatusData& data); ErrCode RegisterMsdp(); ErrCode UnregisterMsdp(void); - DevicestatusDataUtils::DevicestatusData SaveObserverData(const DevicestatusDataUtils::DevicestatusData& data); - std::map GetObserverData() const; + DeviceStatusDataUtils::DeviceStatusData SaveObserverData(const DeviceStatusDataUtils::DeviceStatusData& data); + std::map GetObserverData() const; int32_t LoadAlgorithmLibrary(bool bCreate); int32_t UnloadAlgorithmLibrary(bool bCreate); private: - ErrCode ImplCallback(const DevicestatusDataUtils::DevicestatusData& data); - DevicestatusMsdpInterface* GetAlgorithmInst(); + ErrCode ImplCallback(const DeviceStatusDataUtils::DeviceStatusData& data); + DeviceStatusMsdpInterface* GetAlgorithmInst(); MsdpAlgorithmHandle mAlgorithm_; std::mutex mMutex_; bool notifyManagerFlag_ = false; - void OnResult(const DevicestatusDataUtils::DevicestatusData& data) override; + void OnResult(const DeviceStatusDataUtils::DeviceStatusData& data) override; }; } // namespace DeviceStatus } // Msdp diff --git a/services/native/include/devicestatus_service.h b/services/native/include/devicestatus_service.h index aa54e0964..6d61b5dc5 100644 --- a/services/native/include/devicestatus_service.h +++ b/services/native/include/devicestatus_service.h @@ -39,12 +39,12 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { enum class ServiceRunningState {STATE_NOT_START, STATE_RUNNING, STATE_EXIT}; -class DevicestatusService final : public IContext, +class DeviceStatusService final : public IContext, public UDSServer, public SystemAbility, - public DevicestatusSrvStub { - DECLARE_SYSTEM_ABILITY(DevicestatusService) - DECLARE_DELAYED_SP_SINGLETON(DevicestatusService); + public DeviceStatusSrvStub { + DECLARE_SYSTEM_ABILITY(DeviceStatusService) + DECLARE_DELAYED_SP_SINGLETON(DeviceStatusService); public: virtual void OnDump() override; @@ -94,11 +94,11 @@ public: void SetAbsolutionLocation(double xPercent, double yPercent) override {} - void Subscribe(const DevicestatusDataUtils::DevicestatusType& type, + void Subscribe(const DeviceStatusDataUtils::DeviceStatusType& type, const sptr& callback) override; - void Unsubscribe(const DevicestatusDataUtils::DevicestatusType& type, + void Unsubscribe(const DeviceStatusDataUtils::DeviceStatusType& type, const sptr& callback) override; - DevicestatusDataUtils::DevicestatusData GetCache(const DevicestatusDataUtils::DevicestatusType& type) override; + DeviceStatusDataUtils::DeviceStatusData GetCache(const DeviceStatusDataUtils::DeviceStatusType& type) override; int32_t RegisterCoordinationListener() override; int32_t UnregisterCoordinationListener() override; @@ -109,7 +109,7 @@ public: int32_t GetInputDeviceCoordinationState(int32_t userData, const std::string &deviceId) override; int Dump(int fd, const std::vector& args) override; - void ReportMsdpSysEvent(const DevicestatusDataUtils::DevicestatusType& type, bool enable); + void ReportMsdpSysEvent(const DeviceStatusDataUtils::DeviceStatusType& type, bool enable); int32_t AllocSocketFd(const std::string &programName, const int32_t moduleType, int32_t &toReturnClientFd, int32_t &tokenType) override; @@ -150,8 +150,8 @@ private: #ifdef OHOS_BUILD_ENABLE_COOPERATE CoordinationEventHandler coordinationHandler; #endif // OHOS_BUILD_ENABLE_COOPERATE - std::shared_ptr devicestatusManager_; - std::shared_ptr msdpImpl_; + std::shared_ptr devicestatusManager_; + std::shared_ptr msdpImpl_; }; } // namespace DeviceStatus } // namespace Msdp diff --git a/services/native/include/devicestatus_srv_stub.h b/services/native/include/devicestatus_srv_stub.h index 8c1da39cd..ff4ac9011 100644 --- a/services/native/include/devicestatus_srv_stub.h +++ b/services/native/include/devicestatus_srv_stub.h @@ -26,18 +26,18 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DevicestatusSrvStub : public IRemoteStub { +class DeviceStatusSrvStub : public IRemoteStub { public: - DevicestatusSrvStub() = default; - virtual ~DevicestatusSrvStub() = default; - DISALLOW_COPY_AND_MOVE(DevicestatusSrvStub); + DeviceStatusSrvStub() = default; + virtual ~DeviceStatusSrvStub() = default; + DISALLOW_COPY_AND_MOVE(DeviceStatusSrvStub); int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; int32_t StubHandleAllocSocketFd(MessageParcel& data, MessageParcel& reply); private: int32_t SubscribeStub(MessageParcel& data); int32_t UnsubscribeStub(MessageParcel& data); - int32_t GetLatestDevicestatusDataStub(MessageParcel& data, MessageParcel& reply); + int32_t GetLatestDeviceStatusDataStub(MessageParcel& data, MessageParcel& reply); int32_t StubRegisterCoordinationMonitor(MessageParcel& data, MessageParcel& reply); int32_t StubUnregisterCoordinationMonitor(MessageParcel& data, MessageParcel& reply); diff --git a/services/native/src/devicestatus_dumper.cpp b/services/native/src/devicestatus_dumper.cpp index 7307fc07c..51f35d0ff 100644 --- a/services/native/src/devicestatus_dumper.cpp +++ b/services/native/src/devicestatus_dumper.cpp @@ -35,8 +35,8 @@ namespace DeviceStatus { namespace { constexpr uint32_t MS_NS = 1000000; } -void DevicestatusDumper::ParseCommand(int32_t fd, const std::vector &args, - const std::vector &datas) +void DeviceStatusDumper::ParseCommand(int32_t fd, const std::vector &args, + const std::vector &datas) { int32_t optionIndex = 0; struct option dumpOptions[] = { @@ -64,15 +64,15 @@ void DevicestatusDumper::ParseCommand(int32_t fd, const std::vector break; } case 's': { - DumpDevicestatusSubscriber(fd); + DumpDeviceStatusSubscriber(fd); break; } case 'l': { - DumpDevicestatusChanges(fd); + DumpDeviceStatusChanges(fd); break; } case 'c': { - DumpDevicestatusCurrentStatus(fd, datas); + DumpDeviceStatusCurrentStatus(fd, datas); break; } default: { @@ -89,7 +89,7 @@ void DevicestatusDumper::ParseCommand(int32_t fd, const std::vector delete[] argv; } -void DevicestatusDumper::DumpDevicestatusSubscriber(int32_t fd) +void DeviceStatusDumper::DumpDeviceStatusSubscriber(int32_t fd) { DEV_HILOGI(SERVICE, "start"); if (appInfoMap_.empty()) { @@ -108,7 +108,7 @@ void DevicestatusDumper::DumpDevicestatusSubscriber(int32_t fd) } } -void DevicestatusDumper::DumpDevicestatusChanges(int32_t fd) +void DeviceStatusDumper::DumpDeviceStatusChanges(int32_t fd) { DEV_HILOGI(SERVICE, "start"); if (deviceStatusQueue_.empty()) { @@ -134,8 +134,8 @@ void DevicestatusDumper::DumpDevicestatusChanges(int32_t fd) } } -void DevicestatusDumper::DumpDevicestatusCurrentStatus(int32_t fd, - const std::vector &datas) const +void DeviceStatusDumper::DumpDeviceStatusCurrentStatus(int32_t fd, + const std::vector &datas) const { DEV_HILOGI(SERVICE, "start"); std::string startTime; @@ -147,27 +147,27 @@ void DevicestatusDumper::DumpDevicestatusCurrentStatus(int32_t fd, return; } for (auto it = datas.begin(); it != datas.end(); ++it) { - if (it->value == DevicestatusDataUtils::VALUE_INVALID) { + if (it->value == DeviceStatusDataUtils::VALUE_INVALID) { continue; } - dprintf(fd, "Device status DevicestatusType is %s , current type state is %s .\n", + dprintf(fd, "Device status DeviceStatusType is %s , current type state is %s .\n", GetStatusType(it->type).c_str(), GetDeviceState(it->value).c_str()); } } -std::string DevicestatusDumper::GetDeviceState(const DevicestatusDataUtils::DevicestatusValue &value) const +std::string DeviceStatusDumper::GetDeviceState(const DeviceStatusDataUtils::DeviceStatusValue &value) const { std::string state; switch (value) { - case DevicestatusDataUtils::VALUE_ENTER: { + case DeviceStatusDataUtils::VALUE_ENTER: { state = "enter"; break; } - case DevicestatusDataUtils::VALUE_EXIT: { + case DeviceStatusDataUtils::VALUE_EXIT: { state = "exit"; break; } - case DevicestatusDataUtils::VALUE_INVALID: { + case DeviceStatusDataUtils::VALUE_INVALID: { state = "invalid"; break; } @@ -179,23 +179,23 @@ std::string DevicestatusDumper::GetDeviceState(const DevicestatusDataUtils::Devi return state; } -std::string DevicestatusDumper::GetStatusType(const DevicestatusDataUtils::DevicestatusType &type) const +std::string DeviceStatusDumper::GetStatusType(const DeviceStatusDataUtils::DeviceStatusType &type) const { std::string stateType; switch (type) { - case DevicestatusDataUtils::TYPE_HIGH_STILL: { + case DeviceStatusDataUtils::TYPE_HIGH_STILL: { stateType = "high still"; break; } - case DevicestatusDataUtils::TYPE_FINE_STILL: { + case DeviceStatusDataUtils::TYPE_FINE_STILL: { stateType = "fine still"; break; } - case DevicestatusDataUtils::TYPE_CAR_BLUETOOTH: { + case DeviceStatusDataUtils::TYPE_CAR_BLUETOOTH: { stateType = "car bluetooth"; break; } - case DevicestatusDataUtils::TYPE_LID_OPEN: { + case DeviceStatusDataUtils::TYPE_LID_OPEN: { stateType = "lid open"; break; } @@ -207,7 +207,7 @@ std::string DevicestatusDumper::GetStatusType(const DevicestatusDataUtils::Devic return stateType; } -void DevicestatusDumper::DumpCurrentTime(std::string &startTime) const +void DeviceStatusDumper::DumpCurrentTime(std::string &startTime) const { timespec curTime; clock_gettime(CLOCK_REALTIME, &curTime); @@ -223,7 +223,7 @@ void DevicestatusDumper::DumpCurrentTime(std::string &startTime) const .append(std::to_string(curTime.tv_nsec / MS_NS)); } -void DevicestatusDumper::DumpHelpInfo(int32_t fd) const +void DeviceStatusDumper::DumpHelpInfo(int32_t fd) const { dprintf(fd, "Usage:\n"); dprintf(fd, " -h: dump help\n"); @@ -232,7 +232,7 @@ void DevicestatusDumper::DumpHelpInfo(int32_t fd) const dprintf(fd, " -c: dump the device_status current device status\n"); } -void DevicestatusDumper::SaveAppInfo(std::shared_ptr appInfo) +void DeviceStatusDumper::SaveAppInfo(std::shared_ptr appInfo) { DEV_HILOGI(SERVICE, "Enter"); DumpCurrentTime(appInfo->startTime); @@ -249,7 +249,7 @@ void DevicestatusDumper::SaveAppInfo(std::shared_ptr appInfo) } } -void DevicestatusDumper::RemoveAppInfo(std::shared_ptr appInfo) +void DeviceStatusDumper::RemoveAppInfo(std::shared_ptr appInfo) { DEV_HILOGI(SERVICE, "Enter"); if (appInfo->callback == nullptr) { @@ -278,7 +278,7 @@ void DevicestatusDumper::RemoveAppInfo(std::shared_ptr appInfo) } } -void DevicestatusDumper::pushDeviceStatus(const DevicestatusDataUtils::DevicestatusData& data) +void DeviceStatusDumper::pushDeviceStatus(const DeviceStatusDataUtils::DeviceStatusData& data) { DEV_HILOGI(SERVICE, "Enter"); std::unique_lock lock(mutex_); diff --git a/services/native/src/devicestatus_manager.cpp b/services/native/src/devicestatus_manager.cpp index a0994a07e..85bab3bd6 100644 --- a/services/native/src/devicestatus_manager.cpp +++ b/services/native/src/devicestatus_manager.cpp @@ -23,7 +23,7 @@ namespace { constexpr int32_t ERR_OK = 0; constexpr int32_t ERR_NG = -1; } -void DevicestatusManager::DevicestatusCallbackDeathRecipient::OnRemoteDied(const wptr& remote) +void DeviceStatusManager::DeviceStatusCallbackDeathRecipient::OnRemoteDied(const wptr& remote) { if (remote == nullptr) { DEV_HILOGE(SERVICE, "OnRemoteDied failed, remote is nullptr"); @@ -32,32 +32,32 @@ void DevicestatusManager::DevicestatusCallbackDeathRecipient::OnRemoteDied(const DEV_HILOGD(SERVICE, "Recv death notice"); } -bool DevicestatusManager::Init() +bool DeviceStatusManager::Init() { DEV_HILOGI(SERVICE, "Enter"); if (devicestatusCBDeathRecipient_ == nullptr) { - devicestatusCBDeathRecipient_ = new (std::nothrow) DevicestatusCallbackDeathRecipient(); + devicestatusCBDeathRecipient_ = new (std::nothrow) DeviceStatusCallbackDeathRecipient(); if (devicestatusCBDeathRecipient_ == nullptr) { DEV_HILOGE(SERVICE, "devicestatusCBDeathRecipient_ is nullptr"); return false; } } - msdpImpl_ = std::make_unique(); + msdpImpl_ = std::make_unique(); LoadAlgorithm(false); DEV_HILOGI(SERVICE, "Init success"); return true; } -DevicestatusDataUtils::DevicestatusData DevicestatusManager::GetLatestDevicestatusData(const \ - DevicestatusDataUtils::DevicestatusType& type) +DeviceStatusDataUtils::DeviceStatusData DeviceStatusManager::GetLatestDeviceStatusData(const \ + DeviceStatusDataUtils::DeviceStatusType& type) { DEV_HILOGI(SERVICE, "Enter"); - DevicestatusDataUtils::DevicestatusData data = {type, DevicestatusDataUtils::DevicestatusValue::VALUE_EXIT}; + DeviceStatusDataUtils::DeviceStatusData data = {type, DeviceStatusDataUtils::DeviceStatusValue::VALUE_EXIT}; if (msdpImpl_ == nullptr) { DEV_HILOGI(SERVICE, "GetObserverData func is nullptr,return default!"); - data.value = DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID; + data.value = DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID; return data; } msdpData_ = msdpImpl_->GetObserverData(); @@ -68,11 +68,11 @@ DevicestatusDataUtils::DevicestatusData DevicestatusManager::GetLatestDevicestat } } - data.value = DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID; + data.value = DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID; return data; } -bool DevicestatusManager::EnableMock(DevicestatusDataUtils::DevicestatusType type) +bool DeviceStatusManager::EnableMock(DeviceStatusDataUtils::DeviceStatusType type) { DEV_HILOGE(SERVICE, "Enter"); if (!InitInterface(type)) { @@ -87,7 +87,7 @@ bool DevicestatusManager::EnableMock(DevicestatusDataUtils::DevicestatusType typ return true; } -bool DevicestatusManager::DisableMock(DevicestatusDataUtils::DevicestatusType type) +bool DeviceStatusManager::DisableMock(DeviceStatusDataUtils::DeviceStatusType type) { DEV_HILOGE(SERVICE, "Enter"); if (msdpImpl_ == nullptr) { @@ -108,7 +108,7 @@ bool DevicestatusManager::DisableMock(DevicestatusDataUtils::DevicestatusType ty return true; } -bool DevicestatusManager::InitInterface(DevicestatusDataUtils::DevicestatusType type) +bool DeviceStatusManager::InitInterface(DeviceStatusDataUtils::DeviceStatusType type) { DEV_HILOGE(SERVICE, "Enter"); if (msdpImpl_ == nullptr) { @@ -121,28 +121,28 @@ bool DevicestatusManager::InitInterface(DevicestatusDataUtils::DevicestatusType return true; } -bool DevicestatusManager::InitDataCallback() +bool DeviceStatusManager::InitDataCallback() { DEV_HILOGE(SERVICE, "Enter"); if (msdpImpl_ == nullptr) { DEV_HILOGE(SERVICE, "msdpImpl_ is nullptr"); return false; } - DevicestatusMsdpClientImpl::CallbackManager callback = - std::bind(&DevicestatusManager::MsdpDataCallback, this, std::placeholders::_1); + DeviceStatusMsdpClientImpl::CallbackManager callback = + std::bind(&DeviceStatusManager::MsdpDataCallback, this, std::placeholders::_1); if (msdpImpl_->RegisterImpl(callback) == ERR_NG) { DEV_HILOGE(SERVICE, "register impl failed"); } return true; } -int32_t DevicestatusManager::MsdpDataCallback(const DevicestatusDataUtils::DevicestatusData& data) +int32_t DeviceStatusManager::MsdpDataCallback(const DeviceStatusDataUtils::DeviceStatusData& data) { - NotifyDevicestatusChange(data); + NotifyDeviceStatusChange(data); return ERR_OK; } -void DevicestatusManager::NotifyDevicestatusChange(const DevicestatusDataUtils::DevicestatusData& devicestatusData) +void DeviceStatusManager::NotifyDeviceStatusChange(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) { DEV_HILOGI(SERVICE, "Enter"); @@ -165,12 +165,12 @@ void DevicestatusManager::NotifyDevicestatusChange(const DevicestatusDataUtils:: DEV_HILOGI(SERVICE, "Listener is nullptr"); return; } - listener->OnDevicestatusChanged(devicestatusData); + listener->OnDeviceStatusChanged(devicestatusData); } DEV_HILOGI(SERVICE, "Exit"); } -void DevicestatusManager::Subscribe(const DevicestatusDataUtils::DevicestatusType& type, +void DeviceStatusManager::Subscribe(const DeviceStatusDataUtils::DeviceStatusType& type, const sptr& callback) { DEV_HILOGI(SERVICE, "Enter"); @@ -209,7 +209,7 @@ void DevicestatusManager::Subscribe(const DevicestatusDataUtils::DevicestatusTyp DEV_HILOGI(SERVICE, "Subscribe success,Exit"); } -void DevicestatusManager::Unsubscribe(const DevicestatusDataUtils::DevicestatusType& type, +void DeviceStatusManager::Unsubscribe(const DeviceStatusDataUtils::DeviceStatusType& type, const sptr& callback) { DEV_HILOGI(SERVICE, "Enter"); @@ -244,7 +244,7 @@ void DevicestatusManager::Unsubscribe(const DevicestatusDataUtils::DevicestatusT DEV_HILOGI(SERVICE, "Unsubscribe success,Exit"); } -int32_t DevicestatusManager::LoadAlgorithm(bool bCreate) +int32_t DeviceStatusManager::LoadAlgorithm(bool bCreate) { DEV_HILOGI(SERVICE, "Enter"); if (msdpImpl_ != nullptr) { @@ -254,7 +254,7 @@ int32_t DevicestatusManager::LoadAlgorithm(bool bCreate) return ERR_OK; } -int32_t DevicestatusManager::UnloadAlgorithm(bool bCreate) +int32_t DeviceStatusManager::UnloadAlgorithm(bool bCreate) { DEV_HILOGI(SERVICE, "Enter"); if (msdpImpl_ != nullptr) { @@ -264,7 +264,7 @@ int32_t DevicestatusManager::UnloadAlgorithm(bool bCreate) return ERR_OK; } -void DevicestatusManager::GetPackageName(AccessTokenID tokenId, std::string &packageName) +void DeviceStatusManager::GetPackageName(AccessTokenID tokenId, std::string &packageName) { int32_t tokenType = AccessTokenKit::GetTokenTypeFlag(tokenId); switch (tokenType) { diff --git a/services/native/src/devicestatus_msdp_client_impl.cpp b/services/native/src/devicestatus_msdp_client_impl.cpp index e378b36b9..80dec311d 100644 --- a/services/native/src/devicestatus_msdp_client_impl.cpp +++ b/services/native/src/devicestatus_msdp_client_impl.cpp @@ -35,14 +35,14 @@ constexpr int32_t ERR_OK = 0; constexpr int32_t ERR_NG = -1; const std::string DEVICESTATUS_SENSOR_HDI_LIB_PATH = "libdevicestatus_sensorhdi.z.so"; const std::string DEVICESTATUS_MSDP_ALGORITHM_LIB_PATH = "libdevicestatus_msdp.z.so"; -std::map g_devicestatusDataMap; -DevicestatusMsdpClientImpl::CallbackManager g_callbacksMgr; -using clientType = DevicestatusDataUtils::DevicestatusType; -using clientValue = DevicestatusDataUtils::DevicestatusValue; -DevicestatusMsdpInterface* g_msdpInterface; +std::map g_devicestatusDataMap; +DeviceStatusMsdpClientImpl::CallbackManager g_callbacksMgr; +using clientType = DeviceStatusDataUtils::DeviceStatusType; +using clientValue = DeviceStatusDataUtils::DeviceStatusValue; +DeviceStatusMsdpInterface* g_msdpInterface; } -ErrCode DevicestatusMsdpClientImpl::InitMsdpImpl(DevicestatusDataUtils::DevicestatusType type) +ErrCode DeviceStatusMsdpClientImpl::InitMsdpImpl(DeviceStatusDataUtils::DeviceStatusType type) { DEV_HILOGI(SERVICE, "Enter"); if (g_msdpInterface == nullptr) { @@ -59,7 +59,7 @@ ErrCode DevicestatusMsdpClientImpl::InitMsdpImpl(DevicestatusDataUtils::Devicest return ERR_OK; } -ErrCode DevicestatusMsdpClientImpl::DisableMsdpImpl(DevicestatusDataUtils::DevicestatusType type) +ErrCode DeviceStatusMsdpClientImpl::DisableMsdpImpl(DeviceStatusDataUtils::DeviceStatusType type) { DEV_HILOGI(SERVICE, "Enter"); if (g_msdpInterface == nullptr) { @@ -72,7 +72,7 @@ ErrCode DevicestatusMsdpClientImpl::DisableMsdpImpl(DevicestatusDataUtils::Devic return ERR_OK; } -ErrCode DevicestatusMsdpClientImpl::RegisterImpl(const CallbackManager& callback) +ErrCode DeviceStatusMsdpClientImpl::RegisterImpl(const CallbackManager& callback) { DEV_HILOGI(SERVICE, "Enter"); g_callbacksMgr = callback; @@ -90,7 +90,7 @@ ErrCode DevicestatusMsdpClientImpl::RegisterImpl(const CallbackManager& callback return ERR_OK; } -ErrCode DevicestatusMsdpClientImpl::UnregisterImpl() +ErrCode DeviceStatusMsdpClientImpl::UnregisterImpl() { DEV_HILOGI(SERVICE, "Enter"); if (g_callbacksMgr == nullptr) { @@ -105,7 +105,7 @@ ErrCode DevicestatusMsdpClientImpl::UnregisterImpl() return ERR_OK; } -ErrCode DevicestatusMsdpClientImpl::ImplCallback(const DevicestatusDataUtils::DevicestatusData& data) +ErrCode DeviceStatusMsdpClientImpl::ImplCallback(const DeviceStatusDataUtils::DeviceStatusData& data) { if (g_callbacksMgr == nullptr) { DEV_HILOGI(SERVICE, "g_callbacksMgr is nullptr"); @@ -116,16 +116,16 @@ ErrCode DevicestatusMsdpClientImpl::ImplCallback(const DevicestatusDataUtils::De return ERR_OK; } -void DevicestatusMsdpClientImpl::OnResult(const DevicestatusDataUtils::DevicestatusData& data) +void DeviceStatusMsdpClientImpl::OnResult(const DeviceStatusDataUtils::DeviceStatusData& data) { MsdpCallback(data); } -ErrCode DevicestatusMsdpClientImpl::RegisterMsdp() +ErrCode DeviceStatusMsdpClientImpl::RegisterMsdp() { DEV_HILOGI(SERVICE, "Enter"); if (g_msdpInterface != nullptr) { - std::shared_ptr callback = std::make_shared(); + std::shared_ptr callback = std::make_shared(); g_msdpInterface->RegisterCallback(callback); } @@ -133,7 +133,7 @@ ErrCode DevicestatusMsdpClientImpl::RegisterMsdp() return ERR_OK; } -ErrCode DevicestatusMsdpClientImpl::UnregisterMsdp(void) +ErrCode DeviceStatusMsdpClientImpl::UnregisterMsdp(void) { DEV_HILOGI(SERVICE, "Enter"); @@ -149,10 +149,10 @@ ErrCode DevicestatusMsdpClientImpl::UnregisterMsdp(void) return ERR_OK; } -int32_t DevicestatusMsdpClientImpl::MsdpCallback(const DevicestatusDataUtils::DevicestatusData& data) +int32_t DeviceStatusMsdpClientImpl::MsdpCallback(const DeviceStatusDataUtils::DeviceStatusData& data) { DEV_HILOGI(SERVICE, "Enter"); - DevicestatusDumper::GetInstance().pushDeviceStatus(data); + DeviceStatusDumper::GetInstance().pushDeviceStatus(data); SaveObserverData(data); if (notifyManagerFlag_) { ImplCallback(data); @@ -162,8 +162,8 @@ int32_t DevicestatusMsdpClientImpl::MsdpCallback(const DevicestatusDataUtils::De return ERR_OK; } -DevicestatusDataUtils::DevicestatusData DevicestatusMsdpClientImpl::SaveObserverData( - const DevicestatusDataUtils::DevicestatusData& data) +DeviceStatusDataUtils::DeviceStatusData DeviceStatusMsdpClientImpl::SaveObserverData( + const DeviceStatusDataUtils::DeviceStatusData& data) { DEV_HILOGI(SERVICE, "Enter"); for (auto iter = g_devicestatusDataMap.begin(); iter != g_devicestatusDataMap.end(); ++iter) { @@ -180,13 +180,13 @@ DevicestatusDataUtils::DevicestatusData DevicestatusMsdpClientImpl::SaveObserver return data; } -std::map DevicestatusMsdpClientImpl::GetObserverData() const +std::map DeviceStatusMsdpClientImpl::GetObserverData() const { DEV_HILOGI(SERVICE, "Enter"); return g_devicestatusDataMap; } -int32_t DevicestatusMsdpClientImpl::LoadAlgorithmLibrary(bool bCreate) +int32_t DeviceStatusMsdpClientImpl::LoadAlgorithmLibrary(bool bCreate) { DEV_HILOGI(SERVICE, "Enter"); if (mAlgorithm_.handle != nullptr) { @@ -200,9 +200,9 @@ int32_t DevicestatusMsdpClientImpl::LoadAlgorithmLibrary(bool bCreate) } DEV_HILOGI(SERVICE, "start create pointer"); - mAlgorithm_.create = (DevicestatusMsdpInterface* (*)()) dlsym(mAlgorithm_.handle, "Create"); + mAlgorithm_.create = (DeviceStatusMsdpInterface* (*)()) dlsym(mAlgorithm_.handle, "Create"); DEV_HILOGI(SERVICE, "start destroy pointer"); - mAlgorithm_.destroy = (void *(*)(DevicestatusMsdpInterface*))dlsym(mAlgorithm_.handle, "Destroy"); + mAlgorithm_.destroy = (void *(*)(DeviceStatusMsdpInterface*))dlsym(mAlgorithm_.handle, "Destroy"); if (mAlgorithm_.create == nullptr || mAlgorithm_.destroy == nullptr) { DEV_HILOGE(SERVICE, "%{public}s dlsym Create or Destroy failed", @@ -221,7 +221,7 @@ int32_t DevicestatusMsdpClientImpl::LoadAlgorithmLibrary(bool bCreate) return ERR_OK; } -int32_t DevicestatusMsdpClientImpl::UnloadAlgorithmLibrary(bool bCreate) +int32_t DeviceStatusMsdpClientImpl::UnloadAlgorithmLibrary(bool bCreate) { DEV_HILOGI(SERVICE, "Enter"); if (mAlgorithm_.handle == nullptr) { @@ -242,7 +242,7 @@ int32_t DevicestatusMsdpClientImpl::UnloadAlgorithmLibrary(bool bCreate) return ERR_OK; } -DevicestatusMsdpInterface* DevicestatusMsdpClientImpl::GetAlgorithmInst() +DeviceStatusMsdpInterface* DeviceStatusMsdpClientImpl::GetAlgorithmInst() { DEV_HILOGI(SERVICE, "Enter"); if (mAlgorithm_.handle == nullptr) { diff --git a/services/native/src/devicestatus_service.cpp b/services/native/src/devicestatus_service.cpp index 9e87acc89..cc0840a9b 100644 --- a/services/native/src/devicestatus_service.cpp +++ b/services/native/src/devicestatus_service.cpp @@ -45,8 +45,8 @@ namespace Msdp { namespace DeviceStatus { using namespace OHOS::HiviewDFX; namespace { -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MSDP_DOMAIN_ID, "DevicestatusService" }; -auto ms = DelayedSpSingleton::GetInstance(); +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MSDP_DOMAIN_ID, "DeviceStatusService" }; +auto ms = DelayedSpSingleton::GetInstance(); const bool G_REGISTER_RESULT = SystemAbility::MakeAndRegisterAbility(ms.GetRefPtr()); } // namespace @@ -55,19 +55,19 @@ struct device_status_epoll_event { EpollEventType event_type { EPOLL_EVENT_BEGIN }; }; -DevicestatusService::DevicestatusService() : SystemAbility(MSDP_DEVICESTATUS_SERVICE_ID, true) +DeviceStatusService::DeviceStatusService() : SystemAbility(MSDP_DEVICESTATUS_SERVICE_ID, true) { DEV_HILOGD(SERVICE, "Add SystemAbility"); } -DevicestatusService::~DevicestatusService() {} +DeviceStatusService::~DeviceStatusService() {} -void DevicestatusService::OnDump() +void DeviceStatusService::OnDump() { DEV_HILOGI(SERVICE, "OnDump"); } -void DevicestatusService::OnStart() +void DeviceStatusService::OnStart() { DEV_HILOGI(SERVICE, "Enter"); if (ready_) { @@ -79,17 +79,17 @@ void DevicestatusService::OnStart() DEV_HILOGE(SERVICE, "OnStart call init fail"); return; } - if (!Publish(DelayedSpSingleton::GetInstance())) { + if (!Publish(DelayedSpSingleton::GetInstance())) { DEV_HILOGE(SERVICE, "OnStart register to system ability manager failed"); return; } state_ = ServiceRunningState::STATE_RUNNING; ready_ = true; - t_ = std::thread(std::bind(&DevicestatusService::OnThread, this)); + t_ = std::thread(std::bind(&DeviceStatusService::OnThread, this)); t_.join(); } -void DevicestatusService::OnStop() +void DeviceStatusService::OnStop() { DEV_HILOGI(SERVICE, "Enter"); if (!ready_) { @@ -105,29 +105,29 @@ void DevicestatusService::OnStop() DEV_HILOGI(SERVICE, "unload algorithm library exit"); } -IDelegateTasks& DevicestatusService::GetDelegateTasks() +IDelegateTasks& DeviceStatusService::GetDelegateTasks() { return delegateTasks_; } -IDeviceManager& DevicestatusService::GetDeviceManager() +IDeviceManager& DeviceStatusService::GetDeviceManager() { return devMgr_; } -ITimerManager& DevicestatusService::GetTimerManager() +ITimerManager& DeviceStatusService::GetTimerManager() { return timerMgr_; } -int DevicestatusService::Dump(int fd, const std::vector& args) +int DeviceStatusService::Dump(int fd, const std::vector& args) { DEV_HILOGI(SERVICE, "dump DeviceStatusServiceInfo"); if (fd < 0) { DEV_HILOGE(SERVICE, "fd is invalid"); return RET_NG; } - DevicestatusDumper &deviceStatusDumper = DevicestatusDumper::GetInstance(); + DeviceStatusDumper &deviceStatusDumper = DeviceStatusDumper::GetInstance(); if (args.empty()) { DEV_HILOGE(SERVICE, "param cannot be empty"); dprintf(fd, "param cannot be empty\n"); @@ -140,13 +140,13 @@ int DevicestatusService::Dump(int fd, const std::vector& args) return Str16ToStr8(arg); }); - DevicestatusDataUtils::DevicestatusType type; - std::vector datas; - for (type = DevicestatusDataUtils::TYPE_HIGH_STILL; - type <= DevicestatusDataUtils::TYPE_LID_OPEN; - type = (DevicestatusDataUtils::DevicestatusType)(type+1)) { - DevicestatusDataUtils::DevicestatusData data = GetCache(type); - if (data.value != DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID) { + DeviceStatusDataUtils::DeviceStatusType type; + std::vector datas; + for (type = DeviceStatusDataUtils::TYPE_HIGH_STILL; + type <= DeviceStatusDataUtils::TYPE_LID_OPEN; + type = (DeviceStatusDataUtils::DeviceStatusType)(type+1)) { + DeviceStatusDataUtils::DeviceStatusData data = GetCache(type); + if (data.value != DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID) { datas.emplace_back(data); } } @@ -154,12 +154,12 @@ int DevicestatusService::Dump(int fd, const std::vector& args) return RET_OK; } -bool DevicestatusService::Init() +bool DeviceStatusService::Init() { DEV_HILOGI(SERVICE, "Enter"); if (!devicestatusManager_) { - devicestatusManager_ = std::make_shared(ms); + devicestatusManager_ = std::make_shared(ms); } if (!devicestatusManager_->Init()) { DEV_HILOGE(SERVICE, "OnStart init fail"); @@ -190,7 +190,7 @@ INIT_FAIL: return false; } -void DevicestatusService::Subscribe(const DevicestatusDataUtils::DevicestatusType& type, +void DeviceStatusService::Subscribe(const DeviceStatusDataUtils::DeviceStatusType& type, const sptr& callback) { DEV_HILOGI(SERVICE, "Enter"); @@ -206,14 +206,14 @@ void DevicestatusService::Subscribe(const DevicestatusDataUtils::DevicestatusTyp devicestatusManager_->GetPackageName(appInfo->tokenId, appInfo->packageName); appInfo->type = type; appInfo->callback = callback; - DevicestatusDumper::GetInstance().SaveAppInfo(appInfo); + DeviceStatusDumper::GetInstance().SaveAppInfo(appInfo); StartTrace(HITRACE_TAG_MSDP, "serviceSubscribeStart"); devicestatusManager_->Subscribe(type, callback); FinishTrace(HITRACE_TAG_MSDP); ReportMsdpSysEvent(type, true); } -void DevicestatusService::Unsubscribe(const DevicestatusDataUtils::DevicestatusType& type, +void DeviceStatusService::Unsubscribe(const DeviceStatusDataUtils::DeviceStatusType& type, const sptr& callback) { DEV_HILOGI(SERVICE, "Enter"); @@ -229,27 +229,27 @@ void DevicestatusService::Unsubscribe(const DevicestatusDataUtils::DevicestatusT devicestatusManager_->GetPackageName(appInfo->tokenId, appInfo->packageName); appInfo->type = type; appInfo->callback = callback; - DevicestatusDumper::GetInstance().RemoveAppInfo(appInfo); + DeviceStatusDumper::GetInstance().RemoveAppInfo(appInfo); StartTrace(HITRACE_TAG_MSDP, "serviceUnsubscribeStart"); devicestatusManager_->Unsubscribe(type, callback); FinishTrace(HITRACE_TAG_MSDP); ReportMsdpSysEvent(type, false); } -DevicestatusDataUtils::DevicestatusData DevicestatusService::GetCache(const \ - DevicestatusDataUtils::DevicestatusType& type) +DeviceStatusDataUtils::DeviceStatusData DeviceStatusService::GetCache(const \ + DeviceStatusDataUtils::DeviceStatusType& type) { DEV_HILOGI(SERVICE, "Enter"); if (devicestatusManager_ == nullptr) { - DevicestatusDataUtils::DevicestatusData data = {type, DevicestatusDataUtils::DevicestatusValue::VALUE_EXIT}; - data.value = DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID; - DEV_HILOGI(SERVICE, "GetLatestDevicestatusData func is nullptr,return default!"); + DeviceStatusDataUtils::DeviceStatusData data = {type, DeviceStatusDataUtils::DeviceStatusValue::VALUE_EXIT}; + data.value = DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID; + DEV_HILOGI(SERVICE, "GetLatestDeviceStatusData func is nullptr,return default!"); return data; } - return devicestatusManager_->GetLatestDevicestatusData(type); + return devicestatusManager_->GetLatestDeviceStatusData(type); } -void DevicestatusService::ReportMsdpSysEvent(const DevicestatusDataUtils::DevicestatusType& type, bool enable) +void DeviceStatusService::ReportMsdpSysEvent(const DeviceStatusDataUtils::DeviceStatusType& type, bool enable) { auto uid = this->GetCallingUid(); auto callerToken = this->GetCallingTokenID(); @@ -264,7 +264,7 @@ void DevicestatusService::ReportMsdpSysEvent(const DevicestatusDataUtils::Device "UID", uid, "PKGNAME", packageName, "TYPE", type); } -int32_t DevicestatusService::AllocSocketFd(const std::string &programName, const int32_t moduleType, +int32_t DeviceStatusService::AllocSocketFd(const std::string &programName, const int32_t moduleType, int32_t &toReturnClientFd, int32_t &tokenType) { FI_HILOGD("Enter, programName:%{public}s,moduleType:%{public}d", programName.c_str(), moduleType); @@ -284,18 +284,18 @@ int32_t DevicestatusService::AllocSocketFd(const std::string &programName, const return RET_OK; } -void DevicestatusService::OnConnected(SessionPtr s) +void DeviceStatusService::OnConnected(SessionPtr s) { CHKPV(s); FI_HILOGI("fd:%{public}d", s->GetFd()); } -void DevicestatusService::OnDisconnected(SessionPtr s) +void DeviceStatusService::OnDisconnected(SessionPtr s) { CHKPV(s); FI_HILOGW("Enter, session desc:%{public}s, fd:%{public}d", s->GetDescript().c_str(), s->GetFd()); } -int32_t DevicestatusService::AddEpoll(EpollEventType type, int32_t fd) +int32_t DeviceStatusService::AddEpoll(EpollEventType type, int32_t fd) { if (!(type >= EPOLL_EVENT_BEGIN && type < EPOLL_EVENT_END)) { FI_HILOGE("Invalid param type"); @@ -327,7 +327,7 @@ int32_t DevicestatusService::AddEpoll(EpollEventType type, int32_t fd) return RET_OK; } -int32_t DevicestatusService::DelEpoll(EpollEventType type, int32_t fd) +int32_t DeviceStatusService::DelEpoll(EpollEventType type, int32_t fd) { if (!(type >= EPOLL_EVENT_BEGIN && type < EPOLL_EVENT_END)) { FI_HILOGE("Invalid param type"); @@ -346,12 +346,12 @@ int32_t DevicestatusService::DelEpoll(EpollEventType type, int32_t fd) return RET_OK; } -bool DevicestatusService::IsRunning() const +bool DeviceStatusService::IsRunning() const { return (state_ == ServiceRunningState::STATE_RUNNING); } -int32_t DevicestatusService::InitDelegateTasks() +int32_t DeviceStatusService::InitDelegateTasks() { CALL_DEBUG_ENTER; if (!delegateTasks_.Init()) { @@ -367,7 +367,7 @@ int32_t DevicestatusService::InitDelegateTasks() return RET_OK; } -int32_t DevicestatusService::InitTimerMgr() +int32_t DeviceStatusService::InitTimerMgr() { int32_t ret = timerMgr_.Init(); if (ret != RET_OK) { @@ -382,7 +382,7 @@ int32_t DevicestatusService::InitTimerMgr() return RET_OK; } -void DevicestatusService::OnThread() +void DeviceStatusService::OnThread() { SetThreadName(std::string("mmi_service")); uint64_t tid = GetThisThreadId(); @@ -410,7 +410,7 @@ void DevicestatusService::OnThread() FI_HILOGD("Main worker thread stop. tid:%{public}" PRId64 "", tid); } -void DevicestatusService::OnSignalEvent(int32_t signalFd) +void DeviceStatusService::OnSignalEvent(int32_t signalFd) { CALL_DEBUG_ENTER; signalfd_siginfo sigInfo; @@ -440,7 +440,7 @@ void DevicestatusService::OnSignalEvent(int32_t signalFd) } } -void DevicestatusService::OnDelegateTask(epoll_event &ev) +void DeviceStatusService::OnDelegateTask(epoll_event &ev) { if ((ev.events & EPOLLIN) == 0) { FI_HILOGW("Not epollin"); @@ -456,7 +456,7 @@ void DevicestatusService::OnDelegateTask(epoll_event &ev) delegateTasks_.ProcessTasks(); } -void DevicestatusService::OnTimeout(epoll_event &ev) +void DeviceStatusService::OnTimeout(epoll_event &ev) { if ((ev.events & EPOLLIN) == EPOLLIN) { uint64_t expiration {}; @@ -470,13 +470,13 @@ void DevicestatusService::OnTimeout(epoll_event &ev) } } -int32_t DevicestatusService::RegisterCoordinationListener() +int32_t DeviceStatusService::RegisterCoordinationListener() { CALL_DEBUG_ENTER; #ifdef OHOS_BUILD_ENABLE_COORDINATION int32_t pid = GetCallingPid(); int32_t ret = delegateTasks_.PostSyncTask( - std::bind(&DevicestatusService::OnRegisterCoordinationListener, this, pid)); + std::bind(&DeviceStatusService::OnRegisterCoordinationListener, this, pid)); if (ret != RET_OK) { FI_HILOGE("OnRegisterCoordinationListener failed, ret:%{public}d", ret); return RET_ERR; @@ -485,13 +485,13 @@ int32_t DevicestatusService::RegisterCoordinationListener() return RET_OK; } -int32_t DevicestatusService::UnregisterCoordinationListener() +int32_t DeviceStatusService::UnregisterCoordinationListener() { CALL_DEBUG_ENTER; #ifdef OHOS_BUILD_ENABLE_COORDINATION int32_t pid = GetCallingPid(); int32_t ret = delegateTasks_.PostSyncTask( - std::bind(&DevicestatusService::OnUnregisterCoordinationListener, this, pid)); + std::bind(&DeviceStatusService::OnUnregisterCoordinationListener, this, pid)); if (ret != RET_OK) { FI_HILOGE("OnUnregisterCoordinationListener failed, ret:%{public}d", ret); return RET_ERR; @@ -500,13 +500,13 @@ int32_t DevicestatusService::UnregisterCoordinationListener() return RET_OK; } -int32_t DevicestatusService::EnableInputDeviceCoordination(int32_t userData, bool enabled) +int32_t DeviceStatusService::EnableInputDeviceCoordination(int32_t userData, bool enabled) { CALL_DEBUG_ENTER; #ifdef OHOS_BUILD_ENABLE_COORDINATION int32_t pid = GetCallingPid(); int32_t ret = delegateTasks_.PostSyncTask( - std::bind(&DevicestatusService::OnEnableInputDeviceCoordination, this, pid, userData, enabled)); + std::bind(&DeviceStatusService::OnEnableInputDeviceCoordination, this, pid, userData, enabled)); if (ret != RET_OK) { FI_HILOGE("OnEnableInputDeviceCoordination failed, ret:%{public}d", ret); return ret; @@ -518,14 +518,14 @@ int32_t DevicestatusService::EnableInputDeviceCoordination(int32_t userData, boo return RET_OK; } -int32_t DevicestatusService::StartInputDeviceCoordination(int32_t userData, +int32_t DeviceStatusService::StartInputDeviceCoordination(int32_t userData, const std::string &sinkDeviceId, int32_t srcInputDeviceId) { CALL_DEBUG_ENTER; #ifdef OHOS_BUILD_ENABLE_COORDINATION int32_t pid = GetCallingPid(); int32_t ret = delegateTasks_.PostSyncTask( - std::bind(&DevicestatusService::OnStartInputDeviceCoordination, + std::bind(&DeviceStatusService::OnStartInputDeviceCoordination, this, pid, userData, sinkDeviceId, srcInputDeviceId)); if (ret != RET_OK) { FI_HILOGE("OnStartInputDeviceCoordination failed, ret:%{public}d", ret); @@ -539,13 +539,13 @@ int32_t DevicestatusService::StartInputDeviceCoordination(int32_t userData, return RET_OK; } -int32_t DevicestatusService::StopDeviceCoordination(int32_t userData) +int32_t DeviceStatusService::StopDeviceCoordination(int32_t userData) { CALL_DEBUG_ENTER; #ifdef OHOS_BUILD_ENABLE_COORDINATION int32_t pid = GetCallingPid(); int32_t ret = delegateTasks_.PostSyncTask( - std::bind(&DevicestatusService::OnStopInputDeviceCoordination, this, pid, userData)); + std::bind(&DeviceStatusService::OnStopInputDeviceCoordination, this, pid, userData)); if (ret != RET_OK) { FI_HILOGE("OnStopInputDeviceCoordination failed, ret:%{public}d", ret); return ret; @@ -556,13 +556,13 @@ int32_t DevicestatusService::StopDeviceCoordination(int32_t userData) return RET_OK; } -int32_t DevicestatusService::GetInputDeviceCoordinationState(int32_t userData, const std::string &deviceId) +int32_t DeviceStatusService::GetInputDeviceCoordinationState(int32_t userData, const std::string &deviceId) { CALL_DEBUG_ENTER; #ifdef OHOS_BUILD_ENABLE_COORDINATION int32_t pid = GetCallingPid(); int32_t ret = delegateTasks_.PostSyncTask( - std::bind(&DevicestatusService::OnGetInputDeviceCoordinationState, this, pid, userData, deviceId)); + std::bind(&DeviceStatusService::OnGetInputDeviceCoordinationState, this, pid, userData, deviceId)); if (ret != RET_OK) { FI_HILOGE("OnGetInputDeviceCoordinationState failed, ret:%{public}d", ret); return RET_ERR; @@ -576,7 +576,7 @@ int32_t DevicestatusService::GetInputDeviceCoordinationState(int32_t userData, c } #ifdef OHOS_BUILD_ENABLE_COORDINATION -int32_t DevicestatusService::OnRegisterCoordinationListener(int32_t pid) +int32_t DeviceStatusService::OnRegisterCoordinationListener(int32_t pid) { CALL_DEBUG_ENTER; auto sess = GetSession(GetClientFd(pid)); @@ -590,7 +590,7 @@ int32_t DevicestatusService::OnRegisterCoordinationListener(int32_t pid) return RET_OK; } -int32_t DevicestatusService::OnUnregisterCoordinationListener(int32_t pid) +int32_t DeviceStatusService::OnUnregisterCoordinationListener(int32_t pid) { CALL_DEBUG_ENTER; auto sess = GetSession(GetClientFd(pid)); @@ -602,7 +602,7 @@ int32_t DevicestatusService::OnUnregisterCoordinationListener(int32_t pid) return RET_OK; } -int32_t DevicestatusService::OnEnableInputDeviceCoordination(int32_t pid, int32_t userData, bool enabled) +int32_t DeviceStatusService::OnEnableInputDeviceCoordination(int32_t pid, int32_t userData, bool enabled) { CALL_DEBUG_ENTER; InputDevCooSM->EnableInputDeviceCooperate(enabled); @@ -624,7 +624,7 @@ int32_t DevicestatusService::OnEnableInputDeviceCoordination(int32_t pid, int32_ return RET_OK; } -int32_t DevicestatusService::OnStartInputDeviceCoordination(int32_t pid, +int32_t DeviceStatusService::OnStartInputDeviceCoordination(int32_t pid, int32_t userData, const std::string &sinkDeviceId, int32_t srcInputDeviceId) { CALL_DEBUG_ENTER; @@ -646,7 +646,7 @@ int32_t DevicestatusService::OnStartInputDeviceCoordination(int32_t pid, return RET_OK; } -int32_t DevicestatusService::OnStopInputDeviceCoordination(int32_t pid, int32_t userData) +int32_t DeviceStatusService::OnStopInputDeviceCoordination(int32_t pid, int32_t userData) { CALL_DEBUG_ENTER; auto sess = GetSession(GetClientFd(pid)); @@ -667,7 +667,7 @@ int32_t DevicestatusService::OnStopInputDeviceCoordination(int32_t pid, int32_t return RET_OK; } -int32_t DevicestatusService::OnGetInputDeviceCoordinationState( +int32_t DeviceStatusService::OnGetInputDeviceCoordinationState( int32_t pid, int32_t userData, const std::string &deviceId) { CALL_DEBUG_ENTER; diff --git a/services/native/src/devicestatus_srv_stub.cpp b/services/native/src/devicestatus_srv_stub.cpp index f04ade1df..0bfef498a 100644 --- a/services/native/src/devicestatus_srv_stub.cpp +++ b/services/native/src/devicestatus_srv_stub.cpp @@ -29,17 +29,17 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { namespace { -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MSDP_DOMAIN_ID, "DevicestatusSrvStub" }; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MSDP_DOMAIN_ID, "DeviceStatusSrvStub" }; } // namespace -int32_t DevicestatusSrvStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, \ +int32_t DeviceStatusSrvStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, \ MessageOption &option) { DEV_HILOGD(SERVICE, "cmd = %{public}d, flags = %{public}d", code, option.GetFlags()); - std::u16string descriptor = DevicestatusSrvStub::GetDescriptor(); + std::u16string descriptor = DeviceStatusSrvStub::GetDescriptor(); std::u16string remoteDescriptor = data.ReadInterfaceToken(); if (descriptor != remoteDescriptor) { - DEV_HILOGE(SERVICE, "DevicestatusSrvStub::OnRemoteRequest failed, descriptor is not matched"); + DEV_HILOGE(SERVICE, "DeviceStatusSrvStub::OnRemoteRequest failed, descriptor is not matched"); return E_DEVICESTATUS_GET_SERVICE_FAILED; } @@ -51,7 +51,7 @@ int32_t DevicestatusSrvStub::OnRemoteRequest(uint32_t code, MessageParcel &data, return UnsubscribeStub(data); } case static_cast(Idevicestatus::DEVICESTATUS_GETCACHE): { - return GetLatestDevicestatusDataStub(data, reply); + return GetLatestDeviceStatusDataStub(data, reply); } case REGISTER_COORDINATION_MONITOR: { return StubRegisterCoordinationMonitor(data, reply); @@ -81,7 +81,7 @@ int32_t DevicestatusSrvStub::OnRemoteRequest(uint32_t code, MessageParcel &data, return ERR_OK; } -int32_t DevicestatusSrvStub::SubscribeStub(MessageParcel& data) +int32_t DeviceStatusSrvStub::SubscribeStub(MessageParcel& data) { DEV_HILOGD(SERVICE, "Enter"); int32_t type = -1; @@ -93,11 +93,11 @@ int32_t DevicestatusSrvStub::SubscribeStub(MessageParcel& data) sptr callback = iface_cast(obj); DEVICESTATUS_RETURN_IF_WITH_RET((callback == nullptr), E_DEVICESTATUS_READ_PARCEL_ERROR); DEV_HILOGD(SERVICE, "Read callback successfully"); - Subscribe(DevicestatusDataUtils::DevicestatusType(type), callback); + Subscribe(DeviceStatusDataUtils::DeviceStatusType(type), callback); return ERR_OK; } -int32_t DevicestatusSrvStub::UnsubscribeStub(MessageParcel& data) +int32_t DeviceStatusSrvStub::UnsubscribeStub(MessageParcel& data) { DEV_HILOGD(SERVICE, "Enter"); int32_t type = -1; @@ -106,16 +106,16 @@ int32_t DevicestatusSrvStub::UnsubscribeStub(MessageParcel& data) DEVICESTATUS_RETURN_IF_WITH_RET((obj == nullptr), E_DEVICESTATUS_READ_PARCEL_ERROR); sptr callback = iface_cast(obj); DEVICESTATUS_RETURN_IF_WITH_RET((callback == nullptr), E_DEVICESTATUS_READ_PARCEL_ERROR); - Unsubscribe(DevicestatusDataUtils::DevicestatusType(type), callback); + Unsubscribe(DeviceStatusDataUtils::DeviceStatusType(type), callback); return ERR_OK; } -int32_t DevicestatusSrvStub::GetLatestDevicestatusDataStub(MessageParcel& data, MessageParcel& reply) +int32_t DeviceStatusSrvStub::GetLatestDeviceStatusDataStub(MessageParcel& data, MessageParcel& reply) { DEV_HILOGD(SERVICE, "Enter"); int32_t type = -1; READINT32(data, type, E_DEVICESTATUS_READ_PARCEL_ERROR); - DevicestatusDataUtils::DevicestatusData devicestatusData = GetCache(DevicestatusDataUtils::DevicestatusType(type)); + DeviceStatusDataUtils::DeviceStatusData devicestatusData = GetCache(DeviceStatusDataUtils::DeviceStatusType(type)); DEV_HILOGD(SERVICE, "devicestatusData.type: %{public}d", devicestatusData.type); DEV_HILOGD(SERVICE, "devicestatusData.value: %{public}d", devicestatusData.value); WRITEINT32(reply, devicestatusData.type, E_DEVICESTATUS_WRITE_PARCEL_ERROR); @@ -124,7 +124,7 @@ int32_t DevicestatusSrvStub::GetLatestDevicestatusDataStub(MessageParcel& data, return ERR_OK; } -int32_t DevicestatusSrvStub::StubRegisterCoordinationMonitor(MessageParcel& data, MessageParcel& reply) +int32_t DeviceStatusSrvStub::StubRegisterCoordinationMonitor(MessageParcel& data, MessageParcel& reply) { CALL_DEBUG_ENTER; int32_t ret = RegisterCoordinationListener(); @@ -134,7 +134,7 @@ int32_t DevicestatusSrvStub::StubRegisterCoordinationMonitor(MessageParcel& data return ret; } -int32_t DevicestatusSrvStub::StubUnregisterCoordinationMonitor(MessageParcel& data, MessageParcel& reply) +int32_t DeviceStatusSrvStub::StubUnregisterCoordinationMonitor(MessageParcel& data, MessageParcel& reply) { CALL_DEBUG_ENTER; int32_t ret = UnregisterCoordinationListener(); @@ -144,7 +144,7 @@ int32_t DevicestatusSrvStub::StubUnregisterCoordinationMonitor(MessageParcel& da return ret; } -int32_t DevicestatusSrvStub::StubEnableInputDeviceCoordination(MessageParcel& data, MessageParcel& reply) +int32_t DeviceStatusSrvStub::StubEnableInputDeviceCoordination(MessageParcel& data, MessageParcel& reply) { CALL_DEBUG_ENTER; int32_t userData; @@ -158,7 +158,7 @@ int32_t DevicestatusSrvStub::StubEnableInputDeviceCoordination(MessageParcel& da return ret; } -int32_t DevicestatusSrvStub::StubStartInputDeviceCoordination(MessageParcel& data, MessageParcel& reply) +int32_t DeviceStatusSrvStub::StubStartInputDeviceCoordination(MessageParcel& data, MessageParcel& reply) { CALL_DEBUG_ENTER; int32_t userData; @@ -174,7 +174,7 @@ int32_t DevicestatusSrvStub::StubStartInputDeviceCoordination(MessageParcel& dat return ret; } -int32_t DevicestatusSrvStub::StubStopDeviceCoordination(MessageParcel& data, MessageParcel& reply) +int32_t DeviceStatusSrvStub::StubStopDeviceCoordination(MessageParcel& data, MessageParcel& reply) { CALL_DEBUG_ENTER; int32_t userData; @@ -186,7 +186,7 @@ int32_t DevicestatusSrvStub::StubStopDeviceCoordination(MessageParcel& data, Mes return ret; } -int32_t DevicestatusSrvStub::StubGetInputDeviceCoordinationState(MessageParcel& data, MessageParcel& reply) +int32_t DeviceStatusSrvStub::StubGetInputDeviceCoordinationState(MessageParcel& data, MessageParcel& reply) { CALL_DEBUG_ENTER; int32_t userData; @@ -200,7 +200,7 @@ int32_t DevicestatusSrvStub::StubGetInputDeviceCoordinationState(MessageParcel& return ret; } -int32_t DevicestatusSrvStub::StubHandleAllocSocketFd(MessageParcel& data, MessageParcel& reply) +int32_t DeviceStatusSrvStub::StubHandleAllocSocketFd(MessageParcel& data, MessageParcel& reply) { int32_t pid = GetCallingPid(); if (!IsRunning()) { diff --git a/services/native/src/uds_server.cpp b/services/native/src/uds_server.cpp index 903d1115d..ee1486f46 100644 --- a/services/native/src/uds_server.cpp +++ b/services/native/src/uds_server.cpp @@ -199,8 +199,8 @@ void UDSServer::ReleaseSession(int32_t fd, epoll_event& ev) circleBufMap_.erase(it); } close(fd); - auto DevicestatusService = DeviceStatus::DelayedSpSingleton::GetInstance(); - DevicestatusService->DelEpoll(EPOLL_EVENT_SOCKET, fd); + auto DeviceStatusService = DeviceStatus::DelayedSpSingleton::GetInstance(); + DeviceStatusService->DelEpoll(EPOLL_EVENT_SOCKET, fd); } void UDSServer::OnPacket(int32_t fd, NetPacket& pkt) diff --git a/services/native/test/moduletest/include/devicestatus_module_test.h b/services/native/test/moduletest/include/devicestatus_module_test.h index 629ebb3f0..1e2dba828 100644 --- a/services/native/test/moduletest/include/devicestatus_module_test.h +++ b/services/native/test/moduletest/include/devicestatus_module_test.h @@ -23,14 +23,14 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DevicestatusModuleTest : public testing::Test { +class DeviceStatusModuleTest : public testing::Test { public: - class DevicestatusModuleTestCallback : public DevicestatusCallbackStub { + class DeviceStatusModuleTestCallback : public DeviceStatusCallbackStub { public: - DevicestatusModuleTestCallback() {}; - virtual ~DevicestatusModuleTestCallback() {}; - virtual void OnDevicestatusChanged(const DevicestatusDataUtils::DevicestatusData& devicestatusData) override; + DeviceStatusModuleTestCallback() {}; + virtual ~DeviceStatusModuleTestCallback() {}; + virtual void OnDeviceStatusChanged(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) override; }; }; } // namespace DeviceStatus diff --git a/services/native/test/moduletest/src/devicestatus_module_test.cpp b/services/native/test/moduletest/src/devicestatus_module_test.cpp index 84f06c555..dbad3970c 100644 --- a/services/native/test/moduletest/src/devicestatus_module_test.cpp +++ b/services/native/test/moduletest/src/devicestatus_module_test.cpp @@ -31,26 +31,26 @@ using namespace OHOS::Msdp::DeviceStatus; using namespace OHOS; using namespace std; -void DevicestatusModuleTest::DevicestatusModuleTestCallback::OnDevicestatusChanged(const \ - DevicestatusDataUtils::DevicestatusData& devicestatusData) +void DeviceStatusModuleTest::DeviceStatusModuleTestCallback::OnDeviceStatusChanged(const \ + DeviceStatusDataUtils::DeviceStatusData& devicestatusData) { - GTEST_LOG_(INFO) << "DevicestatusModuleTestCallback type: " << devicestatusData.type; - GTEST_LOG_(INFO) << "DevicestatusModuleTestCallback value: " << devicestatusData.value; - EXPECT_EQ(true, devicestatusData.type == DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL && \ - devicestatusData.value == DevicestatusDataUtils::DevicestatusValue::VALUE_ENTER) << \ - "DevicestatusModuleTestCallback failed"; + GTEST_LOG_(INFO) << "DeviceStatusModuleTestCallback type: " << devicestatusData.type; + GTEST_LOG_(INFO) << "DeviceStatusModuleTestCallback value: " << devicestatusData.value; + EXPECT_EQ(true, devicestatusData.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL && \ + devicestatusData.value == DeviceStatusDataUtils::DeviceStatusValue::VALUE_ENTER) << \ + "DeviceStatusModuleTestCallback failed"; } /** - * @tc.name: DevicestatusCallbackTest + * @tc.name: DeviceStatusCallbackTest * @tc.desc: test devicestatus callback in proxy * @tc.type: FUNC */ -HWTEST_F (DevicestatusModuleTest, DevicestatusCallbackTest, TestSize.Level0) +HWTEST_F (DeviceStatusModuleTest, DeviceStatusCallbackTest, TestSize.Level0) { - DevicestatusDataUtils::DevicestatusType type = DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL; - auto& devicestatusClient = DevicestatusClient::GetInstance(); - sptr cb = new (std::nothrow) DevicestatusModuleTestCallback(); + DeviceStatusDataUtils::DeviceStatusType type = DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL; + auto& devicestatusClient = DeviceStatusClient::GetInstance(); + sptr cb = new (std::nothrow) DeviceStatusModuleTestCallback(); EXPECT_FALSE(cb == nullptr); GTEST_LOG_(INFO) << "Start register"; devicestatusClient.SubscribeCallback(type, cb); @@ -59,52 +59,52 @@ HWTEST_F (DevicestatusModuleTest, DevicestatusCallbackTest, TestSize.Level0) } /** - * @tc.name: GetDevicestatusDataTest + * @tc.name: GetDeviceStatusDataTest * @tc.desc: test get devicestatus data in proxy * @tc.type: FUNC */ -HWTEST_F (DevicestatusModuleTest, GetDevicestatusDataTest001, TestSize.Level0) +HWTEST_F (DeviceStatusModuleTest, GetDeviceStatusDataTest001, TestSize.Level0) { - DEV_HILOGI(SERVICE, "GetDevicestatusDataTest001 Enter"); - DevicestatusDataUtils::DevicestatusType type = DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL; - auto& devicestatusClient = DevicestatusClient::GetInstance(); - DevicestatusDataUtils::DevicestatusData data = devicestatusClient.GetDevicestatusData(type); + DEV_HILOGI(SERVICE, "GetDeviceStatusDataTest001 Enter"); + DeviceStatusDataUtils::DeviceStatusType type = DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL; + auto& devicestatusClient = DeviceStatusClient::GetInstance(); + DeviceStatusDataUtils::DeviceStatusData data = devicestatusClient.GetDeviceStatusData(type); GTEST_LOG_(INFO) << "type: " << data.type; GTEST_LOG_(INFO) << "value: " << data.value; - EXPECT_EQ(true, data.type == DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL && \ - data.value == DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID) << "GetDevicestatusData failed"; + EXPECT_EQ(true, data.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL && \ + data.value == DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID) << "GetDeviceStatusData failed"; } /** - * @tc.name: GetDevicestatusDataTest + * @tc.name: GetDeviceStatusDataTest * @tc.desc: test get devicestatus data in proxy * @tc.type: FUNC */ -HWTEST_F (DevicestatusModuleTest, GetDevicestatusDataTest002, TestSize.Level0) +HWTEST_F (DeviceStatusModuleTest, GetDeviceStatusDataTest002, TestSize.Level0) { - DEV_HILOGI(SERVICE, "GetDevicestatusDataTest002 Enter"); - DevicestatusDataUtils::DevicestatusType type = DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL; - auto& devicestatusClient = DevicestatusClient::GetInstance(); - DevicestatusDataUtils::DevicestatusData data = devicestatusClient.GetDevicestatusData(type); + DEV_HILOGI(SERVICE, "GetDeviceStatusDataTest002 Enter"); + DeviceStatusDataUtils::DeviceStatusType type = DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL; + auto& devicestatusClient = DeviceStatusClient::GetInstance(); + DeviceStatusDataUtils::DeviceStatusData data = devicestatusClient.GetDeviceStatusData(type); GTEST_LOG_(INFO) << "type: " << data.type; GTEST_LOG_(INFO) << "value: " << data.value; - EXPECT_EQ(true, data.type == DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL && \ - data.value == DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID) << "GetDevicestatusData failed"; + EXPECT_EQ(true, data.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL && \ + data.value == DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID) << "GetDeviceStatusData failed"; } /** - * @tc.name: GetDevicestatusDataTest + * @tc.name: GetDeviceStatusDataTest * @tc.desc: test get devicestatus data in proxy * @tc.type: FUNC */ -HWTEST_F (DevicestatusModuleTest, GetDevicestatusDataTest003, TestSize.Level0) +HWTEST_F (DeviceStatusModuleTest, GetDeviceStatusDataTest003, TestSize.Level0) { - DEV_HILOGI(SERVICE, "GetDevicestatusDataTest003 Enter"); - DevicestatusDataUtils::DevicestatusType type = DevicestatusDataUtils::DevicestatusType::TYPE_CAR_BLUETOOTH; - auto& devicestatusClient = DevicestatusClient::GetInstance(); - DevicestatusDataUtils::DevicestatusData data = devicestatusClient.GetDevicestatusData(type); + DEV_HILOGI(SERVICE, "GetDeviceStatusDataTest003 Enter"); + DeviceStatusDataUtils::DeviceStatusType type = DeviceStatusDataUtils::DeviceStatusType::TYPE_CAR_BLUETOOTH; + auto& devicestatusClient = DeviceStatusClient::GetInstance(); + DeviceStatusDataUtils::DeviceStatusData data = devicestatusClient.GetDeviceStatusData(type); GTEST_LOG_(INFO) << "type: " << data.type; GTEST_LOG_(INFO) << "value: " << data.value; - EXPECT_EQ(true, data.type == DevicestatusDataUtils::DevicestatusType::TYPE_CAR_BLUETOOTH && \ - data.value == DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID) << "GetDevicestatusData failed"; + EXPECT_EQ(true, data.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_CAR_BLUETOOTH && \ + data.value == DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID) << "GetDeviceStatusData failed"; } diff --git a/services/native/test/unittest/BUILD.gn b/services/native/test/unittest/BUILD.gn index e78aa4aa7..01cdeae67 100644 --- a/services/native/test/unittest/BUILD.gn +++ b/services/native/test/unittest/BUILD.gn @@ -63,7 +63,7 @@ ohos_unittest("test_devicestatus_service") { ] } -ohos_unittest("DevicestatusAgentTest") { +ohos_unittest("DeviceStatusAgentTest") { module_out_path = module_output_path include_dirs = [ "${device_status_interfaces_path}/innerkits/include" ] @@ -88,7 +88,7 @@ ohos_unittest("DevicestatusAgentTest") { ] } -ohos_unittest("DevicestatusClientTest") { +ohos_unittest("DeviceStatusClientTest") { module_out_path = module_output_path include_dirs = [ "//base/msdp/devicestatus/interfaces/innerkits/include" ] @@ -119,8 +119,8 @@ group("unittest") { deps = [] deps += [ - ":DevicestatusAgentTest", - ":DevicestatusClientTest", + ":DeviceStatusAgentTest", + ":DeviceStatusClientTest", ":test_devicestatus_service", ] } diff --git a/services/native/test/unittest/include/devicestatus_agent_test.h b/services/native/test/unittest/include/devicestatus_agent_test.h index 225a51856..ef7370e4d 100644 --- a/services/native/test/unittest/include/devicestatus_agent_test.h +++ b/services/native/test/unittest/include/devicestatus_agent_test.h @@ -24,22 +24,22 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DevicestatusAgentTest : public testing::Test { +class DeviceStatusAgentTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp(); void TearDown(); }; -class DevicestatusAgentListenerMockFirstClient : public DeviceStatusAgent::DeviceStatusAgentEvent { +class DeviceStatusAgentListenerMockFirstClient : public DeviceStatusAgent::DeviceStatusAgentEvent { public: - virtual ~DevicestatusAgentListenerMockFirstClient() {}; - bool OnEventResult(const DevicestatusDataUtils::DevicestatusData& devicestatusData) override; + virtual ~DeviceStatusAgentListenerMockFirstClient() {}; + bool OnEventResult(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) override; }; -class DevicestatusAgentListenerMockSecondClient : public DeviceStatusAgent::DeviceStatusAgentEvent { +class DeviceStatusAgentListenerMockSecondClient : public DeviceStatusAgent::DeviceStatusAgentEvent { public: - virtual ~DevicestatusAgentListenerMockSecondClient() {}; - bool OnEventResult(const DevicestatusDataUtils::DevicestatusData& devicestatusData) override; + virtual ~DeviceStatusAgentListenerMockSecondClient() {}; + bool OnEventResult(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) override; }; } // namespace DeviceStatus } // namespace Msdp diff --git a/services/native/test/unittest/include/devicestatus_client_test.h b/services/native/test/unittest/include/devicestatus_client_test.h index acac5f49f..e1d4d7db4 100644 --- a/services/native/test/unittest/include/devicestatus_client_test.h +++ b/services/native/test/unittest/include/devicestatus_client_test.h @@ -28,7 +28,7 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DevicestatusClientTest : public testing::Test { +class DeviceStatusClientTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); diff --git a/services/native/test/unittest/include/devicestatus_service_test.h b/services/native/test/unittest/include/devicestatus_service_test.h index df55e650d..248077db9 100644 --- a/services/native/test/unittest/include/devicestatus_service_test.h +++ b/services/native/test/unittest/include/devicestatus_service_test.h @@ -24,14 +24,14 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { const std::u16string ARGS_H = u"-h"; -class DevicestatusServiceTest : public testing::Test { +class DeviceStatusServiceTest : public testing::Test { public: - class DevicestatusServiceTestCallback : public DevicestatusCallbackStub { + class DeviceStatusServiceTestCallback : public DeviceStatusCallbackStub { public: - DevicestatusServiceTestCallback() {}; - virtual ~DevicestatusServiceTestCallback() {}; - virtual void OnDevicestatusChanged(const DevicestatusDataUtils::DevicestatusData& devicestatusData) override; + DeviceStatusServiceTestCallback() {}; + virtual ~DeviceStatusServiceTestCallback() {}; + virtual void OnDeviceStatusChanged(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) override; }; }; } // namespace DeviceStatus diff --git a/services/native/test/unittest/src/devicestatus_agent_test.cpp b/services/native/test/unittest/src/devicestatus_agent_test.cpp index 0de53964e..a0e28f627 100644 --- a/services/native/test/unittest/src/devicestatus_agent_test.cpp +++ b/services/native/test/unittest/src/devicestatus_agent_test.cpp @@ -25,307 +25,307 @@ using namespace std; static std::shared_ptr agent1_; static std::shared_ptr agent2_; -void DevicestatusAgentTest::SetUpTestCase() +void DeviceStatusAgentTest::SetUpTestCase() { } -void DevicestatusAgentTest::TearDownTestCase() +void DeviceStatusAgentTest::TearDownTestCase() { } -void DevicestatusAgentTest::SetUp() +void DeviceStatusAgentTest::SetUp() { agent1_ = std::make_shared(); agent2_ = std::make_shared(); } -void DevicestatusAgentTest::TearDown() +void DeviceStatusAgentTest::TearDown() { } -bool DevicestatusAgentListenerMockFirstClient::OnEventResult( - const DevicestatusDataUtils::DevicestatusData& devicestatusData) +bool DeviceStatusAgentListenerMockFirstClient::OnEventResult( + const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) { GTEST_LOG_(INFO) << "agent type: " << devicestatusData.type; GTEST_LOG_(INFO) << "agent value: " << devicestatusData.value; - EXPECT_TRUE(devicestatusData.type == DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN); + EXPECT_TRUE(devicestatusData.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN); return true; } -bool DevicestatusAgentListenerMockSecondClient::OnEventResult( - const DevicestatusDataUtils::DevicestatusData& devicestatusData) +bool DeviceStatusAgentListenerMockSecondClient::OnEventResult( + const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) { GTEST_LOG_(INFO) << "agent type: " << devicestatusData.type; GTEST_LOG_(INFO) << "agent value: " << devicestatusData.value; - EXPECT_TRUE(devicestatusData.type == DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN); + EXPECT_TRUE(devicestatusData.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN); return true; } namespace { /** - * @tc.name: DevicestatusAgentTest001 + * @tc.name: DeviceStatusAgentTest001 * @tc.desc: test subscribing lid open event * @tc.type: FUNC */ -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest001, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest001, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest001 start"; - std::shared_ptr agentEvent = - std::make_shared(); - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest001 start"; + std::shared_ptr agentEvent = + std::make_shared(); + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, agentEvent); EXPECT_TRUE(ret == ERR_OK); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; sleep(2); - agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN); - GTEST_LOG_(INFO) << "DevicestatusAgentTest001 end"; + agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest001 end"; } /** - * @tc.name: DevicestatusAgentTest002 + * @tc.name: DeviceStatusAgentTest002 * @tc.desc: test subscribing lid open event repeatedly * @tc.type: FUNC */ -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest002, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest002, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest002 start"; - std::shared_ptr agentEvent = - std::make_shared(); - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest002 start"; + std::shared_ptr agentEvent = + std::make_shared(); + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, agentEvent); EXPECT_TRUE(ret == ERR_OK); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; sleep(2); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN); EXPECT_TRUE(ret == ERR_OK); GTEST_LOG_(INFO) << "Open and close the lid, and event will not report"; sleep(2); - ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, agentEvent); + ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, agentEvent); EXPECT_TRUE(ret == ERR_OK); GTEST_LOG_(INFO) << "Open and close the lid, and event will report again"; sleep(2); - agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN); - GTEST_LOG_(INFO) << "DevicestatusAgentTest002 end"; + agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest002 end"; } /** - * @tc.name: DevicestatusAgentTest003 + * @tc.name: DeviceStatusAgentTest003 * @tc.desc: test subscribing lid open event for 2 client * @tc.type: FUNC */ -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest003, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest003, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest003 start"; - std::shared_ptr agentEvent1 = - std::make_shared(); - std::shared_ptr agentEvent2 = - std::make_shared(); - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, agentEvent1); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest003 start"; + std::shared_ptr agentEvent1 = + std::make_shared(); + std::shared_ptr agentEvent2 = + std::make_shared(); + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, agentEvent1); EXPECT_TRUE(ret == ERR_OK); - ret = agent2_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, agentEvent2); + ret = agent2_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, agentEvent2); EXPECT_TRUE(ret == ERR_OK); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; sleep(2); GTEST_LOG_(INFO) << "Unsubscribe agentEvent1"; - agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN); + agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN); sleep(2); GTEST_LOG_(INFO) << "Unsubscribe agentEvent2"; - agent2_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN); - GTEST_LOG_(INFO) << "DevicestatusAgentTest003 end"; + agent2_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest003 end"; } -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest004, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest004, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest004 start"; - std::shared_ptr agentEvent = - std::make_shared(); - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_CAR_BLUETOOTH, agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest004 start"; + std::shared_ptr agentEvent = + std::make_shared(); + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_CAR_BLUETOOTH, agentEvent); EXPECT_TRUE(ret == ERR_OK); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; sleep(2); - agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_CAR_BLUETOOTH); - GTEST_LOG_(INFO) << "DevicestatusAgentTest004 end"; + agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_CAR_BLUETOOTH); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest004 end"; } -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest005, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest005, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest005 start"; - std::shared_ptr agentEvent = - std::make_shared(); - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL, agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest005 start"; + std::shared_ptr agentEvent = + std::make_shared(); + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL, agentEvent); EXPECT_TRUE(ret == ERR_OK); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; sleep(2); - agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL); - GTEST_LOG_(INFO) << "DevicestatusAgentTest005 end"; + agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest005 end"; } -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest006, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest006, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest006 start"; - std::shared_ptr agentEvent = - std::make_shared(); - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL, agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest006 start"; + std::shared_ptr agentEvent = + std::make_shared(); + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL, agentEvent); EXPECT_TRUE(ret == ERR_OK); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; sleep(2); - agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL); - GTEST_LOG_(INFO) << "DevicestatusAgentTest006 end"; + agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest006 end"; } -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest007, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest007, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest007 start"; - std::shared_ptr agentEvent = - std::make_shared(); - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID, agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest007 start"; + std::shared_ptr agentEvent = + std::make_shared(); + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID, agentEvent); EXPECT_TRUE(ret == ERR_INVALID_VALUE); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; sleep(2); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - GTEST_LOG_(INFO) << "DevicestatusAgentTest007 end"; + GTEST_LOG_(INFO) << "DeviceStatusAgentTest007 end"; } -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest008, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest008, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest008 start"; - std::shared_ptr agentEvent = - std::make_shared(); - int32_t ret = agent1_->SubscribeAgentEvent(static_cast(10), agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest008 start"; + std::shared_ptr agentEvent = + std::make_shared(); + int32_t ret = agent1_->SubscribeAgentEvent(static_cast(10), agentEvent); EXPECT_TRUE(ret == ERR_INVALID_VALUE); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; sleep(2); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - GTEST_LOG_(INFO) << "DevicestatusAgentTest008 end"; + GTEST_LOG_(INFO) << "DeviceStatusAgentTest008 end"; } -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest009, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest009, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest009 start"; - std::shared_ptr agentEvent = - std::make_shared(); - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID, agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest009 start"; + std::shared_ptr agentEvent = + std::make_shared(); + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID, agentEvent); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL, agentEvent); + ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL, agentEvent); EXPECT_TRUE(ret == ERR_OK); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; sleep(2); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL); EXPECT_TRUE(ret == ERR_OK); - GTEST_LOG_(INFO) << "DevicestatusAgentTest009 end"; + GTEST_LOG_(INFO) << "DeviceStatusAgentTest009 end"; } -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest010, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest010, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest010 start"; - std::shared_ptr agentEvent = nullptr; - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest010 start"; + std::shared_ptr agentEvent = nullptr; + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, agentEvent); EXPECT_TRUE(ret == ERR_INVALID_VALUE); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; - GTEST_LOG_(INFO) << "DevicestatusAgentTest010 end"; + GTEST_LOG_(INFO) << "DeviceStatusAgentTest010 end"; } -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest011, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest011, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest011 start"; - std::shared_ptr agentEvent = - std::make_shared(); - std::shared_ptr agentEvent1 = nullptr; - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID, agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest011 start"; + std::shared_ptr agentEvent = + std::make_shared(); + std::shared_ptr agentEvent1 = nullptr; + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID, agentEvent); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL, agentEvent); + ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL, agentEvent); EXPECT_TRUE(ret == ERR_OK); - ret = agent1_->SubscribeAgentEvent(static_cast(10), agentEvent); + ret = agent1_->SubscribeAgentEvent(static_cast(10), agentEvent); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL, agentEvent); + ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL, agentEvent); EXPECT_TRUE(ret == ERR_OK); - ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_CAR_BLUETOOTH, agentEvent1); + ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_CAR_BLUETOOTH, agentEvent1); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, agentEvent); + ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, agentEvent); EXPECT_TRUE(ret == ERR_OK); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; sleep(2); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL); EXPECT_TRUE(ret == ERR_OK); - ret = agent1_->UnsubscribeAgentEvent(static_cast(10)); + ret = agent1_->UnsubscribeAgentEvent(static_cast(10)); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL); EXPECT_TRUE(ret == ERR_OK); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_CAR_BLUETOOTH); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_CAR_BLUETOOTH); EXPECT_TRUE(ret == ERR_OK); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN); EXPECT_TRUE(ret == ERR_OK); - GTEST_LOG_(INFO) << "DevicestatusAgentTest011 end"; + GTEST_LOG_(INFO) << "DeviceStatusAgentTest011 end"; } -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest012, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest012, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest012 start"; - std::shared_ptr agentEvent = - std::make_shared(); - std::shared_ptr agentEvent1 = nullptr; - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID, agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest012 start"; + std::shared_ptr agentEvent = + std::make_shared(); + std::shared_ptr agentEvent1 = nullptr; + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID, agentEvent); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL, agentEvent); + ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL, agentEvent); EXPECT_TRUE(ret == ERR_OK); - ret = agent1_->SubscribeAgentEvent(static_cast(10), agentEvent); + ret = agent1_->SubscribeAgentEvent(static_cast(10), agentEvent); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_CAR_BLUETOOTH, agentEvent1); + ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_CAR_BLUETOOTH, agentEvent1); EXPECT_TRUE(ret == ERR_INVALID_VALUE); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; sleep(2); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL); EXPECT_TRUE(ret == ERR_OK); - ret = agent1_->UnsubscribeAgentEvent(static_cast(10)); + ret = agent1_->UnsubscribeAgentEvent(static_cast(10)); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL); EXPECT_TRUE(ret == ERR_OK); - GTEST_LOG_(INFO) << "DevicestatusAgentTest012 end"; + GTEST_LOG_(INFO) << "DeviceStatusAgentTest012 end"; } -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest013, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest013, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest013 start"; - std::shared_ptr agentEvent = - std::make_shared(); - std::shared_ptr agentEvent1 = nullptr; - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID, agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest013 start"; + std::shared_ptr agentEvent = + std::make_shared(); + std::shared_ptr agentEvent1 = nullptr; + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID, agentEvent); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->SubscribeAgentEvent(static_cast(10), agentEvent); + ret = agent1_->SubscribeAgentEvent(static_cast(10), agentEvent); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL, agentEvent1); + ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL, agentEvent1); EXPECT_TRUE(ret == ERR_INVALID_VALUE); GTEST_LOG_(INFO) << "Open and close the lid, and event will report"; sleep(2); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - ret = agent1_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL); + ret = agent1_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL); EXPECT_TRUE(ret == ERR_OK); - ret = agent1_->UnsubscribeAgentEvent(static_cast(10)); + ret = agent1_->UnsubscribeAgentEvent(static_cast(10)); EXPECT_TRUE(ret == ERR_INVALID_VALUE); - GTEST_LOG_(INFO) << "DevicestatusAgentTest013 end"; + GTEST_LOG_(INFO) << "DeviceStatusAgentTest013 end"; } -HWTEST_F (DevicestatusAgentTest, DevicestatusAgentTest014, TestSize.Level1) +HWTEST_F (DeviceStatusAgentTest, DeviceStatusAgentTest014, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusAgentTest014 start"; - std::shared_ptr agentEvent = - std::make_shared(); - int32_t ret = agent1_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, agentEvent); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest014 start"; + std::shared_ptr agentEvent = + std::make_shared(); + int32_t ret = agent1_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, agentEvent); EXPECT_TRUE(ret == ERR_OK); sptr callback = new DeviceStatusAgent::DeviceStatusAgentCallback(agent1_); - DevicestatusDataUtils::DevicestatusData devicestatusData = { - DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, - DevicestatusDataUtils::DevicestatusValue::VALUE_ENTER + DeviceStatusDataUtils::DeviceStatusData devicestatusData = { + DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, + DeviceStatusDataUtils::DeviceStatusValue::VALUE_ENTER }; - callback->OnDevicestatusChanged(devicestatusData); - GTEST_LOG_(INFO) << "DevicestatusAgentTest014 end"; + callback->OnDeviceStatusChanged(devicestatusData); + GTEST_LOG_(INFO) << "DeviceStatusAgentTest014 end"; } } diff --git a/services/native/test/unittest/src/devicestatus_client_test.cpp b/services/native/test/unittest/src/devicestatus_client_test.cpp index e1d47aefa..d8dcab0ae 100644 --- a/services/native/test/unittest/src/devicestatus_client_test.cpp +++ b/services/native/test/unittest/src/devicestatus_client_test.cpp @@ -29,34 +29,34 @@ using namespace std; static std::shared_ptr callbackProxy_; static std::shared_ptr agent_; -void DevicestatusClientTest::SetUpTestCase() +void DeviceStatusClientTest::SetUpTestCase() { GTEST_LOG_(INFO) << "SetUpTestCase start"; agent_ = std::make_shared(); GTEST_LOG_(INFO) << "SetUpTestCase end"; } -void DevicestatusClientTest::TearDownTestCase() +void DeviceStatusClientTest::TearDownTestCase() { } -void DevicestatusClientTest::SetUp() +void DeviceStatusClientTest::SetUp() { } -void DevicestatusClientTest::TearDown() +void DeviceStatusClientTest::TearDown() { } namespace { /** - * @tc.name: DevicestatusClientTest001 + * @tc.name: DeviceStatusClientTest001 * @tc.desc: test OnRemoteDied * @tc.type: FUNC */ -HWTEST_F (DevicestatusClientTest, DevicestatusClientTest001, TestSize.Level1) +HWTEST_F (DeviceStatusClientTest, DeviceStatusClientTest001, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusClientTest001 start"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest001 start"; sptr sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (sam == nullptr) { GTEST_LOG_(INFO) << "GetSystemAbilityManager failed"; @@ -67,25 +67,25 @@ HWTEST_F (DevicestatusClientTest, DevicestatusClientTest001, TestSize.Level1) GTEST_LOG_(INFO) << "CheckSystemAbility failed"; return; } - auto& client = DevicestatusClient::GetInstance(); + auto& client = DeviceStatusClient::GetInstance(); DEV_HILOGE(INNERKIT, "test OnRemoteDied start"); sptr deathRecipient_ = - sptr(new DevicestatusClient::DevicestatusDeathRecipient()); + sptr(new DeviceStatusClient::DeviceStatusDeathRecipient()); deathRecipient_->OnRemoteDied(remoteObject_); DEV_HILOGE(INNERKIT, "test OnRemoteDied end"); EXPECT_TRUE(client.devicestatusProxy_ == nullptr); - GTEST_LOG_(INFO) << "DevicestatusClientTest001 end"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest001 end"; } /** - * @tc.name: DevicestatusClientTest002 - * @tc.desc: test OnDevicestatusChanged + * @tc.name: DeviceStatusClientTest002 + * @tc.desc: test OnDeviceStatusChanged * @tc.type: FUNC */ -HWTEST_F (DevicestatusClientTest, DevicestatusClientTest002, TestSize.Level1) +HWTEST_F (DeviceStatusClientTest, DeviceStatusClientTest002, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusClientTest002 start"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest002 start"; sptr sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (sam == nullptr) { GTEST_LOG_(INFO) << "GetSystemAbilityManager failed"; @@ -97,122 +97,122 @@ HWTEST_F (DevicestatusClientTest, DevicestatusClientTest002, TestSize.Level1) return; } callbackProxy_ = std::make_shared(remoteObject_); - DevicestatusDataUtils::DevicestatusData devicestatusData = { - DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL, - DevicestatusDataUtils::DevicestatusValue::VALUE_ENTER + DeviceStatusDataUtils::DeviceStatusData devicestatusData = { + DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL, + DeviceStatusDataUtils::DeviceStatusValue::VALUE_ENTER }; - DEV_HILOGE(INNERKIT, "test OnDevicestatusChanged start"); - callbackProxy_->OnDevicestatusChanged(devicestatusData); - DEV_HILOGE(INNERKIT, "test OnDevicestatusChanged end"); - GTEST_LOG_(INFO) << "DevicestatusClientTest002 end"; + DEV_HILOGE(INNERKIT, "test OnDeviceStatusChanged start"); + callbackProxy_->OnDeviceStatusChanged(devicestatusData); + DEV_HILOGE(INNERKIT, "test OnDeviceStatusChanged end"); + GTEST_LOG_(INFO) << "DeviceStatusClientTest002 end"; } /** - * @tc.name: DevicestatusClientTest003 + * @tc.name: DeviceStatusClientTest003 * @tc.desc: test null proxy subscribe * @tc.type: FUNC */ -HWTEST_F (DevicestatusClientTest, DevicestatusClientTest003, TestSize.Level1) +HWTEST_F (DeviceStatusClientTest, DeviceStatusClientTest003, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusClientTest003 start"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest003 start"; sptr callback = sptr(new DeviceStatusAgent::DeviceStatusAgentCallback(agent_)); - auto& client = DevicestatusClient::GetInstance(); + auto& client = DeviceStatusClient::GetInstance(); client.devicestatusProxy_ = nullptr; DEV_HILOGE(INNERKIT, "test SubscribeCallback start"); - client.SubscribeCallback(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, callback); + client.SubscribeCallback(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, callback); DEV_HILOGE(INNERKIT, "test SubscribeCallback end"); - GTEST_LOG_(INFO) << "DevicestatusClientTest003 end"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest003 end"; } /** - * @tc.name: DevicestatusClientTest004 + * @tc.name: DeviceStatusClientTest004 * @tc.desc: test null proxy unsubscribe * @tc.type: FUNC */ -HWTEST_F (DevicestatusClientTest, DevicestatusClientTest004, TestSize.Level1) +HWTEST_F (DeviceStatusClientTest, DeviceStatusClientTest004, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusClientTest004 start"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest004 start"; sptr callback = sptr(new DeviceStatusAgent::DeviceStatusAgentCallback(agent_)); - auto& client = DevicestatusClient::GetInstance(); + auto& client = DeviceStatusClient::GetInstance(); client.devicestatusProxy_ = nullptr; DEV_HILOGE(INNERKIT, "test UnsubscribeCallback start"); - client.UnsubscribeCallback(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, callback); + client.UnsubscribeCallback(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, callback); DEV_HILOGE(INNERKIT, "test UnsubscribeCallback end"); - GTEST_LOG_(INFO) << "DevicestatusClientTest004 end"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest004 end"; } /** - * @tc.name: DevicestatusClientTest005 + * @tc.name: DeviceStatusClientTest005 * @tc.desc: test null proxy unsubscribe * @tc.type: FUNC */ -HWTEST_F (DevicestatusClientTest, DevicestatusClientTest005, TestSize.Level1) +HWTEST_F (DeviceStatusClientTest, DeviceStatusClientTest005, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusClientTest005 start"; - auto& client = DevicestatusClient::GetInstance(); + GTEST_LOG_(INFO) << "DeviceStatusClientTest005 start"; + auto& client = DeviceStatusClient::GetInstance(); client.devicestatusProxy_ = nullptr; - DEV_HILOGE(INNERKIT, "test GetDevicestatusData start"); - auto data = client.GetDevicestatusData(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN); - DEV_HILOGE(INNERKIT, "test GetDevicestatusData end"); - EXPECT_TRUE(data.type == DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN && \ - data.value == DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID) << "GetDevicestatusData failed"; - GTEST_LOG_(INFO) << "DevicestatusClientTest005 end"; + DEV_HILOGE(INNERKIT, "test GetDeviceStatusData start"); + auto data = client.GetDeviceStatusData(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN); + DEV_HILOGE(INNERKIT, "test GetDeviceStatusData end"); + EXPECT_TRUE(data.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN && \ + data.value == DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID) << "GetDeviceStatusData failed"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest005 end"; } /** - * @tc.name: DevicestatusClientTest006 + * @tc.name: DeviceStatusClientTest006 * @tc.desc: test null proxy destructor * @tc.type: FUNC */ -HWTEST_F (DevicestatusClientTest, DevicestatusClientTest006, TestSize.Level1) +HWTEST_F (DeviceStatusClientTest, DeviceStatusClientTest006, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusClientTest006 start"; - DevicestatusClient* client1 = new(std::nothrow) DevicestatusClient(); + GTEST_LOG_(INFO) << "DeviceStatusClientTest006 start"; + DeviceStatusClient* client1 = new(std::nothrow) DeviceStatusClient(); delete client1; client1 = nullptr; - DevicestatusClient* client2 = new(std::nothrow) DevicestatusClient(); + DeviceStatusClient* client2 = new(std::nothrow) DeviceStatusClient(); client2->devicestatusProxy_ = nullptr; delete client2; client2 = nullptr; - GTEST_LOG_(INFO) << "DevicestatusClientTest006 end"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest006 end"; } /** - * @tc.name: DevicestatusClientTest007 + * @tc.name: DeviceStatusClientTest007 * @tc.desc: test null OnRemoteDied * @tc.type: FUNC */ -HWTEST_F (DevicestatusClientTest, DevicestatusClientTest007, TestSize.Level1) +HWTEST_F (DeviceStatusClientTest, DeviceStatusClientTest007, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusClientTest007 start"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest007 start"; DEV_HILOGE(INNERKIT, "test OnRemoteDied start"); sptr deathRecipient_ = - sptr(new DevicestatusClient::DevicestatusDeathRecipient()); + sptr(new DeviceStatusClient::DeviceStatusDeathRecipient()); deathRecipient_->OnRemoteDied(nullptr); DEV_HILOGE(INNERKIT, "test OnRemoteDied end"); - auto& client = DevicestatusClient::GetInstance(); + auto& client = DeviceStatusClient::GetInstance(); EXPECT_TRUE(client.devicestatusProxy_ != nullptr); - GTEST_LOG_(INFO) << "DevicestatusClientTest007 end"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest007 end"; } /** - * @tc.name: DevicestatusClientTest008 + * @tc.name: DeviceStatusClientTest008 * @tc.desc: test proxy double subscribe * @tc.type: FUNC */ -HWTEST_F (DevicestatusClientTest, DevicestatusClientTest008, TestSize.Level1) +HWTEST_F (DeviceStatusClientTest, DeviceStatusClientTest008, TestSize.Level1) { - GTEST_LOG_(INFO) << "DevicestatusClientTest008 start"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest008 start"; sptr callback = sptr(new (std::nothrow) DeviceStatusAgent::DeviceStatusAgentCallback(agent_)); - auto& client = DevicestatusClient::GetInstance(); + auto& client = DeviceStatusClient::GetInstance(); DEV_HILOGE(INNERKIT, "test SubscribeCallback start"); - client.SubscribeCallback(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, callback); - client.SubscribeCallback(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, callback); + client.SubscribeCallback(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, callback); + client.SubscribeCallback(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, callback); DEV_HILOGE(INNERKIT, "test SubscribeCallback end"); - GTEST_LOG_(INFO) << "DevicestatusClientTest008 end"; + GTEST_LOG_(INFO) << "DeviceStatusClientTest008 end"; } } diff --git a/services/native/test/unittest/src/devicestatus_service_test.cpp b/services/native/test/unittest/src/devicestatus_service_test.cpp index a6ab610df..f005f48ff 100644 --- a/services/native/test/unittest/src/devicestatus_service_test.cpp +++ b/services/native/test/unittest/src/devicestatus_service_test.cpp @@ -33,26 +33,26 @@ using namespace OHOS::Msdp::DeviceStatus; using namespace OHOS; using namespace std; -void DevicestatusServiceTest::DevicestatusServiceTestCallback::OnDevicestatusChanged(const \ - DevicestatusDataUtils::DevicestatusData& devicestatusData) +void DeviceStatusServiceTest::DeviceStatusServiceTestCallback::OnDeviceStatusChanged(const \ + DeviceStatusDataUtils::DeviceStatusData& devicestatusData) { - GTEST_LOG_(INFO) << "DevicestatusServiceTestCallback type: " << devicestatusData.type; - GTEST_LOG_(INFO) << "DevicestatusServiceTestCallback value: " << devicestatusData.value; - EXPECT_TRUE(devicestatusData.type == DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL && \ - devicestatusData.value == DevicestatusDataUtils::DevicestatusValue::VALUE_ENTER) << \ - "DevicestatusServiceTestCallback failed"; + GTEST_LOG_(INFO) << "DeviceStatusServiceTestCallback type: " << devicestatusData.type; + GTEST_LOG_(INFO) << "DeviceStatusServiceTestCallback value: " << devicestatusData.value; + EXPECT_TRUE(devicestatusData.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL && \ + devicestatusData.value == DeviceStatusDataUtils::DeviceStatusValue::VALUE_ENTER) << \ + "DeviceStatusServiceTestCallback failed"; } /** - * @tc.name: DevicestatusCallbackTest + * @tc.name: DeviceStatusCallbackTest * @tc.desc: test devicestatus callback in proxy * @tc.type: FUNC */ -HWTEST_F (DevicestatusServiceTest, DevicestatusCallbackTest, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, DeviceStatusCallbackTest, TestSize.Level0) { - DevicestatusDataUtils::DevicestatusType type = DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL; - auto& devicestatusClient = DevicestatusClient::GetInstance(); - sptr cb = new (std::nothrow) DevicestatusServiceTestCallback(); + DeviceStatusDataUtils::DeviceStatusType type = DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL; + auto& devicestatusClient = DeviceStatusClient::GetInstance(); + sptr cb = new (std::nothrow) DeviceStatusServiceTestCallback(); EXPECT_FALSE(cb == nullptr); GTEST_LOG_(INFO) << "Start register"; devicestatusClient.SubscribeCallback(type, cb); @@ -61,110 +61,110 @@ HWTEST_F (DevicestatusServiceTest, DevicestatusCallbackTest, TestSize.Level0) } /** - * @tc.name: GetDevicestatusDataTest + * @tc.name: GetDeviceStatusDataTest * @tc.desc: test get devicestatus data in proxy * @tc.type: FUNC */ -HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest001, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, GetDeviceStatusDataTest001, TestSize.Level0) { - DEV_HILOGI(SERVICE, "GetDevicestatusDataTest001 Enter"); - DevicestatusDataUtils::DevicestatusType type = DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL; - auto& devicestatusClient = DevicestatusClient::GetInstance(); - DevicestatusDataUtils::DevicestatusData data = devicestatusClient.GetDevicestatusData(type); + DEV_HILOGI(SERVICE, "GetDeviceStatusDataTest001 Enter"); + DeviceStatusDataUtils::DeviceStatusType type = DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL; + auto& devicestatusClient = DeviceStatusClient::GetInstance(); + DeviceStatusDataUtils::DeviceStatusData data = devicestatusClient.GetDeviceStatusData(type); GTEST_LOG_(INFO) << "type: " << data.type; GTEST_LOG_(INFO) << "value: " << data.value; - EXPECT_TRUE(data.type == DevicestatusDataUtils::DevicestatusType::TYPE_HIGH_STILL && \ - data.value == DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID) << "GetDevicestatusData failed"; - DEV_HILOGI(SERVICE, "GetDevicestatusDataTest001 end"); + EXPECT_TRUE(data.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_HIGH_STILL && \ + data.value == DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID) << "GetDeviceStatusData failed"; + DEV_HILOGI(SERVICE, "GetDeviceStatusDataTest001 end"); } /** - * @tc.name: GetDevicestatusDataTest + * @tc.name: GetDeviceStatusDataTest * @tc.desc: test get devicestatus data in proxy * @tc.type: FUNC */ -HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest002, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, GetDeviceStatusDataTest002, TestSize.Level0) { - DEV_HILOGI(SERVICE, "GetDevicestatusDataTest002 Enter"); - DevicestatusDataUtils::DevicestatusType type = DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL; - auto& devicestatusClient = DevicestatusClient::GetInstance(); - DevicestatusDataUtils::DevicestatusData data = devicestatusClient.GetDevicestatusData(type); + DEV_HILOGI(SERVICE, "GetDeviceStatusDataTest002 Enter"); + DeviceStatusDataUtils::DeviceStatusType type = DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL; + auto& devicestatusClient = DeviceStatusClient::GetInstance(); + DeviceStatusDataUtils::DeviceStatusData data = devicestatusClient.GetDeviceStatusData(type); GTEST_LOG_(INFO) << "type: " << data.type; GTEST_LOG_(INFO) << "value: " << data.value; - EXPECT_TRUE(data.type == DevicestatusDataUtils::DevicestatusType::TYPE_FINE_STILL && \ - data.value == DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID) << "GetDevicestatusData failed"; - DEV_HILOGI(SERVICE, "GetDevicestatusDataTest002 end"); + EXPECT_TRUE(data.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_FINE_STILL && \ + data.value == DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID) << "GetDeviceStatusData failed"; + DEV_HILOGI(SERVICE, "GetDeviceStatusDataTest002 end"); } /** - * @tc.name: GetDevicestatusDataTest + * @tc.name: GetDeviceStatusDataTest * @tc.desc: test get devicestatus data in proxy * @tc.type: FUNC */ -HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest003, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, GetDeviceStatusDataTest003, TestSize.Level0) { - DEV_HILOGI(SERVICE, "GetDevicestatusDataTest003 Enter"); - DevicestatusDataUtils::DevicestatusType type = DevicestatusDataUtils::DevicestatusType::TYPE_CAR_BLUETOOTH; - auto& devicestatusClient = DevicestatusClient::GetInstance(); - DevicestatusDataUtils::DevicestatusData data = devicestatusClient.GetDevicestatusData(type); + DEV_HILOGI(SERVICE, "GetDeviceStatusDataTest003 Enter"); + DeviceStatusDataUtils::DeviceStatusType type = DeviceStatusDataUtils::DeviceStatusType::TYPE_CAR_BLUETOOTH; + auto& devicestatusClient = DeviceStatusClient::GetInstance(); + DeviceStatusDataUtils::DeviceStatusData data = devicestatusClient.GetDeviceStatusData(type); GTEST_LOG_(INFO) << "type: " << data.type; GTEST_LOG_(INFO) << "value: " << data.value; - EXPECT_TRUE(data.type == DevicestatusDataUtils::DevicestatusType::TYPE_CAR_BLUETOOTH && \ - data.value == DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID) << "GetDevicestatusData failed"; - DEV_HILOGI(SERVICE, "GetDevicestatusDataTest003 end"); + EXPECT_TRUE(data.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_CAR_BLUETOOTH && \ + data.value == DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID) << "GetDeviceStatusData failed"; + DEV_HILOGI(SERVICE, "GetDeviceStatusDataTest003 end"); } -HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest004, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, GetDeviceStatusDataTest004, TestSize.Level0) { - GTEST_LOG_(INFO) << "GetDevicestatusDataTest004 Enter"; - DevicestatusDataUtils::DevicestatusType type = DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN; - auto& devicestatusClient = DevicestatusClient::GetInstance(); - DevicestatusDataUtils::DevicestatusData data = devicestatusClient.GetDevicestatusData(type); + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest004 Enter"; + DeviceStatusDataUtils::DeviceStatusType type = DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN; + auto& devicestatusClient = DeviceStatusClient::GetInstance(); + DeviceStatusDataUtils::DeviceStatusData data = devicestatusClient.GetDeviceStatusData(type); GTEST_LOG_(INFO) << "type: " << data.type; GTEST_LOG_(INFO) << "value: " << data.value; - EXPECT_TRUE(data.type == DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN && \ - data.value == DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID) << "GetDevicestatusDataTest004 failed"; - GTEST_LOG_(INFO) << "GetDevicestatusDataTest004 end"; + EXPECT_TRUE(data.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN && \ + data.value == DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID) << "GetDeviceStatusDataTest004 failed"; + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest004 end"; } -HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest005, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, GetDeviceStatusDataTest005, TestSize.Level0) { - GTEST_LOG_(INFO) << "GetDevicestatusDataTest005 Enter"; - DevicestatusDataUtils::DevicestatusType type = DevicestatusDataUtils::DevicestatusType::TYPE_INVALID; - auto& devicestatusClient = DevicestatusClient::GetInstance(); - DevicestatusDataUtils::DevicestatusData data = devicestatusClient.GetDevicestatusData(type); + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest005 Enter"; + DeviceStatusDataUtils::DeviceStatusType type = DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID; + auto& devicestatusClient = DeviceStatusClient::GetInstance(); + DeviceStatusDataUtils::DeviceStatusData data = devicestatusClient.GetDeviceStatusData(type); GTEST_LOG_(INFO) << "type: " << data.type; GTEST_LOG_(INFO) << "value: " << data.value; - EXPECT_TRUE(data.type == DevicestatusDataUtils::DevicestatusType::TYPE_INVALID && \ - data.value == DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID) << "GetDevicestatusDataTest005 failed"; - GTEST_LOG_(INFO) << "GetDevicestatusDataTest005 end"; + EXPECT_TRUE(data.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID && \ + data.value == DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID) << "GetDeviceStatusDataTest005 failed"; + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest005 end"; } -HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest006, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, GetDeviceStatusDataTest006, TestSize.Level0) { - GTEST_LOG_(INFO) << "GetDevicestatusDataTest006 Enter"; - DevicestatusDataUtils::DevicestatusType type = static_cast(10); - auto& devicestatusClient = DevicestatusClient::GetInstance(); - DevicestatusDataUtils::DevicestatusData data = devicestatusClient.GetDevicestatusData(type); + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest006 Enter"; + DeviceStatusDataUtils::DeviceStatusType type = static_cast(10); + auto& devicestatusClient = DeviceStatusClient::GetInstance(); + DeviceStatusDataUtils::DeviceStatusData data = devicestatusClient.GetDeviceStatusData(type); GTEST_LOG_(INFO) << "type: " << data.type; GTEST_LOG_(INFO) << "value: " << data.value; - EXPECT_TRUE(data.type == DevicestatusDataUtils::DevicestatusType::TYPE_INVALID && \ - data.value == DevicestatusDataUtils::DevicestatusValue::VALUE_INVALID) << "GetDevicestatusDataTest006 failed"; - GTEST_LOG_(INFO) << "GetDevicestatusDataTest006 end"; + EXPECT_TRUE(data.type == DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID && \ + data.value == DeviceStatusDataUtils::DeviceStatusValue::VALUE_INVALID) << "GetDeviceStatusDataTest006 failed"; + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest006 end"; } -HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest007, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, GetDeviceStatusDataTest007, TestSize.Level0) { - GTEST_LOG_(INFO) << "GetDevicestatusDataTest007 Enter"; - auto devicestatusService = DelayedSpSingleton::GetInstance(); + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest007 Enter"; + auto devicestatusService = DelayedSpSingleton::GetInstance(); devicestatusService->OnDump(); - GTEST_LOG_(INFO) << "GetDevicestatusDataTest007 end"; + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest007 end"; } -HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest008, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, GetDeviceStatusDataTest008, TestSize.Level0) { - GTEST_LOG_(INFO) << "GetDevicestatusDataTest008 Enter"; - auto devicestatusService = DelayedSpSingleton::GetInstance(); + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest008 Enter"; + auto devicestatusService = DelayedSpSingleton::GetInstance(); std::vector args; int32_t ret = devicestatusService->Dump(-1, args); EXPECT_TRUE(ret == RET_NG); @@ -173,50 +173,50 @@ HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest008, TestSize.Level0) args.emplace_back(ARGS_H); ret = devicestatusService->Dump(1, args); EXPECT_TRUE(ret == RET_OK); - GTEST_LOG_(INFO) << "GetDevicestatusDataTest008 end"; + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest008 end"; } -HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest009, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, GetDeviceStatusDataTest009, TestSize.Level0) { - GTEST_LOG_(INFO) << "GetDevicestatusDataTest009 Enter"; - auto devicestatusCBDeathRecipient = new (std::nothrow) DevicestatusManager::DevicestatusCallbackDeathRecipient(); + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest009 Enter"; + auto devicestatusCBDeathRecipient = new (std::nothrow) DeviceStatusManager::DeviceStatusCallbackDeathRecipient(); devicestatusCBDeathRecipient->OnRemoteDied(nullptr); - GTEST_LOG_(INFO) << "GetDevicestatusDataTest009 end"; + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest009 end"; } -HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest010, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, GetDeviceStatusDataTest010, TestSize.Level0) { - GTEST_LOG_(INFO) << "GetDevicestatusDataTest010 Enter"; - auto devicestatusService = DelayedSpSingleton::GetInstance(); - auto devicestatusManager = std::make_shared(devicestatusService); + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest010 Enter"; + auto devicestatusService = DelayedSpSingleton::GetInstance(); + auto devicestatusManager = std::make_shared(devicestatusService); Security::AccessToken::AccessTokenID tokenId = static_cast(1); std::string packageName; devicestatusManager->GetPackageName(tokenId, packageName); - GTEST_LOG_(INFO) << "GetDevicestatusDataTest010 end"; + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest010 end"; } -HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest011, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, GetDeviceStatusDataTest011, TestSize.Level0) { - GTEST_LOG_(INFO) << "GetDevicestatusDataTest011 Enter"; - auto devicestatusService = DelayedSpSingleton::GetInstance(); + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest011 Enter"; + auto devicestatusService = DelayedSpSingleton::GetInstance(); devicestatusService->OnStop(); devicestatusService->OnStart(); devicestatusService->OnStart(); devicestatusService->OnStop(); - GTEST_LOG_(INFO) << "GetDevicestatusDataTest011 end"; + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest011 end"; } -HWTEST_F (DevicestatusServiceTest, GetDevicestatusDataTest012, TestSize.Level0) +HWTEST_F (DeviceStatusServiceTest, GetDeviceStatusDataTest012, TestSize.Level0) { - GTEST_LOG_(INFO) << "GetDevicestatusDataTest012 Enter"; - auto devicestatusService = DelayedSpSingleton::GetInstance(); - auto devicestatusManager = std::make_shared(devicestatusService); + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest012 Enter"; + auto devicestatusService = DelayedSpSingleton::GetInstance(); + auto devicestatusManager = std::make_shared(devicestatusService); bool result = devicestatusManager->Init(); EXPECT_TRUE(result); int32_t ret = devicestatusManager->LoadAlgorithm(false); EXPECT_TRUE(ret == RET_OK); ret = devicestatusManager->UnloadAlgorithm(false); EXPECT_TRUE(ret == RET_OK); - DelayedSpSingleton::DestroyInstance(); - GTEST_LOG_(INFO) << "GetDevicestatusDataTest012 end"; + DelayedSpSingleton::DestroyInstance(); + GTEST_LOG_(INFO) << "GetDeviceStatusDataTest012 end"; } \ No newline at end of file diff --git a/test/fuzztest/devicestatusagent_fuzzer/devicestatusagent_fuzzer.cpp b/test/fuzztest/devicestatusagent_fuzzer/devicestatusagent_fuzzer.cpp index 719a9b291..78b07ae36 100644 --- a/test/fuzztest/devicestatusagent_fuzzer/devicestatusagent_fuzzer.cpp +++ b/test/fuzztest/devicestatusagent_fuzzer/devicestatusagent_fuzzer.cpp @@ -21,56 +21,56 @@ using namespace OHOS::Msdp::DeviceStatus; namespace { const int WAIT_TIME = 1000; } -static std::shared_ptr agentEvent_ = - std::make_shared(); +static std::shared_ptr agentEvent_ = + std::make_shared(); static std::shared_ptr agent_ = std::make_shared(); -bool DevicestatusAgentFuzzer::DeviceStatusAgentClient::OnEventResult( - const DevicestatusDataUtils::DevicestatusData& devicestatusData) +bool DeviceStatusAgentFuzzer::DeviceStatusAgentClient::OnEventResult( + const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) { std::cout << "type: " << devicestatusData.type << std::endl; std::cout << "value: " << devicestatusData.value << std::endl; return true; } -void DevicestatusAgentFuzzer::TestSubscribeAgentEvent(const uint8_t* data) +void DeviceStatusAgentFuzzer::TestSubscribeAgentEvent(const uint8_t* data) { std::cout << "TestSubscribeAgentEvent: Enter " << std::endl; - agent_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, agentEvent_); + agent_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, agentEvent_); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_TIME)); TestUnsubscribeAgentEvent(agent_); } -void DevicestatusAgentFuzzer::TestUnsubscribeAgentEvent(const std::shared_ptr& agent_) +void DeviceStatusAgentFuzzer::TestUnsubscribeAgentEvent(const std::shared_ptr& agent_) { std::cout << "TestUnsubscribeAgentEvent: Enter " << std::endl; - agent_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN); + agent_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN); } -void DevicestatusAgentFuzzer::TestSubscribeAgentEventIsNullptr(const uint8_t* data) +void DeviceStatusAgentFuzzer::TestSubscribeAgentEventIsNullptr(const uint8_t* data) { std::cout << "TestSubscribeAgentEventIsNullptr: Enter " << std::endl; agentEvent_ = nullptr; - agent_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, agentEvent_); + agent_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, agentEvent_); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_TIME)); TestUnsubscribeAgentEvent(agent_); } -void DevicestatusAgentFuzzer::TestSubscribeAgentEventTypeIsNullptr(const uint8_t* data) +void DeviceStatusAgentFuzzer::TestSubscribeAgentEventTypeIsNullptr(const uint8_t* data) { std::cout << "TestSubscribeAgentEventTypeIsNullptr: Enter " << std::endl; - agent_->SubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID, agentEvent_); + agent_->SubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID, agentEvent_); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_TIME)); TestUnsubscribeAgentEventTypeIsNullptr(agent_); } -void DevicestatusAgentFuzzer::TestUnsubscribeAgentEventTypeIsNullptr(const std::shared_ptr& agent_) +void DeviceStatusAgentFuzzer::TestUnsubscribeAgentEventTypeIsNullptr(const std::shared_ptr& agent_) { std::cout << "TestUnsubscribeAgentEventTypeIsNullptr: Enter " << std::endl; - agent_->UnsubscribeAgentEvent(DevicestatusDataUtils::DevicestatusType::TYPE_INVALID); + agent_->UnsubscribeAgentEvent(DeviceStatusDataUtils::DeviceStatusType::TYPE_INVALID); } -bool DevicestatusAgentFuzzer::DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +bool DeviceStatusAgentFuzzer::DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { int idSize = 8; if (static_cast(size) > idSize) { @@ -85,6 +85,6 @@ bool DevicestatusAgentFuzzer::DoSomethingInterestingWithMyAPI(const uint8_t* dat extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ - OHOS::Msdp::DeviceStatus::DevicestatusAgentFuzzer::DoSomethingInterestingWithMyAPI(data, size); + OHOS::Msdp::DeviceStatus::DeviceStatusAgentFuzzer::DoSomethingInterestingWithMyAPI(data, size); return 0; } diff --git a/test/fuzztest/devicestatusagent_fuzzer/devicestatusagent_fuzzer.h b/test/fuzztest/devicestatusagent_fuzzer/devicestatusagent_fuzzer.h index 64f6467d4..51aa998a2 100644 --- a/test/fuzztest/devicestatusagent_fuzzer/devicestatusagent_fuzzer.h +++ b/test/fuzztest/devicestatusagent_fuzzer/devicestatusagent_fuzzer.h @@ -39,7 +39,7 @@ enum class ApiNumber { NUM_TWO, NUM_THREE }; -class DevicestatusAgentFuzzer { +class DeviceStatusAgentFuzzer { public: static bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size); static void TestSubscribeAgentEvent(const uint8_t* data); @@ -50,7 +50,7 @@ public: class DeviceStatusAgentClient : public DeviceStatusAgent::DeviceStatusAgentEvent { public: virtual ~DeviceStatusAgentClient() {}; - bool OnEventResult(const DevicestatusDataUtils::DevicestatusData& devicestatusData) override; + bool OnEventResult(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) override; }; }; } // namespace DeviceStatus diff --git a/test/fuzztest/devicestatusclient_fuzzer/devicestatusclient_fuzzer.cpp b/test/fuzztest/devicestatusclient_fuzzer/devicestatusclient_fuzzer.cpp index d98dd35c4..049e5e28b 100755 --- a/test/fuzztest/devicestatusclient_fuzzer/devicestatusclient_fuzzer.cpp +++ b/test/fuzztest/devicestatusclient_fuzzer/devicestatusclient_fuzzer.cpp @@ -21,45 +21,45 @@ using namespace std; using namespace OHOS; using namespace OHOS::Msdp::DeviceStatus; -auto &client_ = DevicestatusClient::GetInstance(); -sptr cb = new DevicestatusClientFuzzer::DevicestatusTestCallback(); +auto &client_ = DeviceStatusClient::GetInstance(); +sptr cb = new DeviceStatusClientFuzzer::DeviceStatusTestCallback(); const int WAIT_TIME = 1000; -void DevicestatusClientFuzzer::DevicestatusTestCallback::OnDevicestatusChanged(const \ - DevicestatusDataUtils::DevicestatusData& devicestatusData) +void DeviceStatusClientFuzzer::DeviceStatusTestCallback::OnDeviceStatusChanged(const \ + DeviceStatusDataUtils::DeviceStatusData& devicestatusData) { - std::cout << "DevicestatusTestCallback type: " << devicestatusData.type << std::endl; - std::cout << "DevicestatusTestCallback value: " << devicestatusData.value << std::endl; + std::cout << "DeviceStatusTestCallback type: " << devicestatusData.type << std::endl; + std::cout << "DeviceStatusTestCallback value: " << devicestatusData.value << std::endl; } -void DevicestatusClientFuzzer::TestSubscribeCallback(const uint8_t* data) +void DeviceStatusClientFuzzer::TestSubscribeCallback(const uint8_t* data) { std::cout << "TestSubscribeCallback: Enter " << std::endl; - client_.SubscribeCallback(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, cb); + client_.SubscribeCallback(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, cb); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_TIME)); - TestGetDevicestatusData(); + TestGetDeviceStatusData(); } -void DevicestatusClientFuzzer::TestGetDevicestatusData() +void DeviceStatusClientFuzzer::TestGetDeviceStatusData() { - std::cout << "TestGetDevicestatusData: Enter " << std::endl; - client_.GetDevicestatusData(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN); + std::cout << "TestGetDeviceStatusData: Enter " << std::endl; + client_.GetDeviceStatusData(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_TIME)); TestUnsubscribeCallback(); } -void DevicestatusClientFuzzer::TestUnsubscribeCallback() +void DeviceStatusClientFuzzer::TestUnsubscribeCallback() { std::cout << "TestUnsubscribeCallback: Enter " << std::endl; - client_.UnsubscribeCallback(DevicestatusDataUtils::DevicestatusType::TYPE_LID_OPEN, cb); + client_.UnsubscribeCallback(DeviceStatusDataUtils::DeviceStatusType::TYPE_LID_OPEN, cb); } bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { - DevicestatusClientFuzzer::TestSubscribeCallback(data); + DeviceStatusClientFuzzer::TestSubscribeCallback(data); return true; } diff --git a/test/fuzztest/devicestatusclient_fuzzer/devicestatusclient_fuzzer.h b/test/fuzztest/devicestatusclient_fuzzer/devicestatusclient_fuzzer.h index 53a372655..7be16c78c 100755 --- a/test/fuzztest/devicestatusclient_fuzzer/devicestatusclient_fuzzer.h +++ b/test/fuzztest/devicestatusclient_fuzzer/devicestatusclient_fuzzer.h @@ -32,18 +32,18 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DevicestatusClientFuzzer { +class DeviceStatusClientFuzzer { public: static bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size); static void TestSubscribeCallback(const uint8_t* data); - static void TestGetDevicestatusData(); + static void TestGetDeviceStatusData(); static void TestUnsubscribeCallback(); - class DevicestatusTestCallback : public DevicestatusCallbackStub { + class DeviceStatusTestCallback : public DeviceStatusCallbackStub { public: - DevicestatusTestCallback() {}; - virtual ~DevicestatusTestCallback() {}; - virtual void OnDevicestatusChanged(const DevicestatusDataUtils::DevicestatusData& devicestatusData) override; + DeviceStatusTestCallback() {}; + virtual ~DeviceStatusTestCallback() {}; + virtual void OnDeviceStatusChanged(const DeviceStatusDataUtils::DeviceStatusData& devicestatusData) override; }; }; } // namespace DeviceStatus diff --git a/utils/common/include/devicestatus_common.h b/utils/common/include/devicestatus_common.h index 5655e6fe3..585430a41 100644 --- a/utils/common/include/devicestatus_common.h +++ b/utils/common/include/devicestatus_common.h @@ -140,7 +140,7 @@ namespace DeviceStatus { } while (0) template -constexpr auto DevicestatusToUnderlying(E e) noexcept +constexpr auto DeviceStatusToUnderlying(E e) noexcept { return static_cast>(e); } diff --git a/utils/common/include/devicestatus_errors.h b/utils/common/include/devicestatus_errors.h index afeba51e4..e1fad9db1 100644 --- a/utils/common/include/devicestatus_errors.h +++ b/utils/common/include/devicestatus_errors.h @@ -23,11 +23,11 @@ namespace Msdp { namespace DeviceStatus { enum { /** - * Module type: Devicestatus Service + * Module type: DeviceStatus Service */ DEVICESTATUS_MODULE_TYPE_SERVICE = 0, /** - * Module type: Devicestatus Kit + * Module type: DeviceStatus Kit */ DEVICESTATUS_MODULE_TYPE_KIT = 1, DEVICESTATUS_MODULE_TYPE_CLIENT = 2 diff --git a/utils/common/include/devicestatus_hilog_wrapper.h b/utils/common/include/devicestatus_hilog_wrapper.h index 35609c929..79ec2a8f1 100644 --- a/utils/common/include/devicestatus_hilog_wrapper.h +++ b/utils/common/include/devicestatus_hilog_wrapper.h @@ -56,7 +56,7 @@ namespace DeviceStatus { #endif // param of log interface, such as DEV_HILOGF. -enum DevicestatusSubModule { +enum DeviceStatusSubModule { INNERKIT = 0, SERVICE, JS_NAPI, @@ -64,10 +64,10 @@ enum DevicestatusSubModule { BUTT, }; -// 0xD002220: subsystem:Msdp module:Devicestatus, 8 bits reserved. +// 0xD002220: subsystem:Msdp module:DeviceStatus, 8 bits reserved. static constexpr unsigned int BASE_MSDP_DOMAIN_ID = 0xD002220; -enum DevicestatusDomainId { +enum DeviceStatusDomainId { DEVICESTATUS_INNERKIT_DOMAIN = BASE_MSDP_DOMAIN_ID + INNERKIT, DEVICESTATUS_SERVICE_DOMAIN, DEVICESTATUS_JS_NAPI, @@ -76,10 +76,10 @@ enum DevicestatusDomainId { }; static constexpr OHOS::HiviewDFX::HiLogLabel DEVICESTATUS_LABEL[BUTT] = { - {LOG_CORE, DEVICESTATUS_INNERKIT_DOMAIN, "DevicestatusClient"}, - {LOG_CORE, DEVICESTATUS_SERVICE_DOMAIN, "DevicestatusService"}, - {LOG_CORE, DEVICESTATUS_JS_NAPI, "DevicestatusJsNapi"}, - {LOG_CORE, DEVICESTATUS_COMMON, "DevicestatusCommon"}, + {LOG_CORE, DEVICESTATUS_INNERKIT_DOMAIN, "DeviceStatusClient"}, + {LOG_CORE, DEVICESTATUS_SERVICE_DOMAIN, "DeviceStatusService"}, + {LOG_CORE, DEVICESTATUS_JS_NAPI, "DeviceStatusJsNapi"}, + {LOG_CORE, DEVICESTATUS_COMMON, "DeviceStatusCommon"}, }; // In order to improve performance, do not check the module range. diff --git a/utils/common/include/devicestatus_permission.h b/utils/common/include/devicestatus_permission.h index 9bd7eb6d8..9657f7f30 100644 --- a/utils/common/include/devicestatus_permission.h +++ b/utils/common/include/devicestatus_permission.h @@ -21,7 +21,7 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -class DevicestatusPermission { +class DeviceStatusPermission { public: /* check caller's permission by finding pid uid by system */ static bool CheckCallingPermission(const std::string &permissionName); diff --git a/utils/common/src/devicestatus_permission.cpp b/utils/common/src/devicestatus_permission.cpp index cc3cfaa44..559c89d85 100644 --- a/utils/common/src/devicestatus_permission.cpp +++ b/utils/common/src/devicestatus_permission.cpp @@ -21,7 +21,7 @@ namespace OHOS { namespace Msdp { namespace DeviceStatus { -bool DevicestatusPermission::CheckCallingPermission(const string &permissionName) +bool DeviceStatusPermission::CheckCallingPermission(const string &permissionName) { Security::AccessToken::AccessTokenID callingToken = IPCSkeleton::GetCallingTokenID(); int32_t auth = Security::AccessToken::TypePermissionState::PERMISSION_DENIED; @@ -34,7 +34,7 @@ bool DevicestatusPermission::CheckCallingPermission(const string &permissionName } } -string DevicestatusPermission::GetAppInfo() +string DeviceStatusPermission::GetAppInfo() { pid_t pid = IPCSkeleton::GetCallingPid(); uid_t uid = IPCSkeleton::GetCallingUid();