Skip to content

Commit

Permalink
[androiddebugbridge] fix power wake lock and minor fixes (#10316)
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel <miguelwork92@gmail.com>
  • Loading branch information
GiviMAD authored Mar 13, 2021
1 parent f085dc0 commit affc082
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.androiddebugbridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public String getCurrentPackage() throws AndroidDebugBridgeDeviceException, Inte
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()
Expand All @@ -137,7 +137,7 @@ public boolean isScreenOn() throws InterruptedException, AndroidDebugBridgeDevic
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)
Expand Down Expand Up @@ -175,12 +175,12 @@ public int getPowerWakeLock() throws InterruptedException, AndroidDebugBridgeDev
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)
Expand Down

0 comments on commit affc082

Please sign in to comment.