• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 
21 #include "bundlemgr/bundle_mgr_interface.h"
22 #include "bundlemgr/bundle_mgr_proxy.h"
23 #include "distributed_bms_interface.h"
24 #include "distributed_bms_proxy.h"
25 #include "single_instance.h"
26 
27 namespace OHOS {
28 namespace DistributedSchedule {
29 class BundleManagerInternal {
30     DECLARE_SINGLE_INSTANCE(BundleManagerInternal);
31 
32 public:
33     static bool GetCallerAppIdFromBms(int32_t callingUid, std::string& appId);
34     static bool GetCallerAppIdFromBms(const std::string& bundleName, std::string& appId);
35     static bool GetBundleNameListFromBms(int32_t callingUid, std::vector<std::string>& bundleNameList);
36     static bool GetBundleNameListFromBms(int32_t callingUid, std::vector<std::u16string>& u16BundleNameList);
37     static bool QueryAbilityInfo(const AAFwk::Want& want, AppExecFwk::AbilityInfo& abilityInfo);
38     static bool QueryExtensionAbilityInfo(const AAFwk::Want& want, AppExecFwk::ExtensionAbilityInfo& extensionInfo);
39     static void InitAbilityInfoFromExtension(const AppExecFwk::ExtensionAbilityInfo &extensionAbilityInfo,
40         AppExecFwk::AbilityInfo &abilityInfo);
41     static bool IsSameAppId(const std::string& callerAppId, const std::string& targetBundleName);
42     static int32_t GetLocalBundleInfo(const std::string& bundleName, AppExecFwk::BundleInfo &localBundleInfo);
43     static int32_t GetLocalBundleInfoV9(const std::string& bundleName, AppExecFwk::BundleInfo &bundleInfo);
44     static int32_t CheckRemoteBundleInfoForContinuation(const std::string& dstDeviceId,
45         const std::string& bundleName, AppExecFwk::DistributedBundleInfo& remoteBundleInfo);
46     static sptr<AppExecFwk::IBundleMgr> GetBundleManager();
47     static sptr<AppExecFwk::IDistributedBms> GetDistributedBundleManager();
48     static int32_t GetUidFromBms(const std::string& bundleName);
49     static bool CheckIfRemoteCanInstall(const AAFwk::Want& want, int32_t missionId);
50     static int32_t GetBundleIdFromBms(const std::string& bundleName, uint32_t& accessTokenId);
51     static int32_t GetBundleNameFromDbms(const std::string& networkId,
52         const uint32_t accessTokenId, std::string& bundleName);
53     static int32_t GetApplicationInfoFromBms(const std::string& bundleName, const AppExecFwk::BundleFlag flag,
54         const int32_t userId, AppExecFwk::ApplicationInfo &appInfo);
55 };
56 } // namespace DistributedSchedule
57 } // namespace OHOS
58 #endif /* OHOS_DISTRIBUTED_BUNDLE_MANANGER_INTERNAL_H */
59