• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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_MULTI_INSTANCE_UTILS_H
17 #define OHOS_ABILITY_RUNTIME_MULTI_INSTANCE_UTILS_H
18 
19 #include <string>
20 
21 #include "ability_record.h"
22 #include "application_info.h"
23 #include "extension_ability_info.h"
24 #include "want.h"
25 
26 namespace OHOS {
27 namespace AAFwk {
28 /**
29  * @class MultiInstanceUtils
30  * provides multi-instance utilities.
31  */
32 class MultiInstanceUtils {
33 public:
34     /**
35      * GetInstanceKey, get instance key of the given want.
36      *
37      * @param want The want param.
38      * @return The instance key.
39      */
40     static std::string GetInstanceKey(const Want& want);
41 
42     /**
43      * GetValidExtensionInstanceKey, get valid extension instance key.
44      *
45      * @param abilityRequest The ability request.
46      * @return The instance key.
47      */
48     static std::string GetValidExtensionInstanceKey(const AbilityRequest &abilityRequest);
49 
50     /**
51      * GetValidExtensionInstanceKey, get valid extension instance key.
52      *
53      * @param abilityRequest The ability request.
54      * @return The instance key.
55      */
56     static std::string GetSelfCallerInstanceKey(const AbilityRequest &abilityRequest);
57 
58     /**
59      * IsDefaultInstanceKey, check if the key is the default instance key.
60      *
61      * @param key The key to be queried.
62      * @return Whether the instance key is the default.
63      */
64     static bool IsDefaultInstanceKey(const std::string& key);
65 
66     /**
67      * IsMultiInstanceApp, check if the app is the default multi-instance app.
68      *
69      * @param appInfo The app info to be queried.
70      * @return Whether the app is the default multi-instance app.
71      */
72     static bool IsMultiInstanceApp(AppExecFwk::ApplicationInfo appInfo);
73 
74     /**
75      * IsSupportedExtensionType, check if the type supports extension type.
76      *
77      * @param type The extension ability type.
78      * @return Whether the type supports extension type.
79      */
80     static bool IsSupportedExtensionType(AppExecFwk::ExtensionAbilityType type);
81 
82     /**
83      * IsInstanceKeyExist, check if the instance key exists.
84      *
85      * @param bundleName The bundle name.
86      * @param key The instance key to be queried.
87      * @return Whether the instance key exists.
88      */
89     static bool IsInstanceKeyExist(const std::string& bundleName, const std::string& key);
90 };
91 }  // namespace AAFwk
92 }  // namespace OHOS
93 #endif  // OHOS_ABILITY_RUNTIME_MULTI_INSTANCE_UTILS_H
94