diff --git a/services/bundlemgr/BUILD.gn b/services/bundlemgr/BUILD.gn index 8c854da0868eda7a9a4111da9bf47876c629a338..8c56e5898207e4562b8f18ff4731ba4a8f1aea7e 100644 --- a/services/bundlemgr/BUILD.gn +++ b/services/bundlemgr/BUILD.gn @@ -308,6 +308,7 @@ ohos_shared_library("libbms") { "access_token:libtokenid_sdk", "appspawn:appspawn_client", "appverify:libhapverify", + "cJSON:cjson", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -575,6 +576,7 @@ ohos_shared_library("installs") { "access_token:el5_filekey_manager_sdk", "appspawn:hnpapi", "bounds_checking_function:libsec_shared", + "cJSON:cjson", "eventhandler:libeventhandler", "ffrt:libffrt", "hilog:libhilog", diff --git a/services/bundlemgr/src/ipc/code_signature_param.cpp b/services/bundlemgr/src/ipc/code_signature_param.cpp index 23b964c6e450bf0f7ac150eabec7329c1daa5942..c84e8563036179ab9fa8b1a8eddccdd56aec8964 100644 --- a/services/bundlemgr/src/ipc/code_signature_param.cpp +++ b/services/bundlemgr/src/ipc/code_signature_param.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -16,7 +16,7 @@ #include "ipc/code_signature_param.h" #include "bundle_constants.h" -#include "nlohmann/json.hpp" +#include "cJSON.h" #include "parcel_macro.h" #include "string_ex.h" @@ -75,18 +75,22 @@ CodeSignatureParam *CodeSignatureParam::Unmarshalling(Parcel &parcel) std::string CodeSignatureParam::ToString() const { - nlohmann::json codeSignatureParamJson = nlohmann::json { - { CODE_SIGNATURE_MODULE_PATH, modulePath }, - { CODE_SIGNATURE_CPU_ABI, cpuAbi }, - { CODE_SIGNATURE_TARGET_SO_PATH, targetSoPath }, - { CODE_SIGNATURE_SIGNATURE_FILE_PATH, signatureFileDir }, - { CODE_SIGNATURE_IS_ENTERPRISE_BUNDLE, isEnterpriseBundle }, - { CODE_SIGNATURE_APP_IDENTIFIER, appIdentifier }, - { CODE_SIGNATURE_IS_PREINSTALLED_BUNDLE, isPreInstalledBundle }, - { CODE_SIGNATURE_IS_COMPILE_SDK_OPENHARMONY, isCompileSdkOpenHarmony }, - { CODE_SIGNATURE_IS_COMPRESS_NATIVE_LIBRARY, isCompressNativeLibrary }, - }; - return codeSignatureParamJson.dump(Constants::DUMP_INDENT); + cJSON *codeSignatureParamJson = cJSON_CreateObject(); + cJSON_AddStringToObject(codeSignatureParamJson, CODE_SIGNATURE_MODULE_PATH, modulePath.c_str()); + cJSON_AddStringToObject(codeSignatureParamJson, CODE_SIGNATURE_CPU_ABI, cpuAbi.c_str()); + cJSON_AddStringToObject(codeSignatureParamJson, CODE_SIGNATURE_TARGET_SO_PATH, targetSoPath.c_str()); + cJSON_AddStringToObject(codeSignatureParamJson, CODE_SIGNATURE_SIGNATURE_FILE_PATH, signatureFileDir.c_str()); + cJSON_AddBoolToObject(codeSignatureParamJson, CODE_SIGNATURE_IS_ENTERPRISE_BUNDLE, isEnterpriseBundle); + cJSON_AddStringToObject(codeSignatureParamJson, CODE_SIGNATURE_APP_IDENTIFIER, appIdentifier.c_str()); + cJSON_AddBoolToObject(codeSignatureParamJson, CODE_SIGNATURE_IS_PREINSTALLED_BUNDLE, isPreInstalledBundle); + cJSON_AddBoolToObject(codeSignatureParamJson, CODE_SIGNATURE_IS_COMPILE_SDK_OPENHARMONY, isCompileSdkOpenHarmony); + cJSON_AddBoolToObject(codeSignatureParamJson, CODE_SIGNATURE_IS_COMPRESS_NATIVE_LIBRARY, isCompressNativeLibrary); + + char *jsonString = cJSON_Print(codeSignatureParamJson); + cJSON_Delete(codeSignatureParamJson); + std::string result(jsonString); + free(jsonString); + return result; } } // AppExecFwk } // OHOS diff --git a/services/bundlemgr/test/unittest/bms_bundle_mgr_ext_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_mgr_ext_test/BUILD.gn index c2f5afb3d07ab3cb2178ed4bb4108c2e2156ce7d..f5256ee24eccdf2b068aa472713a5928acbc1035 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_mgr_ext_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_mgr_ext_test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 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 @@ -63,6 +63,7 @@ ohos_unittest("BmsBundleMgrExtTest") { "appspawn:hnpapi", "appverify:libhapverify", "bounds_checking_function:libsec_shared", + "cJSON:cjson", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn index cb9b243898a156bb346b04ab2834cdccf4828892..3cecf75ee3c6133c57d8a3893d6c7b2e51bdd56b 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn @@ -281,6 +281,7 @@ ohos_unittest("BmsBundlePermissionGrantTest") { "appspawn:hnpapi", "appverify:libhapverify", "bounds_checking_function:libsec_shared", + "cJSON:cjson", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_install_daemon_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_install_daemon_test/BUILD.gn index 95487f0bdd5a628b820907a44d56842e6b0fad38..ac9cef36e7b87aa9ca610c263d4229d40c18c137 100644 --- a/services/bundlemgr/test/unittest/bms_install_daemon_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_install_daemon_test/BUILD.gn @@ -295,6 +295,7 @@ ohos_unittest("BmsInstallDaemonOperatorTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "bounds_checking_function:libsec_shared", + "cJSON:cjson", "c_utils:utils", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_installd_client_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_installd_client_test/BUILD.gn index a74a2d24d165acb69ba3e6ded7843b6211798f0a..0c72ad0fedc4fd742eca3dc8ab58bd84e14754c2 100644 --- a/services/bundlemgr/test/unittest/bms_installd_client_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_installd_client_test/BUILD.gn @@ -43,6 +43,7 @@ ohos_unittest("BmsInstalldClientTest") { "access_token:libaccesstoken_sdk", "appspawn:hnpapi", "bounds_checking_function:libsec_shared", + "cJSON:cjson", "eventhandler:libeventhandler", "hilog:libhilog", "hitrace:hitrace_meter",