mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-23 08:00:07 +00:00
commit
b9d36893ba
@ -82,12 +82,17 @@ struct AsyncDownloadableProfile {
|
||||
std::vector<AsyncAccessRule> accessRules{};
|
||||
};
|
||||
|
||||
struct AsyncDownloadConfiguration {
|
||||
bool switchAfterDownload = false;
|
||||
bool forceDisableProfile = false;
|
||||
bool isPprAllowed = false;
|
||||
};
|
||||
|
||||
struct AsyncDownloadProfileInfo {
|
||||
AsyncContext<napi_value> asyncContext;
|
||||
int32_t portIndex = ERROR_DEFAULT;
|
||||
AsyncDownloadableProfile profile;
|
||||
bool switchAfterDownload = false;
|
||||
bool forceDisableProfile = false;
|
||||
AsyncDownloadConfiguration configuration;
|
||||
DownloadProfileResult result;
|
||||
};
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
return ResetOption::DELETE_OPERATIONAL_PROFILES;
|
||||
@ -901,8 +919,9 @@ void NativeDownloadProfile(napi_env env, void *data)
|
||||
DownloadProfileResult result;
|
||||
DownloadProfileConfigInfo configInfo;
|
||||
configInfo.portIndex_ = profileContext->portIndex;
|
||||
configInfo.isSwitchAfterDownload_ = profileContext->switchAfterDownload;
|
||||
configInfo.isForceDeactivateSim_ = profileContext->forceDisableProfile;
|
||||
configInfo.isSwitchAfterDownload_ = profileContext->configuration.switchAfterDownload;
|
||||
configInfo.isForceDeactivateSim_ = profileContext->configuration.forceDisableProfile;
|
||||
configInfo.isPprAllowed_ = profileContext->configuration.isPprAllowed;
|
||||
DownloadableProfile profile = GetProfileInfo(profileContext->profile);
|
||||
int32_t errorCode = DelayedRefSingleton<EsimServiceClient>::GetInstance().DownloadProfile(
|
||||
profileContext->asyncContext.slotId, configInfo, profile, result);
|
||||
@ -939,10 +958,10 @@ napi_value DownloadProfile(napi_env env, napi_callback_info info)
|
||||
return nullptr;
|
||||
}
|
||||
BaseContext &context = profileContext->asyncContext.context;
|
||||
napi_value object = NapiUtil::CreateUndefined(env);
|
||||
auto initPara = std::make_tuple(&profileContext->asyncContext.slotId, &profileContext->portIndex,
|
||||
&object, &profileContext->switchAfterDownload, &profileContext->forceDisableProfile,
|
||||
&context.callbackRef);
|
||||
napi_value profileObject = NapiUtil::CreateUndefined(env);
|
||||
napi_value configurationObject = NapiUtil::CreateUndefined(env);
|
||||
auto initPara = std::make_tuple(&profileContext->asyncContext.slotId, &profileContext->portIndex, &profileObject,
|
||||
&configurationObject, &context.callbackRef);
|
||||
|
||||
AsyncPara para {
|
||||
.funcName = "DownloadProfile",
|
||||
@ -953,7 +972,8 @@ napi_value DownloadProfile(napi_env env, napi_callback_info info)
|
||||
};
|
||||
napi_value result = NapiCreateAsyncWork2<AsyncDownloadProfileInfo>(para, profileContext, initPara);
|
||||
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));
|
||||
}
|
||||
return result;
|
||||
|
@ -24,6 +24,7 @@ struct DownloadProfileConfigInfo : public Parcelable {
|
||||
int32_t portIndex_ = 0;
|
||||
bool isSwitchAfterDownload_ = false;
|
||||
bool isForceDeactivateSim_ = false;
|
||||
bool isPprAllowed_ = false;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
78
interfaces/kits/js/@ohos.telephony.esim.d.ts
vendored
78
interfaces/kits/js/@ohos.telephony.esim.d.ts
vendored
@ -173,10 +173,7 @@ declare namespace eSIM {
|
||||
* @param { number } slotId - Indicates the card slot index number.
|
||||
* @param { number } portIndex - Index of the port for the slot.
|
||||
* @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 { 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.
|
||||
* @param { DownloadConfiguration } configuration - Configuration information during downloading.
|
||||
* @returns { Promise<DownloadProfileResult> } Return the given downloadableProfile.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @throws { BusinessError } 202 - Non-system applications use system APIs.
|
||||
@ -190,7 +187,7 @@ declare namespace eSIM {
|
||||
* @since 14
|
||||
*/
|
||||
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.
|
||||
@ -254,7 +251,7 @@ declare namespace eSIM {
|
||||
/**
|
||||
* 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 } portIndex - Index of the port for the slot.
|
||||
* @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.
|
||||
*
|
||||
* @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 { string } iccid - The iccid of the profile.
|
||||
* @param { string } nickname - The nickname of the profile.
|
||||
@ -1065,7 +1062,7 @@ declare namespace eSIM {
|
||||
* @syscap SystemCapability.Telephony.CoreService.Esim
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 14
|
||||
*/
|
||||
*/
|
||||
RESULT_CERTIFICATE_RESPONSE_TIMEOUT = 209,
|
||||
|
||||
/**
|
||||
@ -1147,7 +1144,7 @@ declare namespace eSIM {
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 14
|
||||
*/
|
||||
RESULT_USER_CANCEL_DOWNLOAD = 218,
|
||||
RESULT_USER_CANCEL_DOWNLOAD = 218,
|
||||
|
||||
/**
|
||||
* The carrier server is unavailable.
|
||||
@ -1209,7 +1206,7 @@ declare namespace eSIM {
|
||||
* @syscap SystemCapability.Telephony.CoreService.Esim
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 14
|
||||
*/
|
||||
*/
|
||||
RESULT_PROFILE_TYPE_ERROR_AUTHENTICATION_STOPPED = 233,
|
||||
|
||||
/**
|
||||
@ -1248,6 +1245,15 @@ declare namespace eSIM {
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@ -1257,6 +1263,15 @@ declare namespace eSIM {
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@ -1478,6 +1493,49 @@ declare namespace eSIM {
|
||||
*/
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user