1 /*
2  * Copyright (C) 2016 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 CHRE_PLATFORM_PLATFORM_SENSOR_H_
18 #define CHRE_PLATFORM_PLATFORM_SENSOR_H_
19 
20 #include "chre/core/sensor_request.h"
21 #include "chre/core/sensor_type.h"
22 #include "chre/platform/fatal_error.h"
23 #include "chre/target_platform/platform_sensor_base.h"
24 #include "chre/util/dynamic_vector.h"
25 
26 namespace chre {
27 
28 /**
29  * Defines the common interface to sensor functionality that is implemented in a
30  * platform-specific way, and must be supported on every platform.
31  *
32  * @see Sensor
33  */
34 class PlatformSensor : public PlatformSensorBase, public NonCopyable {
35  public:
36   /**
37    * Obtains the SensorType of this platform sensor. The implementation of this
38    * method is supplied by the platform as the mechanism for determining the
39    * type may vary across platforms.
40    *
41    * @return The type of this sensor.
42    */
43   uint8_t getSensorType() const;
44 
45   /**
46    * @return This sensor's minimum supported sampling interval, in nanoseconds.
47    */
48   uint64_t getMinInterval() const;
49 
50   /**
51    * @return Whether this sensor reports bias events.
52    */
53   bool reportsBiasEvents() const;
54 
55   /**
56    * @return Whether this sensor supports passive requests.
57    */
58   bool supportsPassiveMode() const;
59 
60   /**
61    * Returns a descriptive name (e.g. type and model) for this sensor.
62    *
63    * @return A pointer to a string with storage duration at least as long as the
64    *         lifetime of this object.
65    */
66   const char *getSensorName() const;
67 
68   /**
69    * @return The index of the sensor.
70    */
71   uint8_t getSensorIndex() const;
72 
73   /**
74    * @return The mask of groups that events this sensor produces should target.
75    */
76   uint16_t getTargetGroupMask() const;
77 
78  protected:
79   /**
80    * Default constructor that puts this instance in an unspecified state.
81    * Additional platform-specific initialization will likely be necessary to put
82    * this object in a usable state. Do not construct PlatformSensor directly;
83    * instead construct via Sensor.
84    */
85   PlatformSensor() = default;
86 
87   PlatformSensor(PlatformSensor &&other);
88   PlatformSensor &operator=(PlatformSensor &&other);
89 
90   ~PlatformSensor() = default;
91 };
92 
93 }  // namespace chre
94 
95 #endif  // CHRE_PLATFORM_PLATFORM_SENSOR_H_
96