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 Options GetOptions() override; 35 void SetOptions(const Options &options) override; 36 std::string GetBundleName() override; 37 std::string GetBundleCodePath() override; 38 std::string GetBundleCodeDir() override; 39 std::string GetCacheDir() override; 40 std::string GetTempDir() override; 41 std::string GetFilesDir() override; 42 std::string GetDatabaseDir() override; 43 std::string GetPreferencesDir() override; 44 std::string GetDistributedFilesDir() override; 45 void SwitchArea(int mode) override; 46 int GetArea() override; 47 std::string GetBaseDir() override; 48 std::string GetPreviewPath(); 49 static bool Access(const std::string &path); 50 void Mkdir(const std::string &path); 51 static void FsReqCleanup(uv_fs_t *req); 52 bool CreateMultiDir(const std::string &path); 53 54 private: 55 static const int EL_DEFAULT = 1; 56 Options options_; 57 std::string currArea_ = "el2"; 58 std::string fileSeparator_ = "/"; 59 std::shared_ptr<AppExecFwk::Configuration> configuration_; 60 std::shared_ptr<AppExecFwk::ApplicationInfo> applicationInfo_; 61 std::shared_ptr<AppExecFwk::HapModuleInfo> hapModuleInfo_; 62 }; 63 } // namespace AbilityRuntime 64 } // namespace OHOS 65 #endif // OHOS_ABILITY_RUNTIME_SIMULATOR_ABILITY_STAGE_CONTEXT_H 66