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 UDMF_SERVICE_STUB_H 17 #define UDMF_SERVICE_STUB_H 18 19 #include <map> 20 #include <string> 21 22 #include "feature/feature_system.h" 23 #include "message_parcel.h" 24 25 #include "distributeddata_udmf_ipc_interface_code.h" 26 #include "error_code.h" 27 #include "udmf_service.h" 28 29 namespace OHOS { 30 namespace UDMF { 31 /* 32 * UDMF server stub 33 */ 34 class UdmfServiceStub : public UdmfService, public DistributedData::FeatureSystem::Feature { 35 public: 36 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply) override; 37 38 private: 39 int32_t OnSetData(MessageParcel &data, MessageParcel &reply); 40 int32_t OnGetData(MessageParcel &data, MessageParcel &reply); 41 int32_t OnGetBatchData(MessageParcel &data, MessageParcel &reply); 42 int32_t OnUpdateData(MessageParcel &data, MessageParcel &reply); 43 int32_t OnDeleteData(MessageParcel &data, MessageParcel &reply); 44 int32_t OnGetSummary(MessageParcel &data, MessageParcel &reply); 45 int32_t OnAddPrivilege(MessageParcel &data, MessageParcel &reply); 46 int32_t OnSync(MessageParcel &data, MessageParcel &reply); 47 48 bool VerifyPermission(const std::string &permission); 49 50 const std::string READ_PERMISSION = "ohos.permission.READ_UDMF_DATA"; 51 const std::string WRITE_PERMISSION = "ohos.permission.WRITE_UDMF_DATA"; 52 const std::string SYNC_PERMISSION = "ohos.permission.SYNC_UDMF_DATA"; 53 54 using Handler = int32_t (UdmfServiceStub::*)(MessageParcel &data, MessageParcel &reply); 55 static constexpr Handler HANDLERS[static_cast<uint32_t>(UdmfServiceInterfaceCode::CODE_BUTT)] = { 56 &UdmfServiceStub::OnSetData, 57 &UdmfServiceStub::OnGetData, 58 &UdmfServiceStub::OnGetBatchData, 59 &UdmfServiceStub::OnUpdateData, 60 &UdmfServiceStub::OnDeleteData, 61 &UdmfServiceStub::OnGetSummary, 62 &UdmfServiceStub::OnAddPrivilege, 63 &UdmfServiceStub::OnSync 64 }; 65 }; 66 } // namespace UDMF 67 } // namespace OHOS 68 #endif // UDMF_SERVICE_STUB_H 69