Merge "Add pipeline to get the sysfs path for an InputDevice's battery"

This commit is contained in:
Prabir Pradhan
2022-09-12 20:33:31 +00:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 0 deletions

View File

@@ -16,6 +16,7 @@
package com.android.server.input;
import android.annotation.Nullable;
import android.hardware.display.DisplayViewport;
import android.hardware.input.InputSensorInfo;
import android.hardware.lights.Light;
@@ -141,6 +142,13 @@ public interface NativeInputManagerService {
int getBatteryStatus(int deviceId);
/**
* Get the device path of the battery for an input device.
* @return the path for the input device battery, or null if there is none.
*/
@Nullable
String getBatteryDevicePath(int deviceId);
List<Light> getLights(int deviceId);
int getLightPlayerId(int deviceId, int lightId);
@@ -326,6 +334,9 @@ public interface NativeInputManagerService {
@Override
public native int getBatteryStatus(int deviceId);
@Override
public native String getBatteryDevicePath(int deviceId);
@Override
public native List<Light> getLights(int deviceId);

View File

@@ -2090,6 +2090,14 @@ static jint nativeGetBatteryStatus(JNIEnv* env, jobject nativeImplObj, jint devi
return static_cast<jint>(ret.value_or(BATTERY_STATUS_UNKNOWN));
}
static jstring nativeGetBatteryDevicePath(JNIEnv* env, jobject nativeImplObj, jint deviceId) {
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
const std::optional<std::string> batteryPath =
im->getInputManager()->getReader().getBatteryDevicePath(deviceId);
return batteryPath ? env->NewStringUTF(batteryPath->c_str()) : nullptr;
}
static void nativeReloadKeyboardLayouts(JNIEnv* env, jobject nativeImplObj) {
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
@@ -2371,6 +2379,7 @@ static const JNINativeMethod gInputManagerMethods[] = {
{"setLightColor", "(III)V", (void*)nativeSetLightColor},
{"getBatteryCapacity", "(I)I", (void*)nativeGetBatteryCapacity},
{"getBatteryStatus", "(I)I", (void*)nativeGetBatteryStatus},
{"getBatteryDevicePath", "(I)Ljava/lang/String;", (void*)nativeGetBatteryDevicePath},
{"reloadKeyboardLayouts", "()V", (void*)nativeReloadKeyboardLayouts},
{"reloadDeviceAliases", "()V", (void*)nativeReloadDeviceAliases},
{"dump", "()Ljava/lang/String;", (void*)nativeDump},