Home | History | Annotate | Download | only in os
      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 package android.os;
     18 
     19 /**
     20  * Temperature values used by IThermalService.
     21  */
     22 
     23 /**
     24  * @hide
     25  */
     26 public class Temperature implements Parcelable {
     27     /* Temperature value */
     28     private float mValue;
     29     /* A temperature type from HardwarePropertiesManager */
     30     private int mType;
     31 
     32     public Temperature() {
     33         this(HardwarePropertiesManager.UNDEFINED_TEMPERATURE,
     34             Integer.MIN_VALUE);
     35     }
     36 
     37     public Temperature(float value, int type) {
     38         mValue = value;
     39         mType = type;
     40     }
     41 
     42     /**
     43      * Return the temperature value.
     44      * @return a temperature value in floating point.
     45      */
     46     public float getValue() {
     47         return mValue;
     48     }
     49 
     50     /**
     51      * Return the temperature type.
     52      * @return a temperature type:
     53      *         HardwarePropertiesManager.DEVICE_TEMPERATURE_CPU, etc.
     54      */
     55     public int getType() {
     56         return mType;
     57     }
     58 
     59     /*
     60      * Parcel read/write code must be kept in sync with
     61      * frameworks/native/services/thermalservice/aidl/android/os/
     62      * Temperature.cpp
     63      */
     64 
     65     private Temperature(Parcel p) {
     66         readFromParcel(p);
     67     }
     68 
     69     /**
     70      * Fill in Temperature members from a Parcel.
     71      * @param p the parceled Temperature object.
     72      */
     73     public void readFromParcel(Parcel p) {
     74         mValue = p.readFloat();
     75         mType = p.readInt();
     76     }
     77 
     78     @Override
     79     public void writeToParcel(Parcel p, int flags) {
     80         p.writeFloat(mValue);
     81         p.writeInt(mType);
     82     }
     83 
     84     public static final Parcelable.Creator<Temperature> CREATOR =
     85             new Parcelable.Creator<Temperature>() {
     86         @Override
     87         public Temperature createFromParcel(Parcel p) {
     88             return new Temperature(p);
     89         }
     90 
     91         @Override
     92         public Temperature[] newArray(int size) {
     93             return new Temperature[size];
     94         }
     95     };
     96 
     97     @Override
     98     public int describeContents() {
     99         return 0;
    100     }
    101 }
    102