• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "chre/platform/platform_sensor.h"
18 
19 namespace chre {
20 
initBase(uint8_t sensorType,uint64_t minInterval,const char * sensorName,bool passiveSupported,uint16_t targetGroupMask)21 void PlatformSensorBase::initBase(uint8_t sensorType, uint64_t minInterval,
22                                   const char *sensorName, bool passiveSupported,
23                                   uint16_t targetGroupMask) {
24   mSensorType = sensorType;
25   mMinInterval = minInterval;
26   memcpy(mSensorName, sensorName, kSensorNameMaxLen);
27 
28   mPassiveSupported = passiveSupported;
29   mTargetGroupMask = targetGroupMask;
30 }
31 
getSensorType() const32 uint8_t PlatformSensor::getSensorType() const {
33   return mSensorType;
34 }
35 
getMinInterval() const36 uint64_t PlatformSensor::getMinInterval() const {
37   return mMinInterval;
38 }
39 
reportsBiasEvents() const40 bool PlatformSensor::reportsBiasEvents() const {
41   return PlatformSensorTypeHelpersBase::reportsBias(mSensorType);
42 }
43 
supportsPassiveMode() const44 bool PlatformSensor::supportsPassiveMode() const {
45   return mPassiveSupported;
46 }
47 
getSensorName() const48 const char *PlatformSensor::getSensorName() const {
49   return mSensorName;
50 }
51 
getTargetGroupMask() const52 uint16_t PlatformSensor::getTargetGroupMask() const {
53   return mTargetGroupMask;
54 }
55 
PlatformSensor(PlatformSensor && other)56 PlatformSensor::PlatformSensor(PlatformSensor &&other) {
57   *this = std::move(other);
58 }
59 
getSensorIndex() const60 uint8_t PlatformSensor::getSensorIndex() const {
61   return CHRE_SENSOR_INDEX_DEFAULT;
62 }
63 
operator =(PlatformSensor && other)64 PlatformSensor &PlatformSensor::operator=(PlatformSensor &&other) {
65   // Note: if this implementation is ever changed to depend on "this" containing
66   // initialized values, the move constructor implementation must be updated.
67   mSensorType = other.mSensorType;
68   mMinInterval = other.mMinInterval;
69   mPassiveSupported = other.mPassiveSupported;
70   mTargetGroupMask = other.mTargetGroupMask;
71 
72   memcpy(mSensorName, other.mSensorName, kSensorNameMaxLen);
73 
74   return *this;
75 }
76 
77 }  // namespace chre
78