1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "interfaces/inner_api/ace/arkts_module_preloader.h" 17 18 #include "ace_forward_compatibility.h" 19 #include "arkui_log.h" 20 #include "utils.h" 21 22 namespace OHOS::Ace { 23 24 using CreateFunc = void (*)(void*); 25 constexpr char PRE_INIT_ACE_ARKTS_MODULE_FUNC[] = "OHOS_ACE_PreloadAceArkTSModule"; 26 InitAceArkTSModule(void * runtime)27void InitAceArkTSModule(void* runtime) 28 { 29 LIBHANDLE handle = LOADLIB(AceForwardCompatibility::GetAceLibName()); 30 if (handle == nullptr) { 31 return; 32 } 33 34 auto entry = reinterpret_cast<CreateFunc>(LOADSYM(handle, PRE_INIT_ACE_ARKTS_MODULE_FUNC)); 35 if (entry == nullptr) { 36 FREELIB(handle); 37 return; 38 } 39 40 entry(runtime); 41 } 42 Preload(void * aniEnv)43void ArkTSModulePreloader::Preload(void* aniEnv) 44 { 45 LOGI("ArkTSModulePreloader::PreloadSTS, aniEnv: %{public}i", aniEnv ? 1 : 0); 46 InitAceArkTSModule(reinterpret_cast<void*>(aniEnv)); 47 } 48 49 } // namespace OHOS::Ace 50