mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-27 00:20:44 +00:00
!1164 回退:使用distributedWant代替want进行传输
Merge pull request !1164 from zhx/master
This commit is contained in:
commit
dc0fb8d657
@ -91,7 +91,6 @@ private:
|
||||
int32_t MarshalCallerInfo(std::string &jsonStr);
|
||||
int32_t MarshalAccountInfo(std::string &jsonStr);
|
||||
int32_t UnmarshalParcel(const std::string &jsonStr);
|
||||
int32_t UnmarshalWantStr(const std::string &jsonStr);
|
||||
int32_t UnmarshalCallerInfo(const std::string &jsonStr);
|
||||
int32_t UnmarshalCallerInfoExtra(const std::string &jsonStr);
|
||||
int32_t UnmarshalAccountInfo(const std::string &jsonStr);
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "cJSON.h"
|
||||
#include "parcel.h"
|
||||
|
||||
#include "distributedWant/distributed_want.h"
|
||||
#include "distributed_sched_utils.h"
|
||||
#include "dms_constant.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
@ -221,9 +220,8 @@ int32_t DSchedContinueDataCmd::Marshal(std::string &jsonStr)
|
||||
|
||||
cJSON_AddStringToObject(rootValue, "BaseCmd", baseJsonStr.c_str());
|
||||
|
||||
DistributedWant dtbWant(want_);
|
||||
Parcel wantParcel;
|
||||
if (!dtbWant.Marshalling(wantParcel)) {
|
||||
if (!want_.Marshalling(wantParcel)) {
|
||||
cJSON_Delete(rootValue);
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
@ -420,11 +418,20 @@ int32_t DSchedContinueDataCmd::UnmarshalParcel(const std::string &jsonStr)
|
||||
HILOGE("Want term is null or not string.");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
if (UnmarshalWantStr(wantStr->valuestring) != ERR_OK) {
|
||||
Parcel wantParcel;
|
||||
int32_t ret = Base64StrToParcel(wantStr->valuestring, wantParcel);
|
||||
if (ret != ERR_OK) {
|
||||
cJSON_Delete(rootValue);
|
||||
HILOGE("UnmarshalWantStr failed!");
|
||||
HILOGE("Want parcel Base64Str unmarshal fail, ret %{public}d.", ret);
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
};
|
||||
}
|
||||
auto wantPtr = AAFwk::Want::Unmarshalling(wantParcel);
|
||||
if (wantPtr == nullptr) {
|
||||
cJSON_Delete(rootValue);
|
||||
HILOGE("AAFwk Want unmarshalling fail, check return null.");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
want_ = *wantPtr;
|
||||
|
||||
cJSON *abilityInfoStr = cJSON_GetObjectItemCaseSensitive(rootValue, "AbilityInfo");
|
||||
if (abilityInfoStr == nullptr || !cJSON_IsString(abilityInfoStr) || (abilityInfoStr->valuestring == nullptr)) {
|
||||
@ -433,7 +440,7 @@ int32_t DSchedContinueDataCmd::UnmarshalParcel(const std::string &jsonStr)
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
Parcel abilityParcel;
|
||||
int32_t ret = Base64StrToParcel(abilityInfoStr->valuestring, abilityParcel);
|
||||
ret = Base64StrToParcel(abilityInfoStr->valuestring, abilityParcel);
|
||||
if (ret != ERR_OK) {
|
||||
cJSON_Delete(rootValue);
|
||||
HILOGE("AbilityInfo parcel Base64Str unmarshal fail, ret %{public}d.", ret);
|
||||
@ -451,31 +458,6 @@ int32_t DSchedContinueDataCmd::UnmarshalParcel(const std::string &jsonStr)
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t DSchedContinueDataCmd::UnmarshalWantStr(const std::string &jsonStr)
|
||||
{
|
||||
Parcel wantParcel;
|
||||
int32_t ret = Base64StrToParcel(jsonStr, wantParcel);
|
||||
if (ret != ERR_OK) {
|
||||
HILOGE("Want parcel Base64Str unmarshal fail, ret %{public}d.", ret);
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
|
||||
auto dtbWantPtr = DistributedWant::Unmarshalling(wantParcel);
|
||||
if (dtbWantPtr == nullptr) {
|
||||
HILOGE("Distributed want unmarshalling fail, check return null.");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
|
||||
DistributedWant dtbWant = *dtbWantPtr;
|
||||
auto wantPtr = dtbWant.ToWant();
|
||||
if (wantPtr == nullptr) {
|
||||
HILOGE("Convert distributedWant to want failed.");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
want_ = *wantPtr;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t DSchedContinueDataCmd::UnmarshalCallerInfo(const std::string &jsonStr)
|
||||
{
|
||||
cJSON *rootValue = cJSON_Parse(jsonStr.c_str());
|
||||
|
@ -15,8 +15,6 @@
|
||||
|
||||
#include "dsched_continue_event_test.h"
|
||||
|
||||
#include "distributedWant/distributed_want.h"
|
||||
#include "distributed_sched_utils.h"
|
||||
#include "dsched_continue_event.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "test_log.h"
|
||||
@ -218,27 +216,5 @@ HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_005_1, TestSize.Level0
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_005_1 end ret:" << ret << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DSchedContinueEventTest_006_1
|
||||
* @tc.desc: Test UnmarshalWantStr
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DSchedContinueEventTest, DSchedContinueEventTest_006_1, TestSize.Level0)
|
||||
{
|
||||
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_006_1 begin" << std::endl;
|
||||
DistributedWant dtbWant;
|
||||
Parcel wantParcel;
|
||||
ASSERT_EQ(dtbWant.Marshalling(wantParcel), true);
|
||||
std::string wantStr = ParcelToBase64Str(wantParcel);
|
||||
|
||||
DSchedContinueDataCmd cmd;
|
||||
int32_t ret = cmd.UnmarshalWantStr(wantStr);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
|
||||
ret = cmd.UnmarshalWantStr("");
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DSchedContinueEventTest DSchedContinueEventTest_006_1 end ret:" << ret << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user