1 /*
2  * Copyright (c) 2021-2022 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 #ifndef OHOS_ABILITY_RUNTIME_APPLICATION_CONTEXT_H
16 #define OHOS_ABILITY_RUNTIME_APPLICATION_CONTEXT_H
17 
18 #include <memory>
19 
20 namespace OHOS {
21 namespace AbilityRuntime {
22 class ApplicationContext;
23 // mock Context from ablity
24 class Context : public std::enable_shared_from_this<Context> {
25 public:
26     Context() = default;
27     virtual ~Context() = default;
28     static std::shared_ptr<ApplicationContext> GetApplicationContext();
29     virtual std::string GetPreferencesDir() = 0;
30     virtual int32_t GetSystemPreferencesDir(const std::string &groupId, bool checkExist,
31         std::string &preferencesDir) = 0;
32     static std::shared_ptr<ApplicationContext> applicationContext_;
33 };
34 
35 class ApplicationContext : public Context {
36 public:
37     ApplicationContext() = default;
38     ~ApplicationContext() override = default;
39     std::string GetPreferencesDir() override;
40     int32_t GetSystemPreferencesDir(const std::string &groupId, bool checkExist, std::string &preferencesDir) override;
41 };
42 }  // namespace AbilityRuntime
43 }  // namespace OHOS
44 #endif  // OHOS_ABILITY_RUNTIME_APPLICATION_CONTEXT_H
45