1 /* 2 * Copyright (c) 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 ABILITYLITE_BMS_HELPER_H 17 #define ABILITYLITE_BMS_HELPER_H 18 19 #include <cstdint> 20 #include "bundle_manager.h" 21 #include "utils_list.h" 22 #include "want.h" 23 24 namespace OHOS { 25 namespace AbilitySlite { 26 struct AbilitySvcInfo { 27 char *bundleName; 28 char *path; 29 void *data; 30 uint16_t dataLength; 31 bool isNativeApp; 32 uint32_t mission; 33 }; 34 35 class BMSHelper final { 36 public: GetInstance()37 static BMSHelper &GetInstance() 38 { 39 static BMSHelper instance; 40 return instance; 41 } 42 43 int32_t RegisterBundleNames(const List<char *> &names); 44 45 int32_t RegisterStartupBundleName(const char *bundleName); 46 47 const char *GetStartupBundleName(); 48 49 int32_t RegisterTemporaryBundleNames(const List<char *> &names); 50 51 bool IsTemporaryBundleName(const char *bundleName); 52 53 void Erase(); 54 55 bool IsNativeApp(const char *bundleName); 56 57 uint8_t QueryAbilitySvcInfo(const Want *want, AbilitySvcInfo *svcInfo); 58 59 bool IsValidAbility(const AbilityInfo *abilityInfo); 60 61 void ClearAbilitySvcInfo(AbilitySvcInfo *abilitySvcInfo); 62 63 private: 64 List<char *> bundleNames_ {}; 65 List<char *> temporaryBundleNames_ {}; 66 char *startupBundleName_ = nullptr; 67 68 BMSHelper() = default; 69 70 ~BMSHelper(); 71 }; 72 } // namespace AbilitySlite 73 } // namespace OHOS 74 75 #endif //ABILITYLITE_BMS_HELPER_H 76