| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.hardware.display; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.annotation.SystemApi; |
| 22 |
import android.os.Parcel; |
| 23 |
import android.os.Parcelable; |
| 24 |
|
| 25 |
import java.util.Objects; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
@SystemApi |
| 34 |
public final class BrightnessChangeEvent implements Parcelable { |
| 35 |
|
| 36 |
public final float brightness; |
| 37 |
|
| 38 |
|
| 39 |
public final long timeStamp; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public final String packageName; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
public final int userId; |
| 49 |
|
| 50 |
|
| 51 |
@NonNull |
| 52 |
public final String uniqueDisplayId; |
| 53 |
|
| 54 |
|
| 55 |
public final float[] luxValues; |
| 56 |
|
| 57 |
|
| 58 |
public final long[] luxTimestamps; |
| 59 |
|
| 60 |
|
| 61 |
public final float batteryLevel; |
| 62 |
|
| 63 |
|
| 64 |
public final float powerBrightnessFactor; |
| 65 |
|
| 66 |
|
| 67 |
public final boolean nightMode; |
| 68 |
|
| 69 |
|
| 70 |
public final int colorTemperature; |
| 71 |
|
| 72 |
|
| 73 |
public final boolean reduceBrightColors; |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
public final int reduceBrightColorsStrength; |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
public final float reduceBrightColorsOffset; |
| 88 |
|
| 89 |
|
| 90 |
public final float lastBrightness; |
| 91 |
|
| 92 |
|
| 93 |
public final boolean isDefaultBrightnessConfig; |
| 94 |
|
| 95 |
|
| 96 |
public final boolean isUserSetBrightness; |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
@Nullable |
| 113 |
public final long[] colorValueBuckets; |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
public final long colorSampleDuration; |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
private BrightnessChangeEvent(float brightness, long timeStamp, String packageName, |
| 127 |
int userId, String uniqueDisplayId, float[] luxValues, long[] luxTimestamps, |
| 128 |
float batteryLevel, float powerBrightnessFactor, boolean nightMode, |
| 129 |
int colorTemperature, boolean reduceBrightColors, int reduceBrightColorsStrength, |
| 130 |
float reduceBrightColorsOffset, float lastBrightness, boolean isDefaultBrightnessConfig, |
| 131 |
boolean isUserSetBrightness, long[] colorValueBuckets, long colorSampleDuration) { |
| 132 |
this.brightness = brightness; |
| 133 |
this.timeStamp = timeStamp; |
| 134 |
this.packageName = packageName; |
| 135 |
this.userId = userId; |
| 136 |
this.uniqueDisplayId = uniqueDisplayId; |
| 137 |
this.luxValues = luxValues; |
| 138 |
this.luxTimestamps = luxTimestamps; |
| 139 |
this.batteryLevel = batteryLevel; |
| 140 |
this.powerBrightnessFactor = powerBrightnessFactor; |
| 141 |
this.nightMode = nightMode; |
| 142 |
this.colorTemperature = colorTemperature; |
| 143 |
this.reduceBrightColors = reduceBrightColors; |
| 144 |
this.reduceBrightColorsStrength = reduceBrightColorsStrength; |
| 145 |
this.reduceBrightColorsOffset = reduceBrightColorsOffset; |
| 146 |
this.lastBrightness = lastBrightness; |
| 147 |
this.isDefaultBrightnessConfig = isDefaultBrightnessConfig; |
| 148 |
this.isUserSetBrightness = isUserSetBrightness; |
| 149 |
this.colorValueBuckets = colorValueBuckets; |
| 150 |
this.colorSampleDuration = colorSampleDuration; |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
public BrightnessChangeEvent(BrightnessChangeEvent other, boolean redactPackage) { |
| 155 |
this.brightness = other.brightness; |
| 156 |
this.timeStamp = other.timeStamp; |
| 157 |
this.packageName = redactPackage ? null : other.packageName; |
| 158 |
this.userId = other.userId; |
| 159 |
this.uniqueDisplayId = other.uniqueDisplayId; |
| 160 |
this.luxValues = other.luxValues; |
| 161 |
this.luxTimestamps = other.luxTimestamps; |
| 162 |
this.batteryLevel = other.batteryLevel; |
| 163 |
this.powerBrightnessFactor = other.powerBrightnessFactor; |
| 164 |
this.nightMode = other.nightMode; |
| 165 |
this.colorTemperature = other.colorTemperature; |
| 166 |
this.reduceBrightColors = other.reduceBrightColors; |
| 167 |
this.reduceBrightColorsStrength = other.reduceBrightColorsStrength; |
| 168 |
this.reduceBrightColorsOffset = other.reduceBrightColorsOffset; |
| 169 |
this.lastBrightness = other.lastBrightness; |
| 170 |
this.isDefaultBrightnessConfig = other.isDefaultBrightnessConfig; |
| 171 |
this.isUserSetBrightness = other.isUserSetBrightness; |
| 172 |
this.colorValueBuckets = other.colorValueBuckets; |
| 173 |
this.colorSampleDuration = other.colorSampleDuration; |
| 174 |
} |
| 175 |
|
| 176 |
private BrightnessChangeEvent(Parcel source) { |
| 177 |
brightness = source.readFloat(); |
| 178 |
timeStamp = source.readLong(); |
| 179 |
packageName = source.readString(); |
| 180 |
userId = source.readInt(); |
| 181 |
uniqueDisplayId = source.readString(); |
| 182 |
luxValues = source.createFloatArray(); |
| 183 |
luxTimestamps = source.createLongArray(); |
| 184 |
batteryLevel = source.readFloat(); |
| 185 |
powerBrightnessFactor = source.readFloat(); |
| 186 |
nightMode = source.readBoolean(); |
| 187 |
colorTemperature = source.readInt(); |
| 188 |
reduceBrightColors = source.readBoolean(); |
| 189 |
reduceBrightColorsStrength = source.readInt(); |
| 190 |
reduceBrightColorsOffset = source.readFloat(); |
| 191 |
lastBrightness = source.readFloat(); |
| 192 |
isDefaultBrightnessConfig = source.readBoolean(); |
| 193 |
isUserSetBrightness = source.readBoolean(); |
| 194 |
colorValueBuckets = source.createLongArray(); |
| 195 |
colorSampleDuration = source.readLong(); |
| 196 |
} |
| 197 |
|
| 198 |
public static final @android.annotation.NonNull Creator<BrightnessChangeEvent> CREATOR = |
| 199 |
new Creator<BrightnessChangeEvent>() { |
| 200 |
public BrightnessChangeEvent createFromParcel(Parcel source) { |
| 201 |
return new BrightnessChangeEvent(source); |
| 202 |
} |
| 203 |
public BrightnessChangeEvent[] newArray(int size) { |
| 204 |
return new BrightnessChangeEvent[size]; |
| 205 |
} |
| 206 |
}; |
| 207 |
|
| 208 |
@Override |
| 209 |
public int describeContents() { |
| 210 |
return 0; |
| 211 |
} |
| 212 |
|
| 213 |
@Override |
| 214 |
public void writeToParcel(Parcel dest, int flags) { |
| 215 |
dest.writeFloat(brightness); |
| 216 |
dest.writeLong(timeStamp); |
| 217 |
dest.writeString(packageName); |
| 218 |
dest.writeInt(userId); |
| 219 |
dest.writeString(uniqueDisplayId); |
| 220 |
dest.writeFloatArray(luxValues); |
| 221 |
dest.writeLongArray(luxTimestamps); |
| 222 |
dest.writeFloat(batteryLevel); |
| 223 |
dest.writeFloat(powerBrightnessFactor); |
| 224 |
dest.writeBoolean(nightMode); |
| 225 |
dest.writeInt(colorTemperature); |
| 226 |
dest.writeBoolean(reduceBrightColors); |
| 227 |
dest.writeInt(reduceBrightColorsStrength); |
| 228 |
dest.writeFloat(reduceBrightColorsOffset); |
| 229 |
dest.writeFloat(lastBrightness); |
| 230 |
dest.writeBoolean(isDefaultBrightnessConfig); |
| 231 |
dest.writeBoolean(isUserSetBrightness); |
| 232 |
dest.writeLongArray(colorValueBuckets); |
| 233 |
dest.writeLong(colorSampleDuration); |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
public static class Builder { |
| 238 |
private float mBrightness; |
| 239 |
private long mTimeStamp; |
| 240 |
private String mPackageName; |
| 241 |
private int mUserId; |
| 242 |
private String mUniqueDisplayId; |
| 243 |
private float[] mLuxValues; |
| 244 |
private long[] mLuxTimestamps; |
| 245 |
private float mBatteryLevel; |
| 246 |
private float mPowerBrightnessFactor; |
| 247 |
private boolean mNightMode; |
| 248 |
private int mColorTemperature; |
| 249 |
private boolean mReduceBrightColors; |
| 250 |
private int mReduceBrightColorsStrength; |
| 251 |
private float mReduceBrightColorsOffset; |
| 252 |
private float mLastBrightness; |
| 253 |
private boolean mIsDefaultBrightnessConfig; |
| 254 |
private boolean mIsUserSetBrightness; |
| 255 |
private long[] mColorValueBuckets; |
| 256 |
private long mColorSampleDuration; |
| 257 |
|
| 258 |
|
| 259 |
public Builder setBrightness(float brightness) { |
| 260 |
mBrightness = brightness; |
| 261 |
return this; |
| 262 |
} |
| 263 |
|
| 264 |
|
| 265 |
public Builder setTimeStamp(long timeStamp) { |
| 266 |
mTimeStamp = timeStamp; |
| 267 |
return this; |
| 268 |
} |
| 269 |
|
| 270 |
|
| 271 |
public Builder setPackageName(String packageName) { |
| 272 |
mPackageName = packageName; |
| 273 |
return this; |
| 274 |
} |
| 275 |
|
| 276 |
|
| 277 |
public Builder setUserId(int userId) { |
| 278 |
mUserId = userId; |
| 279 |
return this; |
| 280 |
} |
| 281 |
|
| 282 |
|
| 283 |
public Builder setUniqueDisplayId(String uniqueId) { |
| 284 |
mUniqueDisplayId = uniqueId; |
| 285 |
return this; |
| 286 |
} |
| 287 |
|
| 288 |
|
| 289 |
public Builder setLuxValues(float[] luxValues) { |
| 290 |
mLuxValues = luxValues; |
| 291 |
return this; |
| 292 |
} |
| 293 |
|
| 294 |
|
| 295 |
public Builder setLuxTimestamps(long[] luxTimestamps) { |
| 296 |
mLuxTimestamps = luxTimestamps; |
| 297 |
return this; |
| 298 |
} |
| 299 |
|
| 300 |
|
| 301 |
public Builder setBatteryLevel(float batteryLevel) { |
| 302 |
mBatteryLevel = batteryLevel; |
| 303 |
return this; |
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
public Builder setPowerBrightnessFactor(float powerBrightnessFactor) { |
| 308 |
mPowerBrightnessFactor = powerBrightnessFactor; |
| 309 |
return this; |
| 310 |
} |
| 311 |
|
| 312 |
|
| 313 |
public Builder setNightMode(boolean nightMode) { |
| 314 |
mNightMode = nightMode; |
| 315 |
return this; |
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
public Builder setColorTemperature(int colorTemperature) { |
| 320 |
mColorTemperature = colorTemperature; |
| 321 |
return this; |
| 322 |
} |
| 323 |
|
| 324 |
|
| 325 |
public Builder setReduceBrightColors(boolean reduceBrightColors) { |
| 326 |
mReduceBrightColors = reduceBrightColors; |
| 327 |
return this; |
| 328 |
} |
| 329 |
|
| 330 |
|
| 331 |
public Builder setReduceBrightColorsStrength(int strength) { |
| 332 |
mReduceBrightColorsStrength = strength; |
| 333 |
return this; |
| 334 |
} |
| 335 |
|
| 336 |
|
| 337 |
public Builder setReduceBrightColorsOffset(float offset) { |
| 338 |
mReduceBrightColorsOffset = offset; |
| 339 |
return this; |
| 340 |
} |
| 341 |
|
| 342 |
|
| 343 |
public Builder setLastBrightness(float lastBrightness) { |
| 344 |
mLastBrightness = lastBrightness; |
| 345 |
return this; |
| 346 |
} |
| 347 |
|
| 348 |
|
| 349 |
public Builder setIsDefaultBrightnessConfig(boolean isDefaultBrightnessConfig) { |
| 350 |
mIsDefaultBrightnessConfig = isDefaultBrightnessConfig; |
| 351 |
return this; |
| 352 |
} |
| 353 |
|
| 354 |
|
| 355 |
public Builder setUserBrightnessPoint(boolean isUserSetBrightness) { |
| 356 |
mIsUserSetBrightness = isUserSetBrightness; |
| 357 |
return this; |
| 358 |
} |
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
public Builder setColorValues(@NonNull long[] colorValueBuckets, long colorSampleDuration) { |
| 363 |
Objects.requireNonNull(colorValueBuckets); |
| 364 |
mColorValueBuckets = colorValueBuckets; |
| 365 |
mColorSampleDuration = colorSampleDuration; |
| 366 |
return this; |
| 367 |
} |
| 368 |
|
| 369 |
|
| 370 |
public BrightnessChangeEvent build() { |
| 371 |
return new BrightnessChangeEvent(mBrightness, mTimeStamp, |
| 372 |
mPackageName, mUserId, mUniqueDisplayId, mLuxValues, mLuxTimestamps, |
| 373 |
mBatteryLevel, mPowerBrightnessFactor, mNightMode, mColorTemperature, |
| 374 |
mReduceBrightColors, mReduceBrightColorsStrength, mReduceBrightColorsOffset, |
| 375 |
mLastBrightness, mIsDefaultBrightnessConfig, mIsUserSetBrightness, |
| 376 |
mColorValueBuckets, mColorSampleDuration); |
| 377 |
} |
| 378 |
} |
| 379 |
} |