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 "android/os/Temperature.h"
18 
19 #include <math.h>
20 #include <stdint.h>
21 #include <binder/Parcel.h>
22 #include <hardware/thermal.h>
23 #include <sys/types.h>
24 #include <utils/Errors.h>
25 
26 namespace android {
27 namespace os {
28 
Temperature()29 Temperature::Temperature() : value_(NAN), type_(DEVICE_TEMPERATURE_UNKNOWN) {}
30 
Temperature(const float value,const int type)31 Temperature::Temperature(const float value, const int type) :
32     value_(value), type_(type)  {}
33 
~Temperature()34 Temperature::~Temperature() {}
35 
36 /*
37  * Parcel read/write code must be kept in sync with
38  * frameworks/base/core/java/android/os/Temperature.java
39  */
40 
readFromParcel(const Parcel * p)41 status_t Temperature::readFromParcel(const Parcel* p) {
42     value_ = p->readFloat();
43     type_ = p->readInt32();
44     return OK;
45 }
46 
writeToParcel(Parcel * p) const47 status_t Temperature::writeToParcel(Parcel* p) const {
48     p->writeFloat(value_);
49     p->writeInt32(type_);
50     return OK;
51 }
52 
53 }  // namespace os
54 }  // namespace android
55