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 MOCK_FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_INTERFACE_H 17 #define MOCK_FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_INTERFACE_H 18 19 #include <string> 20 #include <cwchar> 21 #include "iremote_broker.h" 22 23 namespace OHOS { 24 namespace AppExecFwk { 25 26 enum Constants { 27 BASE_USER_RANGE = 200000, 28 }; 29 30 class IBundleMgr : public IRemoteBroker { 31 public: 32 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.BundleMgr"); 33 /** 34 * @brief Obtains the application UID based on the given bundle name and user ID. 35 * @param bundleName Indicates the bundle name of the application. 36 * @param userId Indicates the user ID. 37 * @return Returns the uid if successfully obtained; returns -1 otherwise. 38 */ GetUidByBundleName(const std::string & bundleName,const int userId)39 virtual int GetUidByBundleName(const std::string &bundleName, const int userId) 40 { 41 return -1; 42 } 43 /** 44 * @brief Obtains the application UID based on the given bundle name and user ID. 45 * @param bundleName Indicates the bundle name of the application. 46 * @param userId Indicates the user ID. 47 * @param userId Indicates the app Index. 48 * @return Returns the uid if successfully obtained; returns -1 otherwise. 49 */ GetUidByBundleName(const std::string & bundleName,const int32_t userId,int32_t appIndex)50 virtual int32_t GetUidByBundleName(const std::string &bundleName, const int32_t userId, int32_t appIndex) 51 { 52 return -1; 53 } 54 /** 55 * @brief Obtains the application ID based on the given bundle name and user ID. 56 * @param bundleName Indicates the bundle name of the application. 57 * @param userId Indicates the user ID. 58 * @return Returns the application ID if successfully obtained; returns empty string otherwise. 59 */ GetAppIdByBundleName(const std::string & bundleName,const int userId)60 virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) 61 { 62 printf("enter IbundleImgr GetAppIdByBundleName"); 63 if (userId == 0) { 64 std::string tmp (4097, 's'); // 4097 is The max length of caInfo->certs 65 return tmp; 66 } else if (userId == 1) { // 2 is flag for cover branchs 67 return "Authentication_Test"; 68 } else { 69 return ""; 70 } 71 72 return ""; 73 } 74 /** 75 * @brief Obtains the formal name associated with the given UID. 76 * @param uid Indicates the uid. 77 * @param name Indicates the obtained formal name. 78 * @return Returns ERR_OK if execute success; returns errCode otherwise. 79 */ GetNameForUid(const int uid,std::string & name)80 virtual int32_t GetNameForUid(const int uid, std::string &name) 81 { 82 return -1; 83 } 84 }; 85 } 86 } 87 #endif // MOCK_FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_INTERFACE_H