1010监视意见修改

Signed-off-by: yangyang <yangyang651@h-partners.com>
This commit is contained in:
yangyang 2024-10-11 10:19:42 +08:00
parent d6fb41832e
commit cb155fc82c
18 changed files with 318 additions and 29 deletions

View File

@ -31,6 +31,7 @@ ohos_shared_library("esim") {
sources = [
"$SUBSYSTEM_DIR/core_service/frameworks/js/napi/napi_util.cpp",
"$SUBSYSTEM_DIR/core_service/frameworks/native/src/download_profile_config_info_parcel.cpp",
"$SUBSYSTEM_DIR/core_service/frameworks/native/src/download_profile_result_parcel.cpp",
"$SUBSYSTEM_DIR/core_service/frameworks/native/src/downloadable_profile_parcel.cpp",
"$SUBSYSTEM_DIR/core_service/frameworks/native/src/euicc_info_parcel.cpp",

View File

@ -20,6 +20,7 @@
#include <string>
#include <vector>
#include "base_context.h"
#include "download_profile_config_info_parcel.h"
#include "download_profile_result_parcel.h"
#include "downloadable_profile_parcel.h"
#include "esim_state_type.h"

View File

@ -839,10 +839,13 @@ void NativeDownloadProfile(napi_env env, void *data)
}
DownloadProfileResult result;
DownloadProfileConfigInfo configInfo;
configInfo.portIndex_ = profileContext->portIndex;
configInfo.isSwitchAfterDownload_ = profileContext->switchAfterDownload;
configInfo.isForceDeactivateSim_ = profileContext->forceDeactivateSim;
DownloadableProfile profile = GetProfileInfo(profileContext->profile);
int32_t errorCode = DelayedRefSingleton<EsimServiceClient>::GetInstance().DownloadProfile(
profileContext->asyncContext.slotId, profileContext->portIndex, profile,
profileContext->switchAfterDownload, profileContext->forceDeactivateSim, result);
profileContext->asyncContext.slotId, configInfo, profile, result);
TELEPHONY_LOGI("NAPI NativeDownloadProfile %{public}d", errorCode);
if (errorCode == ERROR_NONE) {
profileContext->result = result;
@ -1468,7 +1471,7 @@ napi_status InitEnumPolicyRules(napi_env env, napi_value exports)
DECLARE_NAPI_STATIC_PROPERTY("POLICY_RULE_DO_NOT_DISABLE",
GetNapiValue(env, static_cast<int32_t>(PolicyRules::POLICY_RULE_DO_NOT_DISABLE))),
DECLARE_NAPI_STATIC_PROPERTY("POLICY_RULE_DO_NOT_DELETE",
GetNapiValue(env, static_cast<int32_t>(PolicyRules::POLICY_RULE_NO_DELETE))),
GetNapiValue(env, static_cast<int32_t>(PolicyRules::POLICY_RULE_DO_NOT_DELETE))),
DECLARE_NAPI_STATIC_PROPERTY("POLICY_RULE_DELETE_AFTER_DISABLING",
GetNapiValue(env, static_cast<int32_t>(PolicyRules::POLICY_RULE_DELETE_AFTER_DISABLING))),
};

View File

@ -0,0 +1,56 @@
/*
* 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 "download_profile_config_info_parcel.h"
#include "telephony_log_wrapper.h"
namespace OHOS {
namespace Telephony {
bool DownloadProfileConfigInfo::ReadFromParcel(Parcel &parcel)
{
if (!parcel.ReadInt32(portIndex_) ||
!parcel.ReadBool(isSwitchAfterDownload_) ||
!parcel.ReadBool(isForceDeactivateSim_)) {
return false;
}
return true;
}
bool DownloadProfileConfigInfo::Marshalling(Parcel &parcel) const
{
if (!parcel.WriteInt32(portIndex_) ||
!parcel.WriteBool(isSwitchAfterDownload_) ||
!parcel.WriteBool(isForceDeactivateSim_)) {
return false;
}
return true;
}
DownloadProfileConfigInfo *DownloadProfileConfigInfo::Unmarshalling(Parcel &parcel)
{
DownloadProfileConfigInfo *info = new (std::nothrow) DownloadProfileConfigInfo();
if (info == nullptr) {
return nullptr;
}
if (!info->ReadFromParcel(parcel)) {
TELEPHONY_LOGE("DownloadProfileConfigInfo:read from parcel failed");
delete info;
info = nullptr;
}
return info;
}
} // namespace OHOS
} // namespace Telephony

View File

@ -19,7 +19,7 @@
namespace OHOS {
namespace Telephony {
constexpr int32_t MAX_SIZE = 1000;
constexpr uint32_t MAX_SIZE = 1000;
bool DownloadableProfile::ReadFromParcel(Parcel &parcel)
{
if (!parcel.ReadString16(encodedActivationCode_) || !parcel.ReadString16(confirmationCode_) ||

View File

@ -199,16 +199,15 @@ int32_t EsimServiceClient::GetDownloadableProfiles(
return proxy->GetDownloadableProfiles(slotId, portIndex, forceDeactivateSim, profileListResult);
}
int32_t EsimServiceClient::DownloadProfile(int32_t slotId, int32_t portIndex, const DownloadableProfile &profile,
bool switchAfterDownload, bool forceDeactivateSim, DownloadProfileResult &downloadProfileResult)
int32_t EsimServiceClient::DownloadProfile(int32_t slotId, DownloadProfileConfigInfo configInfo,
const DownloadableProfile &profile, DownloadProfileResult &downloadProfileResult)
{
auto proxy = GetProxy();
if (proxy == nullptr) {
TELEPHONY_LOGE("proxy is null!");
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
return proxy->DownloadProfile(slotId, portIndex, profile, switchAfterDownload, forceDeactivateSim,
downloadProfileResult);
return proxy->DownloadProfile(slotId, configInfo, profile, downloadProfileResult);
}
int32_t EsimServiceClient::GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListResult &euiccProfileInfoList)

View File

@ -19,7 +19,7 @@
namespace OHOS {
namespace Telephony {
constexpr int32_t MAX_SIZE = 1000;
constexpr uint32_t MAX_SIZE = 1000;
bool GetDownloadableProfilesResult::ReadFromParcel(Parcel &parcel)
{
int32_t resultValue;

View File

@ -19,7 +19,7 @@
namespace OHOS {
namespace Telephony {
constexpr int32_t MAX_SIZE = 1000;
constexpr uint32_t MAX_SIZE = 1000;
bool GetEuiccProfileInfoListResult::ReadProfileFromParcel(Parcel &parcel, EuiccProfile &profile)
{
int32_t stateValue;
@ -38,7 +38,7 @@ bool GetEuiccProfileInfoListResult::ReadProfileFromParcel(Parcel &parcel, EuiccP
profile.policyRules_ = static_cast<PolicyRules>(policyRulesValue);
uint32_t count;
if (!parcel.ReadUint32(count) || count > MAX_SIZE) {
if (!parcel.ReadUint32(count)) {
return false;
}
if (count > MAX_SIZE) {

View File

@ -19,7 +19,7 @@
namespace OHOS {
namespace Telephony {
constexpr int32_t MAX_SIZE = 1000;
constexpr uint32_t MAX_SIZE = 1000;
bool GetDownloadableProfileMetadataResult::ReadFromParcel(Parcel &parcel)
{
if (!parcel.ReadString16(downloadableProfiles_.encodedActivationCode_) ||

View File

@ -91,6 +91,7 @@ ohos_shared_library("tel_core_service_api") {
if (core_service_support_esim) {
sources += [
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/download_profile_config_info_parcel.cpp",
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/download_profile_result_parcel.cpp",
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/downloadable_profile_parcel.cpp",
"$TELEPHONY_FRAMEWORKS_NATIVE_ROOT/src/esim_service_client.cpp",

View File

@ -12,9 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
sequenceable download_profile_result_parcel..OHOS.Telephony.EuiccInfo;
sequenceable download_profile_config_info_parcel..OHOS.Telephony.DownloadProfileConfigInfo;
sequenceable download_profile_result_parcel..OHOS.Telephony.DownloadableProfile;
sequenceable downloadable_profile_parcel..OHOS.Telephony.DownloadProfileResult;
sequenceable euicc_info_parcel..OHOS.Telephony.DownloadableProfile;
sequenceable euicc_info_parcel..OHOS.Telephony.EuiccInfo;
sequenceable get_downloadable_profiles_result_parcel..OHOS.Telephony.GetDownloadableProfileMetadataResult;
sequenceable profile_info_list_parcel..OHOS.Telephony.GetDownloadableProfilesResult;
sequenceable profile_metadata_result_parcel..OHOS.Telephony.GetEuiccProfileInfoListResult;
@ -37,10 +38,8 @@ interface OHOS.Telephony.IEsimService {
[out] GetDownloadableProfilesResult profileListResult);
void DownloadProfile(
[in] int slotId,
[in] int portIndex,
[in] DownloadProfileConfigInfo configInfo,
[in] DownloadableProfile profile,
[in] boolean switchAfterDownload,
[in] boolean forceDeactivateSim,
[out] DownloadProfileResult downloadProfileResult);
void GetEuiccProfileInfoList([in] int slotId, [out] GetEuiccProfileInfoListResult euiccProfileInfoList);
void GetEuiccInfo([in] int slotId, [out] EuiccInfo eUiccInfo);

View File

@ -0,0 +1,34 @@
/*
* 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_DOWNLOAD_PROFILE_CONFIG_INFO_PARCEL_H
#define OHOS_DOWNLOAD_PROFILE_CONFIG_INFO_PARCEL_H
#include <parcel.h>
namespace OHOS {
namespace Telephony {
struct DownloadProfileConfigInfo : public Parcelable {
int32_t portIndex_ = 0;
bool isSwitchAfterDownload_ = false;
bool isForceDeactivateSim_ = false;
bool ReadFromParcel(Parcel &parcel);
virtual bool Marshalling(Parcel &parcel) const override;
static DownloadProfileConfigInfo *Unmarshalling(Parcel &parcel);
};
} // namespace Telephony
} // namespace OHOS
#endif // OHOS_DOWNLOAD_PROFILE_CONFIG_INFO_PARCEL_H

View File

@ -100,16 +100,13 @@ public:
* @brief Attempt to download the given downloadable Profile.
*
* @param slotId[in], indicates the card slot index number.
* @param portIndex[in], index of the port from the slot.
* @param configInfo[in], downloadprofile config info.
* @param profile[in], the Bound Profile Package data returned by SM-DP+ server.
* @param switchAfterDownload[in], indicates whether to enable profile after successful download.
* @param forceDeactivateSim[in], If true, and if an active SIM must be deactivated to access the eUICC,
* perform this action automatically.
* @param downloadProfileResult[out], the given downloadableProfile.
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
*/
int32_t DownloadProfile(int32_t slotId, int32_t portIndex, const DownloadableProfile &profile,
bool switchAfterDownload, bool forceDeactivateSim, DownloadProfileResult &downloadProfileResult);
int32_t DownloadProfile(int32_t slotId, DownloadProfileConfigInfo configInfo, const DownloadableProfile &profile,
DownloadProfileResult &downloadProfileResult);
/**
* @brief Get a list of all euiccProfile informations.

View File

@ -88,7 +88,7 @@ enum class ProfileClass {
*/
enum class PolicyRules {
POLICY_RULE_DO_NOT_DISABLE = 1,
POLICY_RULE_NO_DELETE = 1 << 1,
POLICY_RULE_DO_NOT_DELETE = 1 << 1,
POLICY_RULE_DELETE_AFTER_DISABLING = 1 << 2,
};

View File

@ -21,6 +21,7 @@ ohos_unittest("esim_service_client_branch_gtest") {
module_out_path = part_name + "/" + test_module
sources = [
"$SOURCE_DIR/frameworks/native/src/download_profile_config_info_parcel.cpp",
"$SOURCE_DIR/frameworks/native/src/download_profile_result_parcel.cpp",
"$SOURCE_DIR/frameworks/native/src/downloadable_profile_parcel.cpp",
"$SOURCE_DIR/frameworks/native/src/euicc_info_parcel.cpp",

View File

@ -114,16 +114,14 @@ HWTEST_F(EsimServiceClientBranchTest, GetDownloadableProfiles_0001, Function | M
HWTEST_F(EsimServiceClientBranchTest, DownloadProfile_0001, Function | MediumTest | Level1)
{
int32_t portIndex = 0;
DownloadProfileConfigInfo configInfo;
DownloadableProfile profile;
bool switchAfterDownload = false;
bool forceDeactivateSim = false;
DownloadProfileResult downloadProfileResult;
EXPECT_CALL(*samgr, LoadSystemAbility(testing::_,
testing::A<const sptr<ISystemAbilityLoadCallback>&>())).WillOnce(testing::Return(-1));
int32_t result = EsimServiceClient::GetInstance().DownloadProfile(
SLOT_ID, portIndex, profile, switchAfterDownload, forceDeactivateSim, downloadProfileResult);
SLOT_ID, configInfo, profile, downloadProfileResult);
EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
}

View File

@ -21,7 +21,7 @@ ohos_unittest("parcel_gtest") {
module_out_path = part_name + "/" + test_module
sources = [
"$SOURCE_DIR/frameworks/native/src/download_profile_result_parcel.cpp",
"$SOURCE_DIR/frameworks/native/src/download_profile_config_info_parcel.cpp",
"$SOURCE_DIR/frameworks/native/src/downloadable_profile_parcel.cpp",
"$SOURCE_DIR/frameworks/native/src/euicc_info_parcel.cpp",
"$SOURCE_DIR/frameworks/native/src/get_downloadable_profiles_result_parcel.cpp",
@ -29,6 +29,7 @@ ohos_unittest("parcel_gtest") {
"$SOURCE_DIR/frameworks/native/src/profile_metadata_result_parcel.cpp",
"$SOURCE_DIR/frameworks/native/src/response_esim_result.cpp",
"$SOURCE_DIR/test/unittest/esim_parcel_gtest/mock/src/parcel.cpp",
"download_profile_config_info_parcel_test.cpp",
"download_profile_result_parcel_test.cpp",
"downloadable_profile_parcel_test.cpp",
"euicc_info_parcel_test.cpp",

View File

@ -0,0 +1,198 @@
/*
* 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 <gtest/gtest.h>
#include "parcel.h"
#include "download_profile_config_info_parcel.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Telephony {
class DownloadProfileConfigInfoTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void DownloadProfileConfigInfoTest::SetUpTestCase(void) {}
void DownloadProfileConfigInfoTest::TearDownTestCase(void) {}
void DownloadProfileConfigInfoTest::SetUp() {}
void DownloadProfileConfigInfoTest::TearDown() {}
HWTEST_F(DownloadProfileConfigInfoTest, ReadFromParcel_0100, Function | MediumTest | Level1)
{
DownloadProfileConfigInfo info;
Parcel parcel;
std::list<bool> readBoolList;
readBoolList.push_back(true);
readBoolList.push_back(true);
MockReadBool(true, &readBoolList);
MockReadInt32(true);
EXPECT_TRUE(info.ReadFromParcel(parcel));
ResetParcelState();
}
HWTEST_F(DownloadProfileConfigInfoTest, ReadFromParcel_0200, Function | MediumTest | Level1)
{
DownloadProfileConfigInfo info;
Parcel parcel;
std::list<bool> readBoolList;
readBoolList.push_back(true);
readBoolList.push_back(true);
MockReadBool(true, &readBoolList);
MockReadInt32(false);
EXPECT_TRUE(info.ReadFromParcel(parcel));
ResetParcelState();
}
HWTEST_F(DownloadProfileConfigInfoTest, ReadFromParcel_0300, Function | MediumTest | Level1)
{
DownloadProfileConfigInfo info;
Parcel parcel;
std::list<bool> readBoolList;
readBoolList.push_back(false);
readBoolList.push_back(true);
MockReadBool(true, &readBoolList);
MockReadInt32(true);
EXPECT_TRUE(info.ReadFromParcel(parcel));
ResetParcelState();
}
HWTEST_F(DownloadProfileConfigInfoTest, ReadFromParcel_0400, Function | MediumTest | Level1)
{
DownloadProfileConfigInfo info;
Parcel parcel;
std::list<bool> readBoolList;
readBoolList.push_back(true);
readBoolList.push_back(false);
MockReadBool(true, &readBoolList);
MockReadInt32(true);
EXPECT_TRUE(info.ReadFromParcel(parcel));
ResetParcelState();
}
HWTEST_F(DownloadProfileConfigInfoTest, Marshalling_0100, Function | MediumTest | Level1)
{
DownloadProfileConfigInfo info;
Parcel parcel;
std::list<bool> writeBoolList;
writeBoolList.push_back(true);
writeBoolList.push_back(true);
MockWriteBool(true, &writeBoolList);
MockWriteInt32(true);
EXPECT_TRUE(info.Marshalling(parcel));
ResetParcelState();
}
HWTEST_F(DownloadProfileConfigInfoTest, Marshalling_0200, Function | MediumTest | Level1)
{
DownloadProfileConfigInfo info;
Parcel parcel;
std::list<bool> writeBoolList;
writeBoolList.push_back(true);
writeBoolList.push_back(true);
MockWriteBool(true, &writeBoolList);
MockWriteInt32(false);
EXPECT_TRUE(info.Marshalling(parcel));
ResetParcelState();
}
HWTEST_F(DownloadProfileConfigInfoTest, Marshalling_0300, Function | MediumTest | Level1)
{
DownloadProfileConfigInfo info;
Parcel parcel;
std::list<bool> writeBoolList;
writeBoolList.push_back(false);
writeBoolList.push_back(true);
MockWriteBool(true, &writeBoolList);
MockWriteInt32(true);
EXPECT_TRUE(info.Marshalling(parcel));
ResetParcelState();
}
HWTEST_F(DownloadProfileConfigInfoTest, Marshalling_0400, Function | MediumTest | Level1)
{
DownloadProfileConfigInfo info;
Parcel parcel;
std::list<bool> writeBoolList;
writeBoolList.push_back(true);
writeBoolList.push_back(false);
MockWriteBool(true, &writeBoolList);
MockWriteInt32(true);
EXPECT_TRUE(info.Marshalling(parcel));
ResetParcelState();
}
HWTEST_F(DownloadProfileConfigInfoTest, Unmarshalling_0100, Function | MediumTest | Level1)
{
DownloadProfileConfigInfo info;
Parcel parcel;
std::list<bool> readBoolList;
readBoolList.push_back(true);
readBoolList.push_back(true);
MockReadBool(true, &readBoolList);
MockReadInt32(true);
EXPECT_NE(info.Unmarshalling(parcel), nullptr);
ResetParcelState();
}
HWTEST_F(DownloadProfileConfigInfoTest, Unmarshalling_0200, Function | MediumTest | Level1)
{
DownloadProfileConfigInfo info;
Parcel parcel;
std::list<bool> readBoolList;
readBoolList.push_back(true);
readBoolList.push_back(true);
MockReadBool(true, &readBoolList);
MockReadInt32(false);
EXPECT_EQ(info.Unmarshalling(parcel), nullptr);
ResetParcelState();
}
HWTEST_F(DownloadProfileConfigInfoTest, Unmarshalling_0300, Function | MediumTest | Level1)
{
DownloadProfileConfigInfo info;
Parcel parcel;
std::list<bool> readBoolList;
readBoolList.push_back(false);
readBoolList.push_back(true);
MockReadBool(true, &readBoolList);
MockReadInt32(true);
EXPECT_EQ(info.Unmarshalling(parcel), nullptr);
ResetParcelState();
}
HWTEST_F(DownloadProfileConfigInfoTest, Unmarshalling_0400, Function | MediumTest | Level1)
{
DownloadProfileConfigInfo info;
Parcel parcel;
std::list<bool> readBoolList;
readBoolList.push_back(true);
readBoolList.push_back(false);
MockReadBool(true, &readBoolList);
MockReadInt32(true);
EXPECT_EQ(info.Unmarshalling(parcel), nullptr);
ResetParcelState();
}
} // namespace Telephony
} // namespace OHOS