Add automatic lighting control framework
Add changes to have the ability to turn on and off the automatic light sensing for the device. This is fully configurable and is by default not present. Vendors should override the ALS setting to enable the automatic lighting controls. These changes will add a check box to the Brightness settings menu to give control to the user to allow the device's display lighting to be controlled via the slide bar or the auto lighting system. If the user selects auto then the slide bar will become invisible. Manual mode will present the slide bar to the user. Change-Id: I146a6d75b99b08c9b839218ce6b85adf21f9fd73 Signed-off-by: Dan Murphy <D.Murphy@motorola.com> Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
committed by
Mike Lockwood
parent
151921a624
commit
951764b970
@@ -59,6 +59,8 @@ public class HardwareService extends IHardwareService.Stub {
|
||||
private boolean mAttentionLightOn;
|
||||
private boolean mPulsing;
|
||||
|
||||
private boolean mAutoBrightnessAvailable;
|
||||
|
||||
private class Vibration implements IBinder.DeathRecipient {
|
||||
private final IBinder mToken;
|
||||
private final long mTimeout;
|
||||
@@ -129,6 +131,9 @@ public class HardwareService extends IHardwareService.Stub {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
context.registerReceiver(mIntentReceiver, filter);
|
||||
|
||||
mAutoBrightnessAvailable = context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_automatic_brightness_available);
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
@@ -302,6 +307,20 @@ public class HardwareService extends IHardwareService.Stub {
|
||||
setLight_native(mNativePointer, light, color, mode, onMS, offMS);
|
||||
}
|
||||
|
||||
public void setAutoBrightness(boolean on) {
|
||||
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.HARDWARE_TEST)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
throw new SecurityException("Requires HARDWARE_TEST permission");
|
||||
}
|
||||
setAutoBrightness_UNCHECKED(on);
|
||||
}
|
||||
|
||||
void setAutoBrightness_UNCHECKED(boolean on) {
|
||||
if (mAutoBrightnessAvailable) {
|
||||
setAutoBrightness_native(mNativePointer, on);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttentionLight(boolean on) {
|
||||
// Not worthy of a permission. We shouldn't have a flashlight permission.
|
||||
synchronized (this) {
|
||||
@@ -502,6 +521,7 @@ public class HardwareService extends IHardwareService.Stub {
|
||||
private static native int init_native();
|
||||
private static native void finalize_native(int ptr);
|
||||
|
||||
private static native void setAutoBrightness_native(int ptr, boolean automatic);
|
||||
private static native void setLight_native(int ptr, int light, int color, int mode,
|
||||
int onMS, int offMS);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user