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 "core/common/ace_engine_ext.h"
17 
18 #include <dlfcn.h>
19 
20 #include "base/log/log.h"
21 #include "base/log/log_wrapper.h"
22 #include "base/utils/utils.h"
23 
24 namespace OHOS::Ace {
25 namespace {
26 #if (defined(__aarch64__) || defined(__x86_64__))
27 const std::string DRAG_EXTENSION_SO_PATH = "system/lib64/module/autorun/libhmos_drag_drop.z.so";
28 #else
29 const std::string DRAG_EXTENSION_SO_PATH = "system/lib/module/autorun/libhmos_drag_drop.z.so";
30 #endif
31 }
32 
CallDragExtFunc()33 void CallDragExtFunc()
34 {
35     auto handle = dlopen(DRAG_EXTENSION_SO_PATH.c_str(), RTLD_LAZY);
36     CHECK_NULL_VOID(handle);
37     auto dragFunc = reinterpret_cast<DragExtFunc>(dlsym(handle, "StartDragService"));
38     if (dragFunc == nullptr) {
39         TAG_LOGE(AceLogTag::ACE_DRAG, "Failed to get drag extension func");
40         dlclose(handle);
41         return;
42     }
43     TAG_LOGI(AceLogTag::ACE_DRAG, "Call drag extension func");
44     dragFunc();
45     dlclose(handle);
46 }
47 } // namespace OHOS::Ace