mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 14:30:21 +00:00
hidumper
Signed-off-by: shihaojie6128 <shihaojie10@huawei.com>
This commit is contained in:
parent
404b7e80cc
commit
3ab4905abb
@ -77,6 +77,7 @@ ohos_shared_library("distributedschedsvr") {
|
||||
"src/bundle/bundle_manager_internal.cpp",
|
||||
"src/connect_death_recipient.cpp",
|
||||
"src/deviceManager/dms_device_info.cpp",
|
||||
"src/dfx/dms_continue_time_dumper.cpp",
|
||||
"src/dfx/dms_hisysevent_report.cpp",
|
||||
"src/dfx/dms_hitrace_chain.cpp",
|
||||
"src/distributedWant/distributed_operation.cpp",
|
||||
|
110
services/dtbschedmgr/include/dfx/dms_continue_time_dumper.h
Normal file
110
services/dtbschedmgr/include/dfx/dms_continue_time_dumper.h
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DISTRIBUTED_CONTINUE_TIME_DUMPER_H
|
||||
#define OHOS_DISTRIBUTED_CONTINUE_TIME_DUMPER_H
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
|
||||
struct DmsDumperInfo {
|
||||
std::string bundleName;
|
||||
std::string netWorkId;
|
||||
std::string abilityName;
|
||||
std::string deviceName;
|
||||
};
|
||||
|
||||
class DmsDuration {
|
||||
public:
|
||||
DmsDuration() = default;
|
||||
DmsDuration(const int64_t begin, const int64_t end, const std::string name);
|
||||
~DmsDuration() = default;
|
||||
|
||||
void SetBeginTime(const int64_t time);
|
||||
void SetEndTime(const int64_t time);
|
||||
void SetDurationTime(const int64_t time);
|
||||
void SetStrTime(const std::string name);
|
||||
void SetDurationName(const std::string name);
|
||||
|
||||
int64_t GetBeginTime();
|
||||
int64_t GetEndTime();
|
||||
int64_t GetDurationTime();
|
||||
std::string GetStrTime();
|
||||
std::string GetDurationName();
|
||||
|
||||
private:
|
||||
int64_t beginTime_;
|
||||
int64_t endTime_;
|
||||
int64_t duration_;
|
||||
std::string strTime_;
|
||||
std::string durationName_;
|
||||
};
|
||||
|
||||
class DmsContinueTime {
|
||||
public:
|
||||
DECLARE_SINGLE_INSTANCE_BASE(DmsContinueTime);
|
||||
|
||||
public:
|
||||
DmsContinueTime() = default;
|
||||
~DmsContinueTime() = default;
|
||||
|
||||
void Init();
|
||||
void SetPull(bool sign);
|
||||
bool GetPull();
|
||||
void SetSrcBundleName(const std::string bundleName);
|
||||
void SetSrcAbilityName(const std::string abilityName);
|
||||
void SetDstBundleName(const std::string bundleName);
|
||||
void SetDstAbilityName(const std::string abilityName);
|
||||
void SetNetWorkId(const std::string srcNetWorkId, const std::string dstNetWorkId);
|
||||
void SetDeviceNamePull();
|
||||
void SetDeviceNamePush();
|
||||
DmsDumperInfo GetDstInfo();
|
||||
|
||||
void SetDurationBegin(const int32_t idx, const int64_t time);
|
||||
void SetDurationEnd(const int32_t idx, const int64_t time);
|
||||
void SetDurationStrTime(const int32_t idx, const std::string info);
|
||||
|
||||
void SetSaveDataDurationBegin(const int64_t time);
|
||||
void SetSaveDataDurationEnd(const int64_t time);
|
||||
DmsDuration GetSaveDataDuration();
|
||||
|
||||
std::string WriteDurationInfo(DmsDuration duration);
|
||||
void ReadDurationInfo(const char* info);
|
||||
std::string WriteDstInfo(const std::string bundleName, const std::string abilityName);
|
||||
void ReadDstInfo(const char* info);
|
||||
std::string GetCurrentTime();
|
||||
void DealDurationPull();
|
||||
void DealDurationPush();
|
||||
void AppendInfo();
|
||||
void ShowInfo(std::string& result);
|
||||
|
||||
private:
|
||||
bool isPull_;
|
||||
std::list<std::string> timeInfoList_;
|
||||
std::vector<DmsDuration> durationInfo_;
|
||||
std::string appendInfo_;
|
||||
DmsDumperInfo srcInfo_;
|
||||
DmsDumperInfo dstInfo_;
|
||||
DmsDuration saveDataDuration_;
|
||||
};
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DISTRIBUTED_CONTINUE_TIME_DUMPER_H
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -31,6 +31,7 @@ private:
|
||||
static bool CanDump();
|
||||
static bool DumpDefault(std::string& result);
|
||||
static void ShowConnectRemoteAbility(std::string& result);
|
||||
static void ShowDuration(std::string& result);
|
||||
static void ShowHelp(std::string& result);
|
||||
static void IllegalInput(std::string& result);
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -78,7 +78,8 @@ public:
|
||||
virtual int32_t StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid,
|
||||
int32_t status, uint32_t accessToken) = 0;
|
||||
virtual void NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess) = 0;
|
||||
virtual int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess) = 0;
|
||||
virtual int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess,
|
||||
const std::string dstInfo) = 0;
|
||||
virtual int32_t NotifyDSchedEventResultFromRemote(const std::string type, int32_t dSchedEventResult)
|
||||
{
|
||||
return 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -45,7 +45,7 @@ public:
|
||||
int32_t StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid,
|
||||
int32_t status, uint32_t accessToken) override;
|
||||
void NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess) override;
|
||||
int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess) override;
|
||||
int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess, const std::string dstInfo) override;
|
||||
int32_t NotifyDSchedEventResultFromRemote(const std::string type, int32_t dSchedEventResult) override;
|
||||
int32_t ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
|
||||
int32_t callerUid, int32_t callerPid, uint32_t accessToken) override;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -89,6 +89,7 @@ public:
|
||||
int32_t Dump(int32_t fd, const std::vector<std::u16string>& args) override;
|
||||
void DeviceOnlineNotify(const std::string& deviceId);
|
||||
void DeviceOfflineNotify(const std::string& deviceId);
|
||||
void DurationStart(const std::string srcDeviceId, const std::string dstDeviceId);
|
||||
|
||||
int32_t StartRemoteAbility(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
|
||||
uint32_t accessToken) override;
|
||||
@ -99,6 +100,12 @@ public:
|
||||
const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t resultCode) override;
|
||||
int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) override;
|
||||
int32_t ProcessContinueLocalMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
const std::string& bundleName, const sptr<IRemoteObject>& callback,
|
||||
const OHOS::AAFwk::WantParams& wantParams);
|
||||
int32_t ProcessContinueRemoteMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
const std::string& bundleName, const sptr<IRemoteObject>& callback,
|
||||
const OHOS::AAFwk::WantParams& wantParams);
|
||||
int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
const std::string& bundleName, const sptr<IRemoteObject>& callback,
|
||||
const OHOS::AAFwk::WantParams& wantParams) override;
|
||||
@ -106,7 +113,7 @@ public:
|
||||
int32_t StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid,
|
||||
int32_t status, uint32_t accessToken) override;
|
||||
void NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess) override;
|
||||
int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess) override;
|
||||
int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess, const std::string dstInfo) override;
|
||||
int32_t NotifyDSchedEventResultFromRemote(const std::string type, int32_t dSchedEventResult) override;
|
||||
void NotifyContinuationCallbackResult(int32_t missionId, int32_t resultCode);
|
||||
void NotifyDSchedEventCallbackResult(const std::string type, int32_t resultCode);
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
void DeviceOnlineNotify(const std::shared_ptr<DmsDeviceInfo> devInfo);
|
||||
void DeviceOfflineNotify(const std::string& networkId);
|
||||
void OnDeviceInfoChanged(const std::string& networkId);
|
||||
std::string GetDeviceName(std::string netWorkId);
|
||||
|
||||
/**
|
||||
* get device info by device id
|
||||
|
389
services/dtbschedmgr/src/dfx/dms_continue_time_dumper.cpp
Normal file
389
services/dtbschedmgr/src/dfx/dms_continue_time_dumper.cpp
Normal file
@ -0,0 +1,389 @@
|
||||
/*
|
||||
* 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 "dfx/dms_continue_time_dumper.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include "adapter/dnetwork_adapter.h"
|
||||
#include "cJSON.h"
|
||||
#include "datetime_ex.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "dtbschedmgr_device_info_storage.h"
|
||||
#include "deviceManager/dms_device_info.h"
|
||||
#include "distributed_device_node_listener.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
namespace {
|
||||
const std::string TAG = "DmsContinueTime";
|
||||
const std::string DMSDURATION_STARTTIME = "Continue Start Time: ";
|
||||
const std::string DMSDURATION_ENDTIME = "Continue End Time : ";
|
||||
const std::string DMSDURATION_TOTAL = "Total Time Cost : ";
|
||||
const std::string DMSDURATION_SINKTOSOURCERPC = "--Sink to Source RPC Cost: ";
|
||||
const std::string DMSDURATION_SOURCEDATASAVE = "--Source Data Save Cost : ";
|
||||
const std::string DMSDURATION_SOURCETOSINKRPC = "--Source to Sink RPC Cost: ";
|
||||
const std::string DMSDURATION_SINKABILITYSTART = "--Sink Ability Start Cost: ";
|
||||
constexpr int32_t DMSDURATION_MAXSIZE = 100;
|
||||
constexpr int32_t DMSDURATION_SPACE = 40;
|
||||
constexpr int32_t DMSDURATION_TOTALTIME = 2;
|
||||
constexpr int32_t DMSDURATION_DSTTOSRCRPCTIME = 3;
|
||||
constexpr int32_t DMSDURATION_SAVETIME = 4;
|
||||
constexpr int32_t DMSDURATION_SRCTODSTSAVETIME = 5;
|
||||
constexpr int32_t DMSDURATION_STARTABILITY = 6;
|
||||
}
|
||||
|
||||
IMPLEMENT_SINGLE_INSTANCE(DmsContinueTime);
|
||||
|
||||
DmsDuration::DmsDuration(const int64_t begin, const int64_t end, const std::string name)
|
||||
{
|
||||
beginTime_ = begin;
|
||||
endTime_ = end;
|
||||
durationName_ = name;
|
||||
}
|
||||
|
||||
void DmsDuration::SetBeginTime(const int64_t time)
|
||||
{
|
||||
beginTime_ = time;
|
||||
}
|
||||
|
||||
void DmsDuration::SetEndTime(const int64_t time)
|
||||
{
|
||||
endTime_ = time;
|
||||
}
|
||||
|
||||
void DmsDuration::SetDurationTime(const int64_t time)
|
||||
{
|
||||
duration_ = time;
|
||||
}
|
||||
|
||||
void DmsDuration::SetStrTime(const std::string name)
|
||||
{
|
||||
strTime_ = name;
|
||||
}
|
||||
|
||||
void DmsDuration::SetDurationName(const std::string name)
|
||||
{
|
||||
durationName_ = name;
|
||||
}
|
||||
|
||||
int64_t DmsDuration::GetBeginTime()
|
||||
{
|
||||
return beginTime_;
|
||||
}
|
||||
|
||||
int64_t DmsDuration::GetEndTime()
|
||||
{
|
||||
return endTime_;
|
||||
}
|
||||
|
||||
int64_t DmsDuration::GetDurationTime()
|
||||
{
|
||||
return duration_;
|
||||
}
|
||||
|
||||
std::string DmsDuration::GetStrTime()
|
||||
{
|
||||
return strTime_;
|
||||
}
|
||||
|
||||
std::string DmsDuration::GetDurationName()
|
||||
{
|
||||
return durationName_;
|
||||
}
|
||||
|
||||
void DmsContinueTime::Init()
|
||||
{
|
||||
srcInfo_.bundleName.clear();
|
||||
srcInfo_.abilityName.clear();
|
||||
srcInfo_.netWorkId.clear();
|
||||
srcInfo_.deviceName.clear();
|
||||
dstInfo_.bundleName.clear();
|
||||
dstInfo_.abilityName.clear();
|
||||
dstInfo_.netWorkId.clear();
|
||||
dstInfo_.deviceName.clear();
|
||||
durationInfo_.clear();
|
||||
|
||||
durationInfo_.push_back(DmsDuration(0, 0, DMSDURATION_STARTTIME));
|
||||
durationInfo_.push_back(DmsDuration(0, 0, DMSDURATION_ENDTIME));
|
||||
durationInfo_.push_back(DmsDuration(0, 0, DMSDURATION_TOTAL));
|
||||
durationInfo_.push_back(DmsDuration(0, 0, DMSDURATION_SINKTOSOURCERPC));
|
||||
durationInfo_.push_back(DmsDuration(0, 0, DMSDURATION_SOURCEDATASAVE));
|
||||
durationInfo_.push_back(DmsDuration(0, 0, DMSDURATION_SOURCETOSINKRPC));
|
||||
durationInfo_.push_back(DmsDuration(0, 0, DMSDURATION_SINKABILITYSTART));
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetPull(bool sign)
|
||||
{
|
||||
isPull_ = sign;
|
||||
}
|
||||
|
||||
bool DmsContinueTime::GetPull()
|
||||
{
|
||||
return isPull_;
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetSrcBundleName(const std::string bundleName)
|
||||
{
|
||||
srcInfo_.bundleName = bundleName;
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetSrcAbilityName(const std::string abilityName)
|
||||
{
|
||||
srcInfo_.abilityName = abilityName;
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetDstBundleName(const std::string bundleName)
|
||||
{
|
||||
dstInfo_.bundleName = bundleName;
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetDstAbilityName(const std::string abilityName)
|
||||
{
|
||||
dstInfo_.abilityName = abilityName;
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetNetWorkId(const std::string srcNetWorkId, const std::string dstNetWorkId)
|
||||
{
|
||||
srcInfo_.netWorkId = srcNetWorkId;
|
||||
dstInfo_.netWorkId = dstNetWorkId;
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetDeviceNamePull()
|
||||
{
|
||||
srcInfo_.deviceName = DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceName(srcInfo_.netWorkId);
|
||||
|
||||
DistributedHardware::DmDeviceInfo dmDeviceInfo;
|
||||
DnetworkAdapter::GetInstance()->GetLocalBasicInfo(dmDeviceInfo);
|
||||
dstInfo_.deviceName = dmDeviceInfo.deviceName;
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetDeviceNamePush()
|
||||
{
|
||||
dstInfo_.deviceName = DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceName(dstInfo_.netWorkId);
|
||||
|
||||
DistributedHardware::DmDeviceInfo dmDeviceInfo;
|
||||
DnetworkAdapter::GetInstance()->GetLocalBasicInfo(dmDeviceInfo);
|
||||
srcInfo_.deviceName = dmDeviceInfo.deviceName;
|
||||
}
|
||||
|
||||
DmsDumperInfo DmsContinueTime::GetDstInfo()
|
||||
{
|
||||
return dstInfo_;
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetDurationBegin(const int32_t idx, const int64_t time)
|
||||
{
|
||||
durationInfo_[idx].SetBeginTime(time);
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetDurationEnd(const int32_t idx, const int64_t time)
|
||||
{
|
||||
durationInfo_[idx].SetEndTime(time);
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetDurationStrTime(const int32_t idx, const std::string info)
|
||||
{
|
||||
durationInfo_[idx].SetStrTime(info);
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetSaveDataDurationBegin(const int64_t time)
|
||||
{
|
||||
saveDataDuration_.SetBeginTime(time);
|
||||
}
|
||||
|
||||
void DmsContinueTime::SetSaveDataDurationEnd(const int64_t time)
|
||||
{
|
||||
saveDataDuration_.SetEndTime(time);
|
||||
}
|
||||
|
||||
DmsDuration DmsContinueTime::GetSaveDataDuration()
|
||||
{
|
||||
return saveDataDuration_;
|
||||
}
|
||||
|
||||
std::string DmsContinueTime::WriteDurationInfo(DmsDuration duration)
|
||||
{
|
||||
cJSON* durationInfo = cJSON_CreateObject();
|
||||
if (durationInfo == nullptr) {
|
||||
HILOGW("Create cJSON Object failed!");
|
||||
return "";
|
||||
}
|
||||
cJSON_AddNumberToObject(durationInfo, "beginTime", duration.GetBeginTime());
|
||||
cJSON_AddNumberToObject(durationInfo, "endTime", duration.GetEndTime());
|
||||
char* cjson_str = cJSON_PrintUnformatted(durationInfo);
|
||||
std::string message(cjson_str);
|
||||
if (message.empty()) {
|
||||
HILOGW("Write Info failed!");
|
||||
}
|
||||
cJSON_Delete(durationInfo);
|
||||
free(cjson_str);
|
||||
return message;
|
||||
}
|
||||
|
||||
void DmsContinueTime::ReadDurationInfo(const char* info)
|
||||
{
|
||||
cJSON* durationInfo = cJSON_Parse(info);
|
||||
if (durationInfo == nullptr) {
|
||||
HILOGW("Accept cJSON Object failed!");
|
||||
return;
|
||||
}
|
||||
int64_t beginTime = cJSON_GetObjectItem(durationInfo, "beginTime")->valueint;
|
||||
int64_t endTime = cJSON_GetObjectItem(durationInfo, "endTime")->valueint;
|
||||
saveDataDuration_.SetBeginTime(beginTime);
|
||||
saveDataDuration_.SetEndTime(endTime);
|
||||
cJSON_Delete(durationInfo);
|
||||
}
|
||||
|
||||
std::string DmsContinueTime::WriteDstInfo(const std::string bundleName, const std::string abilityName)
|
||||
{
|
||||
cJSON* info = cJSON_CreateObject();
|
||||
if (info == nullptr) {
|
||||
HILOGW("Create cJSON Object failed!");
|
||||
return "";
|
||||
}
|
||||
cJSON_AddStringToObject(info, "DstBundleName", bundleName.c_str());
|
||||
cJSON_AddStringToObject(info, "DstAbilityName", abilityName.c_str());
|
||||
char* cjson_str = cJSON_PrintUnformatted(info);
|
||||
std::string message(cjson_str);
|
||||
if (message.empty()) {
|
||||
HILOGW("Write info failed!");
|
||||
}
|
||||
cJSON_Delete(info);
|
||||
free(cjson_str);
|
||||
return message;
|
||||
}
|
||||
|
||||
void DmsContinueTime::ReadDstInfo(const char* info)
|
||||
{
|
||||
cJSON* dstInfo = cJSON_Parse(info);
|
||||
if (dstInfo == nullptr) {
|
||||
HILOGW("Accept cJSON Object failed!");
|
||||
return;
|
||||
}
|
||||
std::string bundleName = cJSON_GetObjectItem(dstInfo, "DstBundleName")->valuestring;
|
||||
std::string abilityName = cJSON_GetObjectItem(dstInfo, "DstAbilityName")->valuestring;
|
||||
dstInfo_.bundleName = bundleName;
|
||||
dstInfo_.abilityName = abilityName;
|
||||
cJSON_Delete(dstInfo);
|
||||
}
|
||||
|
||||
std::string DmsContinueTime::GetCurrentTime()
|
||||
{
|
||||
std::chrono::system_clock::time_point time = std::chrono::system_clock::now();
|
||||
std::time_t time_c = std::chrono::system_clock::to_time_t(time);
|
||||
std::tm* time_tm = std::localtime(&time_c);
|
||||
std::stringstream timeStr;
|
||||
timeStr << std::put_time(time_tm, "%Y/%m/%d %H:%M:%S");
|
||||
return timeStr.str();
|
||||
}
|
||||
|
||||
void DmsContinueTime::DealDurationPull()
|
||||
{
|
||||
durationInfo_[DMSDURATION_SAVETIME].SetBeginTime(saveDataDuration_.GetBeginTime());
|
||||
durationInfo_[DMSDURATION_SAVETIME].SetEndTime(saveDataDuration_.GetEndTime());
|
||||
|
||||
for (auto& duration : durationInfo_) {
|
||||
if (duration.GetStrTime().empty() && duration.GetBeginTime() != 0 && duration.GetEndTime() != 0) {
|
||||
duration.SetDurationTime(duration.GetEndTime() - duration.GetBeginTime());
|
||||
duration.SetStrTime(std::to_string(duration.GetDurationTime()) += "ms");
|
||||
}
|
||||
}
|
||||
durationInfo_[DMSDURATION_STARTABILITY].SetDurationTime(
|
||||
durationInfo_[DMSDURATION_TOTALTIME].GetDurationTime() -
|
||||
durationInfo_[DMSDURATION_DSTTOSRCRPCTIME].GetDurationTime() -
|
||||
durationInfo_[DMSDURATION_SAVETIME].GetDurationTime() -
|
||||
durationInfo_[DMSDURATION_SRCTODSTSAVETIME].GetDurationTime());
|
||||
durationInfo_[DMSDURATION_STARTABILITY].SetStrTime(
|
||||
std::to_string(durationInfo_[DMSDURATION_STARTABILITY].GetDurationTime()) += "ms");
|
||||
}
|
||||
|
||||
void DmsContinueTime::DealDurationPush()
|
||||
{
|
||||
durationInfo_[DMSDURATION_SAVETIME].SetBeginTime(saveDataDuration_.GetBeginTime());
|
||||
durationInfo_[DMSDURATION_SAVETIME].SetEndTime(saveDataDuration_.GetEndTime());
|
||||
|
||||
for (auto& duration : durationInfo_) {
|
||||
if (duration.GetStrTime().empty() && duration.GetBeginTime() != 0 && duration.GetEndTime() != 0) {
|
||||
duration.SetDurationTime(duration.GetEndTime() - duration.GetBeginTime());
|
||||
duration.SetStrTime(std::to_string(duration.GetDurationTime()) += "ms");
|
||||
}
|
||||
}
|
||||
durationInfo_[DMSDURATION_TOTALTIME].SetDurationTime(
|
||||
durationInfo_[DMSDURATION_SAVETIME].GetDurationTime() +
|
||||
durationInfo_[DMSDURATION_STARTABILITY].GetDurationTime() +
|
||||
durationInfo_[DMSDURATION_SRCTODSTSAVETIME].GetDurationTime());
|
||||
durationInfo_[DMSDURATION_TOTALTIME].SetStrTime(
|
||||
std::to_string(durationInfo_[DMSDURATION_TOTALTIME].GetDurationTime()) += "ms");
|
||||
}
|
||||
|
||||
void DmsContinueTime::AppendInfo()
|
||||
{
|
||||
if (isPull_) {
|
||||
SetDeviceNamePull();
|
||||
DealDurationPull();
|
||||
appendInfo_.append("PULL\n");
|
||||
} else {
|
||||
SetDeviceNamePush();
|
||||
DealDurationPush();
|
||||
durationInfo_[DMSDURATION_DSTTOSRCRPCTIME].SetStrTime("NA");
|
||||
appendInfo_.append("PUSH\n");
|
||||
}
|
||||
|
||||
std::stringstream str;
|
||||
str << "== SOURCE ==\n"
|
||||
<< "Network Id : " << std::setw(DMSDURATION_SPACE) << std::left
|
||||
<< DnetworkAdapter::AnonymizeNetworkId(srcInfo_.netWorkId.c_str())
|
||||
<< "Device Name : " << srcInfo_.deviceName << "\n"
|
||||
<< "Bundle Name : " << std::setw(DMSDURATION_SPACE) << std::left
|
||||
<< srcInfo_.bundleName
|
||||
<< "Ability Name : " << srcInfo_.abilityName << "\n"
|
||||
<< "== SINK ==\n"
|
||||
<< "Network Id : " << std::setw(DMSDURATION_SPACE) << std::left
|
||||
<< DnetworkAdapter::AnonymizeNetworkId(dstInfo_.netWorkId.c_str())
|
||||
<< "Device Name : " << dstInfo_.deviceName << "\n"
|
||||
<< "Bundle Name : " << std::setw(DMSDURATION_SPACE) << std::left
|
||||
<< dstInfo_.bundleName
|
||||
<< "Ability Name : " << dstInfo_.abilityName << "\n";
|
||||
appendInfo_.append(str.str());
|
||||
appendInfo_.append("------------------------------------------------------------------------------------\n");
|
||||
|
||||
for (auto duration : durationInfo_) {
|
||||
appendInfo_.append(duration.GetDurationName().c_str());
|
||||
appendInfo_.append(duration.GetStrTime().c_str());
|
||||
appendInfo_.append("\n");
|
||||
}
|
||||
|
||||
if (timeInfoList_.size() >= DMSDURATION_MAXSIZE) {
|
||||
timeInfoList_.pop_front();
|
||||
}
|
||||
timeInfoList_.push_back(appendInfo_);
|
||||
appendInfo_.clear();
|
||||
}
|
||||
|
||||
void DmsContinueTime::ShowInfo(std::string& result)
|
||||
{
|
||||
int32_t nIdx = 1;
|
||||
for (const auto& info : timeInfoList_) {
|
||||
result.append("[" + std::to_string(nIdx) + "]\n");
|
||||
result.append("------------------------------------------------------------------------------------\n");
|
||||
result.append(info.c_str());
|
||||
result.append("------------------------------------------------------------------------------------\n");
|
||||
nIdx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -16,6 +16,7 @@
|
||||
#include "distributed_sched_dumper.h"
|
||||
|
||||
#include "accesstoken_kit.h"
|
||||
#include "dfx/dms_continue_time_dumper.h"
|
||||
#include "distributed_sched_service.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "ipc_skeleton.h"
|
||||
@ -27,6 +28,7 @@ const std::string TAG = "DistributedSchedDumper";
|
||||
const std::string HIDUMPER_PROCESS_NAME = "hidumper_service";
|
||||
const std::string ARGS_HELP = "-h";
|
||||
const std::string ARGS_CONNECT_REMOTE_ABILITY = "-connect";
|
||||
const std::string ARGS_CONNECT_CONTINUETIME_ABILITY = "-continueTime";
|
||||
constexpr size_t MIN_ARGS_SIZE = 1;
|
||||
}
|
||||
|
||||
@ -51,6 +53,11 @@ bool DistributedSchedDumper::Dump(const std::vector<std::string>& args, std::str
|
||||
ShowConnectRemoteAbility(result);
|
||||
return true;
|
||||
}
|
||||
// -continueTime
|
||||
if (args[0] == ARGS_CONNECT_CONTINUETIME_ABILITY) {
|
||||
ShowDuration(result);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
IllegalInput(result);
|
||||
return false;
|
||||
@ -80,6 +87,11 @@ void DistributedSchedDumper::ShowConnectRemoteAbility(std::string& result)
|
||||
DistributedSchedService::GetInstance().DumpConnectInfo(result);
|
||||
}
|
||||
|
||||
void DistributedSchedDumper::ShowDuration(std::string& result)
|
||||
{
|
||||
DmsContinueTime::GetInstance().ShowInfo(result);
|
||||
}
|
||||
|
||||
void DistributedSchedDumper::ShowHelp(std::string& result)
|
||||
{
|
||||
result.append("DistributedSched Dump options:\n")
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -237,7 +237,8 @@ int32_t DistributedSchedProxy::NotifyDSchedEventResultFromRemote(const std::stri
|
||||
(IDSchedInterfaceCode::NOTIFY_DSCHED_EVENT_RESULT_FROM_REMOTE), data, reply);
|
||||
}
|
||||
|
||||
int32_t DistributedSchedProxy::NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess)
|
||||
int32_t DistributedSchedProxy::NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess,
|
||||
const std::string dstInfo)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
@ -250,6 +251,7 @@ int32_t DistributedSchedProxy::NotifyContinuationResultFromRemote(int32_t sessio
|
||||
}
|
||||
PARCEL_WRITE_HELPER(data, Int32, sessionId);
|
||||
PARCEL_WRITE_HELPER(data, Bool, isSuccess);
|
||||
PARCEL_WRITE_HELPER(data, String, dstInfo);
|
||||
MessageParcel reply;
|
||||
PARCEL_TRANSACT_SYNC_RET_INT(remote, static_cast<uint32_t>
|
||||
(IDSchedInterfaceCode::NOTIFY_CONTINUATION_RESULT_FROM_REMOTE), data, reply);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#endif
|
||||
#include "connect_death_recipient.h"
|
||||
#include "datetime_ex.h"
|
||||
#include "dfx/dms_continue_time_dumper.h"
|
||||
#include "distributed_sched_adapter.h"
|
||||
#include "distributed_sched_dumper.h"
|
||||
#include "distributed_sched_permission.h"
|
||||
@ -94,6 +95,7 @@ const std::string SUPPORT_CONTINUE_PAGE_STACK_KEY = "ohos.extra.param.key.suppor
|
||||
const std::string SUPPORT_CONTINUE_SOURCE_EXIT_KEY = "ohos.extra.param.key.supportContinueSourceExit";
|
||||
const std::string SUPPORT_CONTINUE_MODULE_NAME_UPDATE_KEY = "ohos.extra.param.key.supportContinueModuleNameUpdate";
|
||||
const std::string DSCHED_EVENT_KEY = "IDSchedEventListener";
|
||||
const std::string DMSDURATION_SAVETIME = "ohos.dschedule.SaveDataTime";
|
||||
constexpr int32_t DEFAULT_DMS_MISSION_ID = -1;
|
||||
constexpr int32_t DEFAULT_DMS_CONNECT_TOKEN = -1;
|
||||
constexpr int32_t BIND_CONNECT_RETRY_TIMES = 3;
|
||||
@ -111,6 +113,12 @@ constexpr int64_t CONTINUATION_TIMEOUT = 20000; // 20s
|
||||
constexpr int64_t CHECK_REMOTE_INSTALL_ABILITY = 40000;
|
||||
constexpr int32_t MAX_TOKEN_NUM = 100000000;
|
||||
constexpr uint32_t MAX_MODULENAME_LEN = 2048;
|
||||
constexpr int32_t DMSDURATION_BEGINTIME = 0;
|
||||
constexpr int32_t DMSDURATION_ENDTIME = 1;
|
||||
constexpr int32_t DMSDURATION_TOTALTIME = 2;
|
||||
constexpr int32_t DMSDURATION_DSTTOSRCRPCTIME = 3;
|
||||
constexpr int32_t DMSDURATION_SRCTODSTSAVETIME = 5;
|
||||
constexpr int32_t DMSDURATION_STARTABILITY = 6;
|
||||
}
|
||||
|
||||
IMPLEMENT_SINGLE_INSTANCE(DistributedSchedService);
|
||||
@ -229,6 +237,14 @@ void DistributedSchedService::InitCommonEventListener()
|
||||
#endif
|
||||
}
|
||||
|
||||
void DistributedSchedService::DurationStart(const std::string srcDeviceId, const std::string dstDeviceId)
|
||||
{
|
||||
DmsContinueTime::GetInstance().Init();
|
||||
std::string strBeginTime = DmsContinueTime::GetInstance().GetCurrentTime();
|
||||
DmsContinueTime::GetInstance().SetDurationStrTime(DMSDURATION_BEGINTIME, strBeginTime);
|
||||
DmsContinueTime::GetInstance().SetNetWorkId(srcDeviceId, dstDeviceId);
|
||||
}
|
||||
|
||||
int32_t DistributedSchedService::StartRemoteAbility(const OHOS::AAFwk::Want& want,
|
||||
int32_t callerUid, int32_t requestCode, uint32_t accessToken)
|
||||
{
|
||||
@ -266,7 +282,16 @@ int32_t DistributedSchedService::StartRemoteAbility(const OHOS::AAFwk::Want& wan
|
||||
AAFwk::Want* newWant = const_cast<Want*>(&want);
|
||||
newWant->SetParam(DMS_SRC_NETWORK_ID, localDeviceId);
|
||||
HILOGI("[PerformanceTest] StartRemoteAbility transact begin");
|
||||
if (!DmsContinueTime::GetInstance().GetPull()) {
|
||||
int64_t begin = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetDurationBegin(DMSDURATION_STARTABILITY, begin);
|
||||
}
|
||||
int32_t result = remoteDms->StartAbilityFromRemote(*newWant, abilityInfo, requestCode, callerInfo, accountInfo);
|
||||
if (!DmsContinueTime::GetInstance().GetPull()) {
|
||||
int64_t end = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetDurationBegin(DMSDURATION_SRCTODSTSAVETIME, end);
|
||||
DmsContinueTime::GetInstance().SetDurationEnd(DMSDURATION_STARTABILITY, end);
|
||||
}
|
||||
HILOGI("[PerformanceTest] StartRemoteAbility transact end");
|
||||
return result;
|
||||
}
|
||||
@ -276,12 +301,19 @@ int32_t DistributedSchedService::StartAbilityFromRemote(const OHOS::AAFwk::Want&
|
||||
const CallerInfo& callerInfo, const AccountInfo& accountInfo)
|
||||
{
|
||||
std::string localDeviceId;
|
||||
std::string timeInfo;
|
||||
std::string deviceId = want.GetElement().GetDeviceID();
|
||||
if (!GetLocalDeviceId(localDeviceId) ||
|
||||
!CheckDeviceIdFromRemote(localDeviceId, deviceId, callerInfo.sourceDeviceId)) {
|
||||
HILOGE("check deviceId failed");
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
}
|
||||
if (DmsContinueTime::GetInstance().GetPull()) {
|
||||
timeInfo = want.GetStringParam(DMSDURATION_SAVETIME);
|
||||
DmsContinueTime::GetInstance().ReadDurationInfo(timeInfo.c_str());
|
||||
DmsContinueTime::GetInstance().SetSrcBundleName(want.GetElement().GetBundleName());
|
||||
DmsContinueTime::GetInstance().SetSrcAbilityName(want.GetElement().GetAbilityName());
|
||||
}
|
||||
int32_t result = CheckTargetPermission(want, callerInfo, accountInfo, START_PERMISSION, true);
|
||||
if (result != ERR_OK) {
|
||||
HILOGE("CheckTargetPermission failed!!");
|
||||
@ -439,6 +471,8 @@ int32_t DistributedSchedService::ContinueAbilityWithTimeout(const std::string& d
|
||||
return CONTINUE_ALREADY_IN_PROGRESS;
|
||||
}
|
||||
SetContinuationTimeout(missionId, CONTINUATION_TIMEOUT);
|
||||
int64_t saveDataBegin = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetSaveDataDurationBegin(saveDataBegin);
|
||||
int32_t result = AbilityManagerClient::GetInstance()->ContinueAbility(dstDeviceId, missionId, remoteBundleVersion);
|
||||
HILOGI("result: %{public}d!", result);
|
||||
if (result == ERR_INVALID_VALUE) {
|
||||
@ -466,6 +500,11 @@ int32_t DistributedSchedService::ContinueRemoteMission(const std::string& srcDev
|
||||
HILOGI("%{public}s. srcDeviceId: %{public}s. dstDeviceId: %{public}s. bundleName: %{public}s.", __func__,
|
||||
DnetworkAdapter::AnonymizeNetworkId(srcDeviceId).c_str(),
|
||||
DnetworkAdapter::AnonymizeNetworkId(dstDeviceId).c_str(), bundleName.c_str());
|
||||
if (DmsContinueTime::GetInstance().GetPull()) {
|
||||
int64_t begin = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetDurationBegin(DMSDURATION_DSTTOSRCRPCTIME, begin);
|
||||
DmsContinueTime::GetInstance().SetDurationBegin(DMSDURATION_TOTALTIME, begin);
|
||||
}
|
||||
sptr<IDistributedSched> remoteDms = GetRemoteDms(srcDeviceId);
|
||||
if (remoteDms == nullptr) {
|
||||
HILOGE("get remote dms null!");
|
||||
@ -480,6 +519,10 @@ int32_t DistributedSchedService::ContinueRemoteMission(const std::string& srcDev
|
||||
}
|
||||
int32_t result = remoteDms->ContinueMission(srcDeviceId, dstDeviceId, bundleName, callback, wantParams);
|
||||
HILOGI("ContinueRemoteMission result: %{public}d!", result);
|
||||
if (DmsContinueTime::GetInstance().GetPull()) {
|
||||
int64_t end = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetDurationEnd(DMSDURATION_DSTTOSRCRPCTIME, end);
|
||||
}
|
||||
if (result != ERR_OK) {
|
||||
if (dschedContinuation_ == nullptr) {
|
||||
HILOGE("continuation object null!");
|
||||
@ -503,6 +546,7 @@ int32_t DistributedSchedService::ContinueMission(const std::string& srcDeviceId,
|
||||
HILOGE("get local deviceId failed!");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
DurationStart(srcDeviceId, dstDeviceId);
|
||||
|
||||
if (srcDeviceId == localDevId) {
|
||||
if (DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(dstDeviceId) == nullptr) {
|
||||
@ -510,6 +554,7 @@ int32_t DistributedSchedService::ContinueMission(const std::string& srcDeviceId,
|
||||
}
|
||||
return ContinueLocalMission(dstDeviceId, missionId, callback, wantParams);
|
||||
} else if (dstDeviceId == localDevId) {
|
||||
DmsContinueTime::GetInstance().SetPull(true);
|
||||
if (DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(srcDeviceId) == nullptr) {
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
}
|
||||
@ -520,24 +565,11 @@ int32_t DistributedSchedService::ContinueMission(const std::string& srcDeviceId,
|
||||
}
|
||||
}
|
||||
|
||||
int32_t DistributedSchedService::ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
const std::string& bundleName, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
|
||||
int32_t DistributedSchedService::ProcessContinueLocalMission(const std::string& srcDeviceId,
|
||||
const std::string& dstDeviceId, const std::string& bundleName, const sptr<IRemoteObject>& callback,
|
||||
const OHOS::AAFwk::WantParams& wantParams)
|
||||
{
|
||||
HILOGI("%{public}s. srcDeviceId: %{public}s. dstDeviceId: %{public}s. bundleName: %{public}s.", __func__,
|
||||
DnetworkAdapter::AnonymizeNetworkId(srcDeviceId).c_str(),
|
||||
DnetworkAdapter::AnonymizeNetworkId(dstDeviceId).c_str(), bundleName.c_str());
|
||||
if (srcDeviceId.empty() || dstDeviceId.empty() || callback == nullptr) {
|
||||
HILOGE("srcDeviceId or dstDeviceId or callback is null!");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
std::string localDevId;
|
||||
if (!GetLocalDeviceId(localDevId)) {
|
||||
HILOGE("get local deviceId failed!");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
|
||||
if (srcDeviceId == localDevId) {
|
||||
if (DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(dstDeviceId) == nullptr) {
|
||||
if (DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(dstDeviceId) == nullptr) {
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
}
|
||||
int32_t missionId = 1;
|
||||
@ -556,18 +588,47 @@ int32_t DistributedSchedService::ContinueMission(const std::string& srcDeviceId,
|
||||
dschedContinuation_->continueEvent_.dstNetworkId = dstDeviceId;
|
||||
dschedContinuation_->continueEvent_.bundleName = bundleName;
|
||||
return ContinueLocalMission(dstDeviceId, missionId, callback, wantParams);
|
||||
}
|
||||
|
||||
int32_t DistributedSchedService::ProcessContinueRemoteMission(const std::string& srcDeviceId,
|
||||
const std::string& dstDeviceId, const std::string& bundleName, const sptr<IRemoteObject>& callback,
|
||||
const OHOS::AAFwk::WantParams& wantParams)
|
||||
{
|
||||
if (DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(srcDeviceId) == nullptr) {
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
}
|
||||
if (dschedContinuation_ == nullptr) {
|
||||
HILOGE("continuation object null!");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
dschedContinuation_->continueEvent_.srcNetworkId = dstDeviceId;
|
||||
dschedContinuation_->continueEvent_.dstNetworkId = srcDeviceId;
|
||||
dschedContinuation_->continueEvent_.bundleName = bundleName;
|
||||
return ContinueRemoteMission(srcDeviceId, dstDeviceId, bundleName, callback, wantParams);
|
||||
}
|
||||
|
||||
int32_t DistributedSchedService::ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
const std::string& bundleName, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
|
||||
{
|
||||
HILOGI("%{public}s. srcDeviceId: %{public}s. dstDeviceId: %{public}s. bundleName: %{public}s.", __func__,
|
||||
DnetworkAdapter::AnonymizeNetworkId(srcDeviceId).c_str(),
|
||||
DnetworkAdapter::AnonymizeNetworkId(dstDeviceId).c_str(), bundleName.c_str());
|
||||
if (srcDeviceId.empty() || dstDeviceId.empty() || callback == nullptr) {
|
||||
HILOGE("srcDeviceId or dstDeviceId or callback is null!");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
std::string localDevId;
|
||||
if (!GetLocalDeviceId(localDevId)) {
|
||||
HILOGE("get local deviceId failed!");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
DurationStart(srcDeviceId, dstDeviceId);
|
||||
|
||||
if (srcDeviceId == localDevId) {
|
||||
return ProcessContinueLocalMission(srcDeviceId, dstDeviceId, bundleName, callback, wantParams);
|
||||
} else if (dstDeviceId == localDevId) {
|
||||
if (DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(srcDeviceId) == nullptr) {
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
}
|
||||
if (dschedContinuation_ == nullptr) {
|
||||
HILOGE("continuation object null!");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
dschedContinuation_->continueEvent_.srcNetworkId = dstDeviceId;
|
||||
dschedContinuation_->continueEvent_.dstNetworkId = srcDeviceId;
|
||||
dschedContinuation_->continueEvent_.bundleName = bundleName;
|
||||
return ContinueRemoteMission(srcDeviceId, dstDeviceId, bundleName, callback, wantParams);
|
||||
DmsContinueTime::GetInstance().SetPull(true);
|
||||
return ProcessContinueRemoteMission(srcDeviceId, dstDeviceId, bundleName, callback, wantParams);
|
||||
} else {
|
||||
HILOGE("source or target device must be local!");
|
||||
return OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET;
|
||||
@ -584,6 +645,9 @@ int32_t DistributedSchedService::SetWantForContinuation(AAFwk::Want& newWant, in
|
||||
|
||||
newWant.SetParam("sessionId", missionId);
|
||||
newWant.SetParam("deviceId", devId);
|
||||
std::string strInfo = DmsContinueTime::GetInstance().WriteDurationInfo(
|
||||
DmsContinueTime::GetInstance().GetSaveDataDuration());
|
||||
newWant.SetParam(DMSDURATION_SAVETIME, strInfo);
|
||||
BundleInfo localBundleInfo;
|
||||
if (BundleManagerInternal::GetLocalBundleInfo(newWant.GetBundle(), localBundleInfo) != ERR_OK) {
|
||||
HILOGE("get local bundle info failed");
|
||||
@ -614,6 +678,8 @@ int32_t DistributedSchedService::DealDSchedEventResult(const OHOS::AAFwk::Want&
|
||||
dschedContinuation_->continueEvent_.abilityName = want.GetElement().GetAbilityName();
|
||||
HILOGI("dschedContinuation_->continueEvent_.abilityName %{public}s",
|
||||
dschedContinuation_->continueEvent_.abilityName.c_str());
|
||||
DmsContinueTime::GetInstance().SetSrcBundleName(want.GetElement().GetBundleName());
|
||||
DmsContinueTime::GetInstance().SetSrcAbilityName(dschedContinuation_->continueEvent_.abilityName);
|
||||
if (status != ERR_OK) {
|
||||
HILOGD("want.GetElement().GetDeviceId result:%{public}s", want.GetElement().GetDeviceID().c_str());
|
||||
std::string deviceId = want.GetElement().GetDeviceID();
|
||||
@ -698,17 +764,39 @@ void DistributedSchedService::NotifyCompleteContinuation(const std::u16string& d
|
||||
HILOGE("continuation object null!");
|
||||
return;
|
||||
}
|
||||
std::string dstInfo("");
|
||||
if (DmsContinueTime::GetInstance().GetPull()) {
|
||||
int64_t end = GetTickCount();
|
||||
std::string strEndTime = DmsContinueTime::GetInstance().GetCurrentTime();
|
||||
DmsContinueTime::GetInstance().SetDurationEnd(DMSDURATION_SRCTODSTSAVETIME, end);
|
||||
DmsContinueTime::GetInstance().SetDurationEnd(DMSDURATION_TOTALTIME, end);
|
||||
DmsContinueTime::GetInstance().SetDurationStrTime(DMSDURATION_ENDTIME, strEndTime);
|
||||
DmsContinueTime::GetInstance().AppendInfo();
|
||||
DmsContinueTime::GetInstance().SetPull(false);
|
||||
} else {
|
||||
dstInfo = DmsContinueTime::GetInstance().WriteDstInfo(DmsContinueTime::GetInstance().GetDstInfo().bundleName,
|
||||
DmsContinueTime::GetInstance().GetDstInfo().abilityName);
|
||||
}
|
||||
int dSchedEventresult = dschedContinuation_->NotifyDSchedEventResult(DSCHED_EVENT_KEY, ERR_OK);
|
||||
HILOGD("NotifyDSchedEventResult result:%{public}d", dSchedEventresult);
|
||||
remoteDms->NotifyContinuationResultFromRemote(sessionId, isSuccess);
|
||||
remoteDms->NotifyContinuationResultFromRemote(sessionId, isSuccess, dstInfo);
|
||||
}
|
||||
|
||||
int32_t DistributedSchedService::NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess)
|
||||
int32_t DistributedSchedService::NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess,
|
||||
const std::string dstInfo)
|
||||
{
|
||||
if (sessionId <= 0) {
|
||||
HILOGE("NotifyContinuationResultFromRemote sessionId:%{public}d invalid!", sessionId);
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
}
|
||||
if (dstInfo.length() != 0) {
|
||||
int64_t end = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetDurationEnd(DMSDURATION_SRCTODSTSAVETIME, end);
|
||||
std::string strEndTime = DmsContinueTime::GetInstance().GetCurrentTime();
|
||||
DmsContinueTime::GetInstance().SetDurationStrTime(DMSDURATION_ENDTIME, strEndTime);
|
||||
DmsContinueTime::GetInstance().ReadDstInfo(dstInfo.c_str());
|
||||
DmsContinueTime::GetInstance().AppendInfo();
|
||||
}
|
||||
|
||||
int32_t missionId = sessionId;
|
||||
NotifyContinuationCallbackResult(missionId, isSuccess ? 0 : NOTIFYCOMPLETECONTINUATION_FAILED);
|
||||
@ -2328,6 +2416,12 @@ int32_t DistributedSchedService::StartAbility(const OHOS::AAFwk::Want& want, int
|
||||
activeAccountId);
|
||||
} else {
|
||||
HILOGI("StartAbility start");
|
||||
if (DmsContinueTime::GetInstance().GetPull()) {
|
||||
int64_t begin = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetDurationBegin(DMSDURATION_SRCTODSTSAVETIME, begin);
|
||||
}
|
||||
DmsContinueTime::GetInstance().SetDstAbilityName(want.GetElement().GetAbilityName());
|
||||
DmsContinueTime::GetInstance().SetDstBundleName(want.GetElement().GetBundleName());
|
||||
err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, requestCode, activeAccountId);
|
||||
}
|
||||
if (err != ERR_OK) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "bundle/bundle_manager_internal.h"
|
||||
#include "caller_info.h"
|
||||
#include "datetime_ex.h"
|
||||
#include "dfx/dms_continue_time_dumper.h"
|
||||
#include "dfx/dms_hisysevent_report.h"
|
||||
#include "dfx/dms_hitrace_chain.h"
|
||||
#include "dfx/dms_hitrace_constants.h"
|
||||
@ -445,6 +446,9 @@ int32_t DistributedSchedStub::ContinueMissionOfBundleNameInner(MessageParcel& da
|
||||
|
||||
int32_t DistributedSchedStub::StartContinuationInner(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
int64_t saveDataEnd = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetSaveDataDurationEnd(saveDataEnd);
|
||||
|
||||
if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
|
||||
return DMS_PERMISSION_DENIED;
|
||||
}
|
||||
@ -516,7 +520,9 @@ int32_t DistributedSchedStub::NotifyContinuationResultFromRemoteInner(MessagePar
|
||||
PARCEL_READ_HELPER(data, Int32, sessionId);
|
||||
bool continuationResult = false;
|
||||
PARCEL_READ_HELPER(data, Bool, continuationResult);
|
||||
return NotifyContinuationResultFromRemote(sessionId, continuationResult);
|
||||
std::string dstInfo;
|
||||
PARCEL_READ_HELPER_NORET(data, String, dstInfo);
|
||||
return NotifyContinuationResultFromRemote(sessionId, continuationResult, dstInfo);
|
||||
}
|
||||
|
||||
int32_t DistributedSchedStub::ConnectRemoteAbilityInner(MessageParcel& data, MessageParcel& reply)
|
||||
|
@ -361,5 +361,16 @@ void DnetServiceDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
|
||||
HILOGI("OnRemoteDied dnetwork service died");
|
||||
DtbschedmgrDeviceInfoStorage::GetInstance().Init();
|
||||
}
|
||||
|
||||
std::string DtbschedmgrDeviceInfoStorage::GetDeviceName(std::string netWorkId)
|
||||
{
|
||||
for (auto device = remoteDevices_.begin(); device != remoteDevices_.end(); ++device) {
|
||||
if (device->second->GetNetworkId() == netWorkId) {
|
||||
HILOGI("deviceName = %{public}s", device->second->GetDeviceName().c_str());
|
||||
return device->second->GetDeviceName();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,6 +111,7 @@ dtbschedmgr_sources = [
|
||||
"${distributed_service}/dtbschedmgr/src/bundle/bundle_manager_internal.cpp",
|
||||
"${distributed_service}/dtbschedmgr/src/connect_death_recipient.cpp",
|
||||
"${distributed_service}/dtbschedmgr/src/deviceManager/dms_device_info.cpp",
|
||||
"${distributed_service}/dtbschedmgr/src/dfx/dms_continue_time_dumper.cpp",
|
||||
"${distributed_service}/dtbschedmgr/src/dfx/dms_hisysevent_report.cpp",
|
||||
"${distributed_service}/dtbschedmgr/src/dfx/dms_hitrace_chain.cpp",
|
||||
"${distributed_service}/dtbschedmgr/src/distributedWant/distributed_operation.cpp",
|
||||
@ -537,6 +538,7 @@ ohos_unittest("dmsbasetest") {
|
||||
module_out_path = module_output_path
|
||||
sources = [
|
||||
"unittest/deviceManager/dms_device_info_test.cpp",
|
||||
"unittest/dfx/dms_continue_time_dumper_test.cpp",
|
||||
"unittest/dfx/dms_hisysevent_report_test.cpp",
|
||||
"unittest/dms_network_adapter_test.cpp",
|
||||
"unittest/dtbschedmgr_device_info_storage_test.cpp",
|
||||
|
@ -0,0 +1,393 @@
|
||||
/*
|
||||
* 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 "dms_continue_time_dumper_test.h"
|
||||
|
||||
#include "datetime_ex.h"
|
||||
#include "test_log.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
|
||||
namespace {
|
||||
const std::string BUNDLE_NAME = "com.ohos.permissionmanager";
|
||||
const std::string ABILITY_NAME = "com.ohos.permissionmanager.MainAbility";
|
||||
const std::string NETWORK_ID = "NetworkId";
|
||||
constexpr int32_t DMSDURATION_TOTALTIME = 2;
|
||||
}
|
||||
|
||||
void DmsDurationTest::SetUpTestCase()
|
||||
{
|
||||
DTEST_LOG << "DmsDurationTest::SetUpTestCase" << std::endl;
|
||||
}
|
||||
|
||||
void DmsDurationTest::TearDownTestCase()
|
||||
{
|
||||
DTEST_LOG << "DmsDurationTest::TearDownTestCase" << std::endl;
|
||||
}
|
||||
|
||||
void DmsDurationTest::TearDown()
|
||||
{
|
||||
DTEST_LOG << "DmsDurationTest::TearDown" << std::endl;
|
||||
}
|
||||
|
||||
void DmsDurationTest::SetUp()
|
||||
{
|
||||
DTEST_LOG << "DmsDurationTest::SetUp" << std::endl;
|
||||
}
|
||||
|
||||
void DmsContinueTimeTest::SetUpTestCase()
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest::SetUpTestCase" << std::endl;
|
||||
}
|
||||
|
||||
void DmsContinueTimeTest::TearDownTestCase()
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest::TearDownTestCase" << std::endl;
|
||||
}
|
||||
|
||||
void DmsContinueTimeTest::TearDown()
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest::TearDown" << std::endl;
|
||||
}
|
||||
|
||||
void DmsContinueTimeTest::SetUp()
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest::SetUp" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetBeginTime_001
|
||||
* @tc.desc: test SetBeginTime func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsDurationTest, SetBeginTime_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsDurationTest SetBeginTime_001 begin" << std::endl;
|
||||
int64_t time = GetTickCount();
|
||||
dmsDuration.SetBeginTime(time);
|
||||
int64_t ret = dmsDuration.GetBeginTime();
|
||||
EXPECT_EQ(ret, time);
|
||||
DTEST_LOG << "DmsDurationTest SetBeginTime_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetEndTime_001
|
||||
* @tc.desc: test SetEndTime func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsDurationTest, SetEndTime_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsDurationTest SetEndTime_001 begin" << std::endl;
|
||||
int64_t time = GetTickCount();
|
||||
dmsDuration.SetEndTime(time);
|
||||
int64_t ret = dmsDuration.GetEndTime();
|
||||
EXPECT_EQ(ret, time);
|
||||
DTEST_LOG << "DmsDurationTest SetEndTime_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetDurationTime_001
|
||||
* @tc.desc: test SetDurationTime func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsDurationTest, SetDurationTime_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsDurationTest SetDurationTime_001 begin" << std::endl;
|
||||
int64_t time = GetTickCount();
|
||||
dmsDuration.SetDurationTime(time);
|
||||
int64_t ret = dmsDuration.GetDurationTime();
|
||||
EXPECT_EQ(ret, time);
|
||||
DTEST_LOG << "DmsDurationTest SetDurationTime_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetStrTime_001
|
||||
* @tc.desc: test SetStrTime func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsDurationTest, SetStrTime_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsDurationTest SetStrTime_001 begin" << std::endl;
|
||||
dmsDuration.SetStrTime(BUNDLE_NAME);
|
||||
std::string info = dmsDuration.GetStrTime();
|
||||
EXPECT_EQ(info.empty(), false);
|
||||
DTEST_LOG << "DmsDurationTest SetStrTime_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetDurationName_001
|
||||
* @tc.desc: test SetDurationName func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsDurationTest, SetDurationName_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsDurationTest SetDurationName_001 begin" << std::endl;
|
||||
dmsDuration.SetDurationName(BUNDLE_NAME);
|
||||
std::string info = dmsDuration.GetDurationName();
|
||||
EXPECT_EQ(info.empty(), false);
|
||||
DTEST_LOG << "DmsDurationTest SetDurationName_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Init_001
|
||||
* @tc.desc: test Init func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, Init_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest Init_001 begin" << std::endl;
|
||||
DmsContinueTime::GetInstance().Init();
|
||||
bool ret = DmsContinueTime::GetInstance().GetDstInfo().bundleName.empty();
|
||||
EXPECT_EQ(ret, true);
|
||||
DTEST_LOG << "DmsContinueTimeTest Init_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetPull_001
|
||||
* @tc.desc: test SetPull func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, SetPull_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest SetPull_001 begin" << std::endl;
|
||||
DmsContinueTime::GetInstance().SetPull(false);
|
||||
bool ret = DmsContinueTime::GetInstance().GetPull();
|
||||
EXPECT_EQ(ret, false);
|
||||
DTEST_LOG << "DmsContinueTimeTest SetPull_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetSrcBundleName_001
|
||||
* @tc.desc: test SetSrcBundleName func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, SetSrcBundleName_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest SetSrcBundleName_001 begin" << std::endl;
|
||||
DmsContinueTime::GetInstance().SetSrcBundleName(BUNDLE_NAME);
|
||||
DmsContinueTime::GetInstance().SetSrcAbilityName(ABILITY_NAME);
|
||||
DmsContinueTime::GetInstance().SetDstBundleName(BUNDLE_NAME);
|
||||
DmsContinueTime::GetInstance().SetDstAbilityName(ABILITY_NAME);
|
||||
DmsContinueTime::GetInstance().SetNetWorkId(NETWORK_ID, NETWORK_ID);
|
||||
bool ret = DmsContinueTime::GetInstance().GetDstInfo().bundleName.empty();
|
||||
EXPECT_EQ(ret, false);
|
||||
DTEST_LOG << "DmsContinueTimeTest SetSrcBundleName_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetSaveDataDurationBegin_001
|
||||
* @tc.desc: test SetSaveDataDurationBegin func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, SetSaveDataDurationBegin_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest SetSaveDataDurationBegin_001 begin" << std::endl;
|
||||
DmsContinueTime::GetInstance().SetDeviceNamePush();
|
||||
DmsContinueTime::GetInstance().SetDeviceNamePull();
|
||||
|
||||
int64_t begin = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetDurationBegin(DMSDURATION_TOTALTIME, begin);
|
||||
DmsContinueTime::GetInstance().SetDurationEnd(DMSDURATION_TOTALTIME, begin);
|
||||
DmsContinueTime::GetInstance().SetDurationStrTime(DMSDURATION_TOTALTIME, BUNDLE_NAME);
|
||||
DmsContinueTime::GetInstance().SetSaveDataDurationBegin(begin);
|
||||
int64_t ret = DmsContinueTime::GetInstance().GetSaveDataDuration().GetBeginTime();
|
||||
EXPECT_NE(ret, 0);
|
||||
DTEST_LOG << "DmsContinueTimeTest SetSaveDataDurationBegin_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetSaveDataDurationEnd_001
|
||||
* @tc.desc: test SetSaveDataDurationEnd func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, SetSaveDataDurationEnd_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest SetSaveDataDurationEnd_001 begin" << std::endl;
|
||||
int64_t end = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetSaveDataDurationEnd(end);
|
||||
int64_t ret = DmsContinueTime::GetInstance().GetSaveDataDuration().GetEndTime();
|
||||
EXPECT_NE(ret, 0);
|
||||
DTEST_LOG << "DmsContinueTimeTest SetSaveDataDurationEnd_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WriteDurationInfo_001
|
||||
* @tc.desc: test WriteDurationInfo func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, WriteDurationInfo_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest WriteDurationInfo_001 begin" << std::endl;
|
||||
int64_t begin = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetSaveDataDurationBegin(begin);
|
||||
int64_t end = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetSaveDataDurationEnd(end);
|
||||
std::string info = DmsContinueTime::GetInstance().WriteDurationInfo(
|
||||
DmsContinueTime::GetInstance().GetSaveDataDuration());
|
||||
EXPECT_EQ(info.empty(), false);
|
||||
DTEST_LOG << "DmsContinueTimeTest WriteDurationInfo_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReadDurationInfo_001
|
||||
* @tc.desc: test ReadDurationInfo func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, ReadDurationInfo_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest ReadDurationInfo_001 begin" << std::endl;
|
||||
int64_t begin = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetSaveDataDurationBegin(begin);
|
||||
int64_t end = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetSaveDataDurationEnd(end);
|
||||
std::string info = DmsContinueTime::GetInstance().WriteDurationInfo(
|
||||
DmsContinueTime::GetInstance().GetSaveDataDuration());
|
||||
DmsContinueTime::GetInstance().ReadDurationInfo(info.c_str());
|
||||
int64_t ret = DmsContinueTime::GetInstance().GetSaveDataDuration().GetBeginTime();
|
||||
EXPECT_NE(ret, 0);
|
||||
DTEST_LOG << "DmsContinueTimeTest ReadDurationInfo_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WriteDstInfo_001
|
||||
* @tc.desc: test WriteDstInfo func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, WriteDstInfo_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest WriteDstInfo_001 begin" << std::endl;
|
||||
std::string info = DmsContinueTime::GetInstance().WriteDstInfo(BUNDLE_NAME, ABILITY_NAME);
|
||||
EXPECT_EQ(info.empty(), false);
|
||||
DTEST_LOG << "DmsContinueTimeTest WriteDstInfo_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReadDstInfo_001
|
||||
* @tc.desc: test ReadDstInfo func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, ReadDstInfo_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest ReadDstInfo_001 begin" << std::endl;
|
||||
std::string info = DmsContinueTime::GetInstance().WriteDstInfo(BUNDLE_NAME, ABILITY_NAME);
|
||||
DmsContinueTime::GetInstance().ReadDstInfo(info.c_str());
|
||||
bool ret = DmsContinueTime::GetInstance().GetDstInfo().bundleName.empty();
|
||||
EXPECT_EQ(ret, false);
|
||||
DTEST_LOG << "DmsContinueTimeTest ReadDstInfo_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetCurrentTime_001
|
||||
* @tc.desc: test GetCurrentTime func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, GetCurrentTime_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest GetCurrentTime_001 begin" << std::endl;
|
||||
std::string strTime = DmsContinueTime::GetInstance().GetCurrentTime();
|
||||
EXPECT_EQ(strTime.empty(), false);
|
||||
DTEST_LOG << "DmsContinueTimeTest GetCurrentTime_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DealDurationPull_001
|
||||
* @tc.desc: test DealDurationPull func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, DealDurationPull_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest DealDurationPull_001 begin" << std::endl;
|
||||
int64_t begin = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetSaveDataDurationBegin(begin);
|
||||
int64_t end = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetSaveDataDurationEnd(end);
|
||||
DmsContinueTime::GetInstance().DealDurationPull();
|
||||
int64_t ret = DmsContinueTime::GetInstance().GetSaveDataDuration().GetBeginTime();
|
||||
EXPECT_NE(ret, 0);
|
||||
DTEST_LOG << "DmsContinueTimeTest DealDurationPull_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DealDurationPush_001
|
||||
* @tc.desc: test DealDurationPush func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, DealDurationPush_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest DealDurationPush_001 begin" << std::endl;
|
||||
int64_t begin = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetSaveDataDurationBegin(begin);
|
||||
int64_t end = GetTickCount();
|
||||
DmsContinueTime::GetInstance().SetSaveDataDurationEnd(end);
|
||||
DmsContinueTime::GetInstance().DealDurationPush();
|
||||
int64_t ret = DmsContinueTime::GetInstance().GetSaveDataDuration().GetBeginTime();
|
||||
EXPECT_NE(ret, 0);
|
||||
DTEST_LOG << "DmsContinueTimeTest DealDurationPush_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppendInfo_001
|
||||
* @tc.desc: test AppendInfo func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, AppendInfo_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest AppendInfo_001 begin" << std::endl;
|
||||
std::string result;
|
||||
DmsContinueTime::GetInstance().SetSrcBundleName(BUNDLE_NAME);
|
||||
DmsContinueTime::GetInstance().SetDstBundleName(BUNDLE_NAME);
|
||||
DmsContinueTime::GetInstance().SetPull(true);
|
||||
DmsContinueTime::GetInstance().AppendInfo();
|
||||
DmsContinueTime::GetInstance().ShowInfo(result);
|
||||
EXPECT_EQ(result.empty(), false);
|
||||
DTEST_LOG << "DmsContinueTimeTest AppendInfo_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppendInfo_002
|
||||
* @tc.desc: test AppendInfo func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, AppendInfo_002, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest AppendInfo_002 begin" << std::endl;
|
||||
std::string result;
|
||||
DmsContinueTime::GetInstance().SetSrcBundleName(BUNDLE_NAME);
|
||||
DmsContinueTime::GetInstance().SetDstBundleName(BUNDLE_NAME);
|
||||
DmsContinueTime::GetInstance().AppendInfo();
|
||||
DmsContinueTime::GetInstance().ShowInfo(result);
|
||||
EXPECT_EQ(result.empty(), false);
|
||||
DTEST_LOG << "DmsContinueTimeTest AppendInfo_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ShowInfo_001
|
||||
* @tc.desc: test ShowInfo func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DmsContinueTimeTest, ShowInfo_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DmsContinueTimeTest ShowInfo_001 begin" << std::endl;
|
||||
std::string result;
|
||||
DmsContinueTime::GetInstance().ShowInfo(result);
|
||||
EXPECT_EQ(result.empty(), false);
|
||||
DTEST_LOG << "DmsContinueTimeTest ShowInfo_001 end" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef DMS_CONTINUE_TIME_TEST_H
|
||||
#define DMS_CONTINUE_TIME_TEST_H
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define private public
|
||||
#include "dfx/dms_continue_time_dumper.h"
|
||||
#undef private
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
|
||||
class DmsDurationTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
DmsDuration dmsDuration;
|
||||
};
|
||||
|
||||
class DmsContinueTimeTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
#endif // DMS_CONTINUE_TIME_TEST_H
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -14,6 +14,7 @@
|
||||
*/
|
||||
#include <thread>
|
||||
|
||||
#include "dfx/dms_continue_time_dumper.h"
|
||||
#include "distributed_sched_continuation_test.h"
|
||||
#include "distributed_sched_util.h"
|
||||
#include "dtbschedmgr_device_info_storage.h"
|
||||
@ -301,7 +302,9 @@ HWTEST_F(DSchedContinuationTest, NotifyContinuationResultFromRemote_001, TestSiz
|
||||
* @tc.steps: step1. input invalid session.
|
||||
* @tc.expected: step1. return false.
|
||||
*/
|
||||
DistributedSchedService::GetInstance().NotifyContinuationResultFromRemote(-1, true);
|
||||
std::string info;
|
||||
DmsContinueTime::GetInstance().Init();
|
||||
DistributedSchedService::GetInstance().NotifyContinuationResultFromRemote(-1, true, info);
|
||||
EXPECT_TRUE(!timeoutFlag_);
|
||||
DTEST_LOG << "DSchedContinuationTest NotifyContinuationResultFromRemote_001 end" << std::endl;
|
||||
}
|
||||
@ -318,7 +321,9 @@ HWTEST_F(DSchedContinuationTest, NotifyContinuationResultFromRemote_002, TestSiz
|
||||
* @tc.steps: step1. get remote dms failed.
|
||||
* @tc.expected: step1. return false.
|
||||
*/
|
||||
DistributedSchedService::GetInstance().NotifyContinuationResultFromRemote(MOCK_SESSION_ID, true);
|
||||
std::string info;
|
||||
DmsContinueTime::GetInstance().Init();
|
||||
DistributedSchedService::GetInstance().NotifyContinuationResultFromRemote(MOCK_SESSION_ID, true, info);
|
||||
EXPECT_TRUE(!timeoutFlag_);
|
||||
DTEST_LOG << "DSchedContinuationTest NotifyContinuationResultFromRemote_002 end" << std::endl;
|
||||
}
|
||||
@ -1465,9 +1470,10 @@ HWTEST_F(DSchedContinuationTest, ProxyCallNotifyContinuationResultFromRemote001,
|
||||
sptr<IDistributedSched> proxy = GetDms();
|
||||
EXPECT_NE(proxy, nullptr);
|
||||
std::string srcDeviceId;
|
||||
std::string info;
|
||||
DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId);
|
||||
proxy->NotifyCompleteContinuation(Str8ToStr16(srcDeviceId), 0, true);
|
||||
int32_t ret = proxy->NotifyContinuationResultFromRemote(0, true);
|
||||
int32_t ret = proxy->NotifyContinuationResultFromRemote(0, true, info);
|
||||
EXPECT_EQ(ret, REQUEST_CODE_ERR);
|
||||
DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyContinuationResultFromRemote001 end" << std::endl;
|
||||
}
|
||||
|
@ -729,6 +729,8 @@ HWTEST_F(DistributedSchedStubTest, NotifyContinuationResultFromRemoteInner_001,
|
||||
data.WriteInt32(sessionId);
|
||||
bool continuationResult = false;
|
||||
data.WriteBool(continuationResult);
|
||||
std::string info(DMS_VERSION_ID);
|
||||
data.WriteString(info.c_str());
|
||||
int32_t result = distributedSchedStub_->NotifyContinuationResultFromRemoteInner(data, reply);
|
||||
EXPECT_EQ(result, INVALID_REMOTE_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DistributedSchedStubTest NotifyContinuationResultFromRemoteInner_001 end" << std::endl;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -59,7 +59,8 @@ void MockDistributedSched::NotifyCompleteContinuation(const std::u16string& devI
|
||||
(void)isSuccess;
|
||||
}
|
||||
|
||||
int32_t MockDistributedSched::NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess)
|
||||
int32_t MockDistributedSched::NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess,
|
||||
const std::string dstInfo)
|
||||
{
|
||||
(void)isSuccess;
|
||||
return 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -40,7 +40,7 @@ public:
|
||||
int32_t StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid,
|
||||
int32_t status, uint32_t accessToken) override;
|
||||
void NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess) override;
|
||||
int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess) override;
|
||||
int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess, const std::string dstInfo) override;
|
||||
int32_t ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
|
||||
int32_t callerUid, int32_t callerPid, uint32_t accessToken) override;
|
||||
int32_t DisconnectRemoteAbility(const sptr<IRemoteObject>& connect, int32_t callerUid,
|
||||
|
Loading…
Reference in New Issue
Block a user