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 ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_IRENDER_SERVICE_CONNECTION_INTERFACE_CODE_ACCESS_VERIFIER_H 17 #define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_IRENDER_SERVICE_CONNECTION_INTERFACE_CODE_ACCESS_VERIFIER_H 18 19 #include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" 20 #include "platform/ohos/rs_irender_service_connection_ipc_interface_code.h" 21 22 namespace OHOS { 23 namespace Rosen { 24 class RSIRenderServiceConnectionInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { 25 public: 26 /* 27 * specify the enum class of the associated interface code (i.e. CodeEnumType) here 28 * note that term **CodeEnumType** should not be changed 29 */ 30 using CodeEnumType = RSIRenderServiceConnectionInterfaceCode; 31 static inline const std::string codeEnumTypeName_ {"RSIRenderServiceConnectionInterfaceCode"}; 32 33 /* specify constructor and destructor here */ 34 RSIRenderServiceConnectionInterfaceCodeAccessVerifier(); 35 ~RSIRenderServiceConnectionInterfaceCodeAccessVerifier() noexcept override = default; 36 #ifdef ENABLE_IPC_SECURITY 37 bool IsAccessTimesVerificationPassed(CodeUnderlyingType code, uint32_t times) const override; 38 #endif 39 40 protected: 41 /* specify exclusive verification rules here */ 42 bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; 43 44 private: 45 DISALLOW_COPY_AND_MOVE(RSIRenderServiceConnectionInterfaceCodeAccessVerifier); 46 #ifdef ENABLE_IPC_SECURITY 47 void AddRSIRenderServiceConnectionInterfaceCodePermission(); 48 static inline const std::vector<std::pair<CodeEnumType, PermissionType>> 49 permissionRSIRenderServiceConnectionInterfaceMappings_ { 50 { CodeEnumType::TAKE_SURFACE_CAPTURE, PermissionType::CAPTURE_SCREEN }, 51 { CodeEnumType::SET_REFRESH_RATE_MODE, PermissionType::UPDATE_CONFIGURATION }, 52 { CodeEnumType::GET_MEMORY_GRAPHICS, PermissionType::GET_RUNNING_INFO }, 53 { CodeEnumType::SHOW_WATERMARK, PermissionType::UPDATE_CONFIGURATION } 54 }; 55 static inline const std::unordered_map<CodeEnumType, uint32_t> 56 accessRSIRenderServiceConnectionInterfaceTimesRestrictions_ { 57 { CodeEnumType::REGISTER_APPLICATION_AGENT, 15 }, 58 }; 59 #endif 60 }; 61 } // namespace Rosen 62 } // namespace OHOS 63 #endif // ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_IRENDER_SERVICE_CONNECTION_INTERFACE_CODE_ACCESS_VERIFIER_H 64