The batteries of my nvidia shield tv sucks so i made a web remote for linux with adb installed
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
include_once 'ADBKeyCodes.php';
|
|
|
|
|
include_once 'AppNames.php';
|
|
|
|
|
|
|
|
|
|
class ADBService
|
|
|
|
|
{
|
|
|
|
|
const DEFAULT_HOST = '192.168.1.132';
|
|
|
|
|
private $host;
|
|
|
|
|
|
|
|
|
|
public function __construct($host)
|
|
|
|
|
{
|
|
|
|
|
$this->host = $host;
|
|
|
|
|
$this->connect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function connect()
|
|
|
|
|
{
|
|
|
|
|
return $this->executeCommand('connect ' . escapeshellarg($this->host));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function disconnect()
|
|
|
|
|
{
|
|
|
|
|
return $this->executeCommand('disconnect');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function executeCommand($command)
|
|
|
|
|
{
|
|
|
|
|
return shell_exec('adb ' . $command);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function sendKey($keyIdentifier)
|
|
|
|
|
{
|
|
|
|
|
return $this->executeCommand(' shell input keyevent ' . ADB_KEYCODES[$keyIdentifier]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function startApp($appName)
|
|
|
|
|
{
|
|
|
|
|
return $this->executeCommand(' shell am start ' . APP_NAMES[$appName]);
|
|
|
|
|
}
|
|
|
|
|
}
|