From 23c19c37765c4ee27880a59271c79fa5e64dcea2 Mon Sep 17 00:00:00 2001 From: qianli Date: Mon, 5 Jul 2021 20:37:52 +0800 Subject: [PATCH] Get SA Change-Id: Ib91a1846e31f9a761fa0621b28b743ab3d96e732 --- services/samgr/native/source/sa_main.cpp | 5 +++++ .../samgr/native/source/system_ability_manager.cpp | 11 +++++++++-- utils/native/include/tools.h | 2 ++ utils/native/source/tools.cpp | 12 ++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/services/samgr/native/source/sa_main.cpp b/services/samgr/native/source/sa_main.cpp index 9811be2c..21617062 100755 --- a/services/samgr/native/source/sa_main.cpp +++ b/services/samgr/native/source/sa_main.cpp @@ -31,6 +31,11 @@ int main(int argc, char *argv[]) // Tell IPCThreadState we're the service manager OHOS::sptr serv = manager->AsObject(); IPCSkeleton::SetContextObject(serv); + auto dBinder = manager->GetDBinder(); + if (dBinder != nullptr) { + bool ret = dBinder->StartDBinderService(); + HILOGI("started dbinder service result is %{public}s", ret ? "ok" : "fail"); + } // Create IPCThreadPool and join in. HILOGI("start System Ability Manager Loop"); diff --git a/services/samgr/native/source/system_ability_manager.cpp b/services/samgr/native/source/system_ability_manager.cpp index 3c6058db..b3b77bae 100755 --- a/services/samgr/native/source/system_ability_manager.cpp +++ b/services/samgr/native/source/system_ability_manager.cpp @@ -145,7 +145,7 @@ sptr SystemAbilityManager::CheckLocalAbilityManager(const u16stri sptr SystemAbilityManager::GetSystemAbility(int32_t systemAbilityId, const std::string& deviceId) { - return nullptr; + return CheckSystemAbility(systemAbilityId, deviceId); } sptr SystemAbilityManager::CheckSystemAbility(int32_t systemAbilityId) @@ -190,7 +190,14 @@ bool SystemAbilityManager::CheckDistributedPermission() sptr SystemAbilityManager::CheckSystemAbility(int32_t systemAbilityId, const std::string& deviceId) { - return nullptr; + sptr remoteBinder = nullptr; + if (dBinderService_ != nullptr) { + string strName = to_string(systemAbilityId); + remoteBinder = dBinderService_->MakeRemoteBinder(Str8ToStr16(strName), deviceId, systemAbilityId, 0); + HILOGI("CheckSystemAbility, MakeRemoteBinder, systemAbilityId is %{public}d, deviceId is %s", + systemAbilityId, AnonymizeDeviceId(deviceId).c_str()); + } + return remoteBinder; } int32_t SystemAbilityManager::FindSystemAbilityManagerNotify(int32_t systemAbilityId, int32_t code) diff --git a/utils/native/include/tools.h b/utils/native/include/tools.h index 5b1fa2bf..ff018c76 100644 --- a/utils/native/include/tools.h +++ b/utils/native/include/tools.h @@ -27,6 +27,8 @@ std::u16string DeleteAllMark(const std::u16string& str, const std::u16string& ma // template std::u16string DeleteBlank(const std::u16string& str); + +std::string AnonymizeDeviceId(const std::string& deviceId); } #endif // !defined(UTILS_NATIVE_INCLUDE_TOOLS_H_) diff --git a/utils/native/source/tools.cpp b/utils/native/source/tools.cpp index abc9248b..bdb7f950 100644 --- a/utils/native/source/tools.cpp +++ b/utils/native/source/tools.cpp @@ -20,6 +20,8 @@ #include namespace OHOS { +const std::string EMPTY_DEVICEID = ""; +constexpr int NON_ANONYMIZE_LENGTH = 6; // template std::u16string DeleteAllMark(const std::u16string& str, const std::u16string& mark) { @@ -43,4 +45,14 @@ std::u16string DeleteBlank(const std::u16string& str) res = DeleteAllMark(res, u"/n"); return DeleteAllMark(res, u"/r"); } + +std::string AnonymizeDeviceId(const std::string& deviceId) +{ + if (deviceId.length() < NON_ANONYMIZE_LENGTH) { + return EMPTY_DEVICEID; + } + std::string anonymizeDeviceId = deviceId.substr(0, NON_ANONYMIZE_LENGTH); + anonymizeDeviceId.append("******"); + return anonymizeDeviceId; +} } \ No newline at end of file -- Gitee