Kenny Guy | 22bd044 | 2017-10-26 00:15:54 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 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.hardware.display; |
| 18 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | |
| 22 | /** |
| 23 | * Data about a brightness settings change. |
| 24 | * TODO make this SystemAPI |
| 25 | * @hide |
| 26 | */ |
| 27 | public final class BrightnessChangeEvent implements Parcelable { |
| 28 | /** Brightness in nits */ |
| 29 | public int brightness; |
| 30 | |
| 31 | /** Timestamp of the change {@see System.currentTimeMillis()} */ |
| 32 | public long timeStamp; |
| 33 | |
| 34 | /** Package name of focused activity when brightness was changed. */ |
| 35 | public String packageName; |
| 36 | |
| 37 | /** User id of of the user running when brightness was changed. |
| 38 | * @hide */ |
| 39 | public int userId; |
| 40 | |
| 41 | /** Lux values of recent sensor data */ |
| 42 | public float[] luxValues; |
| 43 | |
| 44 | /** Timestamps of the lux sensor readings {@see System.currentTimeMillis()} */ |
| 45 | public long[] luxTimestamps; |
| 46 | |
| 47 | /** Most recent battery level when brightness was changed or Float.NaN */ |
| 48 | public float batteryLevel; |
| 49 | |
| 50 | /** Color filter active to provide night mode */ |
| 51 | public boolean nightMode; |
| 52 | |
| 53 | /** If night mode color filter is active this will be the temperature in kelvin */ |
| 54 | public int colorTemperature; |
| 55 | |
| 56 | /** Brightness level before slider adjustment */ |
| 57 | public int lastBrightness; |
| 58 | |
| 59 | public BrightnessChangeEvent() { |
| 60 | } |
| 61 | |
| 62 | private BrightnessChangeEvent(Parcel source) { |
| 63 | brightness = source.readInt(); |
| 64 | timeStamp = source.readLong(); |
| 65 | packageName = source.readString(); |
| 66 | userId = source.readInt(); |
| 67 | luxValues = source.createFloatArray(); |
| 68 | luxTimestamps = source.createLongArray(); |
| 69 | batteryLevel = source.readFloat(); |
| 70 | nightMode = source.readBoolean(); |
| 71 | colorTemperature = source.readInt(); |
| 72 | lastBrightness = source.readInt(); |
| 73 | } |
| 74 | |
| 75 | public static final Creator<BrightnessChangeEvent> CREATOR = |
| 76 | new Creator<BrightnessChangeEvent>() { |
| 77 | public BrightnessChangeEvent createFromParcel(Parcel source) { |
| 78 | return new BrightnessChangeEvent(source); |
| 79 | } |
| 80 | public BrightnessChangeEvent[] newArray(int size) { |
| 81 | return new BrightnessChangeEvent[size]; |
| 82 | } |
| 83 | }; |
| 84 | |
| 85 | @Override |
| 86 | public int describeContents() { |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public void writeToParcel(Parcel dest, int flags) { |
| 92 | dest.writeInt(brightness); |
| 93 | dest.writeLong(timeStamp); |
| 94 | dest.writeString(packageName); |
| 95 | dest.writeInt(userId); |
| 96 | dest.writeFloatArray(luxValues); |
| 97 | dest.writeLongArray(luxTimestamps); |
| 98 | dest.writeFloat(batteryLevel); |
| 99 | dest.writeBoolean(nightMode); |
| 100 | dest.writeInt(colorTemperature); |
| 101 | dest.writeInt(lastBrightness); |
| 102 | } |
| 103 | } |