• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_HANDLER
17 #define FOUNDATION_BUNDLE_FRAMEWORK_AOT_AOT_HANDLER
18 
19 #include <mutex>
20 #include <optional>
21 #include <string>
22 #include <unordered_map>
23 
24 #include "aot/aot_args.h"
25 #include "inner_bundle_info.h"
26 #include "nocopyable.h"
27 
28 namespace OHOS {
29 namespace AppExecFwk {
30 class AOTHandler final {
31 public:
32     static AOTHandler& GetInstance();
33     void HandleInstall(const std::unordered_map<std::string, InnerBundleInfo> &infos) const;
34     void HandleOTA() const;
35     void HandleIdle() const;
36     void HandleCompile(const std::string &bundleName, const std::string &compileMode, bool isAllBundle) const;
37     void HandleResetAOT(const std::string &bundleName, bool isAllBundle) const;
38 private:
39     AOTHandler() = default;
40     ~AOTHandler() = default;
41     DISALLOW_COPY_AND_MOVE(AOTHandler);
42 
43     bool IsSupportARM64() const;
44     std::string GetArkProfilePath(const std::string &bundleName, const std::string &moduleName) const;
45     std::optional<AOTArgs> BuildAOTArgs(
46         const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const;
47     void HandleInstallWithSingleHap(const InnerBundleInfo &info, const std::string &compileMode) const;
48     void HandleCompileWithSingleHap(
49     const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const;
50     void ClearArkCacheDir() const;
51     void ResetAOTFlags() const;
52     void HandleIdleWithSingleHap(
53         const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const;
54     bool CheckDeviceState() const;
55     void AOTInternal(std::optional<AOTArgs> aotArgs, uint32_t versionCode) const;
56 private:
57     mutable std::mutex executeMutex_;
58     mutable std::mutex idleMutex_;
59     mutable std::mutex compileMutex_;
60 };
61 }  // namespace AppExecFwk
62 }  // namespace OHOS
63 #endif  // FOUNDATION_BUNDLE_FRAMEWORK_AOT_AOT_HANDLER
64