!2464 open权限及接口修改

Merge pull request !2464 from 郑晓晴/master
This commit is contained in:
openharmony_ci 2024-11-22 10:20:06 +00:00 committed by Gitee
commit b9d36893ba
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 103 additions and 19 deletions

View File

@ -82,12 +82,17 @@ struct AsyncDownloadableProfile {
std::vector<AsyncAccessRule> accessRules{}; std::vector<AsyncAccessRule> accessRules{};
}; };
struct AsyncDownloadConfiguration {
bool switchAfterDownload = false;
bool forceDisableProfile = false;
bool isPprAllowed = false;
};
struct AsyncDownloadProfileInfo { struct AsyncDownloadProfileInfo {
AsyncContext<napi_value> asyncContext; AsyncContext<napi_value> asyncContext;
int32_t portIndex = ERROR_DEFAULT; int32_t portIndex = ERROR_DEFAULT;
AsyncDownloadableProfile profile; AsyncDownloadableProfile profile;
bool switchAfterDownload = false; AsyncDownloadConfiguration configuration;
bool forceDisableProfile = false;
DownloadProfileResult result; DownloadProfileResult result;
}; };

View File

@ -408,6 +408,24 @@ void ProfileInfoAnalyze(napi_env env, napi_value arg, AsyncDownloadableProfile &
} }
} }
void ConfigurationInfoAnalyze(napi_env env, napi_value arg, AsyncDownloadConfiguration &configuration)
{
napi_value switchState = NapiUtil::GetNamedProperty(env, arg, "switchAfterDownload");
if (switchState) {
NapiValueToCppValue(env, switchState, napi_boolean, &configuration.switchAfterDownload);
}
napi_value forceState = NapiUtil::GetNamedProperty(env, arg, "forceDisableProfile");
if (forceState) {
NapiValueToCppValue(env, forceState, napi_boolean, &configuration.forceDisableProfile);
}
napi_value alowState = NapiUtil::GetNamedProperty(env, arg, "isPprAllowed");
if (alowState) {
NapiValueToCppValue(env, alowState, napi_boolean, &configuration.isPprAllowed);
}
}
ResetOption GetDefaultResetOption(void) ResetOption GetDefaultResetOption(void)
{ {
return ResetOption::DELETE_OPERATIONAL_PROFILES; return ResetOption::DELETE_OPERATIONAL_PROFILES;
@ -901,8 +919,9 @@ void NativeDownloadProfile(napi_env env, void *data)
DownloadProfileResult result; DownloadProfileResult result;
DownloadProfileConfigInfo configInfo; DownloadProfileConfigInfo configInfo;
configInfo.portIndex_ = profileContext->portIndex; configInfo.portIndex_ = profileContext->portIndex;
configInfo.isSwitchAfterDownload_ = profileContext->switchAfterDownload; configInfo.isSwitchAfterDownload_ = profileContext->configuration.switchAfterDownload;
configInfo.isForceDeactivateSim_ = profileContext->forceDisableProfile; configInfo.isForceDeactivateSim_ = profileContext->configuration.forceDisableProfile;
configInfo.isPprAllowed_ = profileContext->configuration.isPprAllowed;
DownloadableProfile profile = GetProfileInfo(profileContext->profile); DownloadableProfile profile = GetProfileInfo(profileContext->profile);
int32_t errorCode = DelayedRefSingleton<EsimServiceClient>::GetInstance().DownloadProfile( int32_t errorCode = DelayedRefSingleton<EsimServiceClient>::GetInstance().DownloadProfile(
profileContext->asyncContext.slotId, configInfo, profile, result); profileContext->asyncContext.slotId, configInfo, profile, result);
@ -939,10 +958,10 @@ napi_value DownloadProfile(napi_env env, napi_callback_info info)
return nullptr; return nullptr;
} }
BaseContext &context = profileContext->asyncContext.context; BaseContext &context = profileContext->asyncContext.context;
napi_value object = NapiUtil::CreateUndefined(env); napi_value profileObject = NapiUtil::CreateUndefined(env);
auto initPara = std::make_tuple(&profileContext->asyncContext.slotId, &profileContext->portIndex, napi_value configurationObject = NapiUtil::CreateUndefined(env);
&object, &profileContext->switchAfterDownload, &profileContext->forceDisableProfile, auto initPara = std::make_tuple(&profileContext->asyncContext.slotId, &profileContext->portIndex, &profileObject,
&context.callbackRef); &configurationObject, &context.callbackRef);
AsyncPara para { AsyncPara para {
.funcName = "DownloadProfile", .funcName = "DownloadProfile",
@ -953,7 +972,8 @@ napi_value DownloadProfile(napi_env env, napi_callback_info info)
}; };
napi_value result = NapiCreateAsyncWork2<AsyncDownloadProfileInfo>(para, profileContext, initPara); napi_value result = NapiCreateAsyncWork2<AsyncDownloadProfileInfo>(para, profileContext, initPara);
if (result) { if (result) {
ProfileInfoAnalyze(env, object, profileContext->profile); ProfileInfoAnalyze(env, profileObject, profileContext->profile);
ConfigurationInfoAnalyze(env, configurationObject, profileContext->configuration);
NAPI_CALL(env, napi_queue_async_work_with_qos(env, context.work, napi_qos_default)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, context.work, napi_qos_default));
} }
return result; return result;

View File

@ -24,6 +24,7 @@ struct DownloadProfileConfigInfo : public Parcelable {
int32_t portIndex_ = 0; int32_t portIndex_ = 0;
bool isSwitchAfterDownload_ = false; bool isSwitchAfterDownload_ = false;
bool isForceDeactivateSim_ = false; bool isForceDeactivateSim_ = false;
bool isPprAllowed_ = false;
bool ReadFromParcel(Parcel &parcel); bool ReadFromParcel(Parcel &parcel);
virtual bool Marshalling(Parcel &parcel) const override; virtual bool Marshalling(Parcel &parcel) const override;

View File

@ -173,10 +173,7 @@ declare namespace eSIM {
* @param { number } slotId - Indicates the card slot index number. * @param { number } slotId - Indicates the card slot index number.
* @param { number } portIndex - Index of the port for the slot. * @param { number } portIndex - Index of the port for the slot.
* @param { DownloadableProfile } profile - The Bound Profile Package data returned by SM-DP+ server. * @param { DownloadableProfile } profile - The Bound Profile Package data returned by SM-DP+ server.
* @param { boolean } switchAfterDownload - Indicates whether to enable profile after successful download. * @param { DownloadConfiguration } configuration - Configuration information during downloading.
* @param { boolean } forceDisableProfile - If true, the active profile must be disabled in order to perform the
* operation. Otherwise, the resultCode should return {@link RESULT_MUST_DISABLE_PROFILE} to allow
* the user to agree to this operation first.
* @returns { Promise<DownloadProfileResult> } Return the given downloadableProfile. * @returns { Promise<DownloadProfileResult> } Return the given downloadableProfile.
* @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs. * @throws { BusinessError } 202 - Non-system applications use system APIs.
@ -190,7 +187,7 @@ declare namespace eSIM {
* @since 14 * @since 14
*/ */
function downloadProfile(slotId: number, portIndex: number, profile: DownloadableProfile, function downloadProfile(slotId: number, portIndex: number, profile: DownloadableProfile,
switchAfterDownload: boolean, forceDisableProfile: boolean): Promise<DownloadProfileResult>; configuration: DownloadConfiguration): Promise<DownloadProfileResult>;
/** /**
* Returns a list of all eUICC profile information. * Returns a list of all eUICC profile information.
@ -254,7 +251,7 @@ declare namespace eSIM {
/** /**
* Switch to (enable) the given profile on the eUICC. * Switch to (enable) the given profile on the eUICC.
* *
* @permission ohos.permission.SET_TELEPHONY_ESIM_STATE_OPEN * @permission ohos.permission.SET_TELEPHONY_ESIM_STATE
* @param { number } slotId - Indicates the card slot index number. * @param { number } slotId - Indicates the card slot index number.
* @param { number } portIndex - Index of the port for the slot. * @param { number } portIndex - Index of the port for the slot.
* @param { string } iccid - The iccid of the profile to switch to. * @param { string } iccid - The iccid of the profile to switch to.
@ -279,7 +276,7 @@ declare namespace eSIM {
/** /**
* Adds or updates the given profile nickname. * Adds or updates the given profile nickname.
* *
* @permission ohos.permission.SET_TELEPHONY_ESIM_STATE_OPEN * @permission ohos.permission.SET_TELEPHONY_ESIM_STATE
* @param { number } slotId - Indicates the card slot index number. * @param { number } slotId - Indicates the card slot index number.
* @param { string } iccid - The iccid of the profile. * @param { string } iccid - The iccid of the profile.
* @param { string } nickname - The nickname of the profile. * @param { string } nickname - The nickname of the profile.
@ -1248,6 +1245,15 @@ declare namespace eSIM {
*/ */
RESULT_PPR_FORBIDDEN = 268, RESULT_PPR_FORBIDDEN = 268,
/**
* Nothing is to be deleted.
*
* @syscap SystemCapability.Telephony.CoreService.Esim
* @systemapi Hide this for inner system use.
* @since 14
*/
RESULT_NOTHING_TO_DELETE = 270,
/** /**
* The profile policy rule does not match. * The profile policy rule does not match.
* *
@ -1257,6 +1263,15 @@ declare namespace eSIM {
*/ */
RESULT_PPR_NOT_MATCH = 276, RESULT_PPR_NOT_MATCH = 276,
/**
* A session is ongoing.
*
* @syscap SystemCapability.Telephony.CoreService.Esim
* @systemapi Hide this for inner system use.
* @since 14
*/
RESULT_CAT_BUSY = 283,
/** /**
* This eSIM profile is already in use or is invalid. * This eSIM profile is already in use or is invalid.
* *
@ -1478,6 +1493,49 @@ declare namespace eSIM {
*/ */
SOLVABLE_ERROR_NEED_POLICY_RULE = 1 << 1, SOLVABLE_ERROR_NEED_POLICY_RULE = 1 << 1,
} }
/**
* Specifies the download configuration.
*
* @interface DownloadConfiguration
* @syscap SystemCapability.Telephony.CoreService.Esim
* @systemapi Hide this for inner system use.
* @since 14
*/
export interface DownloadConfiguration {
/**
* Specifies whether to enable the profile after successful download.
*
* @type { boolean }
* @syscap SystemCapability.Telephony.CoreService.Esim
* @systemapi Hide this for inner system use.
* @since 14
*/
switchAfterDownload: boolean;
/**
* Specifies whether to forcibly disable the profile. If true, the active profile is disabled in order to perform
* the operation. Otherwise, {@link RESULT_MUST_DISABLE_PROFILE} is returned in resultCode to ask for the user's
* agreement to the operation.
*
* @type { boolean }
* @syscap SystemCapability.Telephony.CoreService.Esim
* @systemapi Hide this for inner system use.
* @since 14
*/
forceDisableProfile: boolean;
/**
* Specifies whether the user allows the service provider to enforce this Profile Policy Rule (PPR)
* after being informed of its restrictions.
*
* @type { boolean }
* @syscap SystemCapability.Telephony.CoreService.Esim
* @systemapi Hide this for inner system use.
* @since 14
*/
isPprAllowed: boolean;
}
} }
export default eSIM; export default eSIM;