From 3f5a589deb9abc033723f16887ede57e3a01390c Mon Sep 17 00:00:00 2001 From: 189******51 Date: Thu, 10 Aug 2023 03:26:15 +0000 Subject: [PATCH 01/10] IssueNo: #I7R8M8: Add sync interfaces in app_control Description: Add sync interfaces in app_control Sig: SIG_ApplicaitonFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: 189******51 --- .../kits/js/app_control/js_app_control.cpp | 94 ++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/js/app_control/js_app_control.cpp b/interfaces/kits/js/app_control/js_app_control.cpp index b649f3a515..f57be725de 100644 --- a/interfaces/kits/js/app_control/js_app_control.cpp +++ b/interfaces/kits/js/app_control/js_app_control.cpp @@ -37,6 +37,9 @@ const std::string PERMISSION_DISPOSED_STATUS = "ohos.permission.MANAGE_DISPOSED_ const std::string SET_DISPOSED_STATUS = "SetDisposedStatus"; const std::string GET_DISPOSED_STATUS = "GetDisposedStatus"; const std::string DELETE_DISPOSED_STATUS = "DeleteDisposedStatus"; +const std::string SET_DISPOSED_STATUS_SYNC = "SetDisposedStatusSync"; +const std::string DELETE_DISPOSED_STATUS_SYNC = "DeleteDisposedStatusSync"; +const std::string GET_DISPOSED_STATUS_SYNC = "GetDisposedStatusSync"; const std::string APP_ID = "appId"; const std::string DISPOSED_WANT = "disposedWant"; } @@ -183,6 +186,53 @@ napi_value SetDisposedStatus(napi_env env, napi_callback_info info) return promise; } +napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) +{ + APP_LOGD("begin to SetDisposedStatusSync"); + NapiArg args(env, info); + napi_value nRet = nullptr; + if (!args.Init(ARGS_SIZE_TWO, ARGS_SIZE_THREE)) { + APP_LOGE("Napi func init failed"); + BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR); + NAPI_CALL(env, napi_create_int32(env, ERROR_PARAM_CHECK_ERROR, &nRet)); + return nRet; + } + std::string appId; + if (!CommonFunc::ParseString(env, args[ARGS_POS_ZERO], appId)) { + APP_LOGE("appId %{public}s invalid!", appId.c_str()); + BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING); + NAPI_CALL(env, napi_create_int32(env, ERROR_PARAM_CHECK_ERROR, &nRet)); + return nRet; + } + OHOS::AAFwk::Want want; + if (!CommonFunc::ParseWantWithoutVerification(env, args[ARGS_POS_ONE], want)) { + APP_LOGE("want invalid!"); + BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, DISPOSED_WANT, TYPE_WANT); + NAPI_CALL(env, napi_create_int32(env, ERROR_PARAM_CHECK_ERROR, &nRet)); + return nRet; + } + auto appControlProxy = GetAppControlProxy(); + if (appControlProxy == nullptr) { + APP_LOGE("AppControlProxy is null."); + napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, + SET_DISPOSED_STATUS_SYNC); + napi_throw(env, error); + NAPI_CALL(env, napi_create_int32(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, &nRet)); + return nRet; + } + ErrCode ret = appControlProxy->SetDisposedStatus(appId, want); + ret = CommonFunc::ConvertErrCode(ret); + if (ret != NO_ERROR) { + APP_LOGE("SetDisposedStatusSync err = %{public}d", ret); + napi_value businessError = BusinessError::CreateCommonError( + env, ret, SET_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS); + napi_throw(env, businessError); + } + NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); + APP_LOGD("call SetDisposedStatusSync done."); + return nRet; +} + void DeleteDisposedStatusExec(napi_env env, void *data) { DisposedStatus *asyncCallbackInfo = reinterpret_cast(data); @@ -273,6 +323,45 @@ napi_value DeleteDisposedStatus(napi_env env, napi_callback_info info) return promise; } +napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) +{ + APP_LOGD("begin to DeleteDisposedStatusSync."); + NapiArg args(env, info); + napi_value nRet = nullptr; + if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_TWO)) { + APP_LOGE("param count invalid."); + BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR); + NAPI_CALL(env, napi_create_int32(env, ERROR_PARAM_CHECK_ERROR, &nRet)); + return nRet; + } + std::string appId; + if (!CommonFunc::ParseString(env, args[ARGS_POS_ZERO], appId)) { + APP_LOGE("appId %{public}s invalid!", appId.c_str()); + BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING); + NAPI_CALL(env, napi_create_int32(env, ERROR_PARAM_CHECK_ERROR, &nRet)); + return nRet; + } + auto appControlProxy = GetAppControlProxy(); + if (appControlProxy == nullptr) { + napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, + DELETE_DISPOSED_STATUS_SYNC); + napi_throw(env, error); + NAPI_CALL(env, napi_create_int32(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, &nRet)); + return nRet; + } + ErrCode ret = appControlProxy->DeleteDisposedStatus(appId); + ret = CommonFunc::ConvertErrCode(ret); + if (ret != NO_ERROR) { + APP_LOGE("DeleteDisposedStatusSync err = %{public}d", ret); + napi_value businessError = BusinessError::CreateCommonError( + env, ret, DELETE_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS); + napi_throw(env, businessError); + } + NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); + APP_LOGD("call DeleteDisposedStatusSync done."); + return nRet; +} + void GetDisposedStatusExec(napi_env env, void *data) { DisposedStatus *asyncCallbackInfo = reinterpret_cast(data); @@ -383,7 +472,7 @@ napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info) auto appControlProxy = GetAppControlProxy(); if (appControlProxy == nullptr) { napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, - GET_DISPOSED_STATUS); + GET_DISPOSED_STATUS_SYNC); napi_throw(env, error); return nullptr; } @@ -393,12 +482,13 @@ napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info) if (ret != ERR_OK) { APP_LOGE("GetDisposedStatusSync failed"); napi_value businessError = BusinessError::CreateCommonError( - env, ret, GET_DISPOSED_STATUS, PERMISSION_DISPOSED_STATUS); + env, ret, GET_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS); napi_throw(env, businessError); return nullptr; } napi_value nWant = nullptr; CommonFunc::ConvertWantInfo(env, nWant, disposedWant); + NAPI_CALL(env, napi_create_object(env, &nWant)); APP_LOGD("call GetDisposedStatusSync done."); return nWant; } -- Gitee From bb596e2b40d992bec9a879ff76bd104aa374273a Mon Sep 17 00:00:00 2001 From: 189******51 Date: Thu, 10 Aug 2023 03:27:36 +0000 Subject: [PATCH 02/10] IssueNo: #I7R8M8: Add sync interfaces in app_control Description: Add sync interfaces in app_control Sig: SIG_ApplicaitonFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: 189******51 --- interfaces/kits/js/app_control/js_app_control.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interfaces/kits/js/app_control/js_app_control.h b/interfaces/kits/js/app_control/js_app_control.h index 036b26cfc6..c256ba5df9 100644 --- a/interfaces/kits/js/app_control/js_app_control.h +++ b/interfaces/kits/js/app_control/js_app_control.h @@ -35,6 +35,8 @@ napi_value GetDisposedStatus(napi_env env, napi_callback_info info); napi_value SetDisposedStatus(napi_env env, napi_callback_info info); napi_value DeleteDisposedStatus(napi_env env, napi_callback_info info); napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info); +napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info); +napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info); } // namespace AppExecFwk } // namespace OHOS #endif /* JS_APP_CONTROL_H */ \ No newline at end of file -- Gitee From 8c45dba57893bb5e353cab7b96fb655878ed113e Mon Sep 17 00:00:00 2001 From: 189******51 Date: Thu, 10 Aug 2023 03:28:39 +0000 Subject: [PATCH 03/10] IssueNo: #I7R8M8: Add sync interfaces in app_control Description: Add sync interfaces in app_control Sig: SIG_ApplicaitonFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: 189******51 --- interfaces/kits/js/app_control/native_module.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interfaces/kits/js/app_control/native_module.cpp b/interfaces/kits/js/app_control/native_module.cpp index 0f7e6de66a..62cb539ee9 100644 --- a/interfaces/kits/js/app_control/native_module.cpp +++ b/interfaces/kits/js/app_control/native_module.cpp @@ -33,6 +33,8 @@ static napi_value AppControlExport(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("setDisposedStatus", SetDisposedStatus), DECLARE_NAPI_FUNCTION("deleteDisposedStatus", DeleteDisposedStatus), DECLARE_NAPI_FUNCTION("getDisposedStatusSync", GetDisposedStatusSync), + DECLARE_NAPI_FUNCTION("setDisposedStatusSync", SetDisposedStatusSync), + DECLARE_NAPI_FUNCTION("deleteDisposedStatusSync", DeleteDisposedStatusSync), }; NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); -- Gitee From 7bdf416055c8d77dd19ef01f4558ed6c52a77c79 Mon Sep 17 00:00:00 2001 From: 189******51 Date: Thu, 10 Aug 2023 03:30:01 +0000 Subject: [PATCH 04/10] IssueNo: #I7R8M8: Add sync interfaces in app_control Description: Add sync interfaces in app_control Sig: SIG_ApplicaitonFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: 189******51 --- .../app_control/js_app_control_unsupported.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/interfaces/kits/js/app_control/js_app_control_unsupported.cpp b/interfaces/kits/js/app_control/js_app_control_unsupported.cpp index bfa68480aa..cb5bc6c8e8 100644 --- a/interfaces/kits/js/app_control/js_app_control_unsupported.cpp +++ b/interfaces/kits/js/app_control/js_app_control_unsupported.cpp @@ -59,5 +59,23 @@ napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info) napi_throw(env, error); return nullptr; } + +napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) +{ + APP_LOGE("SystemCapability.BundleManager.BundleFramework.AppControl not supported."); + napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, + "setDisposedStatusSync"); + napi_throw(env, error); + return nullptr; +} + +napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) +{ + APP_LOGE("SystemCapability.BundleManager.BundleFramework.AppControl not supported."); + napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, + "deleteDisposedStatusSync"); + napi_throw(env, error); + return nullptr; +} } // AppExecFwk } // OHOS -- Gitee From 70379eb9c655a6143276218bc3d036e665e1e09a Mon Sep 17 00:00:00 2001 From: 189******51 Date: Thu, 10 Aug 2023 06:44:53 +0000 Subject: [PATCH 05/10] IssueNo: #I7R8M8: Add sync interfaces in app_control Description: Add sync interfaces in app_control Sig: SIG_ApplicaitonFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: 189******51 --- .../kits/js/app_control/js_app_control.cpp | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/interfaces/kits/js/app_control/js_app_control.cpp b/interfaces/kits/js/app_control/js_app_control.cpp index f57be725de..062fe897da 100644 --- a/interfaces/kits/js/app_control/js_app_control.cpp +++ b/interfaces/kits/js/app_control/js_app_control.cpp @@ -43,6 +43,7 @@ const std::string GET_DISPOSED_STATUS_SYNC = "GetDisposedStatusSync"; const std::string APP_ID = "appId"; const std::string DISPOSED_WANT = "disposedWant"; } +#define APP_LOGED APP_LOGE static OHOS::sptr GetAppControlProxy() { auto bundleMgr = CommonFunc::GetBundleMgr(); @@ -138,7 +139,7 @@ void SetDisposedStatusComplete(napi_env env, napi_status status, void *data) napi_value SetDisposedStatus(napi_env env, napi_callback_info info) { - APP_LOGD("begin to SetDisposedStatus"); + APP_LOGED("begin to SetDisposedStatus"); NapiArg args(env, info); DisposedStatus *asyncCallbackInfo = new (std::nothrow) DisposedStatus(env); if (asyncCallbackInfo == nullptr) { @@ -171,7 +172,7 @@ napi_value SetDisposedStatus(napi_env env, napi_callback_info info) if (valueType == napi_function) { NAPI_CALL(env, napi_create_reference(env, args[i], NAPI_RETURN_ONE, &asyncCallbackInfo->callback)); } else { - APP_LOGD("SetDisposedStatus extra arg ignored"); + APP_LOGED("SetDisposedStatus extra arg ignored"); } } else { APP_LOGE("SetDisposedStatus arg err!"); @@ -182,13 +183,13 @@ napi_value SetDisposedStatus(napi_env env, napi_callback_info info) auto promise = CommonFunc::AsyncCallNativeMethod( env, asyncCallbackInfo, "SetDisposedStatus", SetDisposedStatusExec, SetDisposedStatusComplete); callbackPtr.release(); - APP_LOGD("call SetDisposedStatus done."); + APP_LOGED("call SetDisposedStatus done."); return promise; } napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) { - APP_LOGD("begin to SetDisposedStatusSync"); + APP_LOGED("begin to SetDisposedStatusSync"); NapiArg args(env, info); napi_value nRet = nullptr; if (!args.Init(ARGS_SIZE_TWO, ARGS_SIZE_THREE)) { @@ -229,7 +230,7 @@ napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) napi_throw(env, businessError); } NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); - APP_LOGD("call SetDisposedStatusSync done."); + APP_LOGED("call SetDisposedStatusSync done."); return nRet; } @@ -279,7 +280,7 @@ void DeleteDisposedStatusComplete(napi_env env, napi_status, void *data) napi_value DeleteDisposedStatus(napi_env env, napi_callback_info info) { - APP_LOGD("begin to DeleteDisposedStatus."); + APP_LOGED("begin to DeleteDisposedStatus."); NapiArg args(env, info); DisposedStatus *asyncCallbackInfo = new (std::nothrow) DisposedStatus(env); if (asyncCallbackInfo == nullptr) { @@ -308,7 +309,7 @@ napi_value DeleteDisposedStatus(napi_env env, napi_callback_info info) if (valueType == napi_function) { NAPI_CALL(env, napi_create_reference(env, args[i], NAPI_RETURN_ONE, &asyncCallbackInfo->callback)); } else { - APP_LOGD("DeleteDisposedStatus extra arg ignored"); + APP_LOGED("DeleteDisposedStatus extra arg ignored"); } } else { APP_LOGE("DeleteDisposedStatus arg err!"); @@ -319,13 +320,13 @@ napi_value DeleteDisposedStatus(napi_env env, napi_callback_info info) auto promise = CommonFunc::AsyncCallNativeMethod( env, asyncCallbackInfo, "DeleteDisposedStatus", DeleteDisposedStatusExec, DeleteDisposedStatusComplete); callbackPtr.release(); - APP_LOGD("call DeleteDisposedStatus done."); + APP_LOGED("call DeleteDisposedStatus done."); return promise; } napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) { - APP_LOGD("begin to DeleteDisposedStatusSync."); + APP_LOGED("begin to DeleteDisposedStatusSync."); NapiArg args(env, info); napi_value nRet = nullptr; if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_TWO)) { @@ -343,6 +344,7 @@ napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) } auto appControlProxy = GetAppControlProxy(); if (appControlProxy == nullptr) { + APP_LOGE("AppControlProxy is null"); napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, DELETE_DISPOSED_STATUS_SYNC); napi_throw(env, error); @@ -358,7 +360,7 @@ napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) napi_throw(env, businessError); } NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); - APP_LOGD("call DeleteDisposedStatusSync done."); + APP_LOGED("call DeleteDisposedStatusSync done."); return nRet; } @@ -410,7 +412,7 @@ void GetDisposedStatusComplete(napi_env env, napi_status status, void *data) napi_value GetDisposedStatus(napi_env env, napi_callback_info info) { - APP_LOGD("NAPI GetDisposedStatus called"); + APP_LOGED("NAPI GetDisposedStatus called"); NapiArg args(env, info); DisposedStatus *asyncCallbackInfo = new (std::nothrow) DisposedStatus(env); if (asyncCallbackInfo == nullptr) { @@ -439,7 +441,7 @@ napi_value GetDisposedStatus(napi_env env, napi_callback_info info) if (valueType == napi_function) { NAPI_CALL(env, napi_create_reference(env, args[i], NAPI_RETURN_ONE, &asyncCallbackInfo->callback)); } else { - APP_LOGD("GetDisposedStatus extra arg ignored"); + APP_LOGED("GetDisposedStatus extra arg ignored"); } } else { APP_LOGE("GetDisposedStatus arg err!"); @@ -450,13 +452,13 @@ napi_value GetDisposedStatus(napi_env env, napi_callback_info info) auto promise = CommonFunc::AsyncCallNativeMethod( env, asyncCallbackInfo, "GetDisposedStatus", GetDisposedStatusExec, GetDisposedStatusComplete); callbackPtr.release(); - APP_LOGD("call GetDisposedStatus done."); + APP_LOGED("call GetDisposedStatus done."); return promise; } napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info) { - APP_LOGD("NAPI GetDisposedStatusSync called"); + APP_LOGED("NAPI GetDisposedStatusSync called"); NapiArg args(env, info); if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_ONE)) { APP_LOGE("param count invalid."); @@ -471,6 +473,7 @@ napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info) } auto appControlProxy = GetAppControlProxy(); if (appControlProxy == nullptr) { + APP_LOGE("AppControlProxy is null"); napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, GET_DISPOSED_STATUS_SYNC); napi_throw(env, error); @@ -489,7 +492,7 @@ napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info) napi_value nWant = nullptr; CommonFunc::ConvertWantInfo(env, nWant, disposedWant); NAPI_CALL(env, napi_create_object(env, &nWant)); - APP_LOGD("call GetDisposedStatusSync done."); + APP_LOGED("call GetDisposedStatusSync done."); return nWant; } } -- Gitee From 81a97a517f0de1e29310791ce3304e4e75e397e9 Mon Sep 17 00:00:00 2001 From: 189******51 Date: Thu, 10 Aug 2023 06:53:09 +0000 Subject: [PATCH 06/10] IssueNo: #I7R8M8: Add sync interfaces in app_control Description: Add sync interfaces in app_control Sig: SIG_ApplicaitonFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: 189******51 --- interfaces/kits/js/app_control/js_app_control.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/js/app_control/js_app_control.cpp b/interfaces/kits/js/app_control/js_app_control.cpp index 062fe897da..d28137dd7b 100644 --- a/interfaces/kits/js/app_control/js_app_control.cpp +++ b/interfaces/kits/js/app_control/js_app_control.cpp @@ -490,8 +490,8 @@ napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info) return nullptr; } napi_value nWant = nullptr; - CommonFunc::ConvertWantInfo(env, nWant, disposedWant); NAPI_CALL(env, napi_create_object(env, &nWant)); + CommonFunc::ConvertWantInfo(env, nWant, disposedWant); APP_LOGED("call GetDisposedStatusSync done."); return nWant; } -- Gitee From 0feb1c5fedcf5dc6681ff487f022afa964cc015a Mon Sep 17 00:00:00 2001 From: 189******51 Date: Thu, 10 Aug 2023 07:25:25 +0000 Subject: [PATCH 07/10] IssueNo: #I7R8M8: Add sync interfaces in app_control Description: Add sync interfaces in app_control Sig: SIG_ApplicaitonFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: 189******51 --- .../kits/js/app_control/js_app_control.cpp | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/interfaces/kits/js/app_control/js_app_control.cpp b/interfaces/kits/js/app_control/js_app_control.cpp index d28137dd7b..5c530b21dd 100644 --- a/interfaces/kits/js/app_control/js_app_control.cpp +++ b/interfaces/kits/js/app_control/js_app_control.cpp @@ -43,7 +43,6 @@ const std::string GET_DISPOSED_STATUS_SYNC = "GetDisposedStatusSync"; const std::string APP_ID = "appId"; const std::string DISPOSED_WANT = "disposedWant"; } -#define APP_LOGED APP_LOGE static OHOS::sptr GetAppControlProxy() { auto bundleMgr = CommonFunc::GetBundleMgr(); @@ -139,7 +138,7 @@ void SetDisposedStatusComplete(napi_env env, napi_status status, void *data) napi_value SetDisposedStatus(napi_env env, napi_callback_info info) { - APP_LOGED("begin to SetDisposedStatus"); + APP_LOGD("begin to SetDisposedStatus"); NapiArg args(env, info); DisposedStatus *asyncCallbackInfo = new (std::nothrow) DisposedStatus(env); if (asyncCallbackInfo == nullptr) { @@ -172,7 +171,7 @@ napi_value SetDisposedStatus(napi_env env, napi_callback_info info) if (valueType == napi_function) { NAPI_CALL(env, napi_create_reference(env, args[i], NAPI_RETURN_ONE, &asyncCallbackInfo->callback)); } else { - APP_LOGED("SetDisposedStatus extra arg ignored"); + APP_LOGD("SetDisposedStatus extra arg ignored"); } } else { APP_LOGE("SetDisposedStatus arg err!"); @@ -183,13 +182,13 @@ napi_value SetDisposedStatus(napi_env env, napi_callback_info info) auto promise = CommonFunc::AsyncCallNativeMethod( env, asyncCallbackInfo, "SetDisposedStatus", SetDisposedStatusExec, SetDisposedStatusComplete); callbackPtr.release(); - APP_LOGED("call SetDisposedStatus done."); + APP_LOGD("call SetDisposedStatus done."); return promise; } napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) { - APP_LOGED("begin to SetDisposedStatusSync"); + APP_LOGD("begin to SetDisposedStatusSync"); NapiArg args(env, info); napi_value nRet = nullptr; if (!args.Init(ARGS_SIZE_TWO, ARGS_SIZE_THREE)) { @@ -230,7 +229,7 @@ napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) napi_throw(env, businessError); } NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); - APP_LOGED("call SetDisposedStatusSync done."); + APP_LOGD("call SetDisposedStatusSync done."); return nRet; } @@ -280,7 +279,7 @@ void DeleteDisposedStatusComplete(napi_env env, napi_status, void *data) napi_value DeleteDisposedStatus(napi_env env, napi_callback_info info) { - APP_LOGED("begin to DeleteDisposedStatus."); + APP_LOGD("begin to DeleteDisposedStatus."); NapiArg args(env, info); DisposedStatus *asyncCallbackInfo = new (std::nothrow) DisposedStatus(env); if (asyncCallbackInfo == nullptr) { @@ -309,7 +308,7 @@ napi_value DeleteDisposedStatus(napi_env env, napi_callback_info info) if (valueType == napi_function) { NAPI_CALL(env, napi_create_reference(env, args[i], NAPI_RETURN_ONE, &asyncCallbackInfo->callback)); } else { - APP_LOGED("DeleteDisposedStatus extra arg ignored"); + APP_LOGD("DeleteDisposedStatus extra arg ignored"); } } else { APP_LOGE("DeleteDisposedStatus arg err!"); @@ -320,13 +319,13 @@ napi_value DeleteDisposedStatus(napi_env env, napi_callback_info info) auto promise = CommonFunc::AsyncCallNativeMethod( env, asyncCallbackInfo, "DeleteDisposedStatus", DeleteDisposedStatusExec, DeleteDisposedStatusComplete); callbackPtr.release(); - APP_LOGED("call DeleteDisposedStatus done."); + APP_LOGD("call DeleteDisposedStatus done."); return promise; } napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) { - APP_LOGED("begin to DeleteDisposedStatusSync."); + APP_LOGD("begin to DeleteDisposedStatusSync."); NapiArg args(env, info); napi_value nRet = nullptr; if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_TWO)) { @@ -360,7 +359,7 @@ napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) napi_throw(env, businessError); } NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); - APP_LOGED("call DeleteDisposedStatusSync done."); + APP_LOGD("call DeleteDisposedStatusSync done."); return nRet; } @@ -412,7 +411,7 @@ void GetDisposedStatusComplete(napi_env env, napi_status status, void *data) napi_value GetDisposedStatus(napi_env env, napi_callback_info info) { - APP_LOGED("NAPI GetDisposedStatus called"); + APP_LOGD("NAPI GetDisposedStatus called"); NapiArg args(env, info); DisposedStatus *asyncCallbackInfo = new (std::nothrow) DisposedStatus(env); if (asyncCallbackInfo == nullptr) { @@ -441,7 +440,7 @@ napi_value GetDisposedStatus(napi_env env, napi_callback_info info) if (valueType == napi_function) { NAPI_CALL(env, napi_create_reference(env, args[i], NAPI_RETURN_ONE, &asyncCallbackInfo->callback)); } else { - APP_LOGED("GetDisposedStatus extra arg ignored"); + APP_LOGD("GetDisposedStatus extra arg ignored"); } } else { APP_LOGE("GetDisposedStatus arg err!"); @@ -452,13 +451,13 @@ napi_value GetDisposedStatus(napi_env env, napi_callback_info info) auto promise = CommonFunc::AsyncCallNativeMethod( env, asyncCallbackInfo, "GetDisposedStatus", GetDisposedStatusExec, GetDisposedStatusComplete); callbackPtr.release(); - APP_LOGED("call GetDisposedStatus done."); + APP_LOGD("call GetDisposedStatus done."); return promise; } napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info) { - APP_LOGED("NAPI GetDisposedStatusSync called"); + APP_LOGD("NAPI GetDisposedStatusSync called"); NapiArg args(env, info); if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_ONE)) { APP_LOGE("param count invalid."); @@ -492,7 +491,7 @@ napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info) napi_value nWant = nullptr; NAPI_CALL(env, napi_create_object(env, &nWant)); CommonFunc::ConvertWantInfo(env, nWant, disposedWant); - APP_LOGED("call GetDisposedStatusSync done."); + APP_LOGD("call GetDisposedStatusSync done."); return nWant; } } -- Gitee From e539ac87d39ff8d7d1b75a6105ccc573cee830be Mon Sep 17 00:00:00 2001 From: 189******51 Date: Thu, 10 Aug 2023 08:41:50 +0000 Subject: [PATCH 08/10] IssueNo: #I7R8M8: Add sync interfaces in app_control Description: Add sync interfaces in app_control Sig: SIG_ApplicaitonFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: 189******51 --- interfaces/kits/js/app_control/js_app_control.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/interfaces/kits/js/app_control/js_app_control.cpp b/interfaces/kits/js/app_control/js_app_control.cpp index 5c530b21dd..f5153e1f69 100644 --- a/interfaces/kits/js/app_control/js_app_control.cpp +++ b/interfaces/kits/js/app_control/js_app_control.cpp @@ -227,6 +227,8 @@ napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) napi_value businessError = BusinessError::CreateCommonError( env, ret, SET_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS); napi_throw(env, businessError); + NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); + return nRet; } NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); APP_LOGD("call SetDisposedStatusSync done."); @@ -357,6 +359,8 @@ napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) napi_value businessError = BusinessError::CreateCommonError( env, ret, DELETE_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS); napi_throw(env, businessError); + NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); + return nRet; } NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); APP_LOGD("call DeleteDisposedStatusSync done."); -- Gitee From 289cff830cd2fe4568026f627e9e8a9ec4c1d1f4 Mon Sep 17 00:00:00 2001 From: 189******51 Date: Fri, 11 Aug 2023 06:33:18 +0000 Subject: [PATCH 09/10] IssueNo: #I7R8M8: Add sync interfaces in app_control Description: Add sync interfaces in app_control Sig: SIG_ApplicaitonFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: 189******51 --- interfaces/kits/js/app_control/js_app_control.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/interfaces/kits/js/app_control/js_app_control.cpp b/interfaces/kits/js/app_control/js_app_control.cpp index f5153e1f69..ff1bb0a4df 100644 --- a/interfaces/kits/js/app_control/js_app_control.cpp +++ b/interfaces/kits/js/app_control/js_app_control.cpp @@ -191,7 +191,7 @@ napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) APP_LOGD("begin to SetDisposedStatusSync"); NapiArg args(env, info); napi_value nRet = nullptr; - if (!args.Init(ARGS_SIZE_TWO, ARGS_SIZE_THREE)) { + if (!args.Init(ARGS_SIZE_TWO, ARGS_SIZE_TWO)) { APP_LOGE("Napi func init failed"); BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR); NAPI_CALL(env, napi_create_int32(env, ERROR_PARAM_CHECK_ERROR, &nRet)); @@ -217,8 +217,6 @@ napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, SET_DISPOSED_STATUS_SYNC); napi_throw(env, error); - NAPI_CALL(env, napi_create_int32(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, &nRet)); - return nRet; } ErrCode ret = appControlProxy->SetDisposedStatus(appId, want); ret = CommonFunc::ConvertErrCode(ret); @@ -227,8 +225,6 @@ napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) napi_value businessError = BusinessError::CreateCommonError( env, ret, SET_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS); napi_throw(env, businessError); - NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); - return nRet; } NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); APP_LOGD("call SetDisposedStatusSync done."); @@ -330,7 +326,7 @@ napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) APP_LOGD("begin to DeleteDisposedStatusSync."); NapiArg args(env, info); napi_value nRet = nullptr; - if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_TWO)) { + if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_ONE)) { APP_LOGE("param count invalid."); BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR); NAPI_CALL(env, napi_create_int32(env, ERROR_PARAM_CHECK_ERROR, &nRet)); @@ -349,8 +345,6 @@ napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, DELETE_DISPOSED_STATUS_SYNC); napi_throw(env, error); - NAPI_CALL(env, napi_create_int32(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, &nRet)); - return nRet; } ErrCode ret = appControlProxy->DeleteDisposedStatus(appId); ret = CommonFunc::ConvertErrCode(ret); @@ -359,8 +353,6 @@ napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) napi_value businessError = BusinessError::CreateCommonError( env, ret, DELETE_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS); napi_throw(env, businessError); - NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); - return nRet; } NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); APP_LOGD("call DeleteDisposedStatusSync done."); -- Gitee From 3e9f6a5bb695ae0344d3126c7334182fc5477399 Mon Sep 17 00:00:00 2001 From: 189******51 Date: Fri, 11 Aug 2023 06:51:09 +0000 Subject: [PATCH 10/10] IssueNo: #I7R8M8: Add sync interfaces in app_control Description: Add sync interfaces in app_control Sig: SIG_ApplicaitonFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: 189******51 --- interfaces/kits/js/app_control/js_app_control.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/interfaces/kits/js/app_control/js_app_control.cpp b/interfaces/kits/js/app_control/js_app_control.cpp index ff1bb0a4df..2319eaca1f 100644 --- a/interfaces/kits/js/app_control/js_app_control.cpp +++ b/interfaces/kits/js/app_control/js_app_control.cpp @@ -190,25 +190,23 @@ napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) { APP_LOGD("begin to SetDisposedStatusSync"); NapiArg args(env, info); - napi_value nRet = nullptr; + napi_value nRet; + napi_get_undefined(env, &nRet); if (!args.Init(ARGS_SIZE_TWO, ARGS_SIZE_TWO)) { APP_LOGE("Napi func init failed"); BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR); - NAPI_CALL(env, napi_create_int32(env, ERROR_PARAM_CHECK_ERROR, &nRet)); return nRet; } std::string appId; if (!CommonFunc::ParseString(env, args[ARGS_POS_ZERO], appId)) { APP_LOGE("appId %{public}s invalid!", appId.c_str()); BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING); - NAPI_CALL(env, napi_create_int32(env, ERROR_PARAM_CHECK_ERROR, &nRet)); return nRet; } OHOS::AAFwk::Want want; if (!CommonFunc::ParseWantWithoutVerification(env, args[ARGS_POS_ONE], want)) { APP_LOGE("want invalid!"); BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, DISPOSED_WANT, TYPE_WANT); - NAPI_CALL(env, napi_create_int32(env, ERROR_PARAM_CHECK_ERROR, &nRet)); return nRet; } auto appControlProxy = GetAppControlProxy(); @@ -217,6 +215,7 @@ napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, SET_DISPOSED_STATUS_SYNC); napi_throw(env, error); + return nRet; } ErrCode ret = appControlProxy->SetDisposedStatus(appId, want); ret = CommonFunc::ConvertErrCode(ret); @@ -226,7 +225,6 @@ napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) env, ret, SET_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS); napi_throw(env, businessError); } - NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); APP_LOGD("call SetDisposedStatusSync done."); return nRet; } @@ -325,18 +323,17 @@ napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) { APP_LOGD("begin to DeleteDisposedStatusSync."); NapiArg args(env, info); - napi_value nRet = nullptr; + napi_value nRet; + napi_get_undefined(env, &nRet); if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_ONE)) { APP_LOGE("param count invalid."); BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR); - NAPI_CALL(env, napi_create_int32(env, ERROR_PARAM_CHECK_ERROR, &nRet)); return nRet; } std::string appId; if (!CommonFunc::ParseString(env, args[ARGS_POS_ZERO], appId)) { APP_LOGE("appId %{public}s invalid!", appId.c_str()); BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING); - NAPI_CALL(env, napi_create_int32(env, ERROR_PARAM_CHECK_ERROR, &nRet)); return nRet; } auto appControlProxy = GetAppControlProxy(); @@ -345,6 +342,7 @@ napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, DELETE_DISPOSED_STATUS_SYNC); napi_throw(env, error); + return nRet; } ErrCode ret = appControlProxy->DeleteDisposedStatus(appId); ret = CommonFunc::ConvertErrCode(ret); @@ -354,7 +352,6 @@ napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info) env, ret, DELETE_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS); napi_throw(env, businessError); } - NAPI_CALL(env, napi_create_int32(env, ret, &nRet)); APP_LOGD("call DeleteDisposedStatusSync done."); return nRet; } -- Gitee