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 
21 void PlatformSensorBase::initBase(uint8_t sensorType, uint64_t minInterval,
22                                   const char *sensorName,
23                                   bool passiveSupported) {
24   mSensorType = sensorType;
25   mMinInterval = minInterval;
26   memcpy(mSensorName, sensorName, kSensorNameMaxLen);
27 
28   mPassiveSupported = passiveSupported;
29 }
30 
31 uint8_t PlatformSensor::getSensorType() const {
32   return mSensorType;
33 }
34 
35 uint64_t PlatformSensor::getMinInterval() const {
36   return mMinInterval;
37 }
38 
39 bool PlatformSensor::reportsBiasEvents() const {
40   return PlatformSensorTypeHelpersBase::reportsBias(mSensorType);
41 }
42 
43 bool PlatformSensor::supportsPassiveMode() const {
44   return mPassiveSupported;
45 }
46 
47 const char *PlatformSensor::getSensorName() const {
48   return mSensorName;
49 }
50 
51 PlatformSensor::PlatformSensor(PlatformSensor &&other) {
52   *this = std::move(other);
53 }
54 
55 PlatformSensor &PlatformSensor::operator=(PlatformSensor &&other) {
56   // Note: if this implementation is ever changed to depend on "this" containing
57   // initialized values, the move constructor implementation must be updated.
58   mSensorType = other.mSensorType;
59   mMinInterval = other.mMinInterval;
60   mPassiveSupported = other.mPassiveSupported;
61 
62   memcpy(mSensorName, other.mSensorName, kSensorNameMaxLen);
63 
64   return *this;
65 }
66 
67 }  // namespace chre
68