mirror of
https://gitee.com/openharmony/deviceprofile_device_info_manager
synced 2024-11-23 07:30:13 +00:00
commit
672c47b4c5
@ -55,6 +55,7 @@ ohos_shared_library("distributed_device_profile_common") {
|
||||
"src/interfaces/dp_inited_callback_stub.cpp",
|
||||
"src/interfaces/dp_subscribe_info.cpp",
|
||||
"src/interfaces/dp_sync_options.cpp",
|
||||
"src/interfaces/i_profile_change_listener.cpp",
|
||||
"src/interfaces/profile_change_listener_proxy.cpp",
|
||||
"src/interfaces/profile_change_listener_stub.cpp",
|
||||
"src/interfaces/service_profile.cpp",
|
||||
|
@ -53,6 +53,7 @@ extern const std::string CHARACTERISTIC_VALUE;
|
||||
extern const std::string SUBSCRIBE_TRUST_DEVICE_PROFILE;
|
||||
extern const std::string DEVICE_ID_TYPE;
|
||||
extern const std::string DEVICE_ID_HASH;
|
||||
extern const std::string PEER_USER_ID;
|
||||
/* AccessControlProfile Attribute */
|
||||
extern const std::string ACCESS_CONTROL_ID;
|
||||
extern const std::string ACCESSER_ID;
|
||||
@ -127,7 +128,7 @@ constexpr int32_t MAX_DUMP_ARGS_SIZE = 1000;
|
||||
constexpr int32_t MAX_LISTENER_SIZE = 100;
|
||||
constexpr int32_t MAX_EVENT_HANDLER_SIZE = 50;
|
||||
constexpr int32_t MAX_DB_RECORD_SIZE = 10000;
|
||||
constexpr int32_t MAX_SUBSCRIBE_CHANGE_SIZE = 3;
|
||||
constexpr int32_t MAX_SUBSCRIBE_CHANGE_SIZE = 6;
|
||||
constexpr int32_t MAX_INTERFACE_SIZE = 20;
|
||||
constexpr int32_t MAX_SUBSCRIBE_INFO_SIZE = 500;
|
||||
constexpr int32_t MAX_SYNC_RESULTS_SIZE = 50;
|
||||
@ -175,6 +176,8 @@ constexpr int32_t ROWCOUNT_INIT = -1;
|
||||
constexpr int32_t CHANGEROWCNT_INIT = -1;
|
||||
constexpr int32_t COLUMNINDEX_INIT = -1;
|
||||
constexpr int32_t STATUS_INIT = 0;
|
||||
constexpr int32_t STATUS_ACTIVE = 1;
|
||||
constexpr int32_t STATUS_INACTIVE = 0;
|
||||
constexpr int32_t BINDTYPE_INIT = -1;
|
||||
constexpr int32_t BINDLEVEL_INIT = -1;
|
||||
constexpr int32_t DELETEROWS_INIT = -1;
|
||||
@ -220,15 +223,20 @@ extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_ACCESSERUSER
|
||||
extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_ACCESSEEUSERID;
|
||||
extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_DEVICEID_AND_ACCESSERTOKENID;
|
||||
extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_DEVICEID_AND_ACCESSEETOKENID;
|
||||
extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_DEVICEID_AND_USERID;
|
||||
extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_DEVICEID_AND_USERID;
|
||||
extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_ACCESSERDEVICEID;
|
||||
extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_ACCESSEEDEVICEID;
|
||||
extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_ACCESSERBUNDLENAME;
|
||||
extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_ACCESSEEBUNDLENAME;
|
||||
extern const std::string SELECT_ACCESSEE_TABLE;
|
||||
extern const std::string SELECT_ACCESSER_TABLE;
|
||||
extern const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_ALL;
|
||||
extern const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_ALL_EXCEPT_STATUS;
|
||||
extern const std::string SELECT_ACCESSER_TABLE_WHERE_ALL;
|
||||
extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ALL;
|
||||
extern const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERDEVICEID_AND_ACCESSERUSERID;
|
||||
extern const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEDEVICEID_AND_ACCESSEEUSERID;
|
||||
extern const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_ACCESSERID_AND_ACCESSEEID;
|
||||
/* SubscribeTrustInfoManager */
|
||||
extern const std::string SUBSCRIBE_TRUST_INFO_TABLE;
|
||||
extern const std::string CREATE_SUBSCRIBE_TRUST_INFO_TABLE_SQL;
|
||||
|
@ -58,7 +58,9 @@ enum class DPInterfaceCode : uint32_t {
|
||||
ON_DEVICE_PROFILE_INITED = 40,
|
||||
SUBSCRIBE_DEVICE_PROFILE_INITED = 41,
|
||||
UNSUBSCRIBE_DEVICE_PROFILE_INITED = 42,
|
||||
MAX = 43
|
||||
ON_TRUST_DEVICE_PROFILE_ACTIVE = 43,
|
||||
ON_TRUST_DEVICE_PROFILE_INACTIVE = 44,
|
||||
MAX = 45
|
||||
};
|
||||
|
||||
enum class DeviceIdType : uint32_t {
|
||||
@ -136,7 +138,9 @@ enum ProfileChangeType {
|
||||
CHAR_PROFILE_ADD = 10,
|
||||
CHAR_PROFILE_UPDATE = 11,
|
||||
CHAR_PROFILE_DELETE = 12,
|
||||
PROFILE_CHANGE_TYPE_MAX = 13
|
||||
TRUST_DEVICE_PROFILE_ACTIVE = 13,
|
||||
TRUST_DEVICE_PROFILE_INACTIVE = 14,
|
||||
PROFILE_CHANGE_TYPE_MAX = 15
|
||||
};
|
||||
enum StaticCapabilityFlag {
|
||||
CAPABILITY_FLAG_MIN = -1,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -33,6 +33,8 @@ public:
|
||||
virtual int32_t OnTrustDeviceProfileDelete(const TrustDeviceProfile& profile) = 0;
|
||||
virtual int32_t OnTrustDeviceProfileUpdate(const TrustDeviceProfile& oldProfile,
|
||||
const TrustDeviceProfile& newProfile) = 0;
|
||||
virtual int32_t OnTrustDeviceProfileActive(const TrustDeviceProfile& profile);
|
||||
virtual int32_t OnTrustDeviceProfileInactive(const TrustDeviceProfile& profile);
|
||||
virtual int32_t OnDeviceProfileAdd(const DeviceProfile& profile) = 0;
|
||||
virtual int32_t OnDeviceProfileDelete(const DeviceProfile& profile) = 0;
|
||||
virtual int32_t OnDeviceProfileUpdate(const DeviceProfile& oldProfile, const DeviceProfile& newProfile) = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -32,6 +32,8 @@ public:
|
||||
int32_t OnTrustDeviceProfileDelete(const TrustDeviceProfile& profile) override;
|
||||
int32_t OnTrustDeviceProfileUpdate(const TrustDeviceProfile& oldProfile,
|
||||
const TrustDeviceProfile& newProfile) override;
|
||||
int32_t OnTrustDeviceProfileActive(const TrustDeviceProfile& profile) override;
|
||||
int32_t OnTrustDeviceProfileInactive(const TrustDeviceProfile& profile) override;
|
||||
int32_t OnDeviceProfileAdd(const DeviceProfile& profile) override;
|
||||
int32_t OnDeviceProfileDelete(const DeviceProfile& profile) override;
|
||||
int32_t OnDeviceProfileUpdate(const DeviceProfile& oldProfile, const DeviceProfile& newProfile) override;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -35,6 +35,8 @@ public:
|
||||
int32_t OnTrustDeviceProfileAddInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t OnTrustDeviceProfileDeleteInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t OnTrustDeviceProfileUpdateInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t OnTrustDeviceProfileActiveInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t OnTrustDeviceProfileInactiveInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t OnDeviceProfileAddInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t OnDeviceProfileDeleteInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t OnDeviceProfileUpdateInner(MessageParcel& data, MessageParcel& reply);
|
||||
@ -44,6 +46,8 @@ public:
|
||||
int32_t OnCharacteristicProfileAddInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t OnCharacteristicProfileDeleteInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t OnCharacteristicProfileUpdateInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t OnTrustDeviceProfileActive(const TrustDeviceProfile& profile) override;
|
||||
int32_t OnTrustDeviceProfileInactive(const TrustDeviceProfile& profile) override;
|
||||
|
||||
private:
|
||||
using Func = int32_t(ProfileChangeListenerStub::*)(MessageParcel& data, MessageParcel& reply);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -29,7 +29,8 @@ public:
|
||||
deviceIdType_(static_cast<uint32_t>(DeviceIdType::MIN)),
|
||||
deviceIdHash_(""),
|
||||
status_(static_cast<int32_t>(Status::MIN)),
|
||||
bindType_(static_cast<uint32_t>(BindType::MIN))
|
||||
bindType_(static_cast<uint32_t>(BindType::MIN)),
|
||||
peerUserId_(-1)
|
||||
{}
|
||||
~TrustDeviceProfile() = default;
|
||||
|
||||
@ -43,6 +44,8 @@ public:
|
||||
void SetStatus(int32_t status);
|
||||
uint32_t GetBindType() const;
|
||||
void SetBindType(uint32_t bindType);
|
||||
int32_t GetPeerUserId() const;
|
||||
void SetPeerUserId(int32_t peerUserId);
|
||||
bool Marshalling(MessageParcel& parcel) const override;
|
||||
bool UnMarshalling(MessageParcel& parcel) override;
|
||||
std::string dump() const override;
|
||||
@ -53,6 +56,7 @@ private:
|
||||
std::string deviceIdHash_;
|
||||
int32_t status_;
|
||||
uint32_t bindType_;
|
||||
int32_t peerUserId_;
|
||||
};
|
||||
} // namespace DistributedDeviceProfile
|
||||
} // namespace OHOS
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "result_set.h"
|
||||
#include "values_bucket.h"
|
||||
|
||||
#include "access_control_profile.h"
|
||||
@ -117,6 +118,17 @@ public:
|
||||
static int32_t GenerateCharacteristicDBkeys(const std::string& deviceId, const std::string& serviceName,
|
||||
const std::string& characteristicKey, std::vector<std::string>& dbKeys, bool isMultiUser = false,
|
||||
int32_t userId = DEFAULT_USER_ID);
|
||||
static int32_t ConvertToTrustDeviceProfile(const AccessControlProfile& accessControlProfile,
|
||||
TrustDeviceProfile& trustDeviceProfile);
|
||||
static int32_t ConvertToAccessControlProfiles(std::shared_ptr<ResultSet> resultSet,
|
||||
std::shared_ptr<ResultSet> accesserResultSet, std::shared_ptr<ResultSet> accesseeResultSet,
|
||||
std::vector<AccessControlProfile>& profile);
|
||||
static int32_t ConvertToTrustDeviceProfile(std::shared_ptr<ResultSet> trustResultSet,
|
||||
TrustDeviceProfile& trustDeviceProfile);
|
||||
static int32_t ConvertToAccesser(std::shared_ptr<ResultSet> accesserResultSet, Accesser& accesser);
|
||||
static int32_t ConvertToAccessee(std::shared_ptr<ResultSet> accesseeResultSet, Accessee& accessee);
|
||||
static int32_t ConvertToAccessControlProfile(std::shared_ptr<ResultSet> accessControlResultSet,
|
||||
AccessControlProfile& accessControlProfile);
|
||||
};
|
||||
} // namespace DistributedDeviceProfile
|
||||
} // namespace OHOS
|
||||
|
@ -43,6 +43,7 @@ const std::string CHARACTERISTIC_VALUE = "characteristicValue";
|
||||
const std::string SUBSCRIBE_TRUST_DEVICE_PROFILE = "trust_device_profile";
|
||||
const std::string DEVICE_ID_TYPE = "deviceIdType";
|
||||
const std::string DEVICE_ID_HASH = "deviceIdHash";
|
||||
const std::string PEER_USER_ID = "peerUserId";
|
||||
/* AccessControlProfile Attribute */
|
||||
const std::string ACCESS_CONTROL_ID = "accessControlId";
|
||||
const std::string ACCESSER_ID = "accesserId";
|
||||
@ -182,7 +183,6 @@ const std::string CREATE_ACCESS_CONTROL_TABLE_UNIQUE_INDEX_SQL =
|
||||
authenticationType,\
|
||||
deviceIdType,\
|
||||
deviceIdHash,\
|
||||
status,\
|
||||
validPeriod,\
|
||||
lastAuthTime,\
|
||||
bindLevel);";
|
||||
@ -250,6 +250,10 @@ const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_DEVICEID_AND_ACCESS
|
||||
"SELECT * FROM accesser_table WHERE accesserId = ? and accesserDeviceId = ? and accesserTokenId = ? ";
|
||||
const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_DEVICEID_AND_ACCESSEETOKENID =
|
||||
"SELECT * FROM accessee_table WHERE accesseeId = ? and accesseeDeviceId = ? and accesseeTokenId = ? ";
|
||||
const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_DEVICEID_AND_USERID =
|
||||
"SELECT * FROM accesser_table WHERE accesserId = ? and accesserDeviceId = ? and accesserUserId = ? ";
|
||||
const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_DEVICEID_AND_USERID =
|
||||
"SELECT * FROM accessee_table WHERE accesseeId = ? and accesseeDeviceId = ? and accesseeUserId = ? ";
|
||||
const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERID_AND_ACCESSERDEVICEID =
|
||||
"SELECT * FROM accesser_table WHERE accesserId = ? and accesserDeviceId = ? ";
|
||||
const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_ACCESSEEDEVICEID =
|
||||
@ -260,16 +264,22 @@ const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEID_AND_ACCESSEEBUNDLENAME
|
||||
"SELECT * FROM accessee_table WHERE accesseeId = ? and accesseeBundleName = ? ";
|
||||
const std::string SELECT_ACCESSEE_TABLE = "SELECT * FROM accessee_table ";
|
||||
const std::string SELECT_ACCESSER_TABLE = "SELECT * FROM accesser_table ";
|
||||
const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_ALL =
|
||||
const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_ALL_EXCEPT_STATUS =
|
||||
"SELECT * FROM access_control_table WHERE accesserId = ? and accesseeId = ? and trustDeviceId = ? and \
|
||||
sessionKey = ? and bindType = ? and authenticationType = ? and deviceIdType = ? and deviceIdHash = ? \
|
||||
and status = ? and validPeriod = ? and lastAuthTime = ? and bindLevel = ? ";
|
||||
and validPeriod = ? and lastAuthTime = ? and bindLevel = ? ";
|
||||
const std::string SELECT_ACCESSER_TABLE_WHERE_ALL =
|
||||
"SELECT * FROM accesser_table WHERE accesserDeviceId = ? and accesserUserId = ? and accesserAccountId = ? and \
|
||||
accesserTokenId = ? and accesserBundleName = ? and accesserHapSignature = ? and accesserBindLevel = ? ";
|
||||
const std::string SELECT_ACCESSEE_TABLE_WHERE_ALL =
|
||||
"SELECT * FROM accessee_table WHERE accesseeDeviceId = ? and accesseeUserId = ? and accesseeAccountId = ? and \
|
||||
accesseeTokenId = ? and accesseeBundleName = ? and accesseeHapSignature = ? and accesseeBindLevel = ? ";
|
||||
const std::string SELECT_ACCESSER_TABLE_WHERE_ACCESSERDEVICEID_AND_ACCESSERUSERID =
|
||||
"SELECT * FROM accesser_table WHERE accesserDeviceId = ? and accesserUserId = ? ";
|
||||
const std::string SELECT_ACCESSEE_TABLE_WHERE_ACCESSEEDEVICEID_AND_ACCESSEEUSERID =
|
||||
"SELECT * FROM accessee_table WHERE accesseeDeviceId = ? and accesseeUserId = ? ";
|
||||
const std::string SELECT_ACCESS_CONTROL_TABLE_WHERE_ACCESSERID_AND_ACCESSEEID =
|
||||
"SELECT * FROM access_control_table WHERE accesserId = ? and accesseeId = ? ";
|
||||
/* SubscribeTrustInfoManager */
|
||||
const std::string SUBSCRIBE_TRUST_INFO_TABLE = "subscribe_trust_info_table";
|
||||
const std::string CREATE_SUBSCRIBE_TRUST_INFO_TABLE_SQL =
|
||||
|
@ -118,9 +118,11 @@ std::unordered_set<ProfileChangeType> SubscribeInfo::GetProfileChangeTypes() con
|
||||
void SubscribeInfo::AddProfileChangeType(ProfileChangeType profileChangeType)
|
||||
{
|
||||
if (profileChangeType <= PROFILE_CHANGE_TYPE_MIN || profileChangeType >= PROFILE_CHANGE_TYPE_MAX) {
|
||||
HILOGE("profileChangeType is invaild");
|
||||
return;
|
||||
}
|
||||
if (subscribeChangeTypes_.size() > MAX_SUBSCRIBE_CHANGE_SIZE) {
|
||||
HILOGE("subscribeChangeTypes_ size greater than max");
|
||||
return;
|
||||
}
|
||||
subscribeChangeTypes_.emplace(profileChangeType);
|
||||
|
37
common/src/interfaces/i_profile_change_listener.cpp
Normal file
37
common/src/interfaces/i_profile_change_listener.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "i_profile_change_listener.h"
|
||||
#include "distributed_device_profile_errors.h"
|
||||
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedDeviceProfile {
|
||||
namespace {
|
||||
const std::string TAG = "IProfileChangeListener";
|
||||
}
|
||||
int32_t IProfileChangeListener::OnTrustDeviceProfileActive(const TrustDeviceProfile& profile)
|
||||
{
|
||||
(void)profile;
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t IProfileChangeListener::OnTrustDeviceProfileInactive(const TrustDeviceProfile& profile)
|
||||
{
|
||||
(void)profile;
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
} // namespace DistributedDeviceProfile
|
||||
} // namespace OHOS
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -74,6 +74,36 @@ int32_t ProfileListenerProxy::OnTrustDeviceProfileUpdate(const TrustDeviceProfil
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileListenerProxy::OnTrustDeviceProfileActive(const TrustDeviceProfile& profile)
|
||||
{
|
||||
sptr<IRemoteObject> remote = nullptr;
|
||||
GET_REMOTE_OBJECT(remote);
|
||||
MessageParcel data;
|
||||
WRITE_CHANGE_LISTENER_TOKEN(data);
|
||||
if (!profile.Marshalling(data)) {
|
||||
HILOGE("write reply failed!");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
MessageParcel reply;
|
||||
SEND_REQUEST(remote, static_cast<uint32_t>(DPInterfaceCode::ON_TRUST_DEVICE_PROFILE_ACTIVE), data, reply);
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileListenerProxy::OnTrustDeviceProfileInactive(const TrustDeviceProfile& profile)
|
||||
{
|
||||
sptr<IRemoteObject> remote = nullptr;
|
||||
GET_REMOTE_OBJECT(remote);
|
||||
MessageParcel data;
|
||||
WRITE_CHANGE_LISTENER_TOKEN(data);
|
||||
if (!profile.Marshalling(data)) {
|
||||
HILOGE("write reply failed!");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
MessageParcel reply;
|
||||
SEND_REQUEST(remote, static_cast<uint32_t>(DPInterfaceCode::ON_TRUST_DEVICE_PROFILE_INACTIVE), data, reply);
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileListenerProxy::OnDeviceProfileAdd(const DeviceProfile& profile)
|
||||
{
|
||||
sptr<IRemoteObject> remote = nullptr;
|
||||
|
@ -38,6 +38,10 @@ ProfileChangeListenerStub::ProfileChangeListenerStub()
|
||||
&ProfileChangeListenerStub::OnTrustDeviceProfileDeleteInner;
|
||||
funcsMap_[static_cast<uint32_t>(DPInterfaceCode::ON_TRUST_DEVICE_PROFILE_UPDATE)] =
|
||||
&ProfileChangeListenerStub::OnTrustDeviceProfileUpdateInner;
|
||||
funcsMap_[static_cast<uint32_t>(DPInterfaceCode::ON_TRUST_DEVICE_PROFILE_ACTIVE)] =
|
||||
&ProfileChangeListenerStub::OnTrustDeviceProfileActiveInner;
|
||||
funcsMap_[static_cast<uint32_t>(DPInterfaceCode::ON_TRUST_DEVICE_PROFILE_INACTIVE)] =
|
||||
&ProfileChangeListenerStub::OnTrustDeviceProfileInactiveInner;
|
||||
funcsMap_[static_cast<uint32_t>(DPInterfaceCode::ON_DEVICE_PROFILE_ADD)] =
|
||||
&ProfileChangeListenerStub::OnDeviceProfileAddInner;
|
||||
funcsMap_[static_cast<uint32_t>(DPInterfaceCode::ON_DEVICE_PROFILE_DELETE)] =
|
||||
@ -84,6 +88,10 @@ int32_t ProfileChangeListenerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
||||
return ProfileChangeListenerStub::OnTrustDeviceProfileDeleteInner(data, reply);
|
||||
case static_cast<uint32_t>(DPInterfaceCode::ON_TRUST_DEVICE_PROFILE_UPDATE):
|
||||
return ProfileChangeListenerStub::OnTrustDeviceProfileUpdateInner(data, reply);
|
||||
case static_cast<uint32_t>(DPInterfaceCode::ON_TRUST_DEVICE_PROFILE_ACTIVE):
|
||||
return ProfileChangeListenerStub::OnTrustDeviceProfileActiveInner(data, reply);
|
||||
case static_cast<uint32_t>(DPInterfaceCode::ON_TRUST_DEVICE_PROFILE_INACTIVE):
|
||||
return ProfileChangeListenerStub::OnTrustDeviceProfileInactiveInner(data, reply);
|
||||
case static_cast<uint32_t>(DPInterfaceCode::ON_DEVICE_PROFILE_ADD):
|
||||
return ProfileChangeListenerStub::OnDeviceProfileAddInner(data, reply);
|
||||
case static_cast<uint32_t>(DPInterfaceCode::ON_DEVICE_PROFILE_DELETE):
|
||||
@ -161,6 +169,38 @@ int32_t ProfileChangeListenerStub::OnTrustDeviceProfileUpdateInner(MessageParcel
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileChangeListenerStub::OnTrustDeviceProfileActiveInner(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
HILOGI("called");
|
||||
TrustDeviceProfile trustDeviceProfile;
|
||||
if (!trustDeviceProfile.UnMarshalling(data)) {
|
||||
HILOGE("Read reply failed");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
OnTrustDeviceProfileActive(trustDeviceProfile);
|
||||
if (!reply.WriteInt32(DP_SUCCESS)) {
|
||||
HILOGE("Read reply failed");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileChangeListenerStub::OnTrustDeviceProfileInactiveInner(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
HILOGI("called");
|
||||
TrustDeviceProfile trustDeviceProfile;
|
||||
if (!trustDeviceProfile.UnMarshalling(data)) {
|
||||
HILOGE("Read reply failed");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
OnTrustDeviceProfileInactive(trustDeviceProfile);
|
||||
if (!reply.WriteInt32(DP_SUCCESS)) {
|
||||
HILOGE("Read reply failed");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileChangeListenerStub::OnDeviceProfileAddInner(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
HILOGI("called");
|
||||
@ -319,5 +359,17 @@ int32_t ProfileChangeListenerStub::OnCharacteristicProfileUpdateInner(MessagePar
|
||||
}
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileChangeListenerStub::OnTrustDeviceProfileActive(const TrustDeviceProfile& profile)
|
||||
{
|
||||
(void)profile;
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileChangeListenerStub::OnTrustDeviceProfileInactive(const TrustDeviceProfile& profile)
|
||||
{
|
||||
(void)profile;
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
} // namespace DistributedDeviceProfile
|
||||
} // namespace OHOS
|
||||
|
@ -74,6 +74,16 @@ void TrustDeviceProfile::SetBindType(uint32_t bindType)
|
||||
bindType_ = bindType;
|
||||
}
|
||||
|
||||
int32_t TrustDeviceProfile::GetPeerUserId() const
|
||||
{
|
||||
return peerUserId_;
|
||||
}
|
||||
|
||||
void TrustDeviceProfile::SetPeerUserId(int32_t peerUserId)
|
||||
{
|
||||
peerUserId_ = peerUserId;
|
||||
}
|
||||
|
||||
bool TrustDeviceProfile::Marshalling(MessageParcel& parcel) const
|
||||
{
|
||||
WRITE_HELPER_RET(parcel, String, deviceId_, false);
|
||||
@ -81,6 +91,7 @@ bool TrustDeviceProfile::Marshalling(MessageParcel& parcel) const
|
||||
WRITE_HELPER_RET(parcel, String, deviceIdHash_, false);
|
||||
WRITE_HELPER_RET(parcel, Int32, status_, false);
|
||||
WRITE_HELPER_RET(parcel, Uint32, bindType_, false);
|
||||
WRITE_HELPER_RET(parcel, Int32, peerUserId_, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -91,6 +102,7 @@ bool TrustDeviceProfile::UnMarshalling(MessageParcel& parcel)
|
||||
READ_HELPER_RET(parcel, String, deviceIdHash_, false);
|
||||
READ_HELPER_RET(parcel, Int32, status_, false);
|
||||
READ_HELPER_RET(parcel, Uint32, bindType_, false);
|
||||
READ_HELPER_RET(parcel, Int32, peerUserId_, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -105,6 +117,9 @@ std::string TrustDeviceProfile::dump() const
|
||||
cJSON_AddNumberToObject(json, DEVICE_ID_TYPE.c_str(), deviceIdType_);
|
||||
cJSON_AddStringToObject(json, DEVICE_ID_HASH.c_str(), deviceIdHash_.c_str());
|
||||
cJSON_AddNumberToObject(json, STATUS.c_str(), status_);
|
||||
cJSON_AddNumberToObject(json, BIND_TYPE.c_str(), bindType_);
|
||||
cJSON_AddStringToObject(json, PEER_USER_ID.c_str(),
|
||||
ProfileUtils::GetAnonyString(std::to_string(peerUserId_)).c_str());
|
||||
char* jsonChars = cJSON_PrintUnformatted(json);
|
||||
if (jsonChars == NULL) {
|
||||
cJSON_Delete(json);
|
||||
|
@ -972,5 +972,183 @@ int32_t ProfileUtils::GenerateCharacteristicDBkeys(const std::string& deviceId,
|
||||
}
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileUtils::ConvertToTrustDeviceProfile(
|
||||
const AccessControlProfile& accessControlProfile, TrustDeviceProfile& trustDeviceProfile)
|
||||
{
|
||||
trustDeviceProfile.SetDeviceId(accessControlProfile.GetTrustDeviceId());
|
||||
trustDeviceProfile.SetDeviceIdType(accessControlProfile.GetDeviceIdType());
|
||||
trustDeviceProfile.SetDeviceIdHash(accessControlProfile.GetDeviceIdHash());
|
||||
trustDeviceProfile.SetStatus(accessControlProfile.GetStatus());
|
||||
trustDeviceProfile.SetBindType(accessControlProfile.GetBindType());
|
||||
std::string peerDeviceId = accessControlProfile.GetTrustDeviceId();
|
||||
int32_t peerUserId = accessControlProfile.GetAccesser().GetAccesserUserId();
|
||||
if (accessControlProfile.GetAccessee().GetAccesseeDeviceId() == peerDeviceId) {
|
||||
peerUserId = accessControlProfile.GetAccessee().GetAccesseeUserId();
|
||||
}
|
||||
trustDeviceProfile.SetPeerUserId(peerUserId);
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileUtils::ConvertToAccessControlProfiles(std::shared_ptr<ResultSet> resultSet,
|
||||
std::shared_ptr<ResultSet> accesserResultSet, std::shared_ptr<ResultSet> accesseeResultSet,
|
||||
std::vector<AccessControlProfile>& profile)
|
||||
{
|
||||
if (accesserResultSet == nullptr) {
|
||||
HILOGE("accesserResultSet is nullptr");
|
||||
return DP_GET_RESULTSET_FAIL;
|
||||
}
|
||||
if (accesseeResultSet == nullptr) {
|
||||
HILOGE("accesseeResultSet is nullptr");
|
||||
return DP_GET_RESULTSET_FAIL;
|
||||
}
|
||||
Accesser accesser;
|
||||
accesserResultSet->GoToNextRow();
|
||||
ConvertToAccesser(accesserResultSet, accesser);
|
||||
Accessee accessee;
|
||||
accesseeResultSet->GoToNextRow();
|
||||
ConvertToAccessee(accesseeResultSet, accessee);
|
||||
if (resultSet == nullptr) {
|
||||
HILOGE("resultSet is nullptr");
|
||||
return DP_GET_RESULTSET_FAIL;
|
||||
}
|
||||
AccessControlProfile accessControlProfile;
|
||||
ConvertToAccessControlProfile(resultSet, accessControlProfile);
|
||||
|
||||
accessControlProfile.SetAccesser(accesser);
|
||||
accessControlProfile.SetAccessee(accessee);
|
||||
profile.push_back(accessControlProfile);
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileUtils::ConvertToTrustDeviceProfile(
|
||||
std::shared_ptr<ResultSet> trustResultSet, TrustDeviceProfile& trustDeviceProfile)
|
||||
{
|
||||
if (trustResultSet == nullptr) {
|
||||
HILOGE("trustResultSet is nullptr");
|
||||
return DP_GET_RESULTSET_FAIL;
|
||||
}
|
||||
RowEntity rowEntity;
|
||||
if (trustResultSet->GetRow(rowEntity) != DP_SUCCESS) {
|
||||
HILOGE("get trustResultSet failed");
|
||||
return DP_GET_RESULTSET_FAIL;
|
||||
}
|
||||
std::string deviceId = rowEntity.Get(DEVICE_ID);
|
||||
int32_t deviceIdType = rowEntity.Get(DEVICE_ID_TYPE);
|
||||
std::string deviceIdHash = rowEntity.Get(DEVICE_ID_HASH);
|
||||
int32_t status = rowEntity.Get(STATUS);
|
||||
|
||||
trustDeviceProfile.SetDeviceId(deviceId);
|
||||
trustDeviceProfile.SetDeviceIdType(deviceIdType);
|
||||
trustDeviceProfile.SetDeviceIdHash(deviceIdHash);
|
||||
trustDeviceProfile.SetStatus(status);
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileUtils::ConvertToAccesser(std::shared_ptr<ResultSet> accesserResultSet,
|
||||
Accesser& accesser)
|
||||
{
|
||||
if (accesserResultSet == nullptr) {
|
||||
HILOGE("accesserResultSet is nullptr");
|
||||
return DP_GET_RESULTSET_FAIL;
|
||||
}
|
||||
RowEntity rowEntity;
|
||||
if (accesserResultSet->GetRow(rowEntity) != DP_SUCCESS) {
|
||||
HILOGE("get accesserResultSet failed");
|
||||
return DP_GET_RESULTSET_FAIL;
|
||||
}
|
||||
int64_t accesserId = rowEntity.Get(ACCESSER_ID);
|
||||
std::string accesserDeviceId = rowEntity.Get(ACCESSER_DEVICE_ID);
|
||||
int32_t accesserUserId = rowEntity.Get(ACCESSER_USER_ID);
|
||||
std::string accesserAccountId = rowEntity.Get(ACCESSER_ACCOUNT_ID);
|
||||
int64_t accesserTokenId = rowEntity.Get(ACCESSER_TOKEN_ID);
|
||||
std::string accesserBundleName = rowEntity.Get(ACCESSER_BUNDLE_NAME);
|
||||
std::string accesserHapSignature = rowEntity.Get(ACCESSER_HAP_SIGNATURE);
|
||||
int32_t accesserBindLevel = rowEntity.Get(ACCESSER_BIND_LEVEL);
|
||||
|
||||
accesser.SetAccesserId(accesserId);
|
||||
accesser.SetAccesserDeviceId(accesserDeviceId);
|
||||
accesser.SetAccesserUserId(accesserUserId);
|
||||
accesser.SetAccesserAccountId(accesserAccountId);
|
||||
accesser.SetAccesserTokenId(accesserTokenId);
|
||||
accesser.SetAccesserBundleName(accesserBundleName);
|
||||
accesser.SetAccesserHapSignature(accesserHapSignature);
|
||||
accesser.SetAccesserBindLevel(accesserBindLevel);
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileUtils::ConvertToAccessee(std::shared_ptr<ResultSet> accesseeResultSet,
|
||||
Accessee& accessee)
|
||||
{
|
||||
if (accesseeResultSet == nullptr) {
|
||||
HILOGE("accesseeResultSet is nullptr");
|
||||
return DP_GET_RESULTSET_FAIL;
|
||||
}
|
||||
RowEntity rowEntity;
|
||||
if (accesseeResultSet->GetRow(rowEntity) != DP_SUCCESS) {
|
||||
HILOGE("get accesseeResultSet failed");
|
||||
return DP_GET_RESULTSET_FAIL;
|
||||
}
|
||||
int64_t accesseeId = rowEntity.Get(ACCESSEE_ID);
|
||||
std::string accesseeDeviceId = rowEntity.Get(ACCESSEE_DEVICE_ID);
|
||||
int32_t accesseeUserId = rowEntity.Get(ACCESSEE_USER_ID);
|
||||
std::string accesseeAccountId = rowEntity.Get(ACCESSEE_ACCOUNT_ID);
|
||||
int64_t accesseeTokenId = rowEntity.Get(ACCESSEE_TOKEN_ID);
|
||||
std::string accesseeBundleName = rowEntity.Get(ACCESSEE_BUNDLE_NAME);
|
||||
std::string accesseeHapSignature = rowEntity.Get(ACCESSEE_HAP_SIGNATURE);
|
||||
int32_t accesseeBindLevel = rowEntity.Get(ACCESSEE_BIND_LEVEL);
|
||||
|
||||
accessee.SetAccesseeId(accesseeId);
|
||||
accessee.SetAccesseeDeviceId(accesseeDeviceId);
|
||||
accessee.SetAccesseeUserId(accesseeUserId);
|
||||
accessee.SetAccesseeAccountId(accesseeAccountId);
|
||||
accessee.SetAccesseeTokenId(accesseeTokenId);
|
||||
accessee.SetAccesseeBundleName(accesseeBundleName);
|
||||
accessee.SetAccesseeHapSignature(accesseeHapSignature);
|
||||
accessee.SetAccesseeBindLevel(accesseeBindLevel);
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProfileUtils::ConvertToAccessControlProfile(
|
||||
std::shared_ptr<ResultSet> accessControlResultSet, AccessControlProfile& accessControlProfile)
|
||||
{
|
||||
if (accessControlResultSet == nullptr) {
|
||||
HILOGE("accessControlResultSet is nullptr");
|
||||
return DP_GET_RESULTSET_FAIL;
|
||||
}
|
||||
RowEntity rowEntity;
|
||||
if (accessControlResultSet->GetRow(rowEntity) != DP_SUCCESS) {
|
||||
HILOGE("get accessControlResultSet failed");
|
||||
return DP_GET_RESULTSET_FAIL;
|
||||
}
|
||||
int64_t accessControlId = rowEntity.Get(ACCESS_CONTROL_ID);
|
||||
int64_t accesserId = rowEntity.Get(ACCESSER_ID);
|
||||
int64_t accesseeId = rowEntity.Get(ACCESSEE_ID);
|
||||
std::string trustDeviceId = rowEntity.Get(TRUST_DEVICE_ID);
|
||||
std::string sessionKey = rowEntity.Get(SESSION_KEY);
|
||||
int32_t bindType = rowEntity.Get(BIND_TYPE);
|
||||
int32_t authenticationType = rowEntity.Get(AUTHENTICATION_TYPE);
|
||||
int32_t deviceIdType = rowEntity.Get(DEVICE_ID_TYPE);
|
||||
std::string deviceIdHash = rowEntity.Get(DEVICE_ID_HASH);
|
||||
int32_t status = rowEntity.Get(STATUS);
|
||||
int32_t validPeriod = rowEntity.Get(VALID_PERIOD);
|
||||
int32_t lastAuthTime = rowEntity.Get(LAST_AUTH_TIME);
|
||||
int32_t bindLevel = rowEntity.Get(BIND_LEVEL);
|
||||
|
||||
accessControlProfile.SetAccessControlId(accessControlId);
|
||||
accessControlProfile.SetAccesserId(accesserId);
|
||||
accessControlProfile.SetAccesseeId(accesseeId);
|
||||
accessControlProfile.SetTrustDeviceId(trustDeviceId);
|
||||
accessControlProfile.SetSessionKey(sessionKey);
|
||||
accessControlProfile.SetBindType(bindType);
|
||||
accessControlProfile.SetAuthenticationType(authenticationType);
|
||||
accessControlProfile.SetDeviceIdType(deviceIdType);
|
||||
accessControlProfile.SetDeviceIdHash(deviceIdHash);
|
||||
accessControlProfile.SetStatus(status);
|
||||
accessControlProfile.SetValidPeriod(validPeriod);
|
||||
accessControlProfile.SetLastAuthTime(lastAuthTime);
|
||||
accessControlProfile.SetBindLevel(bindLevel);
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
} // namespace DistributedDeviceProfile
|
||||
} // namespace OHOS
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -39,6 +39,8 @@ public:
|
||||
int32_t NotifyTrustDeviceProfileUpdate(const TrustDeviceProfile& oldDeviceProfile,
|
||||
const TrustDeviceProfile& newDeviceProfile);
|
||||
int32_t NotifyTrustDeviceProfileDelete(const TrustDeviceProfile& trustDeviceProfile);
|
||||
int32_t NotifyTrustDeviceProfileActive(const TrustDeviceProfile& trustDeviceProfile);
|
||||
int32_t NotifyTrustDeviceProfileInactive(const TrustDeviceProfile& trustDeviceProfile);
|
||||
int32_t SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo);
|
||||
int32_t SubscribeDeviceProfile(std::map<std::string, SubscribeInfo> subscribeInfos);
|
||||
int32_t UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo);
|
||||
|
@ -68,8 +68,6 @@ private:
|
||||
int32_t GetAccessControlProfile(int32_t userId, std::vector<AccessControlProfile>& profile);
|
||||
int32_t GetAccessControlProfileByTokenId(int64_t tokenId, const std::string& trustDeviceId,
|
||||
int32_t status, std::vector<AccessControlProfile>& profile);
|
||||
int32_t ConvertToTrustDeviceProfile(const AccessControlProfile& accessControlProfile,
|
||||
TrustDeviceProfile& trustDeviceProfile);
|
||||
int32_t GetAclProfileByUserIdAndBundleName(std::shared_ptr<ResultSet> resultSet,
|
||||
int32_t userId, const std::string& bundleName, std::vector<AccessControlProfile>& profile);
|
||||
int32_t GetAclProfileByUserIdAndAccountId(std::shared_ptr<ResultSet> resultSet, int64_t accesserId,
|
||||
@ -78,16 +76,13 @@ private:
|
||||
int64_t tokenId, std::vector<AccessControlProfile>& profile);
|
||||
int32_t GetAclProfileByBundleName(std::shared_ptr<ResultSet> resultSet,
|
||||
const std::string& bundleName, std::vector<AccessControlProfile>& profile);
|
||||
int32_t ConvertToAccessControlProfiles(std::shared_ptr<ResultSet> resultSet,
|
||||
std::shared_ptr<ResultSet> accesserResultSet, std::shared_ptr<ResultSet> accesseeResultSet,
|
||||
std::vector<AccessControlProfile>& profile);
|
||||
int32_t PutAccesserProfile(const AccessControlProfile& profile);
|
||||
int32_t PutAccesseeProfile(const AccessControlProfile& profile);
|
||||
int32_t SetAccessControlId(AccessControlProfile& profile);
|
||||
int32_t SetAccesserId(AccessControlProfile& profile);
|
||||
int32_t SetAccesseeId(AccessControlProfile& profile);
|
||||
int32_t UpdateAccesserProfile(int64_t accesserId, const AccessControlProfile& profile);
|
||||
int32_t UpdateAccesseeProfile(int64_t accesseeId, const AccessControlProfile& profile);
|
||||
int32_t UpdateAccesserProfile(AccessControlProfile& profile, bool& isAcerOrAceeExist);
|
||||
int32_t UpdateAccesseeProfile(AccessControlProfile& profile, bool& isAcerOrAceeExist);
|
||||
int32_t UpdateTrustDeviceProfileNotify(const TrustDeviceProfile& oldProfile,
|
||||
const TrustDeviceProfile& newProfile);
|
||||
int32_t GetResultStatus(const std::string& trustDeviceId, int32_t& trustDeviceStatus);
|
||||
@ -95,13 +90,7 @@ private:
|
||||
int64_t accesserId, int64_t accesseeId, std::vector<AccessControlProfile>& profile);
|
||||
int32_t GetAccessControlProfilesByDeviceId(std::shared_ptr<ResultSet> resultSet, int64_t accesserId,
|
||||
int64_t accesseeId, const std::string& trustDeviceId, std::vector<AccessControlProfile>& profile);
|
||||
int32_t DeleteAccessControlProfileCheck(std::shared_ptr<ResultSet> resultSet);
|
||||
int32_t ConvertToTrustDeviceProfile(std::shared_ptr<ResultSet> trustResultSet,
|
||||
TrustDeviceProfile& trustDeviceProfile);
|
||||
int32_t ConvertToAccesser(std::shared_ptr<ResultSet> accesserResultSet, Accesser& accesser);
|
||||
int32_t ConvertToAccessee(std::shared_ptr<ResultSet> accesseeResultSet, Accessee& accessee);
|
||||
int32_t ConvertToAccessControlProfile(std::shared_ptr<ResultSet> accessControlResultSet,
|
||||
AccessControlProfile& accessControlProfile);
|
||||
int32_t DeleteAccessControlProfileCheck(const AccessControlProfile& profile);
|
||||
std::shared_ptr<ResultSet> GetResultSet(const std::string& sql, std::vector<ValueObject> condition);
|
||||
int32_t SetAccessControlProfileId(AccessControlProfile& accessControlProfile);
|
||||
int32_t GetAccessControlProfiles(std::shared_ptr<ResultSet> resultSet, int64_t accesserId,
|
||||
@ -114,12 +103,16 @@ private:
|
||||
int32_t GetAccessControlProfilesByTokenId(std::shared_ptr<ResultSet> resultSet, int64_t accesserId,
|
||||
int64_t accesseeId, const std::string& trustDeviceId, int64_t tokenId,
|
||||
std::vector<AccessControlProfile>& profile);
|
||||
int32_t DeleteAccesserCheck(int64_t accesserId);
|
||||
int32_t DeleteAccesseeCheck(int64_t accesseeId);
|
||||
int32_t DeleteAccesserCheck(int64_t accesserId, Accesser& accesser);
|
||||
int32_t DeleteAccesseeCheck(int64_t accesseeId, Accessee& accessee);
|
||||
int32_t DeleteTrustDeviceCheck(const AccessControlProfile& profile);
|
||||
int32_t UpdateAclCheck(const AccessControlProfile& profile);
|
||||
int32_t PutAclCheck(const AccessControlProfile& profile);
|
||||
int32_t UpdateAclCheck(const AccessControlProfile& profile, AccessControlProfile& oldProfile);
|
||||
int32_t PutAclCheck(const AccessControlProfile& profile, bool peerDevInfoExists);
|
||||
int32_t IsAclExists(const AccessControlProfile& profile);
|
||||
bool CheckUserIdExists(const AccessControlProfile& profile);
|
||||
int32_t GetConformCount(const std::string& peerDeviceId, int32_t peerUserId);
|
||||
int32_t NotifyCheck(const AccessControlProfile& profile, const AccessControlProfile& oldProfile);
|
||||
int32_t UpdateOrDeleteAclCheck(const AccessControlProfile& profile, bool isAcerOrAceeExist);
|
||||
|
||||
private:
|
||||
std::shared_ptr<IRdbAdapter> rdbStore_;
|
||||
|
@ -159,6 +159,46 @@ int32_t SubscribeProfileManager::NotifyTrustDeviceProfileDelete(const TrustDevic
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SubscribeProfileManager::NotifyTrustDeviceProfileActive(const TrustDeviceProfile& trustDeviceProfile)
|
||||
{
|
||||
auto subscriberInfos = GetSubscribeInfos(SUBSCRIBE_TRUST_DEVICE_PROFILE);
|
||||
if (subscriberInfos.empty()) {
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
HILOGI("%{public}s!", trustDeviceProfile.dump().c_str());
|
||||
for (const auto& subscriberInfo : subscriberInfos) {
|
||||
sptr<IProfileChangeListener> listenerProxy = iface_cast<IProfileChangeListener>(subscriberInfo.GetListener());
|
||||
if (listenerProxy == nullptr) {
|
||||
HILOGE("Cast to IProfileChangeListener failed!");
|
||||
continue;
|
||||
}
|
||||
if (subscriberInfo.GetProfileChangeTypes().count(ProfileChangeType::TRUST_DEVICE_PROFILE_ACTIVE) != 0) {
|
||||
listenerProxy->OnTrustDeviceProfileActive(trustDeviceProfile);
|
||||
}
|
||||
}
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SubscribeProfileManager::NotifyTrustDeviceProfileInactive(const TrustDeviceProfile& trustDeviceProfile)
|
||||
{
|
||||
auto subscriberInfos = GetSubscribeInfos(SUBSCRIBE_TRUST_DEVICE_PROFILE);
|
||||
if (subscriberInfos.empty()) {
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
HILOGI("%{public}s!", trustDeviceProfile.dump().c_str());
|
||||
for (const auto& subscriberInfo : subscriberInfos) {
|
||||
sptr<IProfileChangeListener> listenerProxy = iface_cast<IProfileChangeListener>(subscriberInfo.GetListener());
|
||||
if (listenerProxy == nullptr) {
|
||||
HILOGE("Cast to IProfileChangeListener failed!");
|
||||
continue;
|
||||
}
|
||||
if (subscriberInfo.GetProfileChangeTypes().count(ProfileChangeType::TRUST_DEVICE_PROFILE_INACTIVE) != 0) {
|
||||
listenerProxy->OnTrustDeviceProfileInactive(trustDeviceProfile);
|
||||
}
|
||||
}
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SubscribeProfileManager::SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo)
|
||||
{
|
||||
HILOGI("saId: %{public}d!, subscribeKey: %{public}s", subscribeInfo.GetSaId(),
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -68,6 +68,16 @@ public:
|
||||
cout << "OnTrustDeviceProfileUpdate: newProfile " << newProfile.dump() <<endl;
|
||||
return 0;
|
||||
}
|
||||
int32_t OnTrustDeviceProfileActive(const TrustDeviceProfile& profile)
|
||||
{
|
||||
cout << "OnTrustDeviceProfileActive" << profile.dump() <<endl;
|
||||
return 0;
|
||||
}
|
||||
int32_t OnTrustDeviceProfileInactive(const TrustDeviceProfile& profile)
|
||||
{
|
||||
cout << "OnTrustDeviceProfileInactive" << profile.dump() <<endl;
|
||||
return 0;
|
||||
}
|
||||
int32_t OnDeviceProfileAdd(const DeviceProfile& profile)
|
||||
{
|
||||
return 0;
|
||||
@ -285,5 +295,29 @@ HWTEST_F(DPSubscribeInfoTest, Stub_001, TestSize.Level1)
|
||||
ret = proxy->OnCharacteristicProfileUpdate(oldChaProfile, newChaProfile);
|
||||
EXPECT_EQ(ret, DP_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: Stub_002
|
||||
* @tc.desc: Normal testCase of DPSubscribeInfoTest for CRUD
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DPSubscribeInfoTest, Stub_002, TestSize.Level1)
|
||||
{
|
||||
uint32_t saId = 4801;
|
||||
std::string subscribeKey = "trust_device_profile";
|
||||
std::unordered_set<ProfileChangeType> subscribeTypes = {ProfileChangeType::TRUST_DEVICE_PROFILE_ACTIVE,
|
||||
ProfileChangeType::TRUST_DEVICE_PROFILE_INACTIVE};
|
||||
OHOS::sptr<IProfileChangeListener> subscribeDPChangeListener =
|
||||
sptr<IProfileChangeListener>(new DPSubscribeInfoTest::SubscribeDPChangeListener);
|
||||
SubscribeInfo subscribeInfo(saId, subscribeKey, subscribeTypes, subscribeDPChangeListener);
|
||||
OHOS::sptr<IProfileChangeListener> proxy = OHOS::iface_cast<IProfileChangeListener>(subscribeInfo.GetListener());
|
||||
TrustDeviceProfile profile;
|
||||
profile.SetPeerUserId(1001);
|
||||
ASSERT_NE(proxy, nullptr);
|
||||
int32_t ret = proxy->OnTrustDeviceProfileActive(profile);
|
||||
EXPECT_EQ(ret, DP_SUCCESS);
|
||||
ret = proxy->OnTrustDeviceProfileInactive(profile);
|
||||
EXPECT_EQ(ret, DP_SUCCESS);
|
||||
}
|
||||
} // namespace DistributedDeviceProfile
|
||||
} // namespace OHOS
|
||||
|
@ -160,8 +160,9 @@ HWTEST_F(TrustProfileManagerTest, GetAccessControlProfile_013, TestSize.Level1)
|
||||
GetInstance().GetAccessControlProfile(resultRet, 1, 1, profile);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
AccessControlProfile aclProfile;
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().DeleteAccessControlProfileCheck(resultRet);
|
||||
GetInstance().DeleteAccessControlProfileCheck(aclProfile);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
@ -179,33 +180,30 @@ HWTEST_F(TrustProfileManagerTest, Convert_001, TestSize.Level1)
|
||||
shared_ptr<ResultSet> resultRet = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().GetResultSet("122", { ValueObject(1) });
|
||||
TrustDeviceProfile trustProfile;
|
||||
int32_t ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().ConvertToTrustDeviceProfile(resultRet, trustProfile);
|
||||
int32_t ret = ProfileUtils::ConvertToTrustDeviceProfile(resultRet, trustProfile);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
Accessee accessee;
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().ConvertToAccessee(resultRet, accessee);
|
||||
ret = ProfileUtils::ConvertToAccessee(resultRet, accessee);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
Accesser accesser;
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().ConvertToAccesser(resultRet, accesser);
|
||||
ret = ProfileUtils::ConvertToAccesser(resultRet, accesser);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
AccessControlProfile profile;
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().ConvertToAccessControlProfile(resultRet, profile);
|
||||
ret = ProfileUtils::ConvertToAccessControlProfile(resultRet, profile);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
AccessControlProfile oldProfile;
|
||||
profile.SetAccessControlId(666);
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().UpdateAclCheck(profile);
|
||||
GetInstance().UpdateAclCheck(profile, oldProfile);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
profile.SetTrustDeviceId("4546456");
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().UpdateAclCheck(profile);
|
||||
GetInstance().UpdateAclCheck(profile, oldProfile);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
}
|
||||
|
||||
@ -290,8 +288,7 @@ HWTEST_F(TrustProfileManagerTest, PutTrustDeviceProfile_001, TestSize.Level1)
|
||||
profile.SetBindLevel(1);
|
||||
|
||||
TrustDeviceProfile trustProfile;
|
||||
OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().ConvertToTrustDeviceProfile(profile, trustProfile);
|
||||
ProfileUtils::ConvertToTrustDeviceProfile(profile, trustProfile);
|
||||
int32_t ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().PutTrustDeviceProfile(trustProfile);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
@ -1489,12 +1486,14 @@ HWTEST_F(TrustProfileManagerTest, RdbStoreIsNullptr_002, TestSize.Level1)
|
||||
GetInstance().SetAccesseeId(profile);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
profile.SetAccessControlId(1);
|
||||
bool isAcerOrAceeExist = false;
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().UpdateAccesserProfile(1, profile);
|
||||
GetInstance().UpdateAccesserProfile(profile, isAcerOrAceeExist);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().UpdateAccesseeProfile(1, profile);
|
||||
GetInstance().UpdateAccesseeProfile(profile, isAcerOrAceeExist);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
}
|
||||
|
||||
@ -1592,21 +1591,54 @@ HWTEST_F(TrustProfileManagerTest, RdbStoreIsNullptr_004, TestSize.Level1)
|
||||
GetInstance().GetAccessControlProfilesByDeviceId(resultSet, 1, 1, "1", profiles);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
Accesser accesser;
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().DeleteAccesserCheck(1);
|
||||
GetInstance().DeleteAccesserCheck(1, accesser);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
Accessee accessee;
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().DeleteAccesseeCheck(1);
|
||||
GetInstance().DeleteAccesseeCheck(1, accessee);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
AccessControlProfile oldProfile;
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().UpdateAclCheck(profile);
|
||||
GetInstance().UpdateAclCheck(profile, oldProfile);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
|
||||
ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().DeleteTrustDeviceCheck(profile);
|
||||
EXPECT_NE(ret, DP_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: Check_001
|
||||
* @tc.desc: Normal testCase of TrustProfileManagerTest for Check
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TrustProfileManagerTest, Check_001, TestSize.Level1)
|
||||
{
|
||||
AccessControlProfile profile;
|
||||
profile.SetAccessControlId(1);
|
||||
profile.SetAccesserId(1);
|
||||
profile.SetAccesseeId(1);
|
||||
profile.GetAccessee().SetAccesseeDeviceId("123456");
|
||||
profile.GetAccessee().SetAccesseeUserId(6666);
|
||||
profile.SetStatus(0);
|
||||
bool ret = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().CheckUserIdExists(profile);
|
||||
EXPECT_EQ(ret, false);
|
||||
|
||||
int32_t count = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().GetConformCount("123456", 6666);
|
||||
EXPECT_EQ(count, DP_GET_RESULTSET_FAIL);
|
||||
|
||||
AccessControlProfile oldProfile;
|
||||
oldProfile.SetStatus(1);
|
||||
profile.SetTrustDeviceId("123456");
|
||||
int32_t result = OHOS::DistributedDeviceProfile::TrustProfileManager::
|
||||
GetInstance().NotifyCheck(profile, oldProfile);
|
||||
EXPECT_EQ(result, DP_SUCCESS);
|
||||
}
|
||||
} // namespace DistributedDeviceProfile
|
||||
} // namespace OHOS
|
||||
|
Loading…
Reference in New Issue
Block a user