From 6fbc9d95fdadae5ca249d367741ee3b22c7f9462 Mon Sep 17 00:00:00 2001 From: Vincent Date: Sat, 14 Nov 2020 15:42:13 +0100 Subject: [PATCH] . --- .idea/workspace.xml | 29 +++++++++++------------------ scripts/lib/shield.php | 22 ++++++++++++++++++---- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 99ed3d4..a0cff7b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,14 +2,7 @@ - - - - - - - @@ -1296,12 +1289,12 @@ - + - + diff --git a/scripts/lib/shield.php b/scripts/lib/shield.php index a9c3554..c56d436 100644 --- a/scripts/lib/shield.php +++ b/scripts/lib/shield.php @@ -18,11 +18,17 @@ function shieldConnect($force = false, $device = null) function shieldSleep($device = null) { + if (!shieldIsAwake($device)) { + return; + } shieldKey('sleep', $device); } function shieldWakeup($device = null) { + if (shieldIsAwake($device)) { + return; + } shieldKey('wakeup', $device); `curl 'http://192.168.13.60:9000/plugins/Extensions/settings/plugins/CastBridge/settings/basic.html?playerid=b8%3A27%3Aeb%3Af6%3A1d%3A30' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Accept-Language: fr-FR,en;q=0.5' --compressed -H 'Content-Type: application/x-www-form-urlencoded' -H 'Origin: http://192.168.13.60:9000' -H 'Connection: keep-alive' -H 'Referer: http://192.168.13.60:9000/plugins/Extensions/settings/plugins/CastBridge/settings/basic.html' -H 'Cookie: Squeezebox-player=b8%3A27%3Aeb%3Af6%3A1d%3A30; Squeezebox-enableHiDPI=1; Squeezebox-expandPlayerControl=true; Squeezebox-expanded-MY_MUSIC=0; Squeezebox-expanded-RADIO=1; Squeezebox-expanded-PLUGIN_MY_APPS_MODULE_NAME=1; Squeezebox-expanded-FAVORITES=1; Squeezebox-expanded-PLUGINS=0; Squeezebox-playersettings=settings/player/basic.html%3F; Squeezebox-advancedsettings=plugins/CastBridge/settings/basic.html%3F; Squeezebox-expanded-activePlugins=1; Squeezebox-expanded-inactivePlugins=1; Squeezebox-expanded-otherPlugins0=1; securitytoken=1b5a6a8ddf493f1bf1f0787e0de41708' -H 'Upgrade-Insecure-Requests: 1' --data-raw 'saveSettings=1&useAJAX=0&page=PLUGIN_CASTBRIDGE&playerid=b8%3A27%3Aeb%3Af6%3A1d%3A30&player=b8%3A27%3Aeb%3Af6%3A1d%3A30&autorun=on&bin=squeeze2cast-armv6hf&opts=&debugs=&log_limit=-1&configfile=castbridge.xml&autosave=on&upnp_socket=%3F&xmlparams=1&prevseldevice=.common.&seldevice=.common.&codecs=aac%2Cogg%2Cops%2Cogf%2Cflc%2Calc%2Cwav%2Caif%2Cpcm%2Cmp3&sample_rate=96000&encode_mode=thru&encode_level=&encode_bitrate=&encode_rate=&encode_size=&server=%3F&enabled=1&remove_timeout=0&volume_on_play=1&media_volume=50&send_metadata=1&send_coverart=1&enabled.79a3f5f078d67e3b25a6b3dedc624e18=1&enabled.c4f32d227235313d8c59eff43a01350c=1'`; } @@ -40,7 +46,7 @@ function shieldRunActivity($device = null) function shieldCommand($command, $params, $device = null) { shieldConnect(false, $device); - _adb($command, $params, $device); + return _adb($command, $params, $device); } function shieldText($text, $device = null) @@ -265,18 +271,26 @@ function shieldLogcat($cases = [], $device = null) { shieldConnect(false, $device); $proc = new proc(); - $cmd=_adbcmd('logcat', '', $device); - echo $cmd."\n"; + $cmd = _adbcmd('logcat', '', $device); + echo $cmd . "\n"; $proc->open($cmd); $proc->on($cases); $proc->run(); } +function shieldIsAwake($device = null) +{ + $out = shieldCommand('shell', 'dumpsys power', $device); + return strpos($out, 'Display Power: state=ON') !== false; +} + function _adb($command, $params = '', $device = null) { $c = _adbcmd($command, $params, $device); - echo $c . ' :: ' . `$c` . "\n"; + $output = `$c`; + echo $c . ' :: ' . $output . "\n"; + return $output; } function _adbcmd($command, $params, $device = null) -- 2.39.5