mirror of
https://github.com/openharmony/device_manager.git
synced 2026-07-21 06:05:22 -04:00
@@ -64,6 +64,7 @@ public:
|
||||
int32_t GetRelatedGroups(std::string DeviceId, std::vector<GroupInfo> &groupList);
|
||||
int32_t GetGroupInfo(std::string queryParams, std::vector<GroupInfo> &groupList);
|
||||
int32_t GetGroupInfo(const int32_t userId, std::string queryParams, std::vector<GroupInfo> &groupList);
|
||||
int32_t DeleteTimeOutGroup(const char* deviceId);
|
||||
private:
|
||||
int64_t GenRequestId();
|
||||
int32_t SyncGroups(std::string deviceId, std::vector<std::string> &remoteGroupIdList);
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
typedef void (*TimeoutHandle)(void *data);
|
||||
class DmTimer;
|
||||
typedef void (*TimeoutHandle)(void *data, DmTimer& timer);
|
||||
|
||||
#define MAX_EVENTS 255
|
||||
|
||||
@@ -48,7 +49,7 @@ public:
|
||||
DmTimerStatus Start(uint32_t timeOut, TimeoutHandle handle, void *data);
|
||||
void Stop(int32_t code);
|
||||
void WaitForTimeout();
|
||||
|
||||
std::string GetTimerName();
|
||||
private:
|
||||
int32_t CreateTimeFd();
|
||||
void Release();
|
||||
|
||||
@@ -19,14 +19,17 @@
|
||||
#include "device_manager_service_listener.h"
|
||||
#include "dm_adapter_manager.h"
|
||||
#include "softbus_connector.h"
|
||||
|
||||
#include "dm_timer.h"
|
||||
#include "hichain_connector.h"
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
#define OFFLINE_TIMEOUT 300
|
||||
class DmDeviceStateManager final : public ISoftbusStateCallback,
|
||||
public std::enable_shared_from_this<DmDeviceStateManager> {
|
||||
public:
|
||||
DmDeviceStateManager(std::shared_ptr<SoftbusConnector> softbusConnector,
|
||||
std::shared_ptr<DeviceManagerServiceListener> listener);
|
||||
std::shared_ptr<DeviceManagerServiceListener> listener,
|
||||
std::shared_ptr<HiChainConnector> hiChainConnector);
|
||||
~DmDeviceStateManager();
|
||||
void OnDeviceOnline(const std::string &pkgName, const DmDeviceInfo &info);
|
||||
void OnDeviceOffline(const std::string &pkgName, const DmDeviceInfo &info);
|
||||
@@ -34,6 +37,9 @@ public:
|
||||
void OnDeviceReady(const std::string &pkgName, const DmDeviceInfo &info);
|
||||
void OnProfileReady(const std::string &pkgName, const std::string deviceId);
|
||||
int32_t RegisterSoftbusStateCallback();
|
||||
void RegisterOffLineTimer(const DmDeviceInfo &deviceInfo);
|
||||
void StartOffLineTimer(const DmDeviceInfo &deviceInfo);
|
||||
void DeleteTimeOutGroup(std::string deviceId);
|
||||
|
||||
private:
|
||||
std::shared_ptr<SoftbusConnector> softbusConnector_;
|
||||
@@ -41,6 +47,8 @@ private:
|
||||
std::shared_ptr<DeviceManagerServiceListener> listener_;
|
||||
std::map<std::string, DmDeviceState> deviceStateMap_;
|
||||
std::map<std::string, DmDeviceInfo> remoteDeviceInfos_;
|
||||
std::map<std::string, std::shared_ptr<DmTimer>> timerMap_;
|
||||
std::shared_ptr<HiChainConnector> hiChainConnector_;
|
||||
std::string profileSoName_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
|
||||
@@ -51,7 +51,7 @@ const int32_t WAIT_REQUEST_TIMEOUT = 10;
|
||||
const int32_t CANCEL_PIN_CODE_DISPLAY = 1;
|
||||
const int32_t DEVICE_ID_HALF = 2;
|
||||
|
||||
static void TimeOut(void *data)
|
||||
static void TimeOut(void *data, DmTimer& timer)
|
||||
{
|
||||
LOGE("time out ");
|
||||
DmAuthManager *authMgr = (DmAuthManager *)data;
|
||||
|
||||
@@ -490,5 +490,26 @@ int32_t HiChainConnector::DeleteGroup(const int32_t userId, std::string &groupId
|
||||
}
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t HiChainConnector::DeleteTimeOutGroup(const char* deviceId)
|
||||
{
|
||||
LOGE("HiChainConnector::DeleteTimeOutGroup start");
|
||||
int32_t userId = MultipleUserConnector::GetCurrentAccountUserID();
|
||||
if (userId < 0) {
|
||||
LOGE("get current process account user id failed");
|
||||
return DM_FAILED;
|
||||
}
|
||||
std::vector<GroupInfo> peerGroupInfoList;
|
||||
GetRelatedGroups(deviceId, peerGroupInfoList);
|
||||
char localDeviceId[DEVICE_UUID_LENGTH] = {0};
|
||||
GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH);
|
||||
for (auto &group : peerGroupInfoList) {
|
||||
if (deviceGroupManager_->isDeviceInGroup(userId, DM_PKG_NAME.c_str(), group.groupId.c_str(), localDeviceId)) {
|
||||
DeleteGroup(group.groupId);
|
||||
return DM_OK;
|
||||
}
|
||||
}
|
||||
return DM_FAILED;
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -107,6 +107,10 @@ void DmTimer::WaitForTimeout()
|
||||
int32_t nfds = epoll_wait(mEpFd_, mEvents_, MAX_EVENTS, mTimeOutSec_ * MILL_SECONDS_PER_SECOND);
|
||||
if (nfds < 0) {
|
||||
LOGE("DmTimer %s epoll_wait returned n=%d, error: %d", mTimerName_.c_str(), nfds, errno);
|
||||
if (errno == EINTR) {
|
||||
LOGI("DmTimer is stop");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
char event = 0;
|
||||
@@ -123,7 +127,7 @@ void DmTimer::WaitForTimeout()
|
||||
return;
|
||||
}
|
||||
|
||||
mHandle_(mHandleData_);
|
||||
mHandle_(mHandleData_, *this);
|
||||
Release();
|
||||
|
||||
LOGE("DmTimer %s end timer at (%d)s", mTimerName_.c_str(), mTimeOutSec_);
|
||||
@@ -177,5 +181,10 @@ void DmTimer::Release()
|
||||
mTimeFd_[1] = 0;
|
||||
mEpFd_ = 0;
|
||||
}
|
||||
|
||||
std::string DmTimer::GetTimerName()
|
||||
{
|
||||
return mTimerName_;
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -77,7 +77,7 @@ int32_t DeviceManagerService::Init()
|
||||
}
|
||||
}
|
||||
if (deviceStateMgr_ == nullptr) {
|
||||
deviceStateMgr_ = std::make_shared<DmDeviceStateManager>(softbusConnector_, listener_);
|
||||
deviceStateMgr_ = std::make_shared<DmDeviceStateManager>(softbusConnector_, listener_, hiChainConnector_);
|
||||
if (deviceStateMgr_ == nullptr) {
|
||||
LOGE("Init failed, deviceStateMgr_ apply for failure");
|
||||
return DM_MAKE_SHARED_FAIL;
|
||||
|
||||
@@ -20,9 +20,23 @@
|
||||
#include "dm_log.h"
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
const int32_t SESSION_CANCEL_TIMEOUT = 0;
|
||||
|
||||
static void TimeOut(void *data, DmTimer& timer)
|
||||
{
|
||||
LOGE("time out ");
|
||||
DmDeviceStateManager *deviceStateMgr = (DmDeviceStateManager*)data;
|
||||
if (deviceStateMgr == nullptr) {
|
||||
LOGE("OnDeviceOfflineTimeOut deviceStateMgr = nullptr");
|
||||
return;
|
||||
}
|
||||
deviceStateMgr->DeleteTimeOutGroup(timer.GetTimerName());
|
||||
}
|
||||
|
||||
DmDeviceStateManager::DmDeviceStateManager(std::shared_ptr<SoftbusConnector> softbusConnector,
|
||||
std::shared_ptr<DeviceManagerServiceListener> listener)
|
||||
: softbusConnector_(softbusConnector), listener_(listener)
|
||||
std::shared_ptr<DeviceManagerServiceListener> listener,
|
||||
std::shared_ptr<HiChainConnector> hiChainConnector)
|
||||
: softbusConnector_(softbusConnector), listener_(listener), hiChainConnector_(hiChainConnector)
|
||||
{
|
||||
LOGI("DmDeviceStateManager constructor");
|
||||
profileSoName_ = "libdevicemanagerext_profile.z.so";
|
||||
@@ -37,6 +51,7 @@ DmDeviceStateManager::~DmDeviceStateManager()
|
||||
void DmDeviceStateManager::OnDeviceOnline(const std::string &pkgName, const DmDeviceInfo &info)
|
||||
{
|
||||
LOGI("DmDeviceStateManager::OnDeviceOnline in");
|
||||
RegisterOffLineTimer(info);
|
||||
DmAdapterManager &adapterMgrPtr = DmAdapterManager::GetInstance();
|
||||
std::shared_ptr<IProfileAdapter> profileAdapter = adapterMgrPtr.GetProfileAdapter(profileSoName_);
|
||||
if (profileAdapter == nullptr) {
|
||||
@@ -66,6 +81,7 @@ void DmDeviceStateManager::OnDeviceOnline(const std::string &pkgName, const DmDe
|
||||
|
||||
void DmDeviceStateManager::OnDeviceOffline(const std::string &pkgName, const DmDeviceInfo &info)
|
||||
{
|
||||
StartOffLineTimer(info);
|
||||
DmAdapterManager &adapterMgrPtr = DmAdapterManager::GetInstance();
|
||||
std::shared_ptr<IProfileAdapter> profileAdapter = adapterMgrPtr.GetProfileAdapter(profileSoName_);
|
||||
if (profileAdapter == nullptr) {
|
||||
@@ -113,5 +129,37 @@ int32_t DmDeviceStateManager::RegisterSoftbusStateCallback()
|
||||
std::shared_ptr<DmDeviceStateManager>(shared_from_this()));
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
void DmDeviceStateManager::RegisterOffLineTimer(const DmDeviceInfo &deviceInfo)
|
||||
{
|
||||
std::string deviceId;
|
||||
softbusConnector_->GetUdidByNetworkId(deviceInfo.deviceId, deviceId);
|
||||
LOGI("Device<%s>Online", deviceId.c_str());
|
||||
auto iter = timerMap_.find(deviceId);
|
||||
if (iter != timerMap_.end()) {
|
||||
iter->second->Stop(SESSION_CANCEL_TIMEOUT);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<DmTimer> offLineTimer = std::make_shared<DmTimer>(deviceId);
|
||||
timerMap_[deviceId] = offLineTimer;
|
||||
}
|
||||
|
||||
void DmDeviceStateManager::StartOffLineTimer(const DmDeviceInfo &deviceInfo)
|
||||
{
|
||||
std::string deviceId;
|
||||
softbusConnector_->GetUdidByNetworkId(deviceInfo.deviceId, deviceId);
|
||||
LOGI("Device<%s>Offline", deviceId.c_str());
|
||||
for (auto &iter : timerMap_) {
|
||||
if (iter.first.compare(deviceId) == 0) {
|
||||
iter.second->Start(OFFLINE_TIMEOUT, TimeOut, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DmDeviceStateManager::DeleteTimeOutGroup(std::string deviceId)
|
||||
{
|
||||
LOGI("Remove DmDevice<%s> Hichain Group", deviceId.c_str());
|
||||
hiChainConnector_->DeleteTimeOutGroup(deviceId.c_str());
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -25,7 +25,7 @@ const std::string DISCOVERY_TIMEOUT_TASK = "discoveryTimeout";
|
||||
const int32_t DISCOVERY_TIMEOUT = 120;
|
||||
const int32_t SESSION_CANCEL_TIMEOUT = 0;
|
||||
|
||||
static void TimeOut(void *data)
|
||||
static void TimeOut(void *data, DmTimer& timer)
|
||||
{
|
||||
LOGE("time out ");
|
||||
DmDiscoveryManager *discoveryMgr = (DmDiscoveryManager *)data;
|
||||
|
||||
+53
-47
@@ -105,14 +105,16 @@ ohos_unittest("UTTest_dm_device_state_manager") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/adapter/standard/dm_adapter_manager.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/config/dm_config_manager.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/device_manager_service_listener.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp",
|
||||
"${services_path}/src/adapter/standard/dm_adapter_manager.cpp",
|
||||
"${services_path}/src/config/dm_config_manager.cpp",
|
||||
"${services_path}/src/dependency/hichain/hichain_connector.cpp",
|
||||
"${services_path}/src/dependency/multipleuser/multiple_user_connector.cpp",
|
||||
"${services_path}/src/dependency/softbus/softbus_connector.cpp",
|
||||
"${services_path}/src/dependency/softbus/softbus_session.cpp",
|
||||
"${services_path}/src/dependency/timer/dm_timer.cpp",
|
||||
"${services_path}/src/device_manager_service_listener.cpp",
|
||||
"${services_path}/src/devicestate/dm_device_state_manager.cpp",
|
||||
"${services_path}/src/discovery/dm_discovery_manager.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/test/unittest/mock/ipc_server_listener.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/test/unittest/mock/parameter.cpp",
|
||||
"UTTest_dm_device_state_manager.cpp",
|
||||
@@ -128,7 +130,7 @@ ohos_unittest("UTTest_device_manager_service_listener") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/device_manager_service_listener.cpp",
|
||||
"${services_path}/src/device_manager_service_listener.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/test/unittest/mock/ipc_server_listener.cpp",
|
||||
"UTTest_device_manager_service_listener.cpp",
|
||||
]
|
||||
@@ -186,11 +188,11 @@ ohos_unittest("UTTest_dm_discovery_manager") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/device_manager_service_listener.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp",
|
||||
"${services_path}/src/dependency/softbus/softbus_connector.cpp",
|
||||
"${services_path}/src/dependency/softbus/softbus_session.cpp",
|
||||
"${services_path}/src/dependency/timer/dm_timer.cpp",
|
||||
"${services_path}/src/device_manager_service_listener.cpp",
|
||||
"${services_path}/src/discovery/dm_discovery_manager.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/test/unittest/mock/ipc_server_listener.cpp",
|
||||
"//foundation/distributedhardware/devicemanager/test/unittest/mock/parameter.cpp",
|
||||
"UTTest_dm_discovery_manager.cpp",
|
||||
@@ -205,10 +207,10 @@ config("device_manager_test_common_public_config") {
|
||||
include_dirs = [
|
||||
"//utils/native/base/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include/ipc/standard",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include/ipc",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include/notify",
|
||||
"${innerkits_path}/native_cpp/include",
|
||||
"${innerkits_path}/native_cpp/include/ipc/standard",
|
||||
"${innerkits_path}/native_cpp/include/ipc",
|
||||
"${innerkits_path}/native_cpp/include/notify",
|
||||
"//third_party/json/include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/ipc",
|
||||
@@ -219,25 +221,25 @@ config("device_manager_test_common_public_config") {
|
||||
"${services_path}/include/dependency/timer",
|
||||
"${services_path}/include/discovery",
|
||||
"${services_path}/include/dependency/softbus",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/dependency/softbus",
|
||||
"${services_path}/include/dependency/softbus",
|
||||
"${services_path}/include/authentication",
|
||||
"${services_path}/include/adapter",
|
||||
"${services_path}/include",
|
||||
"${services_path}/include/ipc/standard",
|
||||
"${services_path}/include/discovery",
|
||||
"${services_path}/include/dependency/hichain",
|
||||
"${services_path}/include/deviceinfo/",
|
||||
"${services_path}/include/devicestate",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/bus_center",
|
||||
"//foundation/communication/softbus_lite/interfaces/kits/transport",
|
||||
"//foundation/communication/ipc_lite/interfaces/kits",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/common",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/discovery",
|
||||
"//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/authentication",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/adapter",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/ipc/standard",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/discovery",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/dependency/hichain",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/deviceinfo/",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/devicestate",
|
||||
"//foundation/distributedhardware/devicemanager/test/unittest/mock",
|
||||
"//base/security/deviceauth/interfaces/innerkits",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/ability",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/config",
|
||||
"${services_path}/include/ability",
|
||||
"${services_path}/include/config",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
@@ -263,16 +265,15 @@ ohos_static_library("device_manager_test_common") {
|
||||
public_configs = [ ":device_manager_test_common_public_config" ]
|
||||
|
||||
public_deps = [
|
||||
"${innerkits_path}/native_cpp:devicemanagersdk",
|
||||
"${services_path}:devicemanagerservice",
|
||||
"${utils_path}:devicemanagerutils",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//third_party/googletest:gmock",
|
||||
"//third_party/googletest:gtest",
|
||||
"//utils/native/base:utils",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -283,9 +284,9 @@ config("device_manager_test_common_public") {
|
||||
include_dirs = [
|
||||
"//utils/native/base/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include/ipc",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include/notify",
|
||||
"${innerkits_path}/native_cpp/include",
|
||||
"${innerkits_path}/native_cpp/include/ipc",
|
||||
"${innerkits_path}/native_cpp/include/notify",
|
||||
"//third_party/json/include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/ipc",
|
||||
@@ -296,23 +297,27 @@ config("device_manager_test_common_public") {
|
||||
"${services_path}/include/dependency/timer",
|
||||
"${services_path}/include/discovery",
|
||||
"${services_path}/include/dependency/softbus",
|
||||
"${services_path}/include/dependency/hichain",
|
||||
"${services_path}/include/dependency/multipleuser",
|
||||
"${services_path}/include/dependency/softbus",
|
||||
"${services_path}/include/authentication",
|
||||
"${services_path}/include/adapter",
|
||||
"${services_path}/include",
|
||||
"${services_path}/include/discovery",
|
||||
"${services_path}/include/deviceinfo/",
|
||||
"${services_path}/include/devicestate",
|
||||
"//foundation/distributedhardware/devicemanager/test/unittest/mock/",
|
||||
"${services_path}/include/ability",
|
||||
"${services_path}/include/config",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/bus_center",
|
||||
"//foundation/communication/ipc_lite/interfaces/kits",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/common",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/discovery",
|
||||
"//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/dependency/softbus",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/authentication",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/adapter",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/discovery",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/dependency/hichain",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/deviceinfo/",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/devicestate",
|
||||
"//foundation/distributedhardware/devicemanager/test/unittest/mock/",
|
||||
"//base/security/deviceauth/interfaces/innerkits",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/ability",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/config",
|
||||
"//base/account/os_account/interfaces/innerkits/osaccount/native/include",
|
||||
"//base/account/os_account/frameworks/common/database/include",
|
||||
"//base/account/os_account/frameworks/common/account_error/include",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
@@ -338,9 +343,9 @@ ohos_static_library("device_manager_test") {
|
||||
public_configs = [ ":device_manager_test_common_public" ]
|
||||
|
||||
public_deps = [
|
||||
"${innerkits_path}/native_cpp:devicemanagersdk",
|
||||
"${utils_path}:devicemanagerutils",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//third_party/googletest:gmock",
|
||||
@@ -351,6 +356,7 @@ ohos_static_library("device_manager_test") {
|
||||
deps = [
|
||||
"${innerkits_path}/native_cpp:devicemanagersdk",
|
||||
"${utils_path}:devicemanagerutils",
|
||||
"//base/account/os_account/frameworks/osaccount/native:os_account_innerkits",
|
||||
"//base/security/deviceauth/services:deviceauth_sdk",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/want:want",
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "dm_device_state_manager.h"
|
||||
#include "ipc_notify_device_found_req.h"
|
||||
#include "ipc_notify_discover_result_req.h"
|
||||
#include "hichain_connector.h"
|
||||
#include "UTTest_dm_device_state_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -43,10 +44,11 @@ void DmDeviceStateManagerTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
namespace {
|
||||
std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
|
||||
std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
|
||||
std::shared_ptr<DeviceManagerServiceListener> listener_ = std::make_shared<DeviceManagerServiceListener>();
|
||||
std::shared_ptr<DmDeviceStateManager> dmDeviceStateManager =
|
||||
std::make_shared<DmDeviceStateManager>(softbusConnector, listener_);
|
||||
std::make_shared<DmDeviceStateManager>(softbusConnector, listener_, hiChainConnector_);
|
||||
|
||||
/**
|
||||
* @tc.name: DmDeviceStateManager_001
|
||||
@@ -56,7 +58,8 @@ std::shared_ptr<DmDeviceStateManager> dmDeviceStateManager =
|
||||
*/
|
||||
HWTEST_F(DmDeviceStateManagerTest, DmDeviceStateManager_001, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::shared_ptr<DmDeviceStateManager> p = std::make_shared<DmDeviceStateManager>(softbusConnector, listener_);
|
||||
std::shared_ptr<DmDeviceStateManager> p = std::make_shared<DmDeviceStateManager>(softbusConnector, listener_,
|
||||
hiChainConnector_);
|
||||
ASSERT_NE(p, nullptr);
|
||||
}
|
||||
|
||||
@@ -68,7 +71,8 @@ HWTEST_F(DmDeviceStateManagerTest, DmDeviceStateManager_001, testing::ext::TestS
|
||||
*/
|
||||
HWTEST_F(DmDeviceStateManagerTest, DmDeviceStateManager_002, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::shared_ptr<DmDeviceStateManager> p = std::make_shared<DmDeviceStateManager>(softbusConnector, listener_);
|
||||
std::shared_ptr<DmDeviceStateManager> p = std::make_shared<DmDeviceStateManager>(softbusConnector, listener_,
|
||||
hiChainConnector_);
|
||||
p.reset();
|
||||
EXPECT_EQ(p, nullptr);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -16,10 +16,11 @@
|
||||
#ifndef DEVICE_AUTH_H
|
||||
#define DEVICE_AUTH_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if defined(__LINUX__) || defined(_UNIX)
|
||||
#define DEVICE_AUTH_API_PUBLIC __attribute__((visibility("default")))
|
||||
#define DEVICE_AUTH_API_PUBLIC __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define DEVICE_AUTH_API_PUBLIC
|
||||
#endif
|
||||
@@ -65,51 +66,68 @@
|
||||
#define FIELD_GROUP_VISIBILITY "groupVisibility"
|
||||
#define FIELD_EXPIRE_TIME "expireTime"
|
||||
#define FIELD_IS_DELETE_ALL "isDeleteAll"
|
||||
#define FIELD_BLE_CHALLENGE "bleChallenge"
|
||||
#define FIELD_OS_ACCOUNT_ID "osAccountId"
|
||||
|
||||
enum GroupType {
|
||||
typedef enum {
|
||||
DEFAULT_OS_ACCOUNT = 0,
|
||||
INVALID_OS_ACCOUNT = -1,
|
||||
ANY_OS_ACCOUNT = -2,
|
||||
} OsAccountEnum;
|
||||
|
||||
typedef enum {
|
||||
ALL_GROUP = 0,
|
||||
IDENTICAL_ACCOUNT_GROUP = 1,
|
||||
PEER_TO_PEER_GROUP = 256,
|
||||
COMPATIBLE_GROUP = 512,
|
||||
ACROSS_ACCOUNT_AUTHORIZE_GROUP = 1282
|
||||
};
|
||||
} GroupType;
|
||||
|
||||
enum GroupOperationCode {
|
||||
typedef enum {
|
||||
GROUP_CREATE = 0,
|
||||
GROUP_DISBAND = 1,
|
||||
MEMBER_INVITE = 2,
|
||||
MEMBER_JOIN = 3,
|
||||
MEMBER_DELETE = 4,
|
||||
ACCOUNT_BIND = 5
|
||||
};
|
||||
} GroupOperationCode;
|
||||
|
||||
enum GroupAuthForm {
|
||||
typedef enum {
|
||||
AUTH_FORM_INVALID_TYPE = -1,
|
||||
AUTH_FORM_ACCOUNT_UNRELATED = 0,
|
||||
AUTH_FORM_IDENTICAL_ACCOUNT = 1,
|
||||
AUTH_FORM_ACROSS_ACCOUNT = 2,
|
||||
};
|
||||
} GroupAuthForm;
|
||||
|
||||
enum CredentialCode {
|
||||
CREDENTIAL_SAVE = 0,
|
||||
CREDENTIAL_CLEAR = 1,
|
||||
CREDENTIAL_UPDATE = 2,
|
||||
CREDENTIAL_QUERY = 3,
|
||||
};
|
||||
typedef enum {
|
||||
IMPORT_SELF_CREDENTIAL = 0,
|
||||
DELETE_SELF_CREDENTIAL = 1,
|
||||
QUERY_SELF_CREDENTIAL_INFO = 2,
|
||||
IMPORT_TRUSTED_CREDENTIALS = 3,
|
||||
DELETE_TRUSTED_CREDENTIALS = 4,
|
||||
QUERY_TRUSTED_CREDENTIALS = 5,
|
||||
REQUEST_SIGNATURE = 6,
|
||||
} CredentialCode;
|
||||
|
||||
enum UserType {
|
||||
typedef enum {
|
||||
DEVICE_TYPE_ACCESSORY = 0,
|
||||
DEVICE_TYPE_CONTROLLER = 1,
|
||||
DEVICE_TYPE_PROXY = 2
|
||||
};
|
||||
} UserType;
|
||||
|
||||
enum RequestResponse {
|
||||
typedef enum {
|
||||
EXPIRE_TIME_INDEFINITE = -1,
|
||||
EXPIRE_TIME_MIN = 1,
|
||||
EXPIRE_TIME_MAX = 90,
|
||||
} ExpireTime;
|
||||
|
||||
typedef enum {
|
||||
REQUEST_REJECTED = 0x80000005,
|
||||
REQUEST_ACCEPTED = 0x80000006,
|
||||
REQUEST_WAITING = 0x80000007
|
||||
};
|
||||
} RequestResponse;
|
||||
|
||||
struct DataChangeListener {
|
||||
typedef struct {
|
||||
void (*onGroupCreated)(const char *groupInfo);
|
||||
void (*onGroupDeleted)(const char *groupInfo);
|
||||
void (*onDeviceBound)(const char *peerUdid, const char *groupInfo);
|
||||
@@ -117,38 +135,40 @@ struct DataChangeListener {
|
||||
void (*onDeviceNotTrusted)(const char *peerUdid);
|
||||
void (*onLastGroupDeleted)(const char *peerUdid, int groupType);
|
||||
void (*onTrustedDeviceNumChanged)(int curTrustedDeviceNum);
|
||||
};
|
||||
} DataChangeListener;
|
||||
|
||||
struct DeviceAuthCallback {
|
||||
typedef struct {
|
||||
bool (*onTransmit)(int64_t requestId, const uint8_t *data, uint32_t dataLen);
|
||||
void (*onSessionKeyReturned)(int64_t requestId, const uint8_t *sessionKey, uint32_t sessionKeyLen);
|
||||
void (*onFinish)(int64_t requestId, int operationCode, const char *returnData);
|
||||
void (*onError)(int64_t requestId, int operationCode, int errorCode, const char *errorReturn);
|
||||
char *(*onRequest)(int64_t requestId, int operationCode, const char *reqParams);
|
||||
};
|
||||
} DeviceAuthCallback;
|
||||
|
||||
struct GroupAuthManager {
|
||||
typedef struct {
|
||||
int32_t (*processData)(int64_t authReqId, const uint8_t *data, uint32_t dataLen,
|
||||
const DeviceAuthCallback *gaCallback);
|
||||
const DeviceAuthCallback *gaCallback);
|
||||
int32_t (*queryTrustedDeviceNum)(void);
|
||||
bool (*isTrustedDevice)(const char *udid);
|
||||
int32_t (*getAuthState)(int64_t authReqId, const char *groupId, const char *peerUdid, uint8_t *out,
|
||||
uint32_t *outLen);
|
||||
int32_t (*authDevice)(int64_t authReqId, const char *authParams, const DeviceAuthCallback *gaCallback);
|
||||
int32_t (*getAuthState)(int64_t authReqId, const char *groupId, const char *peerUdid,
|
||||
uint8_t *out, uint32_t *outLen);
|
||||
int32_t (*authDevice)(int32_t osAccountId, int64_t authReqId, const char *authParams,
|
||||
const DeviceAuthCallback *gaCallback);
|
||||
void (*informDeviceDisconnection)(const char *udid);
|
||||
};
|
||||
} GroupAuthManager;
|
||||
|
||||
struct DeviceGroupManager {
|
||||
typedef struct {
|
||||
int32_t (*regCallback)(const char *appId, const DeviceAuthCallback *callback);
|
||||
int32_t (*unRegCallback)(const char *appId);
|
||||
int32_t (*regDataChangeListener)(const char *appId, const DataChangeListener *listener);
|
||||
int32_t (*unRegDataChangeListener)(const char *appId);
|
||||
int32_t (*createGroup)(int64_t requestId, const char *appId, const char *createParams);
|
||||
int32_t (*deleteGroup)(int64_t requestId, const char *appId, const char *disbandParams);
|
||||
int32_t (*addMemberToGroup)(int64_t requestId, const char *appId, const char *addParams);
|
||||
int32_t (*deleteMemberFromGroup)(int64_t requestId, const char *appId, const char *deleteParams);
|
||||
int32_t (*createGroup)(int32_t osAccountId, int64_t requestId, const char *appId, const char *createParams);
|
||||
int32_t (*deleteGroup)(int32_t osAccountId, int64_t requestId, const char *appId, const char *disbandParams);
|
||||
int32_t (*addMemberToGroup)(int32_t osAccountId, int64_t requestId, const char *appId, const char *addParams);
|
||||
int32_t (*deleteMemberFromGroup)(int32_t osAccountId, int64_t requestId, const char *appId,
|
||||
const char *deleteParams);
|
||||
int32_t (*processData)(int64_t requestId, const uint8_t *data, uint32_t dataLen);
|
||||
int32_t (*confirmRequest)(int64_t requestId, const char *appId, const char *confirmParams);
|
||||
int32_t (*confirmRequest)(int32_t osAccountId, int64_t requestId, const char *appId, const char *confirmParams);
|
||||
int32_t (*bindPeer)(int64_t requestId, const char *appId, const char *bindParams);
|
||||
int32_t (*unbindPeer)(int64_t requestId, const char *appId, const char *unbindParams);
|
||||
int32_t (*processLiteData)(int64_t requestId, const char *appId, const uint8_t *data, uint32_t dataLen);
|
||||
@@ -157,24 +177,32 @@ struct DeviceGroupManager {
|
||||
int32_t (*processCredential)(int operationCode, const char *reqJsonStr, char **returnJsonStr);
|
||||
int32_t (*getRegisterInfo)(char **returnRegisterInfo);
|
||||
int32_t (*getLocalConnectInfo)(char *returnInfo, int32_t bufLen);
|
||||
int32_t (*checkAccessToGroup)(const char *appId, const char *groupId);
|
||||
int32_t (*getPkInfoList)(const char *appId, const char *queryParams, char **returnInfoList,
|
||||
uint32_t *returnInfoNum);
|
||||
int32_t (*addGroupManager)(const char *appId, const char *groupId, const char *managerAppId);
|
||||
int32_t (*addGroupFriend)(const char *appId, const char *groupId, const char *friendAppId);
|
||||
int32_t (*deleteGroupManager)(const char *appId, const char *groupId, const char *managerAppId);
|
||||
int32_t (*deleteGroupFriend)(const char *appId, const char *groupId, const char *friendAppId);
|
||||
int32_t (*getGroupManagers)(const char *appId, const char *groupId, char **returnManagers, uint32_t *returnSize);
|
||||
int32_t (*getGroupFriends)(const char *appId, const char *groupId, char **returnFriends, uint32_t *returnSize);
|
||||
int32_t (*getGroupInfoById)(const char *appId, const char *groupId, char **returnGroupInfo);
|
||||
int32_t (*getGroupInfo)(const char *appId, const char *queryParams, char **returnGroupVec, uint32_t *groupNum);
|
||||
int32_t (*getJoinedGroups)(const char *appId, int groupType, char **returnGroupVec, uint32_t *groupNum);
|
||||
int32_t (*getRelatedGroups)(const char *appId, const char *peerDeviceId, char **returnGroupVec, uint32_t *groupNum);
|
||||
int32_t (*getDeviceInfoById)(const char *appId, const char *deviceId, const char *groupId, char **returnDeviceInfo);
|
||||
int32_t (*getTrustedDevices)(const char *appId, const char *groupId, char **returnDevInfoVec, uint32_t *deviceNum);
|
||||
bool (*isDeviceInGroup)(const char *appId, const char *groupId, const char *deviceId);
|
||||
int32_t (*checkAccessToGroup)(int32_t osAccountId, const char *appId, const char *groupId);
|
||||
int32_t (*getPkInfoList)(int32_t osAccountId, const char *appId, const char *queryParams, char **returnInfoList,
|
||||
uint32_t *returnInfoNum);
|
||||
int32_t (*addGroupManager)(int32_t osAccountId, const char *appId, const char *groupId, const char *managerAppId);
|
||||
int32_t (*addGroupFriend)(int32_t osAccountId, const char *appId, const char *groupId, const char *friendAppId);
|
||||
int32_t (*deleteGroupManager)(int32_t osAccountId, const char *appId, const char *groupId,
|
||||
const char *managerAppId);
|
||||
int32_t (*deleteGroupFriend)(int32_t osAccountId, const char *appId, const char *groupId, const char *friendAppId);
|
||||
int32_t (*getGroupManagers)(int32_t osAccountId, const char *appId, const char *groupId, char **returnManagers,
|
||||
uint32_t *returnSize);
|
||||
int32_t (*getGroupFriends)(int32_t osAccountId, const char *appId, const char *groupId,
|
||||
char **returnFriends, uint32_t *returnSize);
|
||||
int32_t (*getGroupInfoById)(int32_t osAccountId, const char *appId, const char *groupId, char **returnGroupInfo);
|
||||
int32_t (*getGroupInfo)(int32_t osAccountId, const char *appId, const char *queryParams,
|
||||
char **returnGroupVec, uint32_t *groupNum);
|
||||
int32_t (*getJoinedGroups)(int32_t osAccountId, const char *appId, int groupType,
|
||||
char **returnGroupVec, uint32_t *groupNum);
|
||||
int32_t (*getRelatedGroups)(int32_t osAccountId, const char *appId, const char *peerDeviceId,
|
||||
char **returnGroupVec, uint32_t *groupNum);
|
||||
int32_t (*getDeviceInfoById)(int32_t osAccountId, const char *appId, const char *deviceId, const char *groupId,
|
||||
char **returnDeviceInfo);
|
||||
int32_t (*getTrustedDevices)(int32_t osAccountId, const char *appId, const char *groupId,
|
||||
char **returnDevInfoVec, uint32_t *deviceNum);
|
||||
bool (*isDeviceInGroup)(int32_t osAccountId, const char *appId, const char *groupId, const char *deviceId);
|
||||
void (*destroyInfo)(char **returnInfo);
|
||||
};
|
||||
} DeviceGroupManager;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -29,3 +29,8 @@ int WatchParameter(const char *keyprefix, ParameterChgPtr callback, void *contex
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetDevUdid(char *udid, int size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -29,6 +29,7 @@ int SetParameter(const char *key, const char *value);
|
||||
typedef void (*ParameterChgPtr)(const char *key, const char *value, void *context);
|
||||
int WatchParameter(const char *keyprefix, ParameterChgPtr callback, void *context);
|
||||
|
||||
int GetDevUdid(char *udid, int size);
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user