1 /* 2 * Copyright (c) 2021-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_DISTRIBUTED_BUNDLE_MANANGER_INTERNAL_H 17 #define OHOS_DISTRIBUTED_BUNDLE_MANANGER_INTERNAL_H 18 19 #include <string> 20 #include <vector> 21 22 #include "bundlemgr/bundle_mgr_interface.h" 23 #include "bundlemgr/bundle_mgr_proxy.h" 24 #include "distributed_bms_interface.h" 25 #include "distributed_bms_proxy.h" 26 #include "mission/distributed_bm_storage.h" 27 #include "mission/distributed_bundle_info.h" 28 #include "single_instance.h" 29 30 namespace OHOS { 31 namespace DistributedSchedule { 32 class BundleManagerInternal { 33 DECLARE_SINGLE_INSTANCE(BundleManagerInternal); 34 35 public: 36 static bool GetCallerAppIdFromBms(int32_t callingUid, std::string& appId); 37 static bool GetCallerAppIdFromBms(const std::string& bundleName, std::string& appId); 38 static bool GetSpecifyBundleNameFromBms(int32_t callingUid, std::string& bundleName); 39 static bool GetBundleNameListFromBms(int32_t callingUid, std::vector<std::string>& bundleNameList); 40 static bool GetBundleNameListFromBms(int32_t callingUid, std::vector<std::u16string>& u16BundleNameList); 41 static bool QueryAbilityInfo(const AAFwk::Want& want, AppExecFwk::AbilityInfo& abilityInfo); 42 static bool QueryExtensionAbilityInfo(const AAFwk::Want& want, AppExecFwk::ExtensionAbilityInfo& extensionInfo); 43 static void InitAbilityInfoFromExtension(const AppExecFwk::ExtensionAbilityInfo &extensionAbilityInfo, 44 AppExecFwk::AbilityInfo &abilityInfo); 45 static bool IsSameAppId(const std::string& callerAppId, const std::string& targetBundleName); 46 static bool IsSameDeveloperId(const std::string &bundleNameInCurrentSide, 47 const std::string &developerId4OtherSide); 48 static int32_t GetLocalBundleInfo(const std::string& bundleName, AppExecFwk::BundleInfo &localBundleInfo); 49 static int32_t GetLocalBundleInfoV9(const std::string& bundleName, AppExecFwk::BundleInfo &bundleInfo); 50 static bool GetContinueBundle4Src(const std::string& srcBundleName, 51 std::vector<std::string>& bundleNameList); 52 static bool GetAppProvisionInfo4CurrentUser(const std::string& bundleName, 53 AppExecFwk::AppProvisionInfo& appProvisionInfo); 54 static int32_t CheckRemoteBundleInfoForContinuation(const std::string& dstDeviceId, 55 const std::string& bundleName, AppExecFwk::DistributedBundleInfo& remoteBundleInfo); 56 static sptr<AppExecFwk::IBundleMgr> GetBundleManager(); 57 static sptr<AppExecFwk::IDistributedBms> GetDistributedBundleManager(); 58 static int32_t GetUidFromBms(const std::string& bundleName); 59 static bool CheckIfRemoteCanInstall(const AAFwk::Want& want, int32_t missionId); 60 static int32_t GetBundleNameId(const std::string& bundleName, uint16_t& bundleNameId); 61 static std::string GetContinueType(const std::string &networkId, 62 std::string &bundleName, uint8_t continueTypeId); 63 static int32_t GetContinueTypeId(const std::string &bundleName, 64 const std::string &abilityName, uint8_t &continueTypeId); 65 static std::string GetAbilityName(const std::string &networkId, std::string &bundleName, std::string &continueType); 66 static int32_t GetBundleNameById(const std::string& networkId, 67 const uint16_t& bundleNameId, std::string& bundleName); 68 static int32_t GetApplicationInfoFromBms(const std::string& bundleName, const AppExecFwk::BundleFlag flag, 69 const int32_t userId, AppExecFwk::ApplicationInfo &appInfo); 70 static ErrCode QueryOsAccount(int32_t& activeAccountId); 71 }; 72 } // namespace DistributedSchedule 73 } // namespace OHOS 74 #endif /* OHOS_DISTRIBUTED_BUNDLE_MANANGER_INTERNAL_H */ 75