I did a lot of googeling and played around a little bit with the source code (of the original binding in openhab 3.1) and I managed to get things working on my Google TV with Chromecast. This is just a very quick & even dirtier solution (as I said, I am not a real programmer and know close to no Java
), but maybe it helps fixing this issue in a future release…
Here is what I did:
public String getCurrentPackage() throws AndroidDebugBridgeDeviceException, InterruptedException,
AndroidDebugBridgeDeviceReadException, TimeoutException, ExecutionException {
var out = runAdbShell("dumpsys", "activity", "recents", "|", "grep", "'Recent #0'", "|", "cut", "-d=", "-f2",
"|", "sed", "'s|", ".*||'", "|", "cut", "-d", "'/'", "-f1");
var packageActivityName = out;
return packageActivityName;
}
Also, I found a problem with starting certain apps (like e.g. Amazon Video), more infos here. I fixed it like this:
public void startPackage(String packageName)
throws InterruptedException, AndroidDebugBridgeDeviceException, TimeoutException, ExecutionException {
if (!PACKAGE_NAME_PATTERN.matcher(packageName).matches()) {
logger.warn("{} is not a valid package name", packageName);
return;
}
var out = runAdbShell("monkey", "--pct-syskeys", "0", "-p", packageName, "-v", "1");
if (out.contains("monkey aborted")) {
out = runAdbShell("monkey", "--pct-syskeys", "0", "-p", packageName, "-c",
"android.intent.category.LEANBACK_LAUNCHER", "1");
}
}