• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_BUNDLE_USER_INFO_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_BUNDLE_USER_INFO_H
18 
19 #include "bundle_user_info.h"
20 #include "inner_bundle_clone_info.h"
21 #include "json_util.h"
22 #include "plugin/plugin_bundle_info.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 struct InnerBundleUserInfo {
27     // app install control
28     bool isRemovable = true;
29 
30     int32_t uid = Constants::INVALID_UID;
31     uint32_t accessTokenId = 0;
32     uint64_t accessTokenIdEx = 0;
33 
34     // The time(unix time) will be recalculated
35     // if the application is reinstalled after being uninstalled.
36     int64_t installTime = 0;
37 
38     // The time(unix time) will be recalculated
39     // if the application is uninstalled after being installed.
40     int64_t updateTime = 0;
41 
42     // app first install time
43     int64_t firstInstallTime = 0;
44     std::string bundleName;
45 
46     // encryption key id
47     std::string keyId;
48     std::vector<int32_t> gids;
49 
50     // dynamic icon
51     std::string curDynamicIconModule;
52 
53     // appIndex -> cloneInfo
54     std::map<std::string, InnerBundleCloneInfo> cloneInfos;
55 
56     // use to record plugin that exist in current user
57     std::unordered_set<std::string> installedPluginSet;
58     BundleUserInfo bundleUserInfo;
59 
operatorInnerBundleUserInfo60     bool operator() (const InnerBundleUserInfo& info) const
61     {
62         if (bundleName == info.bundleName) {
63             return bundleUserInfo.userId == info.bundleUserInfo.userId;
64         }
65 
66         return false;
67     }
68 
AppIndexToKeyInnerBundleUserInfo69     static std::string AppIndexToKey(const int32_t appIndex)
70     {
71         return std::to_string(appIndex);
72     }
73 
IsPluginInstalledInnerBundleUserInfo74     bool IsPluginInstalled(const std::string &pluginBundleName) const
75     {
76         return installedPluginSet.find(pluginBundleName) != installedPluginSet.end();
77     }
78 };
79 
80 void from_json(const nlohmann::json& jsonObject, InnerBundleUserInfo& bundleUserInfo);
81 void to_json(nlohmann::json& jsonObject, const InnerBundleUserInfo& bundleUserInfo);
82 } // namespace AppExecFwk
83 } // namespace OHOS
84 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_BUNDLE_USER_INFO_H