1 /* 2 * Copyright (c) 2022-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 HKS_SESSION_MANAGER_H 17 #define HKS_SESSION_MANAGER_H 18 19 #include <stdbool.h> 20 #include <stdint.h> 21 22 #include "hks_double_list.h" 23 #include "hks_event_info.h" 24 #include "hks_type_inner.h" 25 26 struct HksOperation { 27 struct DoubleList listHead; 28 struct HksProcessInfo processInfo; 29 HksEventInfo eventInfo; 30 uint64_t handle; 31 bool abortable; 32 uint64_t accessTokenId; 33 bool isInUse; 34 uint64_t batchOperationTimestamp; 35 bool isBatchOperation; 36 bool isUserIdPassedDuringInit; 37 int userIdPassedDuringInit; 38 int32_t pid; 39 struct HksBlob errMsgBlob; 40 uint64_t startTime; 41 }; 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 int32_t CreateOperation(const struct HksProcessInfo *processInfo, const struct HksParamSet *paramSet, 48 const struct HksBlob *operationHandle, bool abortable); 49 50 struct HksOperation *QueryOperationAndMarkInUse(const struct HksProcessInfo *processInfo, 51 const struct HksBlob *operationHandle); 52 53 struct HksOperation *QueryOperationByPidAndMarkInUse(int32_t pid); 54 55 void MarkOperationUnUse(struct HksOperation *operation); 56 57 void DeleteOperation(const struct HksBlob *operationHandle); 58 59 void DeleteSessionByProcessInfo(const struct HksProcessInfo *processInfo); 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 #endif 66