1 /* 2 * Copyright (c) 2021-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 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 ServiceStub = std::function<int32_t(uint32_t code, MessageParcel &, MessageParcel &, MessageOption &)>; 30 31 class MiscdeviceServiceStub : public IRemoteStub<IMiscdeviceService> { 32 public: 33 MiscdeviceServiceStub(); 34 virtual ~MiscdeviceServiceStub(); 35 virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, 36 MessageOption &option) override; 37 38 private: 39 DISALLOW_COPY_AND_MOVE(MiscdeviceServiceStub); 40 using MiscBaseFunc = int32_t (MiscdeviceServiceStub::*)(MessageParcel &data, MessageParcel &reply); 41 42 int32_t IsAbilityAvailableStub(MessageParcel &data, MessageParcel &reply); 43 int32_t IsVibratorEffectAvailableStub(MessageParcel &data, MessageParcel &reply); 44 int32_t GetVibratorIdListStub(MessageParcel &data, MessageParcel &reply); 45 int32_t VibrateStub(MessageParcel &data, MessageParcel &reply); 46 int32_t PlayVibratorEffectStub(MessageParcel &data, MessageParcel &reply); 47 int32_t SetVibratorParameterStub(MessageParcel &data, MessageParcel &reply); 48 int32_t GetVibratorParameterStub(MessageParcel &data, MessageParcel &reply); 49 #ifdef OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM 50 int32_t PlayVibratorCustomStub(MessageParcel &data, MessageParcel &reply); 51 #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM 52 int32_t StopVibratorAllStub(MessageParcel &data, MessageParcel &reply); 53 int32_t StopVibratorByModeStub(MessageParcel &data, MessageParcel &reply); 54 int32_t IsSupportEffectStub(MessageParcel &data, MessageParcel &reply); 55 int32_t GetLightListStub(MessageParcel &data, MessageParcel &reply); 56 int32_t TurnOnStub(MessageParcel &data, MessageParcel &reply); 57 int32_t TurnOffStub(MessageParcel &data, MessageParcel &reply); 58 bool CheckVibratePermission(); 59 60 std::map<uint32_t, MiscBaseFunc> baseFuncs_; 61 }; 62 } // namespace Sensors 63 } // namespace OHOS 64 #endif // MISCDEVICE_SERVICE_STUB_H 65