• 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 private:
37     AOTHandler() = default;
38     ~AOTHandler() = default;
39     DISALLOW_COPY_AND_MOVE(AOTHandler);
40 
41     bool IsSupportARM64() const;
42     std::string GetArkProfilePath(const std::string &bundleName, const std::string &moduleName) const;
43     std::optional<AOTArgs> BuildAOTArgs(
44         const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const;
45     void HandleInstallWithSingleHap(const InnerBundleInfo &info, const std::string &compileMode) const;
46     void ClearArkCacheDir() const;
47     void ResetAOTFlags() const;
48     void HandleIdleWithSingleHap(
49         const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const;
50     bool CheckDeviceState() const;
51     void AOTInternal(std::optional<AOTArgs> aotArgs, uint32_t versionCode) const;
52 private:
53     mutable std::mutex mutex_;
54 };
55 }  // namespace AppExecFwk
56 }  // namespace OHOS
57 #endif  // FOUNDATION_BUNDLE_FRAMEWORK_AOT_AOT_HANDLER
58