mirror of
https://github.com/openharmony/device_manager.git
synced 2026-07-18 16:24:27 -04:00
@@ -41,6 +41,7 @@ const int32_t MIN_PIN_CODE = 100000;
|
||||
const int32_t MAX_PIN_CODE = 999999;
|
||||
const int32_t DISCOVER_STATUS_LEN = 20;
|
||||
const int32_t COMMON_CALLBACK_MAX_SIZE = 200;
|
||||
const uint32_t MAX_LOAD_VAVLUE = 3;
|
||||
|
||||
enum {
|
||||
DM_OK = 0,
|
||||
|
||||
@@ -129,7 +129,6 @@ void DmDeviceStateManager::PostDeviceOffline(const std::string &pkgName, const D
|
||||
|
||||
void DmDeviceStateManager::OnDeviceOnline(const std::string &pkgName, const DmDeviceInfo &info)
|
||||
{
|
||||
DmDistributedHardwareLoad::GetInstance().InitDistributedHardwareLoadCount();
|
||||
DmDistributedHardwareLoad::GetInstance().LoadDistributedHardwareFwk();
|
||||
LOGI("OnDeviceOnline function is called back with pkgName: %s", pkgName.c_str());
|
||||
RegisterOffLineTimer(info);
|
||||
|
||||
@@ -24,9 +24,9 @@ class DmDistributedHardwareLoad {
|
||||
public:
|
||||
void LoadDistributedHardwareFwk(void);
|
||||
void InitDistributedHardwareLoadCount(void);
|
||||
uint32_t getDistributedHardwareLoadCount(void);
|
||||
uint32_t GetDistributedHardwareLoadCount(void);
|
||||
private:
|
||||
uint32_t nLoadCount_;
|
||||
uint32_t distributedHardwareLoadCount_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -34,9 +34,9 @@ class DmDistributedHardwareLoad {
|
||||
public:
|
||||
void LoadDistributedHardwareFwk(void);
|
||||
void InitDistributedHardwareLoadCount(void);
|
||||
uint32_t getDistributedHardwareLoadCount(void);
|
||||
uint32_t GetDistributedHardwareLoadCount(void);
|
||||
private:
|
||||
uint32_t nLoadCount_;
|
||||
uint32_t distributedHardwareLoadCount_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -27,7 +27,7 @@ void DmDistributedHardwareLoad::InitDistributedHardwareLoadCount(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint32_t DmDistributedHardwareLoad::getDistributedHardwareLoadCount(void)
|
||||
uint32_t DmDistributedHardwareLoad::GetDistributedHardwareLoadCount(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -19,26 +19,6 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void DistributedHardwareLoadCallback::OnLoadSystemAbilitySuccess(
|
||||
int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject)
|
||||
{
|
||||
LOGI("DmDistributedHhardware Load SA success, systemAbilityId:%d, remoteObject result:%s",
|
||||
systemAbilityId, (remoteObject != nullptr) ? "true" : "false");
|
||||
if (remoteObject == nullptr) {
|
||||
LOGE("remoteObject is nullptr");
|
||||
return;
|
||||
}
|
||||
}
|
||||
void DistributedHardwareLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
{
|
||||
LOGE("DmDistributedHhardware Load SA failed, systemAbilityId:%d", systemAbilityId);
|
||||
uint32_t maxLoadValue = 3;
|
||||
if (DmDistributedHardwareLoad::GetInstance().getDistributedHardwareLoadCount() < maxLoadValue) {
|
||||
DmDistributedHardwareLoad::GetInstance().LoadDistributedHardwareFwk();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
IMPLEMENT_SINGLE_INSTANCE(DmDistributedHardwareLoad);
|
||||
void DmDistributedHardwareLoad::LoadDistributedHardwareFwk(void)
|
||||
{
|
||||
@@ -47,7 +27,7 @@ void DmDistributedHardwareLoad::LoadDistributedHardwareFwk(void)
|
||||
if (samgr == nullptr) {
|
||||
LOGE("failed to get system ability mgr.");
|
||||
}
|
||||
nLoadCount_++;
|
||||
distributedHardwareLoadCount_++;
|
||||
sptr<DistributedHardwareLoadCallback> distributedHardwareLoadCallback_ = new DistributedHardwareLoadCallback();
|
||||
int32_t ret = samgr->LoadSystemAbility(DISTRIBUTED_HARDWARE_SA_ID, distributedHardwareLoadCallback_);
|
||||
if (ret != DM_OK) {
|
||||
@@ -58,11 +38,34 @@ void DmDistributedHardwareLoad::LoadDistributedHardwareFwk(void)
|
||||
}
|
||||
void DmDistributedHardwareLoad::InitDistributedHardwareLoadCount(void)
|
||||
{
|
||||
nLoadCount_ = 0;
|
||||
distributedHardwareLoadCount_ = 0;
|
||||
}
|
||||
uint32_t DmDistributedHardwareLoad::getDistributedHardwareLoadCount()
|
||||
uint32_t DmDistributedHardwareLoad::GetDistributedHardwareLoadCount()
|
||||
{
|
||||
return nLoadCount_;
|
||||
return distributedHardwareLoadCount_;
|
||||
}
|
||||
|
||||
void DistributedHardwareLoadCallback::OnLoadSystemAbilitySuccess(
|
||||
int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject)
|
||||
{
|
||||
LOGI("DmDistributedHhardware Load SA success, systemAbilityId:%d, remoteObject result:%s",
|
||||
systemAbilityId, (remoteObject != nullptr) ? "true" : "false");
|
||||
if (remoteObject == nullptr) {
|
||||
LOGE("remoteObject is nullptr");
|
||||
return;
|
||||
}
|
||||
DmDistributedHardwareLoad::GetInstance().InitDistributedHardwareLoadCount();
|
||||
}
|
||||
void DistributedHardwareLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
{
|
||||
LOGE("DmDistributedHhardware Load SA failed, systemAbilityId:%d", systemAbilityId);
|
||||
|
||||
if (DmDistributedHardwareLoad::GetInstance().GetDistributedHardwareLoadCount() < MAX_LOAD_VAVLUE) {
|
||||
DmDistributedHardwareLoad::GetInstance().LoadDistributedHardwareFwk();
|
||||
} else {
|
||||
DmDistributedHardwareLoad::GetInstance().InitDistributedHardwareLoadCount();
|
||||
}
|
||||
return;
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user