Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[androiddebugbridge] fix power wake lock and minor fixes #10316

Merged
merged 1 commit into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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