string power_dump = instance.DroidInstance.Input.Shell("adb shell dumpsys power", 60 * 1000);
bool mHoldingWakeLockSuspendBlocker = bool.Parse(Regex.Match(power_dump, "(?<=mHoldingWakeLockSuspendBlocker=).*").Value.Trim());
bool mHoldingDisplaySuspendBlocker = bool.Parse(Regex.Match(power_dump, "(?<=mHoldingDisplaySuspendBlocker=).*").Value.Trim());
if (mHoldingWakeLockSuspendBlocker && mHoldingDisplaySuspendBlocker){
project.SendInfoToLog("display on, unlocked", true);
}
else if (!mHoldingWakeLockSuspendBlocker && mHoldingDisplaySuspendBlocker){
project.SendInfoToLog("display on, locked", true);
instance.DroidInstance.Input.Shell("adb shell input keyevent 82", 60 * 1000);
}
else if (!mHoldingWakeLockSuspendBlocker && !mHoldingDisplaySuspendBlocker){
project.SendInfoToLog("display off, locked", true);
instance.DroidInstance.Input.Shell("adb shell input keyevent KEYCODE_WAKEUP", 60 * 1000);
instance.DroidInstance.Input.Shell("adb shell input keyevent 82", 60 * 1000);
}