!1082 应用协同跨设备适配模块修改回退

Merge pull request !1082 from liuhongjie/release_0913
This commit is contained in:
openharmony_ci 2024-09-20 02:25:38 +00:00 committed by Gitee
commit 1e37ff8f15
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
28 changed files with 84 additions and 1510 deletions

View File

@ -24,7 +24,6 @@ ohos_shared_library("distributed_sched_utils") {
include_dirs = [
"${dms_path}/common/include",
"${dms_path}/interfaces/innerkits/common/include",
"${dms_path}/services/dtbschedmgr/include",
]

View File

@ -17,7 +17,6 @@
#define OHOS_DISTRIBUTED_SCHED_UTILS_H
#include "cJSON.h"
#include <initializer_list>
#include <string>
#include "parcel.h"
@ -39,10 +38,6 @@ std::string Base64Decode(const std::string& basicString);
bool IsBase64(unsigned char c);
std::string GetAnonymStr(const std::string &value);
std::string GetAnonymInt32(const int32_t value);
bool IsInt32(const cJSON *paramValue);
bool IsString(const cJSON *paramValue);
bool CJsonParamCheck(const cJSON *jsonObj, const std::initializer_list<std::string> &keys);
bool GetOsInfoFromDM(const std::string &dmInfoEx, int32_t &osType, std::string &osVersion);
} // namespace DistributedSchedule
} // namespace OHOS
#endif // OHOS_DISTRIBUTED_SCHED_UTILS_H

View File

@ -26,13 +26,10 @@
#include "config_policy_utils.h"
#include "securec.h"
#include "dms_constant.h"
#include "dtbschedmgr_log.h"
namespace OHOS {
namespace DistributedSchedule {
using namespace OHOS::DistributedSchedule::Constants;
const std::string TAG = "DistributedSchedUtils";
const std::string CONTINUE_CONFIG_RELATIVE_PATH = "etc/distributedhardware/dms/continue_config.json";
const std::string ALLOW_APP_LIST_KEY = "allow_applist";
@ -60,12 +57,6 @@ static std::string g_continueCfgFullPath = "";
static std::vector<std::string> g_allowAppList;
std::mutex g_allowAppListMtx;
using JsonTypeCheckFunc = bool (*)(const cJSON *paramValue);
std::map<std::string, JsonTypeCheckFunc> jsonTypeCheckMap = {
std::map<std::string, JsonTypeCheckFunc>::value_type(PARAM_KEY_OS_TYPE, &DistributedSchedule::IsInt32),
std::map<std::string, JsonTypeCheckFunc>::value_type(PARAM_KEY_OS_VERSION, &DistributedSchedule::IsString),
};
bool IsValidPath(const std::string &inFilePath, std::string &realFilePath)
{
char path[PATH_MAX + 1] = { 0 };
@ -230,10 +221,12 @@ int32_t Base64StrToParcel(const std::string& rawStr, Parcel& parcel)
std::string str = Base64Decode(rawStr);
auto parcelSize = str.size();
if (!parcel.SetDataCapacity(parcelSize)) {
HILOGE("Base64 string parcel set data capacity %{public}zu fail.", parcelSize);
return INVALID_PARAMETERS_ERR;
}
auto ret = memcpy_s((void *)parcel.GetData(), parcel.GetMaxCapacity(), &str[0], parcelSize);
if (ret != ERR_OK || !parcel.SetDataSize(parcelSize)) {
HILOGE("Base64 string parcel memcpy raw string data fail.");
return INVALID_PARAMETERS_ERR;
}
return ERR_OK;
@ -373,98 +366,5 @@ std::string GetAnonymInt32(const int32_t value)
return GetAnonymStr(tmpStr);
}
bool IsInt32(const cJSON *paramValue)
{
if (paramValue == nullptr) {
HILOGE("JSON parameter is invalid.");
return false;
}
if (!cJSON_IsNumber(paramValue)) {
HILOGE("JSON parameter is not number.");
return false;
}
int32_t value = paramValue->valueint;
if (!(INT32_MIN <= value && value <= INT32_MAX)) {
HILOGE("JSON parameter number is outside the int32_t range.");
return false;
}
return true;
}
bool IsString(const cJSON *paramValue)
{
if (paramValue == nullptr) {
HILOGE("JSON parameter is invalid.");
return false;
}
if (!cJSON_IsString(paramValue)) {
HILOGE("JSON parameter is not string.");
return false;
}
return true;
}
bool CJsonParamCheck(const cJSON *jsonObj, const std::initializer_list<std::string> &keys)
{
if (jsonObj == nullptr || !cJSON_IsObject(jsonObj)) {
HILOGE("JSON parameter is invalid.");
return false;
}
for (auto it = keys.begin(); it != keys.end(); it++) {
cJSON *paramValue = cJSON_GetObjectItemCaseSensitive(jsonObj, (*it).c_str());
if (paramValue == nullptr) {
HILOGE("JSON parameter does not contain key: %{public}s", (*it).c_str());
return false;
}
auto iter = jsonTypeCheckMap.find(*it);
if (iter == jsonTypeCheckMap.end()) {
HILOGE("Check is not supported yet, key %{public}s.", (*it).c_str());
return false;
}
if (iter->second == nullptr) {
HILOGE("JsonTypeCheckFunc for key %{public}s is nullptr.", (*it).c_str());
return false;
}
JsonTypeCheckFunc &func = iter->second;
bool res = (*func)(paramValue);
if (!res) {
HILOGE("The key %{public}s value format in JSON is illegal.", (*it).c_str());
return false;
}
}
return true;
}
bool GetOsInfoFromDM(const std::string &dmInfoEx, int32_t &osType, std::string &osVersion)
{
cJSON *dataJson = nullptr;
bool isSuccess = false;
do {
dataJson = cJSON_Parse(dmInfoEx.c_str());
if (dataJson == nullptr) {
HILOGE("Parse device info extra data to json fail.");
break;
}
if (!CJsonParamCheck(dataJson, {PARAM_KEY_OS_TYPE, PARAM_KEY_OS_VERSION})) {
HILOGE("Check OS type and version from device extra data json fail.");
break;
}
osType = cJSON_GetObjectItemCaseSensitive(dataJson, PARAM_KEY_OS_TYPE)->valueint;
osVersion = std::string(cJSON_GetObjectItemCaseSensitive(dataJson, PARAM_KEY_OS_VERSION)->valuestring);
isSuccess = true;
} while (false);
if (dataJson != nullptr) {
cJSON_Delete(dataJson);
dataJson = nullptr;
}
return isSuccess;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -28,8 +28,6 @@ using namespace testing::ext;
namespace OHOS {
namespace DistributedSchedule {
const std::string TAG = "DistributedSchedUtilsTest";
constexpr const char* PARAM_KEY_OS_TYPE = "OS_TYPE";
constexpr const char* PARAM_KEY_OS_VERSION = "OS_VERSION";
constexpr int32_t MAX_TEST_PATH_LEN = 1024;
const std::string TEST_CONFIG_RELATIVE_PATH = "etc/distributedhardware/distributed_hardware_components_cfg.json";
@ -175,157 +173,5 @@ HWTEST_F(DistributedSchedUtilsTest, CheckBundleContinueConfig_002, TestSize.Leve
std::string bundleName = "test_bundle_1";
EXPECT_TRUE(CheckBundleContinueConfig(bundleName));
}
/**
* @tc.name: ParcelToBase64Str_001
* @tc.desc: ParcelToBase64Str
* @tc.type: FUNC
* @tc.require: I5WKCK
*/
HWTEST_F(DistributedSchedUtilsTest, ParcelToBase64Str_001, TestSize.Level1)
{
EXPECT_EQ(INVALID_MISSION_ID, GetCurrentMissionId());
Parcel parcel;
std::string rawStr;
EXPECT_EQ("", ParcelToBase64Str(parcel));
EXPECT_EQ(INVALID_PARAMETERS_ERR, Base64StrToParcel(rawStr, parcel));
unsigned char *toEncode = nullptr;
unsigned int len = 0;
EXPECT_EQ("", Base64Encode(toEncode, len));
len = 1;
EXPECT_EQ("", Base64Encode(toEncode, len));
std::string basicString;
EXPECT_EQ("", Base64Decode(basicString));
EXPECT_EQ(true, IsBase64('+'));
EXPECT_EQ(true, IsBase64('/'));
EXPECT_EQ(true, IsBase64('3'));
}
/**
* @tc.name: Base64Encode_001
* @tc.desc: Base64Encode
* @tc.type: FUNC
* @tc.require: I5WKCK
*/
HWTEST_F(DistributedSchedUtilsTest, Base64Encode_001, TestSize.Level1)
{
unsigned char *toEncode = nullptr;
unsigned int len = 0;
std::string basicString;
EXPECT_EQ(Base64Encode(toEncode, len), "");
len = 1;
EXPECT_EQ(Base64Encode(toEncode, len), "");
EXPECT_EQ(Base64Decode(basicString), "");
}
/**
* @tc.name: IsInt32_001
* @tc.desc: IsInt32
* @tc.type: FUNC
* @tc.require: I5WKCK
*/
HWTEST_F(DistributedSchedUtilsTest, IsInt32_001, TestSize.Level1)
{
bool ret = IsInt32(nullptr);
EXPECT_FALSE(ret);
cJSON *paramValue = cJSON_CreateObject();
if (paramValue == nullptr) {
return;
}
int32_t data = MAX_TEST_PATH_LEN;
cJSON_AddNumberToObject(paramValue, "data", data);
ret = IsInt32(paramValue);
EXPECT_FALSE(ret);
cJSON *dataValue = cJSON_GetObjectItem(paramValue, "data");
ret = IsInt32(dataValue);
EXPECT_TRUE(ret);
if (paramValue != nullptr) {
cJSON_Delete(paramValue);
paramValue = nullptr;
}
}
/**
* @tc.name: IsString_001
* @tc.desc: IsString
* @tc.type: FUNC
* @tc.require: I5WKCK
*/
HWTEST_F(DistributedSchedUtilsTest, IsString_001, TestSize.Level1)
{
bool ret = IsString(nullptr);
EXPECT_FALSE(ret);
cJSON *paramValue = nullptr;
std::string str("string");
paramValue = cJSON_Parse(str.c_str());
if (paramValue == nullptr) {
return;
}
ret = IsString(paramValue);
EXPECT_TRUE(ret);
if (paramValue != nullptr) {
cJSON_Delete(paramValue);
paramValue = nullptr;
}
}
/**
* @tc.name: IsString_002
* @tc.desc: IsString
* @tc.type: FUNC
* @tc.require: I5WKCK
*/
HWTEST_F(DistributedSchedUtilsTest, IsString_002, TestSize.Level1)
{
cJSON *paramValue = cJSON_CreateObject();
if (paramValue == nullptr) {
return;
}
int32_t data = MAX_TEST_PATH_LEN;
cJSON_AddNumberToObject(paramValue, "data", data);
bool ret = IsString(paramValue);
EXPECT_FALSE(ret);
if (paramValue != nullptr) {
cJSON_Delete(paramValue);
paramValue = nullptr;
}
}
/**
* @tc.name: CJsonParamCheck_001
* @tc.desc: CJsonParamCheck
* @tc.type: FUNC
* @tc.require: I5WKCK
*/
HWTEST_F(DistributedSchedUtilsTest, CJsonParamCheck_001, TestSize.Level1)
{
bool ret = CJsonParamCheck(nullptr, {PARAM_KEY_OS_TYPE, PARAM_KEY_OS_VERSION});
EXPECT_FALSE(ret);
}
/**
* @tc.name: GetOsInfoFromDM_001
* @tc.desc: GetOsInfoFromDM
* @tc.type: FUNC
* @tc.require: I5WKCK
*/
HWTEST_F(DistributedSchedUtilsTest, GetOsInfoFromDM_001, TestSize.Level1)
{
std::string dmInfoEx;
int32_t osType;
std::string osVersion;
bool ret = GetOsInfoFromDM(dmInfoEx, osType, osVersion);
EXPECT_FALSE(ret);
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -19,12 +19,6 @@
namespace OHOS {
namespace DistributedSchedule {
namespace Constants {
constexpr int32_t OH_OS_TYPE = 10;
constexpr int32_t HO_OS_TYPE = 11;
constexpr int32_t HO_OS_TYPE_EX = -1;
constexpr const char* PARAM_KEY_OS_TYPE = "OS_TYPE";
constexpr const char* PARAM_KEY_OS_VERSION = "OS_VERSION";
constexpr const char* DMS_NAME = "dmsfwk";
constexpr const char* DMS_VERSION = "5.0.0";
constexpr const char* DMS_SERVICE_ID = "dmsfwk_svr_id";

View File

@ -1,51 +0,0 @@
/*
* 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_IDMS_INTERACTIVE_ADAPTER_H
#define OHOS_IDMS_INTERACTIVE_ADAPTER_H
#include <string>
#include "caller_info.h"
#include "dm_device_info.h"
#include "message_parcel.h"
#include "want.h"
namespace OHOS {
namespace DistributedSchedule {
typedef struct {
int32_t (*StartRemoteAbilityAdapter)(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
uint32_t accessToken);
int32_t (*StartAbilityFromRemoteAdapter)(MessageParcel& data, MessageParcel& reply);
int32_t (*StopAbilityFromRemoteAdapter)(MessageParcel& data, MessageParcel& reply);
int32_t (*ConnectRemoteAbilityAdapter)(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
int32_t callerUid, int32_t callerPid, uint32_t accessToken);
int32_t (*ConnectAbilityFromRemoteAdapter)(MessageParcel& data, MessageParcel& reply);
int32_t (*DisconnectRemoteAbilityAdapter)(const sptr<IRemoteObject>& connect, int32_t callerUid,
uint32_t accessToken);
int32_t (*DisconnectAbilityFromRemoteAdapter)(MessageParcel& data, MessageParcel& reply);
int32_t (*NotifyAbilityLifecycleChangedFromRemoteAdapter)(MessageParcel& data, MessageParcel& reply);
void (*OnDeviceOnlineEx)(const OHOS::DistributedHardware::DmDeviceInfo& deviceInfo);
void (*OnDeviceOfflineEx)(const OHOS::DistributedHardware::DmDeviceInfo& deviceInfo);
void (*OnDeviceInfoChangedEx)(const OHOS::DistributedHardware::DmDeviceInfo& deviceInfo);
} IDmsInteractiveAdapter;
} // namespace DistributedSchedule
} // namespace OHOS
#endif // OHOS_IDMS_INTERACTIVE_ADAPTER_H

View File

@ -77,7 +77,6 @@ ohos_shared_library("distributedschedsvr") {
if (!dmsfwk_softbus_adapter_common) {
cflags = [
"-DDMSFWK_SAME_ACCOUNT",
"-DDMSFWK_INTERACTIVE_ADAPTER",
"-DDMSFWK_ALL_CONNECT_MGR",
]
}

View File

@ -20,9 +20,7 @@
#include <string>
#include "parcel.h"
#include "dms_constant.h"
namespace OHOS {
namespace DistributedSchedule {
enum {
@ -37,18 +35,15 @@ enum {
class DmsDeviceInfo : public Parcelable {
public:
DmsDeviceInfo(const std::string& deviceName, int32_t deviceType, const std::string& networkId,
int32_t deviceState = ONLINE, int32_t osType = Constants::OH_OS_TYPE, std::string osVersion = "")
: deviceName_(deviceName), deviceType_(deviceType), networkId_(networkId), deviceState_(deviceState),
osType_(osType), osVersion_(osVersion) {}
DmsDeviceInfo(const std::string& deviceName, int32_t deviceType,
const std::string& networkId, int32_t deviceState = ONLINE)
: deviceName_(deviceName), deviceType_(deviceType), networkId_(networkId), deviceState_(deviceState) {}
~DmsDeviceInfo() = default;
const std::string& GetDeviceName() const;
const std::string& GetNetworkId() const;
int32_t GetDeviceType() const;
int32_t GetDeviceState() const;
int32_t GetDeviceOSType() const;
const std::string& GetGetDeviceOSVersion() const;
bool Marshalling(Parcel& parcel) const override;
private:
@ -56,8 +51,6 @@ private:
int32_t deviceType_ = UNKNOWN_TYPE;
std::string networkId_;
int32_t deviceState_ = UNKNOWN_STATE;
int32_t osType_ = Constants::OH_OS_TYPE;
std::string osVersion_ = "";
};
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -21,13 +21,6 @@
#include <set>
#include <unordered_map>
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
#include "form_mgr_interface.h"
#endif
#include "iremote_object.h"
#include "iremote_proxy.h"
#include "system_ability.h"
#include "app_mgr_interface.h"
#include "app_state_observer.h"
#include "datashare_manager.h"
@ -35,13 +28,18 @@
#include "distributed_sched_continuation.h"
#include "dms_callback_task.h"
#include "dsched_collaborate_callback_mgr.h"
#include "idms_interactive_adapter.h"
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
#include "form_mgr_interface.h"
#endif
#include "iremote_object.h"
#include "iremote_proxy.h"
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
#include "mission/distributed_mission_focused_listener.h"
#include "mission/distributed_mission_info.h"
#include "nocopyable.h"
#endif
#include "single_instance.h"
#include "system_ability.h"
namespace OHOS {
namespace DistributedSchedule {
@ -209,23 +207,11 @@ public:
const AccountInfo& accountInfo, int32_t flag, bool needQueryExtension);
ErrCode QueryOsAccount(int32_t& activeAccountId);
#ifdef DMSFWK_INTERACTIVE_ADAPTER
bool CheckRemoteOsType(const std::string& netwokId) override;
int32_t StartAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) override;
int32_t StopAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) override;
int32_t ConnectAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) override;
int32_t DisconnectAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) override;
int32_t NotifyAbilityLifecycleChangedFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) override;
void OnDeviceOnlineEx(const OHOS::DistributedHardware::DmDeviceInfo& deviceInfo);
void OnDeviceOfflineEx(const OHOS::DistributedHardware::DmDeviceInfo& deviceInfo);
void OnDeviceInfoChangedEx(const OHOS::DistributedHardware::DmDeviceInfo& deviceInfo);
#endif
private:
DistributedSchedService();
bool Init();
void InitDataShareManager();
void InitMissionManager();
void InitCommonEventListener();
int32_t GetCallerInfo(const std::string &localDeviceId, int32_t callerUid, uint32_t accessToken,
CallerInfo &callerInfo);
@ -306,16 +292,6 @@ private:
DSchedEventState state, int32_t ret);
bool CheckCallingUid();
#ifdef DMSFWK_INTERACTIVE_ADAPTER
int32_t GetDmsInteractiveAdapterProxy();
int32_t StartRemoteAbilityAdapter(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
uint32_t accessToken);
int32_t ConnectRemoteAbilityAdapter(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
int32_t callerUid, int32_t callerPid, uint32_t accessToken);
int32_t DisconnectRemoteAbilityAdapter(const sptr<IRemoteObject>& connect, int32_t callerUid,
uint32_t accessToken);
#endif
private:
std::shared_ptr<DSchedContinuation> dschedContinuation_;
std::shared_ptr<DSchedCollaborationCallbackMgr> collaborateCbMgr_;
@ -348,24 +324,6 @@ private:
std::map<std::string, sptr<AppStateObserver>> bundleNameMap_;
DataShareManager dataShareManager_;
sptr<DistributedMissionFocusedListener> missionFocusedListener_ = nullptr;
#ifdef DMSFWK_INTERACTIVE_ADAPTER
std::mutex dmsAdapetrLock_;
void *dllHandle_ = nullptr;
IDmsInteractiveAdapter dmsAdapetr_ = {
.StartRemoteAbilityAdapter = nullptr,
.StartAbilityFromRemoteAdapter = nullptr,
.StopAbilityFromRemoteAdapter = nullptr,
.ConnectRemoteAbilityAdapter = nullptr,
.ConnectAbilityFromRemoteAdapter = nullptr,
.DisconnectRemoteAbilityAdapter = nullptr,
.DisconnectAbilityFromRemoteAdapter = nullptr,
.NotifyAbilityLifecycleChangedFromRemoteAdapter = nullptr,
.OnDeviceOnlineEx = nullptr,
.OnDeviceOfflineEx = nullptr,
.OnDeviceInfoChangedEx = nullptr,
};
#endif
};
class ConnectAbilitySession {

View File

@ -31,19 +31,9 @@ public:
int32_t OnRemoteRequest(uint32_t code, MessageParcel& data,
MessageParcel& reply, MessageOption& option) override;
#ifdef DMSFWK_INTERACTIVE_ADAPTER
virtual bool CheckRemoteOsType(const std::string& netwokId) = 0;
virtual int32_t StartAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) = 0;
virtual int32_t StopAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) = 0;
virtual int32_t ConnectAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) = 0;
virtual int32_t DisconnectAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) = 0;
virtual int32_t NotifyAbilityLifecycleChangedFromRemoteAdapter(MessageParcel& data, MessageParcel& reply) = 0;
#endif
private:
int32_t StartRemoteAbilityInner(MessageParcel& data, MessageParcel& reply);
int32_t StartAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply);
int32_t StopAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply);
int32_t SendResultFromRemoteInner(MessageParcel& data, MessageParcel& reply);
bool IsRemoteInstall(const std::string &networkId, const std::string &bundleName);
int32_t ContinueMissionInner(MessageParcel& data, MessageParcel& reply);
@ -57,16 +47,6 @@ private:
int32_t ConnectAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply);
int32_t DisconnectAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply);
int32_t NotifyProcessDiedFromRemoteInner(MessageParcel& data, MessageParcel& reply);
#ifdef DMSFWK_INTERACTIVE_ADAPTER
bool CheckDmsExtensionCallingUid();
int32_t StartAbilityFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply);
int32_t StopAbilityFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply);
int32_t ConnectAbilityFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply);
int32_t DisconnectAbilityFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply);
int32_t NotifyAbilityLifecycleChangedFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply);
#endif
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
int32_t GetMissionInfosInner(MessageParcel& data, MessageParcel& reply);
int32_t GetRemoteMissionSnapshotInfoInner(MessageParcel& data, MessageParcel& reply);

View File

@ -45,10 +45,6 @@ enum class IDSchedInterfaceCode : uint32_t {
START_FREE_INSTALL_FROM_REMOTE = 51,
NOTIFY_COMPLETE_FREE_INSTALL_FROM_REMOTE = 52,
#ifdef DMSFWK_INTERACTIVE_ADAPTER
NOTIFY_ABILITY_LIFECYCLE_CHANGED_FROM_REMOTE = 66,
#endif
// request code for mission
GET_MISSION_INFOS = 80,
REGISTER_MISSION_LISTENER = 84,

View File

@ -43,24 +43,12 @@ int32_t DmsDeviceInfo::GetDeviceState() const
return deviceState_;
}
int32_t DmsDeviceInfo::GetDeviceOSType() const
{
return osType_;
}
const std::string& DmsDeviceInfo::GetGetDeviceOSVersion() const
{
return osVersion_;
}
bool DmsDeviceInfo::Marshalling(Parcel& parcel) const
{
PARCEL_WRITE_HELPER_RET(parcel, String16, Str8ToStr16(networkId_), false);
PARCEL_WRITE_HELPER_RET(parcel, String16, Str8ToStr16(deviceName_), false);
PARCEL_WRITE_HELPER_RET(parcel, Int32, deviceType_, false);
PARCEL_WRITE_HELPER_RET(parcel, Int32, deviceState_, false);
PARCEL_WRITE_HELPER_RET(parcel, Int32, osType_, false);
PARCEL_WRITE_HELPER_RET(parcel, String16, Str8ToStr16(osVersion_), false);
return true;
}
} // namespace DistributedSchedule

View File

@ -19,8 +19,6 @@
#include <string>
#include "deviceManager/dms_device_info.h"
#include "distributed_sched_service.h"
#include "distributed_sched_utils.h"
#include "dtbschedmgr_device_info_storage.h"
#include "dtbschedmgr_log.h"
#include "mission/dms_continue_send_manager.h"
@ -32,35 +30,20 @@ const std::string TAG = "DistributedDeviceNodeListener";
}
void DistributedDeviceNodeListener::OnDeviceOnline(const DistributedHardware::DmDeviceInfo& deviceInfo)
{
int32_t osType = Constants::OH_OS_TYPE;
std::string osVersion = "";
if (!GetOsInfoFromDM(deviceInfo.extraData, osType, osVersion)) {
HILOGE("Get Os info from DM device info fail, extraData %{public}s.", deviceInfo.extraData.c_str());
}
auto dmsDeviceInfo = std::make_shared<DmsDeviceInfo>(deviceInfo.deviceName, deviceInfo.deviceTypeId,
deviceInfo.networkId, ONLINE, osType, osVersion);
auto dmsDeviceInfo = std::make_shared<DmsDeviceInfo>(
deviceInfo.deviceName, deviceInfo.deviceTypeId, deviceInfo.networkId);
DtbschedmgrDeviceInfoStorage::GetInstance().DeviceOnlineNotify(dmsDeviceInfo);
#ifdef DMSFWK_INTERACTIVE_ADAPTER
DistributedSchedService::GetInstance().OnDeviceOnlineEx(deviceInfo);
#endif
DMSContinueSendMgr::GetInstance().NotifyDeviceOnline();
}
void DistributedDeviceNodeListener::OnDeviceOffline(const DistributedHardware::DmDeviceInfo& deviceInfo)
{
DtbschedmgrDeviceInfoStorage::GetInstance().DeviceOfflineNotify(deviceInfo.networkId);
#ifdef DMSFWK_INTERACTIVE_ADAPTER
DistributedSchedService::GetInstance().OnDeviceOfflineEx(deviceInfo);
#endif
}
void DistributedDeviceNodeListener::OnDeviceInfoChanged(const DistributedHardware::DmDeviceInfo& deviceInfo)
{
DtbschedmgrDeviceInfoStorage::GetInstance().OnDeviceInfoChanged(deviceInfo.networkId);
#ifdef DMSFWK_INTERACTIVE_ADAPTER
DistributedSchedService::GetInstance().OnDeviceInfoChangedEx(deviceInfo);
#endif
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -173,7 +173,7 @@ int32_t DistributedSchedPermission::GetAccountInfo(const std::string& remoteNetw
if (CheckAclList(remoteNetworkId, accountInfo, callerInfo)) {
return ERR_OK;
}
HILOGE("Check different account ACL by DM fail.");
HILOGE("Check different account ACL list by DM fail.");
return INVALID_PARAMETERS_ERR;
}

View File

@ -17,7 +17,6 @@
#include <algorithm>
#include <cinttypes>
#include <dlfcn.h>
#include <unistd.h>
#include "ability_manager_client.h"
@ -177,15 +176,6 @@ void DistributedSchedService::OnStart(const SystemAbilityOnDemandReason &startRe
dschedContinuation_->Init(continuationCallback);
collaborateCbMgr_->Init();
dmsCallbackTask_->Init(freeCallback);
#ifdef DMSFWK_INTERACTIVE_ADAPTER
HILOGI("Get dms interactive adapter proxy enter.");
int32_t ret = GetDmsInteractiveAdapterProxy();
if (ret != ERR_OK) {
HILOGE("Get remote dms interactive adapter proxy fail, ret %{public}d.", ret);
}
#endif
HILOGI("OnStart dms service success.");
Publish(this);
HandleBootStart(startReason);
@ -200,11 +190,6 @@ void DistributedSchedService::OnStop(const SystemAbilityOnDemandReason &stopReas
RemoveSystemAbilityListener(WINDOW_MANAGER_SERVICE_ID);
DistributedSchedAdapter::GetInstance().UnRegisterMissionListener(missionFocusedListener_);
#endif
#ifdef DMSFWK_INTERACTIVE_ADAPTER
dlclose(dllHandle_);
dllHandle_ = nullptr;
#endif
HILOGI("OnStop dms service end");
}
@ -290,18 +275,8 @@ bool DistributedSchedService::Init()
HILOGW("DtbschedmgrDeviceInfoStorage init failed.");
}
InitDataShareManager();
InitMissionManager();
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
if (!AddSystemAbilityListener(WINDOW_MANAGER_SERVICE_ID)) {
HILOGE("Add System Ability Listener failed!");
}
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().InitDataStorage();
InitCommonEventListener();
InitWifiStateListener();
DMSContinueSendMgr::GetInstance().Init();
DMSContinueRecvMgr::GetInstance().Init();
#endif
DistributedSchedAdapter::GetInstance().Init();
if (SwitchStatusDependency::GetInstance().IsContinueSwitchOn()) {
DSchedContinueManager::GetInstance().Init();
@ -317,6 +292,21 @@ bool DistributedSchedService::Init()
return true;
}
void DistributedSchedService::InitMissionManager()
{
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
if (!AddSystemAbilityListener(WINDOW_MANAGER_SERVICE_ID)) {
HILOGE("Add System Ability Listener failed!");
}
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().InitDataStorage();
InitCommonEventListener();
InitWifiStateListener();
DMSContinueSendMgr::GetInstance().Init();
DMSContinueRecvMgr::GetInstance().Init();
#endif
}
void DistributedSchedService::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
{
HILOGI("OnAddSystemAbility systemAbilityId:%{public}d added!", systemAbilityId);
@ -403,224 +393,6 @@ void DistributedSchedService::DurationStart(const std::string srcDeviceId, const
DmsContinueTime::GetInstance().SetNetWorkId(srcDeviceId, dstDeviceId);
}
#ifdef DMSFWK_INTERACTIVE_ADAPTER
bool DistributedSchedService::CheckRemoteOsType(const std::string& netwokId)
{
auto devInfo = DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(netwokId);
if (devInfo == nullptr) {
HILOGE("GetDeviceInfoById failed, netwokId: %{public}s.", GetAnonymStr(netwokId).c_str());
return false;
}
HILOGI("Remote device OsType %{public}d, netwokId: %{public}s.", devInfo->GetDeviceOSType(),
GetAnonymStr(netwokId).c_str());
return (devInfo->GetDeviceOSType() == Constants::HO_OS_TYPE_EX);
}
int32_t DistributedSchedService::GetDmsInteractiveAdapterProxy()
{
HILOGI("Get remote dms interactive adapter proxy.");
std::lock_guard<std::mutex> autoLock(dmsAdapetrLock_);
#if (defined(__aarch64__) || defined(__x86_64__))
char resolvedPath[100] = "/system/lib64/libdms_interactive_adapter.z.so";
#else
char resolvedPath[100] = "/system/lib/libdms_interactive_adapter.z.so";
#endif
int32_t (*GetDmsInteractiveAdapter)(const sptr<IRemoteObject> &callerToken,
IDmsInteractiveAdapter &dmsAdpHandle) = nullptr;
dllHandle_ = dlopen(resolvedPath, RTLD_LAZY);
if (dllHandle_ == nullptr) {
HILOGE("Open dms interactive adapter shared object fail, resolvedPath [%{public}s].", resolvedPath);
return NOT_FIND_SERVICE_REGISTRY;
}
int32_t ret = ERR_OK;
do {
GetDmsInteractiveAdapter = reinterpret_cast<int32_t (*)(const sptr<IRemoteObject> &callerToken,
IDmsInteractiveAdapter &dmsAdpHandle)>(dlsym(dllHandle_, "GetDmsInteractiveAdapter"));
if (GetDmsInteractiveAdapter == nullptr) {
HILOGE("Link the GetDmsInteractiveAdapter symbol in dms interactive adapter fail.");
ret = NOT_FIND_SERVICE_REGISTRY;
break;
}
int32_t ret = GetDmsInteractiveAdapter(this, dmsAdapetr_);
if (ret != ERR_OK) {
HILOGE("Init remote dms interactive adapter proxy fail, ret %{public}d.", ret);
ret = INVALID_PARAMETERS_ERR;
break;
}
HILOGI("Init remote dms interactive adapter proxy success.");
ret = ERR_OK;
} while (false);
if (ret != ERR_OK) {
HILOGE("Get remote dms interactive adapter proxy fail, dlclose handle.");
dlclose(dllHandle_);
dllHandle_ = nullptr;
}
return ret;
}
int32_t DistributedSchedService::StartRemoteAbilityAdapter(const OHOS::AAFwk::Want& want,
int32_t callerUid, int32_t requestCode, uint32_t accessToken)
{
std::lock_guard<std::mutex> autoLock(dmsAdapetrLock_);
if (dmsAdapetr_.StartRemoteAbilityAdapter == nullptr) {
HILOGE("Dms interactive start remote ability adapter handle is null.");
return INVALID_PARAMETERS_ERR;
}
int32_t ret = dmsAdapetr_.StartRemoteAbilityAdapter(want, callerUid, requestCode, accessToken);
if (ret != ERR_OK) {
HILOGE("Dms interactive adapter start remote ability adapter fail, ret %{public}d.", ret);
}
return ret;
}
int32_t DistributedSchedService::ConnectRemoteAbilityAdapter(const OHOS::AAFwk::Want& want,
const sptr<IRemoteObject>& connect, int32_t callerUid, int32_t callerPid, uint32_t accessToken)
{
std::lock_guard<std::mutex> autoLock(dmsAdapetrLock_);
if (dmsAdapetr_.ConnectRemoteAbilityAdapter == nullptr) {
HILOGE("Dms interactive connect remote ability adapter handle is null.");
return INVALID_PARAMETERS_ERR;
}
int32_t ret = dmsAdapetr_.ConnectRemoteAbilityAdapter(want, connect, callerUid, callerPid, accessToken);
if (ret != ERR_OK) {
HILOGE("Dms interactive adapter connect remote ability adapter fail, ret %{public}d.", ret);
}
return ret;
}
int32_t DistributedSchedService::DisconnectRemoteAbilityAdapter(const sptr<IRemoteObject>& connect, int32_t callerUid,
uint32_t accessToken)
{
std::lock_guard<std::mutex> autoLock(dmsAdapetrLock_);
if (dmsAdapetr_.DisconnectRemoteAbilityAdapter == nullptr) {
HILOGE("Dms interactive disconnect remote ability adapter handle is null.");
return INVALID_PARAMETERS_ERR;
}
int32_t ret = dmsAdapetr_.DisconnectRemoteAbilityAdapter(connect, callerUid, accessToken);
if (ret != ERR_OK) {
HILOGE("Dms interactive adapter disconnect remote ability adapter fail, ret %{public}d.", ret);
}
return ret;
}
int32_t DistributedSchedService::StartAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply)
{
std::lock_guard<std::mutex> autoLock(dmsAdapetrLock_);
if (dmsAdapetr_.StartAbilityFromRemoteAdapter == nullptr) {
HILOGE("Dms interactive start ability from remote adapter handle is null.");
return INVALID_PARAMETERS_ERR;
}
int32_t ret = dmsAdapetr_.StartAbilityFromRemoteAdapter(data, reply);
if (ret != ERR_OK) {
HILOGE("Dms interactive adapter start ability from remote adapter fail, ret %{public}d.", ret);
}
return ret;
}
int32_t DistributedSchedService::StopAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply)
{
std::lock_guard<std::mutex> autoLock(dmsAdapetrLock_);
if (dmsAdapetr_.StopAbilityFromRemoteAdapter == nullptr) {
HILOGE("Dms interactive stop ability from remote adapter handle is null.");
return INVALID_PARAMETERS_ERR;
}
int32_t ret = dmsAdapetr_.StopAbilityFromRemoteAdapter(data, reply);
if (ret != ERR_OK) {
HILOGE("Dms interactive adapter stop ability from remote adapter fail, ret %{public}d.", ret);
}
return ret;
}
int32_t DistributedSchedService::ConnectAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply)
{
std::lock_guard<std::mutex> autoLock(dmsAdapetrLock_);
if (dmsAdapetr_.ConnectAbilityFromRemoteAdapter == nullptr) {
HILOGE("Dms interactive connect ability from remote adapter handle is null.");
return INVALID_PARAMETERS_ERR;
}
int32_t ret = dmsAdapetr_.ConnectAbilityFromRemoteAdapter(data, reply);
if (ret != ERR_OK) {
HILOGE("Dms interactive adapter connect ability from remote adapter fail, ret %{public}d.", ret);
}
return ret;
}
int32_t DistributedSchedService::DisconnectAbilityFromRemoteAdapter(MessageParcel& data, MessageParcel& reply)
{
std::lock_guard<std::mutex> autoLock(dmsAdapetrLock_);
if (dmsAdapetr_.DisconnectAbilityFromRemoteAdapter == nullptr) {
HILOGE("Dms interactive disconnect ability from remote adapter handle is null.");
return INVALID_PARAMETERS_ERR;
}
int32_t ret = dmsAdapetr_.DisconnectAbilityFromRemoteAdapter(data, reply);
if (ret != ERR_OK) {
HILOGE("Dms interactive adapter disconnect ability from remote adapter fail, ret %{public}d.", ret);
}
return ret;
}
int32_t DistributedSchedService::NotifyAbilityLifecycleChangedFromRemoteAdapter(MessageParcel& data,
MessageParcel& reply)
{
std::lock_guard<std::mutex> autoLock(dmsAdapetrLock_);
if (dmsAdapetr_.NotifyAbilityLifecycleChangedFromRemoteAdapter == nullptr) {
HILOGE("Dms interactive disconnect ability from remote adapter handle is null.");
return INVALID_PARAMETERS_ERR;
}
int32_t ret = dmsAdapetr_.NotifyAbilityLifecycleChangedFromRemoteAdapter(data, reply);
if (ret != ERR_OK) {
HILOGE("Dms interactive adapter disconnect ability from remote adapter fail, ret %{public}d.", ret);
}
return ret;
}
void DistributedSchedService::OnDeviceOnlineEx(const OHOS::DistributedHardware::DmDeviceInfo& deviceInfo)
{
std::lock_guard<std::mutex> autoLock(dmsAdapetrLock_);
if (dmsAdapetr_.OnDeviceOnlineEx == nullptr) {
HILOGE("Dms interactive on device online extention handle is null.");
return;
}
dmsAdapetr_.OnDeviceOnlineEx(deviceInfo);
}
void DistributedSchedService::OnDeviceOfflineEx(const OHOS::DistributedHardware::DmDeviceInfo& deviceInfo)
{
std::lock_guard<std::mutex> autoLock(dmsAdapetrLock_);
if (dmsAdapetr_.OnDeviceOfflineEx == nullptr) {
HILOGE("Dms interactive on device online extention handle is null.");
return;
}
dmsAdapetr_.OnDeviceOfflineEx(deviceInfo);
}
void DistributedSchedService::OnDeviceInfoChangedEx(const OHOS::DistributedHardware::DmDeviceInfo& deviceInfo)
{
std::lock_guard<std::mutex> autoLock(dmsAdapetrLock_);
if (dmsAdapetr_.OnDeviceInfoChangedEx == nullptr) {
HILOGE("Dms interactive on device online extention handle is null.");
return;
}
dmsAdapetr_.OnDeviceInfoChangedEx(deviceInfo);
}
#endif // DMSFWK_INTERACTIVE_ADAPTER
int32_t DistributedSchedService::GetCallerInfo(const std::string &localDeviceId, int32_t callerUid,
uint32_t accessToken, CallerInfo &callerInfo)
{
@ -648,12 +420,6 @@ int32_t DistributedSchedService::StartRemoteAbility(const OHOS::AAFwk::Want& wan
HILOGE("check deviceId failed");
return INVALID_PARAMETERS_ERR;
}
#ifdef DMSFWK_INTERACTIVE_ADAPTER
if (CheckRemoteOsType(deviceId)) {
return StartRemoteAbilityAdapter(want, callerUid, requestCode, accessToken);
}
#endif // DMSFWK_INTERACTIVE_ADAPTER
sptr<IDistributedSched> remoteDms = GetRemoteDms(deviceId);
if (remoteDms == nullptr) {
HILOGE("get remoteDms failed");
@ -1534,13 +1300,6 @@ int32_t DistributedSchedService::ConnectRemoteAbility(const OHOS::AAFwk::Want& w
HILOGE("ConnectRemoteAbility check deviceId failed");
return INVALID_PARAMETERS_ERR;
}
#ifdef DMSFWK_INTERACTIVE_ADAPTER
if (CheckRemoteOsType(remoteDeviceId)) {
return ConnectRemoteAbilityAdapter(want, connect, callerUid, callerPid, accessToken);
}
#endif // DMSFWK_INTERACTIVE_ADAPTER
CallerInfo callerInfo = { callerUid, callerPid, CALLER_TYPE_HARMONY, localDeviceId };
callerInfo.accessToken = accessToken;
{
@ -2407,13 +2166,6 @@ int32_t DistributedSchedService::DisconnectRemoteAbility(const sptr<IRemoteObjec
HILOGE("DisconnectRemoteAbility connect is null");
return INVALID_PARAMETERS_ERR;
}
#ifdef DMSFWK_INTERACTIVE_ADAPTER
if (distributedConnectAbilityMap_.find(connect) == distributedConnectAbilityMap_.end()) {
return DisconnectRemoteAbilityAdapter(connect, callerUid, accessToken);
}
#endif // DMSFWK_INTERACTIVE_ADAPTER
std::list<ConnectAbilitySession> sessionsList;
{
std::lock_guard<std::mutex> autoLock(distributedLock_);

View File

@ -162,8 +162,6 @@ void DistributedSchedStub::InitRemoteFuncsInner()
{
remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_ABILITY_FROM_REMOTE)] =
&DistributedSchedStub::StartAbilityFromRemoteInner;
remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::STOP_ABILITY_FROM_REMOTE)] =
&DistributedSchedStub::StopAbilityFromRemoteInner;
remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::SEND_RESULT_FROM_REMOTE)] =
&DistributedSchedStub::SendResultFromRemoteInner;
remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_CONTINUATION_RESULT_FROM_REMOTE)] =
@ -196,11 +194,6 @@ void DistributedSchedStub::InitRemoteFuncsInner()
remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_STATE_CHANGED_FROM_REMOTE)] =
&DistributedSchedStub::NotifyStateChangedFromRemoteInner;
#ifdef DMSFWK_INTERACTIVE_ADAPTER
remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_STATE_CHANGED_FROM_REMOTE)] =
&DistributedSchedStub::NotifyAbilityLifecycleChangedFromRemoteAdapterInner;
#endif
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_SHARE_FORM_FROM_REMOTE)] =
&DistributedSchedStub::StartShareFormFromRemoteInner;
@ -362,12 +355,6 @@ int32_t DistributedSchedStub::GetConnectAbilityFromRemoteExParam(MessageParcel&
int32_t DistributedSchedStub::StartAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply)
{
#ifdef DMSFWK_INTERACTIVE_ADAPTER
if (CheckRemoteOsType(IPCSkeleton::GetCallingDeviceID())) {
return StartAbilityFromRemoteAdapterInner(data, reply);
}
#endif
if (!CheckCallingUid()) {
HILOGW("request DENIED!");
return DMS_PERMISSION_DENIED;
@ -405,17 +392,6 @@ int32_t DistributedSchedStub::StartAbilityFromRemoteInner(MessageParcel& data, M
return ERR_NONE;
}
int32_t DistributedSchedStub::StopAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply)
{
#ifdef DMSFWK_INTERACTIVE_ADAPTER
if (CheckRemoteOsType(IPCSkeleton::GetCallingDeviceID())) {
return StopAbilityFromRemoteAdapterInner(data, reply);
}
#endif
int32_t result = ERR_OK;
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
}
void DistributedSchedStub::SaveExtraInfo(const nlohmann::json& extraInfoJson, CallerInfo& callerInfo,
AccountInfo& accountInfo)
{
@ -805,12 +781,6 @@ int32_t DistributedSchedStub::ReadDataForConnect(MessageParcel& data, CallerInfo
int32_t DistributedSchedStub::ConnectAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply)
{
#ifdef DMSFWK_INTERACTIVE_ADAPTER
if (CheckRemoteOsType(IPCSkeleton::GetCallingDeviceID())) {
return ConnectAbilityFromRemoteAdapterInner(data, reply);
}
#endif
if (!CheckCallingUid()) {
HILOGW("request DENIED!");
return DMS_PERMISSION_DENIED;
@ -850,12 +820,6 @@ int32_t DistributedSchedStub::ConnectAbilityFromRemoteInner(MessageParcel& data,
int32_t DistributedSchedStub::DisconnectAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply)
{
#ifdef DMSFWK_INTERACTIVE_ADAPTER
if (CheckRemoteOsType(IPCSkeleton::GetCallingDeviceID())) {
return DisconnectAbilityFromRemoteAdapterInner(data, reply);
}
#endif
if (!CheckCallingUid()) {
HILOGW("request DENIED!");
return DMS_PERMISSION_DENIED;
@ -1649,78 +1613,5 @@ int32_t DistributedSchedStub::StopExtensionAbilityFromRemoteInner(MessageParcel&
PARCEL_WRITE_HELPER(reply, Int32, result);
return ERR_NONE;
}
#ifdef DMSFWK_INTERACTIVE_ADAPTER
bool DistributedSchedStub::CheckDmsExtensionCallingUid()
{
// never allow non-system uid for distributed request
constexpr int32_t MULTIUSER_HAP_PER_USER_RANGE_EXT = 100000;
constexpr int32_t HID_HAP_EXT = 10000;
auto callingUid = IPCSkeleton::GetCallingUid();
auto uid = callingUid % MULTIUSER_HAP_PER_USER_RANGE_EXT;
return uid < HID_HAP_EXT;
}
int32_t DistributedSchedStub::StartAbilityFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply)
{
if (!CheckDmsExtensionCallingUid()) {
HILOGW("Start ability from remote adapter request DENIED!");
return DMS_PERMISSION_DENIED;
}
int32_t result = StartAbilityFromRemoteAdapter(data, reply);
HILOGI("Start ability from remote adapter result = %{public}d", result);
return result;
}
int32_t DistributedSchedStub::StopAbilityFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply)
{
if (!CheckDmsExtensionCallingUid()) {
HILOGW("Stop ability from remote adapter request DENIED!");
return DMS_PERMISSION_DENIED;
}
int32_t result = StopAbilityFromRemoteAdapter(data, reply);
HILOGI("Stop ability from remote adapter result = %{public}d", result);
return ERR_OK;
}
int32_t DistributedSchedStub::ConnectAbilityFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply)
{
if (!CheckDmsExtensionCallingUid()) {
HILOGW("Connect ability from remote adapter request DENIED!");
return DMS_PERMISSION_DENIED;
}
int32_t result = ConnectAbilityFromRemoteAdapter(data, reply);
HILOGI("Connect ability from remote adapter result = %{public}d", result);
return ERR_OK;
}
int32_t DistributedSchedStub::DisconnectAbilityFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply)
{
if (!CheckDmsExtensionCallingUid()) {
HILOGW("Disconnect ability from remote adapter request DENIED!");
return DMS_PERMISSION_DENIED;
}
int32_t result = DisconnectAbilityFromRemoteAdapter(data, reply);
HILOGI("Disconnect ability from remote adapter result = %{public}d", result);
return ERR_OK;
}
int32_t DistributedSchedStub::NotifyAbilityLifecycleChangedFromRemoteAdapterInner(MessageParcel& data,
MessageParcel& reply)
{
if (!CheckDmsExtensionCallingUid()) {
HILOGW("Disconnect ability from remote adapter request DENIED!");
return DMS_PERMISSION_DENIED;
}
int32_t result = NotifyAbilityLifecycleChangedFromRemoteAdapter(data, reply);
HILOGI("Disconnect ability from remote adapter result = %{public}d", result);
return ERR_OK;
}
#endif
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -191,13 +191,8 @@ bool DtbschedmgrDeviceInfoStorage::UpdateDeviceInfoStorage()
return false;
}
for (const auto& dmDeviceInfo : dmDeviceInfoList) {
int32_t osType = Constants::OH_OS_TYPE;
std::string osVersion = "";
if (!GetOsInfoFromDM(dmDeviceInfo.extraData, osType, osVersion)) {
HILOGE("Get Os info from DM device info fail, extraData %{public}s.", dmDeviceInfo.extraData.c_str());
}
auto deviceInfo = std::make_shared<DmsDeviceInfo>(dmDeviceInfo.deviceName, dmDeviceInfo.deviceTypeId,
dmDeviceInfo.networkId, ONLINE, osType, osVersion);
auto deviceInfo = std::make_shared<DmsDeviceInfo>(
dmDeviceInfo.deviceName, dmDeviceInfo.deviceTypeId, dmDeviceInfo.networkId);
std::string networkId = deviceInfo->GetNetworkId();
RegisterUuidNetworkIdMap(networkId);
{
@ -360,9 +355,8 @@ void DtbschedmgrDeviceInfoStorage::DeviceOnlineNotify(const std::shared_ptr<DmsD
std::string networkId = devInfo->GetNetworkId();
RegisterUuidNetworkIdMap(networkId);
std::string uuid = GetUuidByNetworkId(networkId);
HILOGI("networkId: %{public}s, uuid: %{public}s, deviceName: %{public}s, osType: %{public}d, "
"osVersion: %{public}s.", GetAnonymStr(networkId).c_str(), GetAnonymStr(uuid).c_str(),
devInfo->GetDeviceName().c_str(), devInfo->GetDeviceOSType(), devInfo->GetGetDeviceOSVersion().c_str());
HILOGI("networkId: %{public}s, uuid: %{public}s, deviceName: %{public}s", GetAnonymStr(networkId).c_str(),
GetAnonymStr(uuid).c_str(), devInfo->GetDeviceName().c_str());
{
lock_guard<mutex> autoLock(deviceLock_);
remoteDevices_[networkId] = devInfo;

View File

@ -494,9 +494,7 @@ ohos_unittest("dmsbasetest") {
debug = false
}
module_out_path = module_output_path
cflags = [ "-Dprivate=public" ]
sources = [
"unittest/collaborate/dsched_collaborate_callback_mgr_test.cpp",
"unittest/deviceManager/dms_device_info_test.cpp",
"unittest/dfx/distributed_radar_test.cpp",
"unittest/dfx/distributed_sched_dumper_test.cpp",
@ -505,7 +503,6 @@ ohos_unittest("dmsbasetest") {
"unittest/dfx/dms_hisysevent_report_test.cpp",
"unittest/dms_network_adapter_test.cpp",
"unittest/dtbschedmgr_device_info_storage_test.cpp",
"unittest/mock_distributed_sched.cpp",
]
sources += dtbschedmgr_sources
@ -556,7 +553,6 @@ ohos_unittest("dschedcontinuestatetest") {
module_out_path = module_output_path
cflags = [ "-Dprivate=public" ]
sources = [
"unittest/continue/dsched_continue_event_test.cpp",
"unittest/continue/dsched_continue_manager_test.cpp",
"unittest/continue/dsched_continue_state_test.cpp",
"unittest/continue/dsched_continue_test.cpp",

View File

@ -1,182 +0,0 @@
/*
* 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 "dsched_collaborate_callback_mgr_test.h"
#include "mock_distributed_sched.h"
#include "test_log.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace DistributedSchedule {
void DSchedCollaborationCallbackMgrTest::SetUpTestCase()
{
DTEST_LOG << "DSchedCollaborationCallbackMgrTest::SetUpTestCase" << std::endl;
}
void DSchedCollaborationCallbackMgrTest::TearDownTestCase()
{
DTEST_LOG << "DSchedCollaborationCallbackMgrTest::TearDownTestCase" << std::endl;
}
void DSchedCollaborationCallbackMgrTest::TearDown()
{
DTEST_LOG << "DSchedCollaborationCallbackMgrTest::TearDown" << std::endl;
}
void DSchedCollaborationCallbackMgrTest::SetUp()
{
dschedcollaborationcallbackmgr_ = std::make_shared<DSchedCollaborationCallbackMgr>();
DTEST_LOG << "DSchedCollaborationCallbackMgrTest::SetUp" << std::endl;
}
sptr<IRemoteObject> DSchedCollaborationCallbackMgrTest::GetDSchedService() const
{
sptr<IRemoteObject> dsched(new MockDistributedSched());
return dsched;
}
/**
* @tc.name: PushCallback_001
* @tc.desc: call PushCallback
* @tc.type: FUNC
* @tc.require: I6SJQ6
*/
HWTEST_F(DSchedCollaborationCallbackMgrTest, PushCallback_001, TestSize.Level3)
{
DTEST_LOG << "DSchedCollaborationCallbackMgrTest PushCallback_001 begin" << std::endl;
ASSERT_NE(dschedcollaborationcallbackmgr_, nullptr);
sptr<IRemoteObject> callback = nullptr;
//diedListener_ is null
bool ret = dschedcollaborationcallbackmgr_->PushCallback(callback);
EXPECT_EQ(ret, false);
//diedListener_ is not null and callback is null
dschedcollaborationcallbackmgr_->Init();
ret = dschedcollaborationcallbackmgr_->PushCallback(callback);
EXPECT_EQ(ret, false);
DTEST_LOG << "DSchedCollaborationCallbackMgrTest PushCallback_001 end" << std::endl;
}
/**
* @tc.name: PushCallback_002
* @tc.desc: call PushCallback
* @tc.type: FUNC
* @tc.require: I6SJQ6
*/
HWTEST_F(DSchedCollaborationCallbackMgrTest, PushCallback_002, TestSize.Level3)
{
DTEST_LOG << "DSchedCollaborationCallbackMgrTest PushCallback_002 begin" << std::endl;
ASSERT_NE(dschedcollaborationcallbackmgr_, nullptr);
dschedcollaborationcallbackmgr_->Init();
//callback already exists!
sptr<IRemoteObject> callback = GetDSchedService();
dschedcollaborationcallbackmgr_->collaborateCbArr_.clear();
bool ret = dschedcollaborationcallbackmgr_->PushCallback(callback);
EXPECT_EQ(ret, true);
dschedcollaborationcallbackmgr_->collaborateCbArr_.clear();
dschedcollaborationcallbackmgr_->collaborateCbArr_.push_back(callback);
ret = dschedcollaborationcallbackmgr_->PushCallback(callback);
EXPECT_EQ(ret, false);
DTEST_LOG << "DSchedCollaborationCallbackMgrTest PushCallback_002 end" << std::endl;
}
/**
* @tc.name: CleanupCallback_001
* @tc.desc: call CleanupCallback
* @tc.type: FUNC
* @tc.require: I6SJQ6
*/
HWTEST_F(DSchedCollaborationCallbackMgrTest, CleanupCallback_001, TestSize.Level3)
{
DTEST_LOG << "DSchedCollaborationCallbackMgrTest CleanupCallback_001 begin" << std::endl;
ASSERT_NE(dschedcollaborationcallbackmgr_, nullptr);
dschedcollaborationcallbackmgr_->Init();
sptr<IRemoteObject> callback = nullptr;
dschedcollaborationcallbackmgr_->collaborateCbArr_.clear();
bool ret = dschedcollaborationcallbackmgr_->CleanupCallback(callback);
EXPECT_EQ(ret, false);
callback = GetDSchedService();
dschedcollaborationcallbackmgr_->collaborateCbArr_.push_back(callback);
ret = dschedcollaborationcallbackmgr_->CleanupCallback(callback);
EXPECT_EQ(ret, true);
DTEST_LOG << "DSchedCollaborationCallbackMgrTest CleanupCallback_001 end" << std::endl;
}
/**
* @tc.name: NotifyDSchedEventForOneCB_001
* @tc.desc: call NotifyDSchedEventForOneCB
* @tc.type: FUNC
* @tc.require: I6SJQ6
*/
HWTEST_F(DSchedCollaborationCallbackMgrTest, NotifyDSchedEventForOneCB_001, TestSize.Level3)
{
DTEST_LOG << "DSchedCollaborationCallbackMgrTest NotifyDSchedEventForOneCB_001 begin" << std::endl;
ASSERT_NE(dschedcollaborationcallbackmgr_, nullptr);
dschedcollaborationcallbackmgr_->Init();
sptr<IRemoteObject> cb = nullptr;
EventNotify event;
int32_t ret = dschedcollaborationcallbackmgr_->NotifyDSchedEventForOneCB(cb, event);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedCollaborationCallbackMgrTest NotifyDSchedEventForOneCB_001 end" << std::endl;
}
/**
* @tc.name: NotifyDSchedEventResult_001
* @tc.desc: call NotifyDSchedEventResult
* @tc.type: FUNC
* @tc.require: I6SJQ6
*/
HWTEST_F(DSchedCollaborationCallbackMgrTest, NotifyDSchedEventResult_001, TestSize.Level3)
{
DTEST_LOG << "DSchedCollaborationCallbackMgrTest NotifyDSchedEventResult_001 begin" << std::endl;
ASSERT_NE(dschedcollaborationcallbackmgr_, nullptr);
dschedcollaborationcallbackmgr_->Init();
int32_t resultCode = 0;
EventNotify event;
dschedcollaborationcallbackmgr_->collaborateCbArr_.clear();
int32_t ret = dschedcollaborationcallbackmgr_->NotifyDSchedEventResult(resultCode, event);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedCollaborationCallbackMgrTest NotifyDSchedEventResult_001 end" << std::endl;
}
/**
* @tc.name: NotifyDSchedEventResult_002
* @tc.desc: call NotifyDSchedEventResult
* @tc.type: FUNC
* @tc.require: I6SJQ6
*/
HWTEST_F(DSchedCollaborationCallbackMgrTest, NotifyDSchedEventResult_002, TestSize.Level3)
{
DTEST_LOG << "DSchedCollaborationCallbackMgrTest NotifyDSchedEventResult_002 begin" << std::endl;
ASSERT_NE(dschedcollaborationcallbackmgr_, nullptr);
dschedcollaborationcallbackmgr_->Init();
int32_t resultCode = 0;
EventNotify event;
sptr<IRemoteObject> callback = GetDSchedService();
dschedcollaborationcallbackmgr_->collaborateCbArr_.clear();
dschedcollaborationcallbackmgr_->collaborateCbArr_.push_back(callback);
int32_t ret = dschedcollaborationcallbackmgr_->NotifyDSchedEventResult(resultCode, event);
EXPECT_EQ(ret, SEND_REQUEST_DEF_FAIL);
DTEST_LOG << "DSchedCollaborationCallbackMgrTest NotifyDSchedEventResult_002 end" << std::endl;
}
}
}

View File

@ -1,37 +0,0 @@
/*
* 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 DSCHED_COLLABORATE_CALLBACK_MGR_TEST
#define DSCHED_COLLABORATE_CALLBACK_MGR_TEST
#include "gtest/gtest.h"
#include "dsched_collaborate_callback_mgr.h"
namespace OHOS {
namespace DistributedSchedule {
class DSchedCollaborationCallbackMgrTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
sptr<IRemoteObject> GetDSchedService() const;
std::shared_ptr<DSchedCollaborationCallbackMgr> dschedcollaborationcallbackmgr_;
};
} // namespace DistributedSchedule
} // namespace OHOS
#endif // DSCHED_COLLABORATE_CALLBACK_MGR_TEST

View File

@ -1,220 +0,0 @@
/*
* 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 "dsched_continue_event_test.h"
#include "dsched_continue_event.h"
#include "dtbschedmgr_log.h"
#include "test_log.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace DistributedSchedule {
void DSchedContinueEventTest::SetUpTestCase()
{
DTEST_LOG << "DSchedContinueEventTest::SetUpTestCase" << std::endl;
}
void DSchedContinueEventTest::TearDownTestCase()
{
DTEST_LOG << "DSchedContinueEventTest::TearDownTestCase" << std::endl;
}
void DSchedContinueEventTest::TearDown()
{
DTEST_LOG << "DSchedContinueEventTest::TearDown" << std::endl;
}
void DSchedContinueEventTest::SetUp()
{
DTEST_LOG << "DSchedContinueEventTest::SetUp" << std::endl;
}
/**
* @tc.name: DSchedContinueEventTest_001_1
* @tc.desc: DSchedContinueCmdBase Marshal and Unmarshal
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_001_1, TestSize.Level0)
{
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_001_1 begin" << std::endl;
DSchedContinueCmdBase cmd;
cmd.version_ = 0;
cmd.serviceType_ = 0;
cmd.subServiceType_ = 0;
cmd.command_ = 0;
cmd.srcDeviceId_ = "123";
cmd.srcBundleName_ = "test";
cmd.dstDeviceId_ = "test";
cmd.dstBundleName_ = "test";
cmd.continueType_ = "test";
cmd.continueByType_ = 0;
cmd.sourceMissionId_ = 0;
cmd.dmsVersion_ = 0;
std::string cmdStr;
int32_t ret = cmd.Marshal(cmdStr);
EXPECT_EQ(ret, ERR_OK);
ret = cmd.Unmarshal(cmdStr);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_001_1 end ret:" << ret << std::endl;
}
/**
* @tc.name: DSchedContinueEventTest_002_1
* @tc.desc: DSchedContinueStartCmd Marshal and Unmarshal
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_002_1, TestSize.Level0)
{
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_002_1 begin" << std::endl;
DSchedContinueStartCmd cmd;
cmd.version_ = 0;
cmd.serviceType_ = 0;
cmd.subServiceType_ = 0;
cmd.command_ = 0;
cmd.srcDeviceId_ = "123";
cmd.srcBundleName_ = "test";
cmd.dstDeviceId_ = "test";
cmd.dstBundleName_ = "test";
cmd.continueType_ = "test";
cmd.continueByType_ = 0;
cmd.sourceMissionId_ = 0;
cmd.dmsVersion_ = 0;
cmd.direction_ = 0;
cmd.appVersion_ = 0;
DistributedWantParams wantParams;
cmd.wantParams_ = wantParams;
std::string cmdStr;
int32_t ret = cmd.Marshal(cmdStr);
EXPECT_EQ(ret, ERR_OK);
ret = cmd.Unmarshal(cmdStr);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_002_1 end ret:" << ret << std::endl;
}
/**
* @tc.name: DSchedContinueEventTest_003_1
* @tc.desc: DSchedContinueDataCmd Marshal and Unmarshal
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_003_1, TestSize.Level0)
{
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_003_1 begin" << std::endl;
DSchedContinueDataCmd cmd;
cmd.version_ = 0;
cmd.serviceType_ = 0;
cmd.subServiceType_ = 0;
cmd.command_ = 0;
cmd.srcDeviceId_ = "123";
cmd.srcBundleName_ = "test";
cmd.dstDeviceId_ = "test";
cmd.dstBundleName_ = "test";
cmd.continueType_ = "test";
cmd.continueByType_ = 0;
cmd.sourceMissionId_ = 0;
cmd.dmsVersion_ = 0;
OHOS::AAFwk::Want want;
cmd.want_ = want;
AppExecFwk::CompatibleAbilityInfo abilityInfo;
cmd.abilityInfo_ = abilityInfo;
cmd.requestCode_ = 0;
CallerInfo callerInfo;
cmd.callerInfo_ = callerInfo;
IDistributedSched::AccountInfo accountInfo;
cmd.accountInfo_ = accountInfo;
std::string cmdStr;
int32_t ret = cmd.Marshal(cmdStr);
EXPECT_EQ(ret, ERR_OK);
ret = cmd.Unmarshal(cmdStr);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_003_1 end ret:" << ret << std::endl;
}
/**
* @tc.name: DSchedContinueEventTest_004_1
* @tc.desc: DSchedContinueReplyCmd Marshal and Unmarshal
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_004_1, TestSize.Level0)
{
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_004_1 begin" << std::endl;
DSchedContinueReplyCmd cmd;
cmd.version_ = 0;
cmd.serviceType_ = 0;
cmd.subServiceType_ = 0;
cmd.command_ = 0;
cmd.srcDeviceId_ = "123";
cmd.srcBundleName_ = "test";
cmd.dstDeviceId_ = "test";
cmd.dstBundleName_ = "test";
cmd.continueType_ = "test";
cmd.continueByType_ = 0;
cmd.sourceMissionId_ = 0;
cmd.dmsVersion_ = 0;
cmd.replyCmd_ = 0;
cmd.appVersion_ = 0;
cmd.result_ = 0;
cmd.reason_ = "reason";
std::string cmdStr;
int32_t ret = cmd.Marshal(cmdStr);
EXPECT_EQ(ret, ERR_OK);
ret = cmd.Unmarshal(cmdStr);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_004_1 end ret:" << ret << std::endl;
}
/**
* @tc.name: DSchedContinueEventTest_005_1
* @tc.desc: DSchedContinueEndCmd Marshal and Unmarshal
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_005_1, TestSize.Level0)
{
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_005_1 begin" << std::endl;
DSchedContinueEndCmd cmd;
cmd.version_ = 0;
cmd.serviceType_ = 0;
cmd.subServiceType_ = 0;
cmd.command_ = 0;
cmd.srcDeviceId_ = "123";
cmd.srcBundleName_ = "test";
cmd.dstDeviceId_ = "test";
cmd.dstBundleName_ = "test";
cmd.continueType_ = "test";
cmd.continueByType_ = 0;
cmd.sourceMissionId_ = 0;
cmd.dmsVersion_ = 0;
cmd.result_ = 0;
std::string cmdStr;
int32_t ret = cmd.Marshal(cmdStr);
EXPECT_EQ(ret, ERR_OK);
ret = cmd.Unmarshal(cmdStr);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_005_1 end ret:" << ret << std::endl;
}
}
}

View File

@ -1,33 +0,0 @@
/*
* 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 DSCHED_CONTINUE_EVENT_TEST_H
#define DSCHED_CONTINUE_EVENT_TEST_H
#include "gtest/gtest.h"
namespace OHOS {
namespace DistributedSchedule {
class DSchedContinueEventTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
};
} // namespace DistributedSchedule
} // namespace OHOS
#endif // DSCHED_CONTINUE_EVENT_TEST_H

View File

@ -29,7 +29,6 @@ namespace DistributedSchedule {
namespace {
const std::string BASEDIR = "/data/service/el1/public/database/DistributedSchedule";
const int32_t WAITTIME = 2000;
const uint32_t DSCHED_BUFFER_SIZE = 1024;
}
void DSchedContinueTest::SetUpTestCase()
{
@ -158,10 +157,6 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_003_1, TestSize.Level0)
cmd->replyCmd_ = DSCHED_CONTINUE_INVALID_EVENT;
ret = conti->PostReplyTask(cmd);
EXPECT_EQ(ret, ERR_OK);
cmd = nullptr;
ret = conti->PostReplyTask(cmd);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_003_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
@ -203,9 +198,6 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_004_1, TestSize.Level0)
ret = conti->PostContinueSendTask(want, callerUid, status, accessToken);
EXPECT_EQ(ret, ERR_OK);
status = ERR_NONE;
ret = conti->PostContinueSendTask(want, callerUid, status, accessToken);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_004_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
@ -288,10 +280,6 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_006_1, TestSize.Level0)
conti->Init();
ret = conti->PostNotifyCompleteTask(ERR_OK);
EXPECT_EQ(ret, ERR_OK);
cmd = nullptr;
ret = conti->OnContinueEndCmd(cmd);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_006_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
@ -375,14 +363,6 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_009_1, TestSize.Level0)
int32_t ret = conti->PackStartCmd(cmd, wantParams);
EXPECT_EQ(ret, ERR_OK);
wantParams = nullptr;
ret = conti->PackStartCmd(cmd, wantParams);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
wantParams = std::make_shared<DistributedWantParams>();
conti->continueInfo_.missionId_ = 0;
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_009_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
@ -501,10 +481,6 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0014_1, TestSize.Level0)
auto data = std::make_shared<ContinueAbilityData>();
int32_t ret = conti->ExecuteContinueSend(data);
EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
data = nullptr;
ret = conti->ExecuteContinueSend(data);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0014_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
@ -558,10 +534,6 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0016_1, TestSize.Level0)
int32_t ret = conti->PackDataCmd(cmd, want, abilityInfo, callerInfo, accountInfo);
EXPECT_EQ(ret, ERR_OK);
cmd = nullptr;
ret = conti->PackDataCmd(cmd, want, abilityInfo, callerInfo, accountInfo);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0016_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
@ -587,10 +559,6 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0017_1, TestSize.Level0)
int32_t ret = conti->ExecuteContinueData(cmd);
EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
cmd = nullptr;
ret = conti->ExecuteContinueData(cmd);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0017_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
@ -615,10 +583,6 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0018_1, TestSize.Level0)
int32_t result = ERR_OK;
int32_t ret = conti->ExecuteNotifyComplete(result);
EXPECT_NE(ret, ERR_OK);
direction = CONTINUE_SOURCE;
ret = conti->ExecuteNotifyComplete(result);
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0018_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
@ -647,10 +611,6 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0019_1, TestSize.Level0)
int32_t ret = conti->PackReplyCmd(cmd, replyCmd, appVersion, result, "");
EXPECT_EQ(ret, ERR_OK);
cmd = nullptr;
ret = conti->PackReplyCmd(cmd, replyCmd, appVersion, result, "");
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0019_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
@ -700,10 +660,6 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0021_1, TestSize.Level0)
int32_t result = 0;
int32_t ret = conti->ExecuteContinueError(result);
EXPECT_EQ(ret, ERR_OK);
direction = CONTINUE_SOURCE;
ret = conti->ExecuteContinueError(result);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0021_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
@ -730,10 +686,6 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0022_1, TestSize.Level0)
int32_t ret = conti->PackEndCmd(cmd, result);
EXPECT_EQ(ret, ERR_OK);
cmd = nullptr;
ret = conti->PackEndCmd(cmd, result);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0022_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
@ -802,29 +754,9 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0025_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
bool ret = conti->CheckDeviceIdFromRemote("", "", "");
EXPECT_FALSE(ret);
std::string localDevId = "localDevId";
std::string destDevId = "destDevId";
std::string srcDevId = "srcDevId";
ret = conti->CheckDeviceIdFromRemote(localDevId, destDevId, srcDevId);
EXPECT_FALSE(ret);
destDevId = "localDevId";
srcDevId = "localDevId";
ret = conti->CheckDeviceIdFromRemote(localDevId, destDevId, srcDevId);
EXPECT_FALSE(ret);
conti->continueInfo_.sourceDeviceId_ = "localDevId";
ret = conti->CheckDeviceIdFromRemote(localDevId, destDevId, srcDevId);
EXPECT_FALSE(ret);
srcDevId = "srcDevId";
conti->continueInfo_.sourceDeviceId_ = "srcDevId";
ret = conti->CheckDeviceIdFromRemote(localDevId, destDevId, srcDevId);
EXPECT_TRUE(ret);
int32_t ret = conti->CheckDeviceIdFromRemote("", "", "");
EXPECT_EQ(ret, false);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0025_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
@ -953,102 +885,5 @@ HWTEST_F(DSchedContinueTest, UpdateWantForContinueTypeTest_0030_1, TestSize.Leve
DTEST_LOG << "DSchedContinueTest UpdateWantForContinueTypeTest_0030_1 end ret:" << ret << std::endl;
usleep(WAITTIME);
}
/**
* @tc.name: DSchedContinueTest_031_1
* @tc.desc: DSchedContinue
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueTest, DSchedContinueTest_031_1, TestSize.Level0)
{
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_031_1 begin" << std::endl;
std::string deviceId = "123";
std::string bundleName = "test";
int32_t subType = CONTINUE_PULL;
int32_t direction = CONTINUE_SINK;
sptr<IRemoteObject> callback = nullptr;
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
AppExecFwk::InnerEvent *event = nullptr;
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
conti->ProcessEvent(AppExecFwk::InnerEvent::Pointer(event, destructor));
conti->continueInfo_.continueType_ = "";
conti->CheckQuickStartConfiguration();
conti->GetSessionId();
conti->GetAbilityNameByContinueType();
EXPECT_NE(nullptr, conti->stateMachine_);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_031_1 end" << std::endl;
usleep(WAITTIME);
}
/**
* @tc.name: OnDataRecvTest_032_1
* @tc.desc: OnDataRecv
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueTest, OnDataRecvTest_032_1, TestSize.Level0)
{
DTEST_LOG << "DSchedContinueTest OnDataRecvTest_032_1 begin" << std::endl;
std::string deviceId = "123";
std::string bundleName = "test";
int32_t subType = CONTINUE_PULL;
int32_t direction = CONTINUE_SINK;
sptr<IRemoteObject> callback = nullptr;
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
int32_t command = 0;
std::shared_ptr<DSchedDataBuffer> dataBuffer = nullptr;
conti->OnDataRecv(command, dataBuffer);
EXPECT_EQ(nullptr, dataBuffer);
command = DSCHED_CONTINUE_CMD_START;
dataBuffer = std::make_shared<DSchedDataBuffer>(DSCHED_BUFFER_SIZE);
conti->OnDataRecv(command, dataBuffer);
EXPECT_NE(nullptr, dataBuffer);
command = DSCHED_CONTINUE_CMD_DATA;
conti->OnDataRecv(command, dataBuffer);
EXPECT_NE(nullptr, dataBuffer);
command = DSCHED_CONTINUE_CMD_REPLY;
conti->OnDataRecv(command, dataBuffer);
EXPECT_NE(nullptr, dataBuffer);
command = DSCHED_CONTINUE_CMD_END;
conti->OnDataRecv(command, dataBuffer);
EXPECT_NE(nullptr, dataBuffer);
command = DSCHED_CONTINUE_CMD_MIN;
conti->OnDataRecv(command, dataBuffer);
EXPECT_NE(nullptr, dataBuffer);
DTEST_LOG << "DSchedContinueTest OnDataRecvTest_032_1 end" << std::endl;
usleep(WAITTIME);
}
/**
* @tc.name: UpdateStateTest_033_1
* @tc.desc: UpdateState
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueTest, UpdateStateTest_033_1, TestSize.Level0)
{
DTEST_LOG << "DSchedContinueTest UpdateStateTest_033_1 begin" << std::endl;
std::string deviceId = "123";
std::string bundleName = "test";
int32_t subType = CONTINUE_PULL;
int32_t direction = CONTINUE_SINK;
sptr<IRemoteObject> callback = nullptr;
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
DSchedContinueStateType stateType = DSCHED_CONTINUE_SINK_START_STATE;
conti->UpdateState(stateType);
EXPECT_NE(nullptr, conti->stateMachine_);
DTEST_LOG << "DSchedContinueTest UpdateStateTest_033_1 end" << std::endl;
}
}
}
}

View File

@ -630,7 +630,7 @@ HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener002, TestSize.Level1)
if (proxy == nullptr) {
return;
}
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
auto ret = proxy->RegisterMissionListener(U16DEVICE_ID, listener);
EXPECT_TRUE(ret != ERR_NONE);
@ -658,7 +658,7 @@ HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener002, TestSize.Level1)
HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener003, TestSize.Level3)
{
DTEST_LOG << "testRegisterMissionListener003 begin" << std::endl;
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
auto ret = DistributedSchedMissionManager::GetInstance().RegisterMissionListener(u"", listener);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "testRegisterMissionListener003 end" << std::endl;
@ -672,7 +672,7 @@ HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener003, TestSize.Level3)
HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener004, TestSize.Level3)
{
DTEST_LOG << "testRegisterMissionListener004 begin" << std::endl;
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_["1234567"] = DEVICE_ID;
auto ret = DistributedSchedMissionManager::GetInstance().RegisterMissionListener(U16DEVICE_ID, listener);
EXPECT_EQ(ret, ERR_NONE);
@ -731,7 +731,7 @@ HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener008, TestSize.Level3)
{
DTEST_LOG << "testRegisterMissionListener008 begin" << std::endl;
u16string deviceId = Str8ToStr16(localDeviceId_);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
auto ret = DistributedSchedMissionManager::GetInstance().RegisterMissionListener(deviceId, listener);
EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
DTEST_LOG << "testRegisterMissionListener008 end" << std::endl;
@ -766,7 +766,7 @@ HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener001, TestSize.Level
HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener002, TestSize.Level3)
{
DTEST_LOG << "testUnRegisterMissionListener002 begin" << std::endl;
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
auto ret = DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(U16DEVICE_ID, listener);
EXPECT_EQ(ret, ERR_NONE);
DTEST_LOG << "testUnRegisterMissionListener002 end" << std::endl;
@ -808,7 +808,7 @@ HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener005, TestSize.Level
{
DTEST_LOG << "testUnRegisterMissionListener005 begin" << std::endl;
u16string deviceId = Str8ToStr16(localDeviceId_);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
auto ret = DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(deviceId, listener);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "testUnRegisterMissionListener005 end" << std::endl;
@ -1309,7 +1309,7 @@ HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedFromRemote002, TestSize
callerInfo.dmsVersion = 0;
std::vector<DstbMissionInfo> missionInfos;
DistributedSchedMissionManager::GetInstance().Init();
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
auto& listenerInfo = DistributedSchedMissionManager::GetInstance().listenDeviceMap_[U16DEVICE_ID];
EXPECT_EQ(listenerInfo.Emplace(listener), true);
auto ret = DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedFromRemote(callerInfo, missionInfos);
@ -1762,7 +1762,7 @@ HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener009, TestSize.Level3)
lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = localDeviceId_;
}
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
auto ret = DistributedSchedMissionManager::GetInstance().RegisterMissionListener(deviceId, listener);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "testRegisterMissionListener009 end" << std::endl;
@ -1784,7 +1784,7 @@ HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener010, TestSize.Level3)
lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = DEVICE_ID;
}
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
ListenerInfo listenerInfo;
@ -2141,8 +2141,8 @@ HWTEST_F(DMSMissionManagerTest, testDeviceOfflineNotify003, TestSize.Level3)
DTEST_LOG << "testDeviceOfflineNotify003 begin" << std::endl;
DistributedSchedMissionManager::GetInstance().Init();
DistributedSchedMissionManager::GetInstance().DeviceOnlineNotify(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IDistributedSched> remoteDmsObj(new DistributedSchedProxy(listener));
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
sptr<IDistributedSched> remoteDmsObj = new DistributedSchedProxy(listener);
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
@ -2164,7 +2164,7 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions015, TestSize.Level3)
{
DTEST_LOG << "testStartSyncRemoteMissions015 begin" << std::endl;
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -2202,7 +2202,7 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions016, TestSize.Level3)
{
DTEST_LOG << "testStartSyncRemoteMissions016 begin" << std::endl;
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -2246,7 +2246,7 @@ HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener006, TestSize.Level
DistributedSchedMissionManager::GetInstance().DeviceOnlineNotify(DEVICE_ID);
DTEST_LOG << "testDeviceOnlineNotify001 end" << std::endl;
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -2287,7 +2287,7 @@ HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener007, TestSize.Level
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
}
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
auto deviceInfo = std::make_shared<DmsDeviceInfo>("", 0, "");
DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_[DEVICE_ID] = deviceInfo;
auto ret = DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(deviceId, listener);
@ -2334,7 +2334,7 @@ HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener008, TestSize.Level
DTEST_LOG << "testRebornMissionCache002 end" << std::endl;
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -2369,7 +2369,7 @@ HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener009, TestSize.Level
DTEST_LOG << "testFetchDeviceHandler001 end" << std::endl;
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
sptr<IRemoteObject> nullListener = nullptr;
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
@ -2553,7 +2553,7 @@ HWTEST_F(DMSMissionManagerTest, testNeedSyncDevice003, TestSize.Level3)
*/
DTEST_LOG << "testDeleteCachedSnapshotInfo001 begin" << std::endl;
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -2627,7 +2627,7 @@ HWTEST_F(DMSMissionManagerTest, testHasSyncListener002, TestSize.Level3)
DTEST_LOG << "testRebornMissionCache003 end" << std::endl;
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -2667,7 +2667,7 @@ HWTEST_F(DMSMissionManagerTest, testDequeueCachedSnapshotInfo003, TestSize.Level
{
DTEST_LOG << "testDequeueCachedSnapshotInfo003 begin" << std::endl;
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -2741,7 +2741,7 @@ HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedFromRemote003, TestSize
callerInfo.dmsVersion = 0;
std::vector<DstbMissionInfo> missionInfos;
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -3030,7 +3030,7 @@ HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions004, TestSize.Le
auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -3057,7 +3057,7 @@ HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions005, TestSize.Le
auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -3094,7 +3094,7 @@ HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied003, TestSize.Level3)
{
DTEST_LOG << "testOnMissionListenerDied003 begin" << std::endl;
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -3119,7 +3119,7 @@ HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied004, TestSize.Level3)
{
DTEST_LOG << "testOnMissionListenerDied004 begin" << std::endl;
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -3146,7 +3146,7 @@ HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied005, TestSize.Level3)
{
DTEST_LOG << "testOnMissionListenerDied005 begin" << std::endl;
u16string deviceId = Str8ToStr16(DEVICE_ID);
sptr<IRemoteObject> listener(new RemoteMissionListenerTest());
sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
@ -3172,8 +3172,8 @@ HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied006, TestSize.Level3)
DTEST_LOG << "testOnRemoteDmsDied006 begin" << std::endl;
auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
sptr<IRemoteObject> remote(new RemoteMissionListenerTest());
sptr<IDistributedSched> remoteDmsObj(new DistributedSchedProxy(remote));
sptr<IRemoteObject> remote = new RemoteMissionListenerTest();
sptr<IDistributedSched> remoteDmsObj = new DistributedSchedProxy(remote);
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
@ -3196,7 +3196,7 @@ HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied007, TestSize.Level3)
DTEST_LOG << "testOnRemoteDmsDied007 begin" << std::endl;
auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
sptr<IRemoteObject> remote(new RemoteMissionListenerTest());
sptr<IRemoteObject> remote = new RemoteMissionListenerTest();
sptr<IDistributedSched> proxy = GetDms();
if (proxy == nullptr) {
return;
@ -3223,8 +3223,8 @@ HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied008, TestSize.Level3)
DTEST_LOG << "testOnRemoteDmsDied008 begin" << std::endl;
auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
sptr<IRemoteObject> remote(new RemoteMissionListenerTest());
sptr<IDistributedSched> remoteDmsObj(new DistributedSchedProxy(remote));
sptr<IRemoteObject> remote = new RemoteMissionListenerTest();
sptr<IDistributedSched> remoteDmsObj = new DistributedSchedProxy(remote);
{
std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();

View File

@ -46,7 +46,7 @@ uint32_t GetU32Data(const uint8_t* ptr, size_t size)
if (size > FOO_MAX_LEN || size < U32_AT_SIZE) {
return 0;
}
char *ch = (char *)malloc(size + 1);
char *ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;

View File

@ -22,36 +22,37 @@ namespace OHOS {
namespace DistributedSchedule {
void FuzzApplyAdvanceResource(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size < sizeof(uint32_t))) {
if ((data == nullptr) || (size < sizeof(size_t))) {
return;
}
const std::string peerNetworkId(reinterpret_cast<const char*>(data), size);
ServiceCollaborationManager_ResourceRequestInfoSets reqInfoSets;
reqInfoSets.remoteHardwareListSize = *(reinterpret_cast<const uint32_t*>(data));
reqInfoSets.localHardwareListSize = *(reinterpret_cast<const uint32_t*>(data));
uint8_t* data1 = const_cast<uint8_t*>(data);
ServiceCollaborationManager_ResourceRequestInfoSets reqInfoSets =
*(reinterpret_cast<ServiceCollaborationManager_ResourceRequestInfoSets*>(data1));
DSchedAllConnectManager::GetInstance().ApplyAdvanceResource(peerNetworkId, reqInfoSets);
}
void FuzzGetResourceRequest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size < sizeof(uint32_t))) {
if ((data == nullptr) || (size < sizeof(size_t))) {
return;
}
ServiceCollaborationManager_ResourceRequestInfoSets reqInfoSets;
reqInfoSets.remoteHardwareListSize = *(reinterpret_cast<const uint32_t*>(data));
reqInfoSets.localHardwareListSize = *(reinterpret_cast<const uint32_t*>(data));
uint8_t* data2 = const_cast<uint8_t*>(data);
ServiceCollaborationManager_ResourceRequestInfoSets reqInfoSets =
*(reinterpret_cast<ServiceCollaborationManager_ResourceRequestInfoSets*>(data2));
DSchedAllConnectManager::GetInstance().GetResourceRequest(reqInfoSets);
}
void FuzzPublishServiceState(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size < sizeof(uint32_t))) {
if ((data == nullptr) || (size < sizeof(size_t))) {
return;
}
const std::string peerNetworkId(reinterpret_cast<const char*>(data), size);
const std::string extraInfo(reinterpret_cast<const char*>(data), size);
uint8_t* temp = const_cast<uint8_t*>(data);
ServiceCollaborationManagerBussinessStatus state =
*(reinterpret_cast<const ServiceCollaborationManagerBussinessStatus*>(data));
*(reinterpret_cast<ServiceCollaborationManagerBussinessStatus*>(temp));
DSchedAllConnectManager::GetInstance().PublishServiceState(peerNetworkId, extraInfo, state);
}
}

View File

@ -25,9 +25,6 @@ namespace OHOS {
namespace DistributedSchedule {
void FuzzOnBytesReceived(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size < sizeof(int32_t))) {
return;
}
std::shared_ptr<DSchedDataBuffer> buffer = std::make_shared<DSchedDataBuffer>(size);
DSchedSoftbusSession dschedSoftbusSession;
dschedSoftbusSession.OnBytesReceived(buffer);

View File

@ -18,7 +18,7 @@
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<max_total_time>20</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>