1 /* 2 * Copyright (c) 2023 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 #ifndef FOUNDATION_BUNDLE_FRAMEWORK_AOT_AOT_EXECUTOR 17 #define FOUNDATION_BUNDLE_FRAMEWORK_AOT_AOT_EXECUTOR 18 19 #include <mutex> 20 21 #include "aot/aot_args.h" 22 #include "appexecfwk_errors.h" 23 #include "nocopyable.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 class AOTExecutor final { 28 public: 29 static AOTExecutor& GetInstance(); 30 void ExecuteAOT(const AOTArgs &aotArgs, ErrCode &ret) const; 31 private: 32 AOTExecutor() = default; 33 ~AOTExecutor() = default; 34 DISALLOW_COPY_AND_MOVE(AOTExecutor); 35 36 std::string DecToHex(uint32_t decimal) const; 37 bool CheckArgs(const AOTArgs &aotArgs) const; 38 bool GetAbcFileInfo(const std::string &hapPath, uint32_t &offset, uint32_t &length) const; 39 ErrCode PrepareArgs(const AOTArgs &aotArgs, AOTArgs &completeArgs) const; 40 void ExecuteInChildProcess(const AOTArgs &aotArgs) const; 41 void ExecuteInParentProcess(pid_t childPid, ErrCode &ret) const; 42 private: 43 mutable std::mutex mutex_; 44 }; 45 } // namespace AppExecFwk 46 } // namespace OHOS 47 #endif // FOUNDATION_BUNDLE_FRAMEWORK_AOT_AOT_EXECUTOR 48