]> git.basschouten.com Git - openhab-addons.git/commitdiff
[androiddebugbridge] Fix screen state channel on android 12 (#14663)
authorGiviMAD <GiviMAD@users.noreply.github.com>
Fri, 24 Mar 2023 22:25:21 +0000 (23:25 +0100)
committerGitHub <noreply@github.com>
Fri, 24 Mar 2023 22:25:21 +0000 (23:25 +0100)
Signed-off-by: Miguel Álvarez <miguelwork92@gmail.com>
bundles/org.openhab.binding.androiddebugbridge/src/main/java/org/openhab/binding/androiddebugbridge/internal/AndroidDebugBridgeDevice.java

index 8b30b9df50aaf8d1e1c79f1cb49053ba0e5a08be..a35897f9a0a5038e1f50a68eea2425f0a3e8ee02 100644 (file)
@@ -244,6 +244,10 @@ public class AndroidDebugBridgeDevice {
 
     public boolean isScreenOn() throws InterruptedException, AndroidDebugBridgeDeviceException,
             AndroidDebugBridgeDeviceReadException, TimeoutException, ExecutionException {
+        if (isAtLeastVersion(12)) {
+            String devicesResp = runAdbShell("getprop", "debug.tracing.screen_state");
+            return devicesResp.replace("\n", "").equals("2");
+        }
         String devicesResp = runAdbShell("dumpsys", "power", "|", "grep", "'Display Power'");
         if (devicesResp.contains("=")) {
             try {