1 /* 2 * Copyright (c) 2021 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 MISCDEVICE_SERVICE_STUB_H 17 #define MISCDEVICE_SERVICE_STUB_H 18 19 #include <map> 20 21 #include "iremote_stub.h" 22 #include "message_parcel.h" 23 #include "nocopyable.h" 24 25 #include "i_miscdevice_service.h" 26 27 namespace OHOS { 28 namespace Sensors { 29 using ServicePb = std::function<int32_t(uint32_t code, MessageParcel &, MessageParcel &, MessageOption &)>; 30 31 class MiscdeviceServiceStub : public IRemoteStub<IMiscdeviceService> { 32 public: 33 MiscdeviceServiceStub(); 34 35 virtual ~MiscdeviceServiceStub(); 36 37 virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, 38 MessageOption &option) override; 39 40 private: 41 DISALLOW_COPY_AND_MOVE(MiscdeviceServiceStub); 42 using MiscBaseFunc = int32_t (MiscdeviceServiceStub::*)(MessageParcel &data, MessageParcel &reply); 43 44 int32_t IsAbilityAvailablePb(MessageParcel &data, MessageParcel &reply); 45 int32_t IsVibratorEffectAvailablePb(MessageParcel &data, MessageParcel &reply); 46 int32_t GetVibratorIdListPb(MessageParcel &data, MessageParcel &reply); 47 int32_t VibratePb(MessageParcel &data, MessageParcel &reply); 48 int32_t CancelVibratorPb(MessageParcel &data, MessageParcel &reply); 49 int32_t PlayVibratorEffectPb(MessageParcel &data, MessageParcel &reply); 50 int32_t PlayCustomVibratorEffectPb(MessageParcel &data, MessageParcel &reply); 51 int32_t StopVibratorEffectPb(MessageParcel &data, MessageParcel &reply); 52 int32_t SetVibratorParameterPb(MessageParcel &data, MessageParcel &reply); 53 int32_t GetVibratorParameterPb(MessageParcel &data, MessageParcel &reply); 54 int32_t GetLightListPb(MessageParcel &data, MessageParcel &reply); 55 int32_t TurnOnPb(MessageParcel &data, MessageParcel &reply); 56 int32_t TurnOffPb(MessageParcel &data, MessageParcel &reply); 57 bool CheckVibratePermission(); 58 59 std::map<uint32_t, MiscBaseFunc> baseFuncs_; 60 }; 61 } // namespace Sensors 62 } // namespace OHOS 63 #endif // MISCDEVICE_SERVICE_STUB_H 64