1 /* 2 * Copyright (c) 2022 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 DSLM_IPC_PROCESS_H 17 #define DSLM_IPC_PROCESS_H 18 19 #include <cstdint> 20 #include <functional> 21 #include <map> 22 #include <mutex> 23 24 #include "iremote_object.h" 25 #include "iservice_registry.h" 26 #include "message_parcel.h" 27 #include "refbase.h" 28 #include "singleton.h" 29 30 #include "device_security_defines.h" 31 #include "utils_timer.h" 32 33 namespace OHOS { 34 namespace Security { 35 namespace DeviceSecurityLevel { 36 class DslmIpcProcess : public Singleton<DslmIpcProcess> { 37 public: 38 int32_t DslmProcessGetDeviceSecurityLevel(MessageParcel &data, MessageParcel &reply); 39 class RemoteHolder : public Singleton<RemoteHolder> { 40 public: 41 bool Push(uint32_t owner, uint32_t cookie, const sptr<IRemoteObject> &object); 42 sptr<IRemoteObject> Pop(uint32_t owner, uint32_t cookie); 43 44 private: 45 std::map<uint64_t, sptr<IRemoteObject>> map_; 46 std::mutex mutex_; 47 }; 48 49 private: 50 TimerHandle unloadTimerHandle_ {0}; 51 int32_t DslmGetRequestFromParcel(MessageParcel &data, DeviceIdentify &identify, RequestOption &option, 52 sptr<IRemoteObject> &object, uint32_t &cookie); 53 54 int32_t DslmSetResponseToParcel(MessageParcel &reply, uint32_t status); 55 }; 56 } // namespace DeviceSecurityLevel 57 } // namespace Security 58 } // namespace OHOS 59 60 #endif // DSLM_IPC_PROCESS_H