Search code examples
javatizentizen-native-app

How to get screen state through SDB command?


I need to develop an Java API for my tool to get screen state of tizen device. Is there any sdb shell command to get screen state of tizen device? We can get android device screen status through adb command like "adb.exe shell dumpsys activity | grep mLockScreenShown". Is there anything like dumpsys activity in tizen?


Solution

  • Here below I have found an alternative solution to get lock screen state of tizen device. When screen is locked in tizen device, org.tizen.lockscreen service has been started automatically. So i have ran a command "ps aux | grep lockscreen" in sdb shell. Here below is the Java API to get lock screen of tizen device:

     public static boolean getLockScreenStatus() throws IOException {
        boolean status = false;
        Process process_screen = null;
        BufferedReader buf_screen;
        String str_screen;
        String command = System.getProperty("java.home") + File.separator + "tools" + File.separator + "sdb.exe"
                + " -s " + "0000d04800009200 shell ps aux | grep lockscreen";
        process_screen = Runtime.getRuntime().exec(command);
        buf_screen = new BufferedReader(new InputStreamReader(process_screen.getInputStream()), 1024);
    
        while ((str_screen = buf_screen.readLine()) != null) {
    
            if (str_screen.contains("org.tizen.lockscreen/bin/lockscreen")) {
                status = true;
                System.out.println(str_screen);
            }
        }
    
        return status;
    }
    

    Here, System.getProperty("java.home") + File.separator + "tools" + File.separator is the SDBpath of my PC environment and 0000d04800009200 is the device Id of my tizen device.But i still don't know how to get screen off state.