From 3bb6b0dea6cfb6420a0cd4e073d77ce1e68b0ef9 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Mon, 25 Apr 2022 15:21:02 +0800 Subject: [PATCH 01/12] =?UTF-8?q?HiSysEvent=E6=89=93=E7=82=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- services/sensor/BUILD.gn | 7 +++- services/sensor/include/client_info.h | 2 +- services/sensor/include/sensor_service.h | 2 ++ services/sensor/src/sensor_manager.cpp | 10 ++++++ services/sensor/src/sensor_service.cpp | 44 +++++++++++++++--------- 5 files changed, 46 insertions(+), 19 deletions(-) diff --git a/services/sensor/BUILD.gn b/services/sensor/BUILD.gn index 96e9a20a..734aad8f 100644 --- a/services/sensor/BUILD.gn +++ b/services/sensor/BUILD.gn @@ -46,7 +46,10 @@ ohos_shared_library("libsensor_service") { "hdi_connection/hardware/include", ] - deps = [ "$SUBSYSTEM_DIR/sensor/utils:libsensor_utils" ] + deps = [ + "$SUBSYSTEM_DIR/sensor/utils:libsensor_utils", + "//foundation/aafwk/standard/interfaces/innerkits/want:want", + ] external_deps = [ "access_token:libaccesstoken_sdk", @@ -57,6 +60,8 @@ ohos_shared_library("libsensor_service") { "samgr_standard:samgr_proxy", "sensor_device_driver:libsensor_proxy_1.0", "utils_base:utils", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", ] part_name = "sensor" subsystem_name = "sensors" diff --git a/services/sensor/include/client_info.h b/services/sensor/include/client_info.h index 6566048a..f2d2e0db 100644 --- a/services/sensor/include/client_info.h +++ b/services/sensor/include/client_info.h @@ -73,10 +73,10 @@ public: void UpdateDataQueue(int32_t sensorId, struct SensorEvent &event); std::unordered_map> GetDumpQueue(); void ClearDataQueue(int32_t sensorId); + int32_t GetUidByPid(int32_t pid); private: DISALLOW_COPY_AND_MOVE(ClientInfo); - int32_t GetUidByPid(int32_t pid); std::vector GetCmdList(uint32_t sensorId, int32_t uid); std::mutex clientMutex_; std::mutex channelMutex_; diff --git a/services/sensor/include/sensor_service.h b/services/sensor/include/sensor_service.h index b84b37ee..89e16106 100644 --- a/services/sensor/include/sensor_service.h +++ b/services/sensor/include/sensor_service.h @@ -70,6 +70,8 @@ public: void ProcessDeathObserver(const wptr &object); + ErrCode DisableSensor(uint32_t sensorId, int32_t pid); + private: DISALLOW_COPY_AND_MOVE(SensorService); void RegisterClientDeathRecipient(sptr sensorClient, int32_t pid); diff --git a/services/sensor/src/sensor_manager.cpp b/services/sensor/src/sensor_manager.cpp index 777834a0..aa2294cc 100644 --- a/services/sensor/src/sensor_manager.cpp +++ b/services/sensor/src/sensor_manager.cpp @@ -15,9 +15,13 @@ #include "sensor_manager.h" +#include "bundle_mgr_interface.h" +#include "bundle_mgr_client.h" +#include "iservice_registry.h" #include "sensor.h" #include "sensors_errors.h" #include "sensors_log_domain.h" +#include "system_ability_definition.h" namespace OHOS { namespace Sensors { @@ -181,6 +185,12 @@ ErrCode SensorManager::AfterDisableSensor(uint32_t sensorId) void SensorManager::GetPackageNameFromUid(int32_t uid, std::string &packageName) { CALL_LOG_ENTER; + AppExecFwk::BundleMgrClient bundleMgrClient; + auto ret = bundleMgrClient.GetBundleNameForUid(uid, packageName); + if (ret != ERR_OK) { + SEN_HILOGE("GetNameForUid failed, ret : %{public}d, packageName : %{public}s", uid, packageName.c_str()); + return; + } } } // namespace Sensors } // namespace OHOS diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index 2d5c0f16..626280d4 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -169,13 +169,13 @@ void SensorService::ReportSensorSysEvent(uint32_t sensorId, bool enable) if (enable) { // define in LogPower.java, 500 stand for enable sensor message.append("uid : ").append(std::to_string(uid)).append(" pkgName : ").append(packageName) - .append(" type : "); + .append(" type : ").append(std::to_string(sensorId)); HiSysEvent::Write(HiSysEvent::Domain::SENSORS, "EnableSensor", HiSysEvent::EventType::FAULT, "LEVEL", logLevel, "TAG", "DUBAI_TAG_HSENSOR_ENABLE", "MESSAGE", message); } else { // define in LogPower.java, 501 stand for disable sensor message.append("uid : ").append(std::to_string(uid)).append(" pkgName : ").append(packageName) - .append(" type : "); + .append(" type : ").append(std::to_string(sensorId)); HiSysEvent::Write(HiSysEvent::Domain::SENSORS, "DisableSensor", HiSysEvent::EventType::FAULT, "LEVEL", logLevel, "TAG", "DUBAI_TAG_HSENSOR_DISABLE", "MESSAGE", message); } @@ -235,7 +235,6 @@ ErrCode SensorService::EnableSensor(uint32_t sensorId, int64_t samplingPeriodNs, SEN_HILOGE("sensorId is 0 or maxReportDelayNs exceeded the maximum value"); return ERR_NO_INIT; } - ReportSensorSysEvent(sensorId, true); std::lock_guard serviceLock(serviceLock_); if (clientInfo_.GetSensorState(sensorId)) { SEN_HILOGW("sensor has been enabled already"); @@ -244,6 +243,7 @@ ErrCode SensorService::EnableSensor(uint32_t sensorId, int64_t samplingPeriodNs, SEN_HILOGE("SaveSubscriber failed"); return ret; } + ReportSensorSysEvent(sensorId, true); uint32_t flag = sensorManager_.GetSensorFlag(sensorId); int32_t pid = this->GetCallingPid(); ret = flushInfo_.FlushProcess(sensorId, flag, pid, true); @@ -266,29 +266,25 @@ ErrCode SensorService::EnableSensor(uint32_t sensorId, int64_t samplingPeriodNs, clientInfo_.RemoveSubscriber(sensorId, this->GetCallingPid()); return ENABLE_SENSOR_ERR; } - + ReportSensorSysEvent(sensorId, true); return ret; } -ErrCode SensorService::DisableSensor(uint32_t sensorId) +ErrCode SensorService::DisableSensor(uint32_t sensorId, int32_t pid) { CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID) { SEN_HILOGE("sensorId is invalid"); return ERR_NO_INIT; } - ReportSensorSysEvent(sensorId, false); - std::lock_guard serviceLock(serviceLock_); - const int32_t clientPid = this->GetCallingPid(); - if (clientPid < 0) { - SEN_HILOGE("clientPid is invalid, clientPid : %{public}d", clientPid); + if (pid < 0) { + SEN_HILOGE("pid is invalid, pid : %{public}d", pid); return CLIENT_PID_INVALID_ERR; } - if (!clientInfo_.GetSensorState(sensorId)) { - SEN_HILOGE("sensor should be enabled first"); - return DISABLE_SENSOR_ERR; - } - if (sensorManager_.IsOtherClientUsingSensor(sensorId, clientPid)) { + ReportSensorSysEvent(sensorId, false); + int32_t uid = clientInfo_.GetUidByPid(pid); + std::lock_guard serviceLock(serviceLock_); + if (sensorManager_.IsOtherClientUsingSensor(sensorId, pid)) { SEN_HILOGW("other client is using this sensor now, cannot disable"); return ERR_OK; } @@ -296,11 +292,17 @@ ErrCode SensorService::DisableSensor(uint32_t sensorId) SEN_HILOGE("DisableSensor is failed"); return DISABLE_SENSOR_ERR; } - clientInfo_.DestroyCmd(this->GetCallingUid()); + clientInfo_.DestroyCmd(uid); clientInfo_.ClearDataQueue(sensorId); return sensorManager_.AfterDisableSensor(sensorId); } +ErrCode SensorService::DisableSensor(uint32_t sensorId) +{ + CALL_LOG_ENTER; + return DisableSensor(sensorId, this->GetCallingPid()); +} + int32_t SensorService::GetSensorState(uint32_t sensorId) { if (sensorId == INVALID_SENSOR_ID) { @@ -404,9 +406,17 @@ void SensorService::ProcessDeathObserver(const wptr &object) return; } SEN_HILOGI("pid is %d", pid); + std::vector activeSensors = clientInfo_.GetSensorIdByPid(pid); + for (uint32_t i = 0;i < activeSensors.size();++i) { + int32_t ret = DisableSensor(activeSensors[i], pid); + if (ret != ERR_OK) { + SEN_HILOGE("disablesensor failed, ret : %{pubilc}d", ret); + } + } + int32_t uid = clientInfo_.GetUidByPid(pid); clientInfo_.DestroySensorChannel(pid); clientInfo_.DestroyClientPid(client); - clientInfo_.DestroyCmd(this->GetCallingUid()); + clientInfo_.DestroyCmd(uid); } void SensorService::RegisterClientDeathRecipient(sptr sensorClient, int32_t pid) -- Gitee From 01d0ae3fbc68884af845bc6fb05022702d7cdf58 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Fri, 29 Apr 2022 14:53:08 +0800 Subject: [PATCH 02/12] =?UTF-8?q?HiSysEvent=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- services/sensor/include/sensor_service.h | 3 +-- services/sensor/src/sensor_manager.cpp | 1 - services/sensor/src/sensor_service.cpp | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/services/sensor/include/sensor_service.h b/services/sensor/include/sensor_service.h index 89e16106..425a13ff 100644 --- a/services/sensor/include/sensor_service.h +++ b/services/sensor/include/sensor_service.h @@ -70,8 +70,6 @@ public: void ProcessDeathObserver(const wptr &object); - ErrCode DisableSensor(uint32_t sensorId, int32_t pid); - private: DISALLOW_COPY_AND_MOVE(SensorService); void RegisterClientDeathRecipient(sptr sensorClient, int32_t pid); @@ -82,6 +80,7 @@ private: bool InitSensorPolicy(); void ReportOnChangeData(uint32_t sensorId); void ReportSensorSysEvent(uint32_t sensorId, bool enable); + ErrCode DisableSensor(uint32_t sensorId, int32_t pid); SensorServiceState state_; std::mutex serviceLock_; std::mutex sensorsMutex_; diff --git a/services/sensor/src/sensor_manager.cpp b/services/sensor/src/sensor_manager.cpp index aa2294cc..65a8d060 100644 --- a/services/sensor/src/sensor_manager.cpp +++ b/services/sensor/src/sensor_manager.cpp @@ -189,7 +189,6 @@ void SensorManager::GetPackageNameFromUid(int32_t uid, std::string &packageName) auto ret = bundleMgrClient.GetBundleNameForUid(uid, packageName); if (ret != ERR_OK) { SEN_HILOGE("GetNameForUid failed, ret : %{public}d, packageName : %{public}s", uid, packageName.c_str()); - return; } } } // namespace Sensors diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index 626280d4..05974cc6 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -405,7 +405,7 @@ void SensorService::ProcessDeathObserver(const wptr &object) SEN_HILOGE("pid is -1"); return; } - SEN_HILOGI("pid is %d", pid); + SEN_HILOGI("pid is %{pubilc}d", pid); std::vector activeSensors = clientInfo_.GetSensorIdByPid(pid); for (uint32_t i = 0;i < activeSensors.size();++i) { int32_t ret = DisableSensor(activeSensors[i], pid); -- Gitee From 5c63a25b0dcb2cbd6326d88a452d5a3f33305ee0 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Mon, 9 May 2022 17:16:52 +0800 Subject: [PATCH 03/12] =?UTF-8?q?HiSysEvent=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- services/sensor/src/sensor_service.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index 05974cc6..df4a28db 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -152,10 +152,9 @@ void SensorService::OnStop() } } -void SensorService::ReportSensorSysEvent(uint32_t sensorId, bool enable) +void SensorService::ReportSensorSysEvent(uint32_t sensorId, bool enable, int32_t uid) { char uidChar[REPORT_STATUS_LEN] = {0}; - int32_t uid = this->GetCallingUid(); std::string packageName(""); sensorManager_.GetPackageNameFromUid(uid, packageName); int32_t ret = sprintf_s(uidChar, sizeof(uidChar) - 1, "%d", uid); @@ -235,6 +234,8 @@ ErrCode SensorService::EnableSensor(uint32_t sensorId, int64_t samplingPeriodNs, SEN_HILOGE("sensorId is 0 or maxReportDelayNs exceeded the maximum value"); return ERR_NO_INIT; } + int32_t pid = this->GetCallingPid(); + int32_t uid = clientInfo_.GetUidByPid(pid); std::lock_guard serviceLock(serviceLock_); if (clientInfo_.GetSensorState(sensorId)) { SEN_HILOGW("sensor has been enabled already"); @@ -243,9 +244,8 @@ ErrCode SensorService::EnableSensor(uint32_t sensorId, int64_t samplingPeriodNs, SEN_HILOGE("SaveSubscriber failed"); return ret; } - ReportSensorSysEvent(sensorId, true); + ReportSensorSysEvent(sensorId, true, uid); uint32_t flag = sensorManager_.GetSensorFlag(sensorId); - int32_t pid = this->GetCallingPid(); ret = flushInfo_.FlushProcess(sensorId, flag, pid, true); if (ret != ERR_OK) { SEN_HILOGE("ret : %{public}d", ret); @@ -266,7 +266,7 @@ ErrCode SensorService::EnableSensor(uint32_t sensorId, int64_t samplingPeriodNs, clientInfo_.RemoveSubscriber(sensorId, this->GetCallingPid()); return ENABLE_SENSOR_ERR; } - ReportSensorSysEvent(sensorId, true); + ReportSensorSysEvent(sensorId, true, uid); return ret; } @@ -281,8 +281,8 @@ ErrCode SensorService::DisableSensor(uint32_t sensorId, int32_t pid) SEN_HILOGE("pid is invalid, pid : %{public}d", pid); return CLIENT_PID_INVALID_ERR; } - ReportSensorSysEvent(sensorId, false); int32_t uid = clientInfo_.GetUidByPid(pid); + ReportSensorSysEvent(sensorId, false, uid); std::lock_guard serviceLock(serviceLock_); if (sensorManager_.IsOtherClientUsingSensor(sensorId, pid)) { SEN_HILOGW("other client is using this sensor now, cannot disable"); -- Gitee From 15d4b2fdb7099a7d439695b507486bc49353f421 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Mon, 9 May 2022 17:20:21 +0800 Subject: [PATCH 04/12] =?UTF-8?q?HiSysEvent=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- services/sensor/src/sensor_manager.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/services/sensor/src/sensor_manager.cpp b/services/sensor/src/sensor_manager.cpp index 65a8d060..480df03d 100644 --- a/services/sensor/src/sensor_manager.cpp +++ b/services/sensor/src/sensor_manager.cpp @@ -185,10 +185,27 @@ ErrCode SensorManager::AfterDisableSensor(uint32_t sensorId) void SensorManager::GetPackageNameFromUid(int32_t uid, std::string &packageName) { CALL_LOG_ENTER; - AppExecFwk::BundleMgrClient bundleMgrClient; - auto ret = bundleMgrClient.GetBundleNameForUid(uid, packageName); - if (ret != ERR_OK) { - SEN_HILOGE("GetNameForUid failed, ret : %{public}d, packageName : %{public}s", uid, packageName.c_str()); + sptr systemMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (systemMgr == nullptr) { + SEN_HILOGE("Fail to get system ability mgr"); + return ; + } + + sptr remoteObject = systemMgr->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); + if (remoteObject == nullptr) { + SEN_HILOGE("Fail to get bundle manager proxy"); + return ; + } + + sptr bundleMgrProxy = iface_cast(remoteObject); + if (bundleMgrProxy == nullptr) { + SEN_HILOGE("Bundle mgr proxy is nullptr"); + return ; + } + + if (!bundleMgrProxy->GetNameForUid(uid, packageName)) { + SEN_HILOGE("Get bundle name failed"); + return ; } } } // namespace Sensors -- Gitee From dcf754bee92263ce5f3c60463f8a65fa47f7413e Mon Sep 17 00:00:00 2001 From: cff-gite Date: Mon, 9 May 2022 17:25:39 +0800 Subject: [PATCH 05/12] =?UTF-8?q?HiSysEvent=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- services/sensor/src/sensor_manager.cpp | 8 ++++---- services/sensor/src/sensor_service.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/services/sensor/src/sensor_manager.cpp b/services/sensor/src/sensor_manager.cpp index 480df03d..71b181e1 100644 --- a/services/sensor/src/sensor_manager.cpp +++ b/services/sensor/src/sensor_manager.cpp @@ -188,24 +188,24 @@ void SensorManager::GetPackageNameFromUid(int32_t uid, std::string &packageName) sptr systemMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (systemMgr == nullptr) { SEN_HILOGE("Fail to get system ability mgr"); - return ; + return; } sptr remoteObject = systemMgr->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); if (remoteObject == nullptr) { SEN_HILOGE("Fail to get bundle manager proxy"); - return ; + return; } sptr bundleMgrProxy = iface_cast(remoteObject); if (bundleMgrProxy == nullptr) { SEN_HILOGE("Bundle mgr proxy is nullptr"); - return ; + return; } if (!bundleMgrProxy->GetNameForUid(uid, packageName)) { SEN_HILOGE("Get bundle name failed"); - return ; + return; } } } // namespace Sensors diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index df4a28db..914146fb 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -407,7 +407,7 @@ void SensorService::ProcessDeathObserver(const wptr &object) } SEN_HILOGI("pid is %{pubilc}d", pid); std::vector activeSensors = clientInfo_.GetSensorIdByPid(pid); - for (uint32_t i = 0;i < activeSensors.size();++i) { + for (uint32_t i = 0; i < activeSensors.size(); ++i) { int32_t ret = DisableSensor(activeSensors[i], pid); if (ret != ERR_OK) { SEN_HILOGE("disablesensor failed, ret : %{pubilc}d", ret); -- Gitee From 82c96939ef2e9ebcd4935df864c8e838cf7ac679 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Mon, 9 May 2022 20:12:09 +0800 Subject: [PATCH 06/12] =?UTF-8?q?HiSysEvent=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- services/sensor/include/sensor_service.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/sensor/include/sensor_service.h b/services/sensor/include/sensor_service.h index 425a13ff..2f84a54d 100644 --- a/services/sensor/include/sensor_service.h +++ b/services/sensor/include/sensor_service.h @@ -79,7 +79,7 @@ private: bool InitSensorList(); bool InitSensorPolicy(); void ReportOnChangeData(uint32_t sensorId); - void ReportSensorSysEvent(uint32_t sensorId, bool enable); + void ReportSensorSysEvent(uint32_t sensorId, bool enable, int32_t uid); ErrCode DisableSensor(uint32_t sensorId, int32_t pid); SensorServiceState state_; std::mutex serviceLock_; -- Gitee From 7ddcc14480b97102797480262e879b322002797a Mon Sep 17 00:00:00 2001 From: cff-gite Date: Mon, 9 May 2022 20:51:41 +0800 Subject: [PATCH 07/12] =?UTF-8?q?HiSysEvent=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- services/sensor/BUILD.gn | 8 ++++---- services/sensor/src/sensor_manager.cpp | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/services/sensor/BUILD.gn b/services/sensor/BUILD.gn index 734aad8f..f17756ae 100644 --- a/services/sensor/BUILD.gn +++ b/services/sensor/BUILD.gn @@ -46,13 +46,15 @@ ohos_shared_library("libsensor_service") { "hdi_connection/hardware/include", ] - deps = [ + deps = [ "$SUBSYSTEM_DIR/sensor/utils:libsensor_utils", "//foundation/aafwk/standard/interfaces/innerkits/want:want", - ] + ] external_deps = [ "access_token:libaccesstoken_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -60,8 +62,6 @@ ohos_shared_library("libsensor_service") { "samgr_standard:samgr_proxy", "sensor_device_driver:libsensor_proxy_1.0", "utils_base:utils", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", ] part_name = "sensor" subsystem_name = "sensors" diff --git a/services/sensor/src/sensor_manager.cpp b/services/sensor/src/sensor_manager.cpp index 71b181e1..0b692363 100644 --- a/services/sensor/src/sensor_manager.cpp +++ b/services/sensor/src/sensor_manager.cpp @@ -17,6 +17,7 @@ #include "bundle_mgr_interface.h" #include "bundle_mgr_client.h" +#include "bundle_mgr_proxy.h" #include "iservice_registry.h" #include "sensor.h" #include "sensors_errors.h" -- Gitee From 0e52744913d9479d4cdf155b99ab0575de0ceaa8 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Mon, 9 May 2022 21:38:45 +0800 Subject: [PATCH 08/12] =?UTF-8?q?HiSysEvent=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- services/sensor/src/sensor_manager.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/services/sensor/src/sensor_manager.cpp b/services/sensor/src/sensor_manager.cpp index 0b692363..ee1bb1bd 100644 --- a/services/sensor/src/sensor_manager.cpp +++ b/services/sensor/src/sensor_manager.cpp @@ -187,23 +187,11 @@ void SensorManager::GetPackageNameFromUid(int32_t uid, std::string &packageName) { CALL_LOG_ENTER; sptr systemMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (systemMgr == nullptr) { - SEN_HILOGE("Fail to get system ability mgr"); - return; - } - + CHKPV(systemMgr); sptr remoteObject = systemMgr->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); - if (remoteObject == nullptr) { - SEN_HILOGE("Fail to get bundle manager proxy"); - return; - } - + CHKPV(remoteObject); sptr bundleMgrProxy = iface_cast(remoteObject); - if (bundleMgrProxy == nullptr) { - SEN_HILOGE("Bundle mgr proxy is nullptr"); - return; - } - + CHKPV(bundleMgrProxy); if (!bundleMgrProxy->GetNameForUid(uid, packageName)) { SEN_HILOGE("Get bundle name failed"); return; -- Gitee From 70e95b1dbda229ca491accd2bb567679523b855b Mon Sep 17 00:00:00 2001 From: cff-gite Date: Tue, 10 May 2022 09:29:55 +0800 Subject: [PATCH 09/12] =?UTF-8?q?HiSysEvent=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- services/sensor/src/sensor_service.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index 914146fb..1f9cbfc0 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -407,7 +407,7 @@ void SensorService::ProcessDeathObserver(const wptr &object) } SEN_HILOGI("pid is %{pubilc}d", pid); std::vector activeSensors = clientInfo_.GetSensorIdByPid(pid); - for (uint32_t i = 0; i < activeSensors.size(); ++i) { + for (size_t i = 0; i < activeSensors.size_t(); ++i) { int32_t ret = DisableSensor(activeSensors[i], pid); if (ret != ERR_OK) { SEN_HILOGE("disablesensor failed, ret : %{pubilc}d", ret); @@ -416,7 +416,7 @@ void SensorService::ProcessDeathObserver(const wptr &object) int32_t uid = clientInfo_.GetUidByPid(pid); clientInfo_.DestroySensorChannel(pid); clientInfo_.DestroyClientPid(client); - clientInfo_.DestroyCmd(uid); + clientInfo_.DestroyCmd(clientInfo_.DestroyCmd(uid)); } void SensorService::RegisterClientDeathRecipient(sptr sensorClient, int32_t pid) -- Gitee From eda99dc7eec831a5f34686d5e9277503a45c1533 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Tue, 10 May 2022 09:39:34 +0800 Subject: [PATCH 10/12] =?UTF-8?q?HiSysEvent=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- services/sensor/src/sensor_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index 1f9cbfc0..74361259 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -416,7 +416,7 @@ void SensorService::ProcessDeathObserver(const wptr &object) int32_t uid = clientInfo_.GetUidByPid(pid); clientInfo_.DestroySensorChannel(pid); clientInfo_.DestroyClientPid(client); - clientInfo_.DestroyCmd(clientInfo_.DestroyCmd(uid)); + clientInfo_.DestroyCmd(uid); } void SensorService::RegisterClientDeathRecipient(sptr sensorClient, int32_t pid) -- Gitee From c49df605880561d12702b5eea40784ec29073b7c Mon Sep 17 00:00:00 2001 From: cff-gite Date: Tue, 10 May 2022 10:15:22 +0800 Subject: [PATCH 11/12] =?UTF-8?q?HiSysEvent=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- services/sensor/src/sensor_service.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index 74361259..fa53476f 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -413,10 +413,9 @@ void SensorService::ProcessDeathObserver(const wptr &object) SEN_HILOGE("disablesensor failed, ret : %{pubilc}d", ret); } } - int32_t uid = clientInfo_.GetUidByPid(pid); clientInfo_.DestroySensorChannel(pid); clientInfo_.DestroyClientPid(client); - clientInfo_.DestroyCmd(uid); + clientInfo_.DestroyCmd(clientInfo_.GetUidByPid(pid)); } void SensorService::RegisterClientDeathRecipient(sptr sensorClient, int32_t pid) -- Gitee From b77c0ae5575243f328a2d9cf6c166fad8985c423 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Tue, 10 May 2022 10:34:34 +0800 Subject: [PATCH 12/12] =?UTF-8?q?HiSysEvent=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- services/sensor/src/sensor_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index fa53476f..5b4501bf 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -407,7 +407,7 @@ void SensorService::ProcessDeathObserver(const wptr &object) } SEN_HILOGI("pid is %{pubilc}d", pid); std::vector activeSensors = clientInfo_.GetSensorIdByPid(pid); - for (size_t i = 0; i < activeSensors.size_t(); ++i) { + for (size_t i = 0; i < activeSensors.size(); ++i) { int32_t ret = DisableSensor(activeSensors[i], pid); if (ret != ERR_OK) { SEN_HILOGE("disablesensor failed, ret : %{pubilc}d", ret); -- Gitee