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 // appIndex -> cloneInfo 51 std::map<std::string, InnerBundleCloneInfo> cloneInfos; 52 std::unordered_map<std::string, PluginBundleInfo> pluginBundleInfos; 53 BundleUserInfo bundleUserInfo; 54 operatorInnerBundleUserInfo55 bool operator() (const InnerBundleUserInfo& info) const 56 { 57 if (bundleName == info.bundleName) { 58 return bundleUserInfo.userId == info.bundleUserInfo.userId; 59 } 60 61 return false; 62 } 63 AppIndexToKeyInnerBundleUserInfo64 static std::string AppIndexToKey(const int32_t appIndex) 65 { 66 return std::to_string(appIndex); 67 } 68 GetPluginBundleInfoInnerBundleUserInfo69 bool GetPluginBundleInfo(const std::string &pluginBundleName, PluginBundleInfo &pluginBundleInfo) const 70 { 71 for (auto &item : pluginBundleInfos) { 72 if (item.first == pluginBundleName) { 73 pluginBundleInfo = item.second; 74 return true; 75 } 76 } 77 return false; 78 } 79 }; 80 81 void from_json(const nlohmann::json& jsonObject, InnerBundleUserInfo& bundleUserInfo); 82 void to_json(nlohmann::json& jsonObject, const InnerBundleUserInfo& bundleUserInfo); 83 } // namespace AppExecFwk 84 } // namespace OHOS 85 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_BUNDLE_USER_INFO_H