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 BMS_WRAPPER 17 #define BMS_WRAPPER 18 19 #include <stdint.h> 20 #include <vector> 21 #include <string> 22 #include "asset_type.h" 23 #include "system_event_wrapper.h" 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #define ARRAY_SIZE(arr) ((sizeof(arr)) / (sizeof((arr)[0]))) 30 31 enum OwnerType { 32 HAP = 0, 33 NATIVE = 1, 34 HAP_GROUP = 2, 35 }; 36 37 typedef struct { 38 int32_t appIndex; 39 Asset_Blob appId; 40 Asset_Blob groupId; 41 Asset_Blob developerId; 42 } HapInfo; 43 44 typedef struct { 45 uint32_t uid; 46 } NativeInfo; 47 48 typedef struct { 49 uint32_t userId; 50 OwnerType ownerType; 51 // Bundle name for hap or process name for native. 52 Asset_Blob processName; 53 HapInfo hapInfo; 54 NativeInfo nativeInfo; 55 } ProcessInfo; 56 57 int32_t GetCallingProcessInfo(uint32_t userId, uint64_t uid, ProcessInfo *processInfo); 58 59 int32_t GetCloneAppIndexes(int32_t userId, int32_t *appIndexes, uint32_t *indexSize, const char *appName); 60 61 int32_t IsHapInAllowList(int32_t userId, const char *appName, bool *is_in_list); 62 63 int32_t GetUninstallGroups(int32_t userId, ConstAssetBlob *developerId, MutAssetBlobArray *groupIds); 64 65 #ifdef __cplusplus 66 } 67 #endif 68 69 #endif