Loading services/core/java/com/android/server/input/InputManagerService.java +20 −3 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ import android.os.RemoteCallbackList; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ShellCallback; import android.os.SystemProperties; import android.os.UserHandle; import android.os.VibrationEffect; import android.os.vibrator.StepSegment; Loading Loading @@ -158,6 +159,11 @@ public class InputManagerService extends IInputManager.Stub private static final AdditionalDisplayInputProperties DEFAULT_ADDITIONAL_DISPLAY_INPUT_PROPERTIES = new AdditionalDisplayInputProperties(); // To disable Keyboard backlight control via Framework, run: // 'adb shell setprop persist.input.keyboard_backlight_control.enabled false' (requires restart) private static final boolean KEYBOARD_BACKLIGHT_CONTROL_ENABLED = SystemProperties.getBoolean( "persist.input.keyboard.backlight_control.enabled", true); private final NativeInputManagerService mNative; private final Context mContext; Loading Loading @@ -305,7 +311,7 @@ public class InputManagerService extends IInputManager.Stub private final BatteryController mBatteryController; // Manages Keyboard backlight private final KeyboardBacklightController mKeyboardBacklightController; private final KeyboardBacklightControllerInterface mKeyboardBacklightController; // Manages Keyboard modifier keys remapping private final KeyRemapper mKeyRemapper; Loading Loading @@ -422,8 +428,10 @@ public class InputManagerService extends IInputManager.Stub mKeyboardLayoutManager = new KeyboardLayoutManager(mContext, mNative, mDataStore, injector.getLooper()); mBatteryController = new BatteryController(mContext, mNative, injector.getLooper()); mKeyboardBacklightController = new KeyboardBacklightController(mContext, mNative, mDataStore, injector.getLooper()); mKeyboardBacklightController = KEYBOARD_BACKLIGHT_CONTROL_ENABLED ? new KeyboardBacklightController(mContext, mNative, mDataStore, injector.getLooper()) : new KeyboardBacklightControllerInterface() {}; mKeyRemapper = new KeyRemapper(mContext, mNative, mDataStore, injector.getLooper()); mUseDevInputEventForAudioJack = Loading Loading @@ -3475,4 +3483,13 @@ public class InputManagerService extends IInputManager.Stub applyAdditionalDisplayInputPropertiesLocked(properties); } } interface KeyboardBacklightControllerInterface { default void incrementKeyboardBacklight(int deviceId) {} default void decrementKeyboardBacklight(int deviceId) {} default void registerKeyboardBacklightListener(IKeyboardBacklightListener l, int pid) {} default void unregisterKeyboardBacklightListener(IKeyboardBacklightListener l, int pid) {} default void systemRunning() {} default void dump(PrintWriter pw) {} } } services/core/java/com/android/server/input/KeyboardBacklightController.java +10 −3 Original line number Diff line number Diff line Loading @@ -47,7 +47,8 @@ import java.util.TreeSet; * A thread-safe component of {@link InputManagerService} responsible for managing the keyboard * backlight for supported keyboards. */ final class KeyboardBacklightController implements InputManager.InputDeviceListener { final class KeyboardBacklightController implements InputManagerService.KeyboardBacklightControllerInterface, InputManager.InputDeviceListener { private static final String TAG = "KbdBacklightController"; Loading Loading @@ -96,7 +97,8 @@ final class KeyboardBacklightController implements InputManager.InputDeviceListe mHandler = new Handler(looper, this::handleMessage); } void systemRunning() { @Override public void systemRunning() { InputManager inputManager = Objects.requireNonNull( mContext.getSystemService(InputManager.class)); inputManager.registerInputDeviceListener(this, mHandler); Loading @@ -106,11 +108,13 @@ final class KeyboardBacklightController implements InputManager.InputDeviceListe } } @Override public void incrementKeyboardBacklight(int deviceId) { Message msg = Message.obtain(mHandler, MSG_INCREMENT_KEYBOARD_BACKLIGHT, deviceId); mHandler.sendMessage(msg); } @Override public void decrementKeyboardBacklight(int deviceId) { Message msg = Message.obtain(mHandler, MSG_DECREMENT_KEYBOARD_BACKLIGHT, deviceId); mHandler.sendMessage(msg); Loading Loading @@ -232,6 +236,7 @@ final class KeyboardBacklightController implements InputManager.InputDeviceListe /** Register the keyboard backlight listener for a process. */ @BinderThread @Override public void registerKeyboardBacklightListener(IKeyboardBacklightListener listener, int pid) { synchronized (mKeyboardBacklightListenerRecords) { Loading @@ -252,6 +257,7 @@ final class KeyboardBacklightController implements InputManager.InputDeviceListe /** Unregister the keyboard backlight listener for a process. */ @BinderThread @Override public void unregisterKeyboardBacklightListener(IKeyboardBacklightListener listener, int pid) { synchronized (mKeyboardBacklightListenerRecords) { Loading Loading @@ -286,7 +292,8 @@ final class KeyboardBacklightController implements InputManager.InputDeviceListe } } void dump(PrintWriter pw) { @Override public void dump(PrintWriter pw) { IndentingPrintWriter ipw = new IndentingPrintWriter(pw); ipw.println(TAG + ": " + mKeyboardBacklights.size() + " keyboard backlights"); ipw.increaseIndent(); Loading Loading
services/core/java/com/android/server/input/InputManagerService.java +20 −3 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ import android.os.RemoteCallbackList; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ShellCallback; import android.os.SystemProperties; import android.os.UserHandle; import android.os.VibrationEffect; import android.os.vibrator.StepSegment; Loading Loading @@ -158,6 +159,11 @@ public class InputManagerService extends IInputManager.Stub private static final AdditionalDisplayInputProperties DEFAULT_ADDITIONAL_DISPLAY_INPUT_PROPERTIES = new AdditionalDisplayInputProperties(); // To disable Keyboard backlight control via Framework, run: // 'adb shell setprop persist.input.keyboard_backlight_control.enabled false' (requires restart) private static final boolean KEYBOARD_BACKLIGHT_CONTROL_ENABLED = SystemProperties.getBoolean( "persist.input.keyboard.backlight_control.enabled", true); private final NativeInputManagerService mNative; private final Context mContext; Loading Loading @@ -305,7 +311,7 @@ public class InputManagerService extends IInputManager.Stub private final BatteryController mBatteryController; // Manages Keyboard backlight private final KeyboardBacklightController mKeyboardBacklightController; private final KeyboardBacklightControllerInterface mKeyboardBacklightController; // Manages Keyboard modifier keys remapping private final KeyRemapper mKeyRemapper; Loading Loading @@ -422,8 +428,10 @@ public class InputManagerService extends IInputManager.Stub mKeyboardLayoutManager = new KeyboardLayoutManager(mContext, mNative, mDataStore, injector.getLooper()); mBatteryController = new BatteryController(mContext, mNative, injector.getLooper()); mKeyboardBacklightController = new KeyboardBacklightController(mContext, mNative, mDataStore, injector.getLooper()); mKeyboardBacklightController = KEYBOARD_BACKLIGHT_CONTROL_ENABLED ? new KeyboardBacklightController(mContext, mNative, mDataStore, injector.getLooper()) : new KeyboardBacklightControllerInterface() {}; mKeyRemapper = new KeyRemapper(mContext, mNative, mDataStore, injector.getLooper()); mUseDevInputEventForAudioJack = Loading Loading @@ -3475,4 +3483,13 @@ public class InputManagerService extends IInputManager.Stub applyAdditionalDisplayInputPropertiesLocked(properties); } } interface KeyboardBacklightControllerInterface { default void incrementKeyboardBacklight(int deviceId) {} default void decrementKeyboardBacklight(int deviceId) {} default void registerKeyboardBacklightListener(IKeyboardBacklightListener l, int pid) {} default void unregisterKeyboardBacklightListener(IKeyboardBacklightListener l, int pid) {} default void systemRunning() {} default void dump(PrintWriter pw) {} } }
services/core/java/com/android/server/input/KeyboardBacklightController.java +10 −3 Original line number Diff line number Diff line Loading @@ -47,7 +47,8 @@ import java.util.TreeSet; * A thread-safe component of {@link InputManagerService} responsible for managing the keyboard * backlight for supported keyboards. */ final class KeyboardBacklightController implements InputManager.InputDeviceListener { final class KeyboardBacklightController implements InputManagerService.KeyboardBacklightControllerInterface, InputManager.InputDeviceListener { private static final String TAG = "KbdBacklightController"; Loading Loading @@ -96,7 +97,8 @@ final class KeyboardBacklightController implements InputManager.InputDeviceListe mHandler = new Handler(looper, this::handleMessage); } void systemRunning() { @Override public void systemRunning() { InputManager inputManager = Objects.requireNonNull( mContext.getSystemService(InputManager.class)); inputManager.registerInputDeviceListener(this, mHandler); Loading @@ -106,11 +108,13 @@ final class KeyboardBacklightController implements InputManager.InputDeviceListe } } @Override public void incrementKeyboardBacklight(int deviceId) { Message msg = Message.obtain(mHandler, MSG_INCREMENT_KEYBOARD_BACKLIGHT, deviceId); mHandler.sendMessage(msg); } @Override public void decrementKeyboardBacklight(int deviceId) { Message msg = Message.obtain(mHandler, MSG_DECREMENT_KEYBOARD_BACKLIGHT, deviceId); mHandler.sendMessage(msg); Loading Loading @@ -232,6 +236,7 @@ final class KeyboardBacklightController implements InputManager.InputDeviceListe /** Register the keyboard backlight listener for a process. */ @BinderThread @Override public void registerKeyboardBacklightListener(IKeyboardBacklightListener listener, int pid) { synchronized (mKeyboardBacklightListenerRecords) { Loading @@ -252,6 +257,7 @@ final class KeyboardBacklightController implements InputManager.InputDeviceListe /** Unregister the keyboard backlight listener for a process. */ @BinderThread @Override public void unregisterKeyboardBacklightListener(IKeyboardBacklightListener listener, int pid) { synchronized (mKeyboardBacklightListenerRecords) { Loading Loading @@ -286,7 +292,8 @@ final class KeyboardBacklightController implements InputManager.InputDeviceListe } } void dump(PrintWriter pw) { @Override public void dump(PrintWriter pw) { IndentingPrintWriter ipw = new IndentingPrintWriter(pw); ipw.println(TAG + ": " + mKeyboardBacklights.size() + " keyboard backlights"); ipw.increaseIndent(); Loading