1 /* 2 * Copyright (c) 2022 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/hot_reloader.h" 17 18 #include <dlfcn.h> 19 20 namespace OHOS::Ace { 21 22 using ReloadFunc = void (*)(); 23 constexpr char HOT_RELOAD_FUNC[] = "OHOS_ACE_HotReloadPage"; 24 InitAceModule()25void InitAceModule() 26 { 27 void* handle = dlopen("libace.z.so", RTLD_LAZY); 28 if (handle == nullptr) { 29 return; 30 } 31 32 auto entry = reinterpret_cast<ReloadFunc>(dlsym(handle, HOT_RELOAD_FUNC)); 33 if (entry == nullptr) { 34 dlclose(handle); 35 return; 36 } 37 38 entry(); 39 } 40 HotReload()41void HotReloader::HotReload() 42 { 43 InitAceModule(); 44 } 45 46 } // namespace OHOS::Ace