From affc082fb5a552edd8df61ff3eb55831f25767f5 Mon Sep 17 00:00:00 2001 From: GiviMAD Date: Sat, 13 Mar 2021 20:26:57 +0100 Subject: [PATCH] [androiddebugbridge] fix power wake lock and minor fixes (#10316) Signed-off-by: Miguel --- bundles/org.openhab.binding.androiddebugbridge/README.md | 2 +- .../internal/AndroidDebugBridgeDevice.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bundles/org.openhab.binding.androiddebugbridge/README.md b/bundles/org.openhab.binding.androiddebugbridge/README.md index 9b1ce5c0da..c2c1595497 100644 --- a/bundles/org.openhab.binding.androiddebugbridge/README.md +++ b/bundles/org.openhab.binding.androiddebugbridge/README.md @@ -6,7 +6,7 @@ If you are not familiar with adb I suggest you to search "How to enable adb over ## Supported Things -This binding was tested on the Fire TV Stick (android version 7.1.2, volume control not working) and Nexus5x (android version 8.1.0, everything works nice), please update this document if you tested it with other android versions to reflect the compatibility of the biding. +This binding was tested on the Fire TV Stick (android version 7.1.2, volume control not working) and Nexus5x (android version 8.1.0, everything works nice), please update this document if you tested it with other android versions to reflect the compatibility of the binding. ## Discovery diff --git a/bundles/org.openhab.binding.androiddebugbridge/src/main/java/org/openhab/binding/androiddebugbridge/internal/AndroidDebugBridgeDevice.java b/bundles/org.openhab.binding.androiddebugbridge/src/main/java/org/openhab/binding/androiddebugbridge/internal/AndroidDebugBridgeDevice.java index 8bcdd58e76..1ddb6e642c 100644 --- a/bundles/org.openhab.binding.androiddebugbridge/src/main/java/org/openhab/binding/androiddebugbridge/internal/AndroidDebugBridgeDevice.java +++ b/bundles/org.openhab.binding.androiddebugbridge/src/main/java/org/openhab/binding/androiddebugbridge/internal/AndroidDebugBridgeDevice.java @@ -117,7 +117,7 @@ public class AndroidDebugBridgeDevice { if (packageActivityName.contains("/")) return packageActivityName.split("/")[0]; } - throw new AndroidDebugBridgeDeviceReadException("can read package name"); + throw new AndroidDebugBridgeDeviceReadException("Unable to read package name"); } public boolean isAwake() @@ -137,7 +137,7 @@ public class AndroidDebugBridgeDevice { logger.debug("Unable to parse device wake lock: {}", e.getMessage()); } } - throw new AndroidDebugBridgeDeviceReadException("can read screen state"); + throw new AndroidDebugBridgeDeviceReadException("Unable to read screen state"); } public boolean isPlayingMedia(String currentApp) @@ -175,12 +175,12 @@ public class AndroidDebugBridgeDevice { String lockResp = runAdbShell("dumpsys", "power", "|", "grep", "Locks", "|", "grep", "'size='"); if (lockResp.contains("=")) { try { - return Integer.parseInt(lockResp.replace("\n", "").split("=")[1]); + return Integer.parseInt(lockResp.replace("\n", "").split("=")[1].trim()); } catch (NumberFormatException e) { logger.debug("Unable to parse device wake lock: {}", e.getMessage()); } } - throw new AndroidDebugBridgeDeviceReadException("can read wake lock"); + throw new AndroidDebugBridgeDeviceReadException("Unable to read wake lock"); } private void setVolume(int stream, int volume) -- 2.47.3