Change-Id: Ib91a1846e31f9a761fa0621b28b743ab3d96e732
This commit is contained in:
qianli
2021-07-05 20:37:52 +08:00
parent e6c1e80b7e
commit 23c19c3776
4 changed files with 28 additions and 2 deletions
+5
View File
@@ -31,6 +31,11 @@ int main(int argc, char *argv[])
// Tell IPCThreadState we're the service manager
OHOS::sptr<OHOS::IRemoteObject> 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");
@@ -145,7 +145,7 @@ sptr<IRemoteObject> SystemAbilityManager::CheckLocalAbilityManager(const u16stri
sptr<IRemoteObject> SystemAbilityManager::GetSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
{
return nullptr;
return CheckSystemAbility(systemAbilityId, deviceId);
}
sptr<IRemoteObject> SystemAbilityManager::CheckSystemAbility(int32_t systemAbilityId)
@@ -190,7 +190,14 @@ bool SystemAbilityManager::CheckDistributedPermission()
sptr<IRemoteObject> SystemAbilityManager::CheckSystemAbility(int32_t systemAbilityId,
const std::string& deviceId)
{
return nullptr;
sptr<DBinderServiceStub> 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)
+2
View File
@@ -27,6 +27,8 @@ std::u16string DeleteAllMark(const std::u16string& str, const std::u16string& ma
// template<typename T>
std::u16string DeleteBlank(const std::u16string& str);
std::string AnonymizeDeviceId(const std::string& deviceId);
}
#endif // !defined(UTILS_NATIVE_INCLUDE_TOOLS_H_)
+12
View File
@@ -20,6 +20,8 @@
#include <string>
namespace OHOS {
const std::string EMPTY_DEVICEID = "";
constexpr int NON_ANONYMIZE_LENGTH = 6;
// template<typename T>
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;
}
}