1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_SENSORHAL_EXT_BASE_DYNAMIC_SENSOR_DAEMON_H 18 #define ANDROID_SENSORHAL_EXT_BASE_DYNAMIC_SENSOR_DAEMON_H 19 20 #include "BaseSensorObject.h" 21 22 #include <utils/RefBase.h> 23 #include <string> 24 #include <unordered_map> 25 26 namespace android { 27 namespace SensorHalExt { 28 29 class DynamicSensorManager; 30 31 typedef std::vector<sp<BaseSensorObject>> BaseSensorVector; 32 33 class BaseDynamicSensorDaemon : public RefBase { 34 public: BaseDynamicSensorDaemon(DynamicSensorManager & manager)35 BaseDynamicSensorDaemon(DynamicSensorManager& manager) : mManager(manager) {} 36 virtual ~BaseDynamicSensorDaemon() = default; 37 38 virtual bool onConnectionChange(const std::string &deviceKey, bool connected); 39 protected: 40 virtual BaseSensorVector createSensor(const std::string &deviceKey) = 0; removeSensor(const std::string &)41 virtual void removeSensor(const std::string &/*deviceKey*/) {}; 42 43 DynamicSensorManager &mManager; 44 std::unordered_map<std::string, BaseSensorVector> mDeviceKeySensorMap; 45 }; 46 47 } // namespace SensorHalExt 48 } // namespace android 49 50 #endif // ANDROID_SENSORHAL_EXT_BASE_DYNAMIC_SENSOR_DAEMON_H 51 52