-
Notifications
You must be signed in to change notification settings - Fork 10
Button Backlight Control
We made a new implementation of button backlight control.
It is relatively easy to set it up, here we'll show you how to do that.
First create the file xoshw/ButtonBacklightControl.java with following content:
/*
* Copyright (C) 2016 halogenOS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.halogenos.hardware.buttons;
import org.halogenos.hardware.buttons.IButtonBacklightControl;
/**
* This class is supposed to control button backlight
*/
public class ButtonBacklightControl extends IButtonBacklightControl {
public ButtonBacklightControl() {
}
}Inside of public ButtonBacklightControl()... you will have to specify some things which are device-specific.
First of all, the CONTROL_TYPE needs to be specified.
CONTROL_TYPE = CONTROL_TYPE_FULL: Brightness can be changed seamlessly.
CONTROL_TYPE = CONTROL_TYPE_PARTIAL: Only 3 brightness modes, On, Dimmed and Off.
CONTROL_TYPE = CONTROL_TYPE_SWITCH: Backlight can only be turned on and off, no brightness change is possible.
CONTROL_TYPE = CONTROL_TYPE_NONE: No backlight. If you don't have backlight, you don't need this file, CONTROL_TYPE_NONE would be default.
Then you will have some optional things which you can also set:
BUTTON_BACKLIGHT_PATH: The path to the button backlight control folder, where the control files are stored. Default is /sys/class/leds/button-backlight/ and should work on any device.
BRIGHTNESS_CONTROL: Direct path to the file which controls the brightness. Default is the file brightness in BUTTON_BACKLIGHT_PATH.
MAX_BRIGHTNESS_CONTORL: Direct path to the file which contains the maximum brightness value. Default is file max_brightness in BUTTON_BACKLIGHT_PATH.
MAXIMUM_BRIGHTNESS: In case you have to specify the brightness manually, specify it here. This value is usually auto-detected.
You can see an example here: https://github.com/halogenOS/android_device_oneplus_oneplus2/blob/XOS-7.0/xoshw/ButtonBacklightControl.java