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 
23 namespace OHOS {
24 namespace AppExecFwk {
25 struct InnerBundleUserInfo {
26     BundleUserInfo bundleUserInfo;
27     int32_t uid = Constants::INVALID_UID;
28     std::vector<int32_t> gids;
29     uint32_t accessTokenId = 0;
30     uint64_t accessTokenIdEx = 0;
31     std::string bundleName;
32 
33     // The time(unix time) will be recalculated
34     // if the application is reinstalled after being uninstalled.
35     int64_t installTime = 0;
36 
37     // The time(unix time) will be recalculated
38     // if the application is uninstalled after being installed.
39     int64_t updateTime = 0;
40 
41     // app install control
42     bool isRemovable = true;
43 
44     // encryption key id
45     std::string keyId;
46 
47     // appIndex -> cloneInfo
48     std::map<std::string, InnerBundleCloneInfo> cloneInfos;
49 
operatorInnerBundleUserInfo50     bool operator() (const InnerBundleUserInfo& info) const
51     {
52         if (bundleName == info.bundleName) {
53             return bundleUserInfo.userId == info.bundleUserInfo.userId;
54         }
55 
56         return false;
57     }
58 
AppIndexToKeyInnerBundleUserInfo59     static std::string AppIndexToKey(const int32_t appIndex)
60     {
61         return std::to_string(appIndex);
62     }
63 };
64 
65 void from_json(const nlohmann::json& jsonObject, InnerBundleUserInfo& bundleUserInfo);
66 void to_json(nlohmann::json& jsonObject, const InnerBundleUserInfo& bundleUserInfo);
67 } // namespace AppExecFwk
68 } // namespace OHOS
69 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_BUNDLE_USER_INFO_H