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 OHOS_ABILITY_RUNTIME_SIMULATOR_ABILITY_STAGE_CONTEXT_H
17 #define OHOS_ABILITY_RUNTIME_SIMULATOR_ABILITY_STAGE_CONTEXT_H
18 
19 #include "context.h"
20 #include "uv.h"
21 
22 namespace OHOS {
23 namespace AbilityRuntime {
24 class AbilityStageContext : public Context {
25 public:
26     AbilityStageContext() = default;
27     virtual ~AbilityStageContext() = default;
28 
29     std::shared_ptr<AppExecFwk::Configuration> GetConfiguration() override;
30     void SetConfiguration(const std::shared_ptr<AppExecFwk::Configuration> &configuration);
31     std::shared_ptr<AppExecFwk::ApplicationInfo> GetApplicationInfo() const override;
32     std::shared_ptr<AppExecFwk::HapModuleInfo> GetHapModuleInfo() const override;
33 
34     void SetApplicationInfo(const std::shared_ptr<AppExecFwk::ApplicationInfo> &info);
35     void SetHapModuleInfo(const std::shared_ptr<AppExecFwk::HapModuleInfo> &info);
36 
37     Options GetOptions() override;
38     void SetOptions(const Options &options) override;
39     std::string GetBundleName() override;
40     std::string GetBundleCodePath() override;
41     std::string GetBundleCodeDir() override;
42     std::string GetCacheDir() override;
43     std::string GetTempDir() override;
44     std::string GetResourceDir() override;
45     std::string GetFilesDir() override;
46     std::string GetDatabaseDir() override;
47     std::string GetPreferencesDir() override;
48     std::string GetDistributedFilesDir() override;
49     std::string GetCloudFileDir() override;
50     void SwitchArea(int mode) override;
51     int GetArea() override;
52     std::string GetBaseDir() override;
53     std::string GetPreviewPath();
54     static bool Access(const std::string &path);
55     void Mkdir(const std::string &path);
56     static void FsReqCleanup(uv_fs_t *req);
57     bool CreateMultiDir(const std::string &path);
58 
59 private:
60     static const int EL_DEFAULT = 1;
61     Options options_;
62     std::string currArea_ = "el2";
63     std::string fileSeparator_ = "/";
64     std::shared_ptr<AppExecFwk::Configuration> configuration_;
65     std::shared_ptr<AppExecFwk::ApplicationInfo> applicationInfo_;
66     std::shared_ptr<AppExecFwk::HapModuleInfo> hapModuleInfo_;
67 };
68 } // namespace AbilityRuntime
69 } // namespace OHOS
70 #endif // OHOS_ABILITY_RUNTIME_SIMULATOR_ABILITY_STAGE_CONTEXT_H
71