1 /* 2 * Copyright (c) 2023 Shanghai Ruisheng Kaitai Acoustic Science 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 HE_VIBRATOR_DECODER_H 17 #define HE_VIBRATOR_DECODER_H 18 19 #include <cstdint> 20 #include <vector> 21 22 #include "i_vibrator_decoder.h" 23 #include "json_parser.h" 24 25 namespace OHOS { 26 namespace Sensors { 27 class HEVibratorDecoder : public IVibratorDecoder { 28 public: 29 HEVibratorDecoder() = default; 30 ~HEVibratorDecoder() = default; 31 int32_t DecodeEffect(const RawFileDescriptor &rawFd, const JsonParser &parser, 32 VibratePackage &patternPackage) override; 33 private: 34 int32_t ParseVersion(const JsonParser &parser); 35 int32_t ParsePatternList(const JsonParser& parser, cJSON* patternListJSON, VibratePackage& pkg); 36 int32_t ParsePattern(const JsonParser &parser, cJSON *patternJSON, VibratePattern &pattern); 37 int32_t ParseEvent(const JsonParser &parser, cJSON *eventJSON, VibrateEvent &event); 38 int32_t ParseCurve(const JsonParser &parser, cJSON *curveJSON, VibrateEvent &event); 39 bool CheckEventParameters(const VibrateEvent& event); 40 bool CheckCommonParameters(const VibrateEvent& event); 41 bool CheckTransientParameters(const VibrateEvent& event); 42 bool CheckContinuousParameters(const VibrateEvent& event); 43 }; 44 } // namespace Sensors 45 } // namespace OHOS 46 #endif // HE_VIBRATOR_DECODER_H