1 /* 2 * Copyright (c) 2022 Chipsea Technologies (Shenzhen) Corp., 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 SENSOR_SERVICE_CLIENT_H 17 #define SENSOR_SERVICE_CLIENT_H 18 19 #include <map> 20 #include <vector> 21 #include "iservice_registry.h" 22 #include "medical_sensor.h" 23 #include "medical_sensor_basic_data_channel.h" 24 #include "medical_sensor_basic_info.h" 25 #include "medical_sensor_client_stub.h" 26 #include "medical_sensor_data_channel.h" 27 #include "medical_sensor_service_proxy.h" 28 #include "singleton.h" 29 #include "medical_native_type.h" 30 31 namespace OHOS { 32 namespace Sensors { 33 class MedicalSensorServiceClient : public Singleton<MedicalSensorServiceClient> { 34 public: 35 std::vector<MedicalSensor> GetSensorList(); 36 int32_t EnableSensor(uint32_t sensorId, int64_t samplingPeroid, int64_t maxReportDelay); 37 int32_t DisableSensor(uint32_t sensorId); 38 int32_t RunCommand(uint32_t sensorId, int32_t cmdType, int32_t parms); 39 int32_t TransferDataChannel(sptr<MedicalSensorDataChannel> sensorDataChannel); 40 int32_t DestroyDataChannel(); 41 void ProcessDeathObserver(const wptr<IRemoteObject> &object); 42 int32_t SetOption(uint32_t sensorId, uint32_t opt); 43 44 private: 45 int32_t InitServiceClient(); 46 void UpdateSensorInfoMap(uint32_t sensorId, int64_t samplingPeroid, int64_t maxReportDelay); 47 void DeleteSensorInfoItem(uint32_t sensorId); 48 bool IsValidSensorId(uint32_t sensorId); 49 std::mutex clientMutex_; 50 sptr<IRemoteObject::DeathRecipient> serviceDeathObserver_; 51 sptr<IMedicalSensorService> afeServer_; 52 std::vector<MedicalSensor> afeList_; 53 sptr<MedicalSensorDataChannel> dataChannel_; 54 sptr<MedicalSensorClientStub> afeClientStub_; 55 std::mutex mapMutex_; 56 std::map<uint32_t, MedicalSensorBasicInfo> sensorInfoMap_; 57 }; 58 } // namespace Sensors 59 } // namespace OHOS 60 61 #endif // SENSOR_SERVICE_CLIENT_H 62