Add pipeline to get the sysfs path for an InputDevice's battery
Bug: 243005009 Test: atest inputflinger_tests Test: manual with logs Change-Id: Ia7f0ecd31cac2f38dc965c74b5c9162fa24f4cbc
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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},
|
||||
|
||||
Reference in New Issue
Block a user