Allow custom path for adb in dashboard
This commit is contained in:
+27
-9
@@ -23,6 +23,7 @@
|
||||
#include <QCoroQmlTask>
|
||||
#include <QProcess>
|
||||
#include <QRegularExpression>
|
||||
#include <QSettings>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
@@ -30,12 +31,20 @@ using namespace std::chrono_literals;
|
||||
|
||||
adb::adb()
|
||||
{
|
||||
QTimer::singleShot(0, this, &adb::checkIfAdbIsInstalled);
|
||||
QSettings settings;
|
||||
if (settings.value("adb_custom").toBool())
|
||||
setPath(settings.value("adb_location").toString());
|
||||
else
|
||||
setPath("adb");
|
||||
}
|
||||
|
||||
QCoro::Task<> adb::checkIfAdbIsInstalled()
|
||||
{
|
||||
auto which_adb = escape_sandbox("which", "adb");
|
||||
std::unique_ptr<QProcess> which_adb;
|
||||
if (m_path == "adb")
|
||||
which_adb = escape_sandbox("which", "adb");
|
||||
else
|
||||
which_adb = escape_sandbox("test", "-x", m_path);
|
||||
which_adb->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
||||
auto co_which_adb = qCoro(*which_adb);
|
||||
|
||||
@@ -44,7 +53,10 @@ QCoro::Task<> adb::checkIfAdbIsInstalled()
|
||||
|
||||
if (which_adb->exitStatus() == QProcess::NormalExit and which_adb->exitCode() == 0)
|
||||
{
|
||||
qDebug() << "adb found at" << QString{which_adb->readAllStandardOutput()}.trimmed();
|
||||
if (m_path == "adb")
|
||||
qDebug() << "adb found at" << QString{which_adb->readAllStandardOutput()}.trimmed();
|
||||
else
|
||||
qDebug() << "adb found at" << m_path << "(custom path)";
|
||||
|
||||
if (!m_adb_installed)
|
||||
{
|
||||
@@ -68,14 +80,14 @@ QCoro::Task<> adb::on_poll_devices_timeout()
|
||||
{
|
||||
if (m_android_devices.empty())
|
||||
{
|
||||
auto wait_for_usb_device = escape_sandbox("adb", "wait-for-usb-device");
|
||||
auto wait_for_usb_device = escape_sandbox(m_path, "wait-for-usb-device");
|
||||
auto co_wait_for_usb_device = qCoro(*wait_for_usb_device);
|
||||
|
||||
co_await co_wait_for_usb_device.start();
|
||||
co_await co_wait_for_usb_device.waitForFinished(-1);
|
||||
}
|
||||
|
||||
auto adb_devices = escape_sandbox("adb", "devices");
|
||||
auto adb_devices = escape_sandbox(m_path, "devices");
|
||||
adb_devices->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
||||
auto co_adb_devices = qCoro(*adb_devices);
|
||||
|
||||
@@ -147,7 +159,7 @@ QCoro::Task<> adb::add_device(QString serial)
|
||||
{
|
||||
device new_dev{.serial = serial};
|
||||
|
||||
auto list_packages = escape_sandbox("adb", "-s", serial, "shell", "pm", "list", "packages");
|
||||
auto list_packages = escape_sandbox(m_path, "-s", serial, "shell", "pm", "list", "packages");
|
||||
list_packages->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
||||
|
||||
auto co_list_packages = qCoro(*list_packages);
|
||||
@@ -172,7 +184,7 @@ QCoro::Task<> adb::add_device(QString serial)
|
||||
}
|
||||
}
|
||||
|
||||
auto getprop = escape_sandbox("adb", "-s", new_dev.serial, "shell", "getprop");
|
||||
auto getprop = escape_sandbox(m_path, "-s", new_dev.serial, "shell", "getprop");
|
||||
getprop->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
||||
|
||||
auto co_get_prop = qCoro(*getprop);
|
||||
@@ -277,6 +289,12 @@ QVariant adb::data(const QModelIndex & index, int role) const
|
||||
}
|
||||
// END
|
||||
|
||||
void adb::setPath(QString path)
|
||||
{
|
||||
m_path = path;
|
||||
QTimer::singleShot(0, this, &adb::checkIfAdbIsInstalled);
|
||||
}
|
||||
|
||||
QCoro::QmlTask adb::startUsbConnection(QString serial, QString pin)
|
||||
{
|
||||
return doStartUsbConnection(serial, pin);
|
||||
@@ -289,7 +307,7 @@ QCoro::Task<> adb::doStartUsbConnection(QString serial, QString pin)
|
||||
if (it == m_android_devices.end())
|
||||
co_return;
|
||||
|
||||
auto adb_reverse = escape_sandbox("adb", "-s", serial, "reverse", "tcp:9757", "tcp:9757");
|
||||
auto adb_reverse = escape_sandbox(m_path, "-s", serial, "reverse", "tcp:9757", "tcp:9757");
|
||||
adb_reverse->setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
auto co_process = qCoro(*adb_reverse);
|
||||
|
||||
@@ -304,7 +322,7 @@ QCoro::Task<> adb::doStartUsbConnection(QString serial, QString pin)
|
||||
|
||||
QString uri = pin == "" ? "wivrn+tcp://127.0.0.1:9757" : "wivrn+tcp://:" + pin + "@127.0.0.1:9757";
|
||||
|
||||
auto adb_start_activity = escape_sandbox("adb", "-s", serial, "shell", "am", "start", "-a", "android.intent.action.VIEW", "-d", uri, it->app);
|
||||
auto adb_start_activity = escape_sandbox(m_path, "-s", serial, "shell", "am", "start", "-a", "android.intent.action.VIEW", "-d", uri, it->app);
|
||||
adb_start_activity->setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
auto co_adb_start_activity = qCoro(*adb_start_activity);
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ class adb : public QAbstractListModel
|
||||
Q_PROPERTY(bool adbInstalled READ adbInstalled NOTIFY adbInstalledChanged)
|
||||
|
||||
bool m_adb_installed = false;
|
||||
QString m_path;
|
||||
std::vector<device> m_android_devices;
|
||||
|
||||
QCoro::Task<> on_poll_devices_timeout();
|
||||
@@ -73,6 +74,8 @@ public:
|
||||
|
||||
QVariant data(const QModelIndex & index, int role) const override;
|
||||
|
||||
Q_INVOKABLE void setPath(QString path);
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
|
||||
+13
-13
@@ -22,23 +22,12 @@
|
||||
#include <QProcess>
|
||||
#include <string>
|
||||
|
||||
template <typename... Args>
|
||||
std::unique_ptr<QProcess> escape_sandbox(const std::string & executable, Args &&... args_orig)
|
||||
template <typename U, typename... Args>
|
||||
std::unique_ptr<QProcess> escape_sandbox(U && executable, Args &&... args_orig)
|
||||
{
|
||||
auto process = std::make_unique<QProcess>();
|
||||
QStringList args;
|
||||
|
||||
if (wivrn::flatpak_key(wivrn::flatpak::section::session_bus_policy, "org.freedesktop.Flatpak") == "talk")
|
||||
{
|
||||
process->setProgram("flatpak-spawn");
|
||||
args.push_back("--host");
|
||||
args.push_back(QString::fromStdString(executable));
|
||||
}
|
||||
else
|
||||
{
|
||||
process->setProgram(QString::fromStdString(executable));
|
||||
}
|
||||
|
||||
auto to_QString = [](const auto & s) {
|
||||
using T = std::decay_t<std::remove_cv_t<std::remove_reference_t<decltype(s)>>>;
|
||||
|
||||
@@ -50,6 +39,17 @@ std::unique_ptr<QProcess> escape_sandbox(const std::string & executable, Args &&
|
||||
return QString::fromStdString(s);
|
||||
};
|
||||
|
||||
if (wivrn::flatpak_key(wivrn::flatpak::section::session_bus_policy, "org.freedesktop.Flatpak") == "talk")
|
||||
{
|
||||
process->setProgram("flatpak-spawn");
|
||||
args.push_back("--host");
|
||||
args.push_back(to_QString(executable));
|
||||
}
|
||||
else
|
||||
{
|
||||
process->setProgram(to_QString(executable));
|
||||
}
|
||||
|
||||
(args.push_back(to_QString(args_orig)), ...);
|
||||
|
||||
process->setArguments(args);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtCore as Core
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls as Controls
|
||||
import QtQuick.Dialogs as Dialogs
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
import io.github.wivrn.wivrn
|
||||
@@ -17,6 +19,13 @@ Kirigami.ScrollablePage {
|
||||
id: config
|
||||
}
|
||||
|
||||
Core.Settings {
|
||||
property alias adb_custom: settings.adb_custom
|
||||
property alias adb_location: settings.adb_location
|
||||
}
|
||||
property bool adb_custom
|
||||
property string adb_location
|
||||
|
||||
ColumnLayout {
|
||||
id: column
|
||||
anchors.fill: parent
|
||||
@@ -302,6 +311,40 @@ Kirigami.ScrollablePage {
|
||||
enabled: encoder_combo.model[encoder_combo.currentIndex].codecs.split(",").includes(name)
|
||||
}
|
||||
}
|
||||
|
||||
Kirigami.Separator {
|
||||
Kirigami.FormData.isSection: true
|
||||
}
|
||||
|
||||
Controls.CheckBox {
|
||||
id: adb_custom
|
||||
Layout.row: 0
|
||||
Layout.column: 0
|
||||
text: i18n("Custom adb location")
|
||||
}
|
||||
|
||||
Dialogs.FileDialog {
|
||||
id: adb_browse
|
||||
onAccepted: {
|
||||
adb_location.text = new URL(selectedFile).pathname;
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Kirigami.FormData.label: i18n("Adb location:")
|
||||
Layout.fillWidth: true
|
||||
enabled: adb_custom.checked
|
||||
Controls.TextField {
|
||||
id: adb_location
|
||||
placeholderText: settings.adb
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Controls.Button {
|
||||
text: i18nc("browse a file to choose the adb binary", "Browse")
|
||||
onClicked: adb_browse.open()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Item {
|
||||
@@ -335,6 +378,9 @@ Kirigami.ScrollablePage {
|
||||
config.bitrate = bitrate.value * 1000000;
|
||||
config.scale = manual_foveation.checked ? 1 - scale_slider.value / 100.0 : -1;
|
||||
config.manualEncoders = encoder_layout.currentIndex > 0;
|
||||
settings.adb_custom = adb_custom.checked;
|
||||
settings.adb_location = adb_location.text;
|
||||
Adb.setPath(adb_custom.checked ? adb_location.text : "adb");
|
||||
}
|
||||
|
||||
function load() {
|
||||
@@ -354,6 +400,9 @@ Kirigami.ScrollablePage {
|
||||
// auto_encoders.checked = true;
|
||||
encoder_layout.currentIndex = 0;
|
||||
}
|
||||
|
||||
adb_custom.checked = settings.adb_custom;
|
||||
adb_location.text = settings.adb_location;
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
|
||||
@@ -2,7 +2,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WiVRn-dashboard\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-03-25 21:15+0100\n"
|
||||
"POT-Creation-Date: 2025-04-17 19:30+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: Guillaume Meunier <guillaume.meunier@centraliens.net>\n"
|
||||
"Language: French\n"
|
||||
@@ -331,7 +331,7 @@ msgstr "Assistant"
|
||||
msgid "Install the app"
|
||||
msgstr "Installer l'appli"
|
||||
|
||||
#: dashboard/qml/Main.qml:349 dashboard/qml/SettingsPage.qml:12
|
||||
#: dashboard/qml/Main.qml:349 dashboard/qml/SettingsPage.qml:14
|
||||
#, kde-format
|
||||
msgid "Settings"
|
||||
msgstr "Paramètres"
|
||||
@@ -359,23 +359,23 @@ msgctxt "browse a file to choose the application to start"
|
||||
msgid "Browse"
|
||||
msgstr "Parcourir"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:31
|
||||
#: dashboard/qml/SettingsPage.qml:40
|
||||
#, kde-format
|
||||
msgctxt "automatic foveation setup"
|
||||
msgid "Manual foveation"
|
||||
msgstr "Fovéation manuelle"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:37
|
||||
#: dashboard/qml/SettingsPage.qml:46
|
||||
#, kde-format
|
||||
msgid "Foveation strength:"
|
||||
msgstr "Intensité de fovéation :"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:53
|
||||
#: dashboard/qml/SettingsPage.qml:62
|
||||
#, kde-format
|
||||
msgid "%1 %"
|
||||
msgstr "%1 %"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:59
|
||||
#: dashboard/qml/SettingsPage.qml:68
|
||||
#, kde-format
|
||||
msgid ""
|
||||
"A stronger foveation makes the image sharper in the center than in the "
|
||||
@@ -394,65 +394,65 @@ msgstr ""
|
||||
"Les valeurs recommandées sont entre 20% et 50% pour les casques sans suivi "
|
||||
"des yeux et entre 50% et 70% pour les casques avec suivi des yeux."
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:65
|
||||
#: dashboard/qml/SettingsPage.qml:74
|
||||
#, kde-format
|
||||
msgctxt "weaker foveation"
|
||||
msgid "Weaker"
|
||||
msgstr "Faible"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:76
|
||||
#: dashboard/qml/SettingsPage.qml:85
|
||||
#, kde-format
|
||||
msgctxt "stronger foveation"
|
||||
msgid "Stronger"
|
||||
msgstr "Fort"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:86
|
||||
#: dashboard/qml/SettingsPage.qml:95
|
||||
#, kde-format
|
||||
msgid "Bitrate:"
|
||||
msgstr "Débit :"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:90 dashboard/qml/SettingsPage.qml:92
|
||||
#: dashboard/qml/SettingsPage.qml:99 dashboard/qml/SettingsPage.qml:101
|
||||
#, kde-format
|
||||
msgctxt "bitrate"
|
||||
msgid "%1 Mbit/s"
|
||||
msgstr "%1 Mbit/s"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:102
|
||||
#: dashboard/qml/SettingsPage.qml:111
|
||||
#, kde-format
|
||||
msgid "Encoder layout:"
|
||||
msgstr "Disposition :"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:105
|
||||
#: dashboard/qml/SettingsPage.qml:114
|
||||
#, kde-format
|
||||
msgctxt "encoder preset"
|
||||
msgid "Automatic"
|
||||
msgstr "Automatique"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:109
|
||||
#: dashboard/qml/SettingsPage.qml:118
|
||||
#, kde-format
|
||||
msgctxt "encoder preset"
|
||||
msgid "Manual"
|
||||
msgstr "Manuelle"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:113
|
||||
#: dashboard/qml/SettingsPage.qml:122
|
||||
#, kde-format
|
||||
msgctxt "encoder preset"
|
||||
msgid "Default preset"
|
||||
msgstr "Configuration prédéfinie : par défaut"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:136
|
||||
#: dashboard/qml/SettingsPage.qml:145
|
||||
#, kde-format
|
||||
msgctxt "encoder preset"
|
||||
msgid "Low latency preset"
|
||||
msgstr "Configuration prédéfinie : basse latence"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:161
|
||||
#: dashboard/qml/SettingsPage.qml:170
|
||||
#, kde-format
|
||||
msgctxt "encoder preset"
|
||||
msgid "Safe preset"
|
||||
msgstr "Configuration prédéfinie : sure"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:184
|
||||
#: dashboard/qml/SettingsPage.qml:193
|
||||
#, kde-format
|
||||
msgid ""
|
||||
"To add a new encoder, split an existing encoder by clicking near an edge.\n"
|
||||
@@ -462,69 +462,85 @@ msgstr ""
|
||||
"d'un bord.\n"
|
||||
"Déplacez un bord pour redimensionner ou supprimer un encodeur."
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:211
|
||||
#: dashboard/qml/SettingsPage.qml:220
|
||||
#, kde-format
|
||||
msgid "Encoder:"
|
||||
msgstr "Encodeur :"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:220
|
||||
#: dashboard/qml/SettingsPage.qml:229
|
||||
#, kde-format
|
||||
msgctxt "automatic encoder setup"
|
||||
msgid "Auto"
|
||||
msgstr "Automatique"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:225
|
||||
#: dashboard/qml/SettingsPage.qml:234
|
||||
#, kde-format
|
||||
msgid "nvenc (NVIDIA GPUs)"
|
||||
msgstr "nvenc (GPUs NVIDIA)"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:230
|
||||
#: dashboard/qml/SettingsPage.qml:239
|
||||
#, kde-format
|
||||
msgid "vaapi (AMD and Intel GPUs)"
|
||||
msgstr "vaapi (GPUs AMD et Intel)"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:235
|
||||
#: dashboard/qml/SettingsPage.qml:244
|
||||
#, kde-format
|
||||
msgid "x264 (software encoding)"
|
||||
msgstr "x264 (encodage logiciel)"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:240
|
||||
#: dashboard/qml/SettingsPage.qml:249
|
||||
#, kde-format
|
||||
msgid "Vulkan (Vulkan Video)"
|
||||
msgstr "Vulkan (Vulkan Vidéo)"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:263
|
||||
#: dashboard/qml/SettingsPage.qml:272
|
||||
#, kde-format
|
||||
msgid "\"Auto\" will use hardware acceleration if it is available"
|
||||
msgstr ""
|
||||
"\"Automatique\" utilisera l'accélération matérielle si elle est disponible"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:269
|
||||
#: dashboard/qml/SettingsPage.qml:278
|
||||
#, kde-format
|
||||
msgid "Codec:"
|
||||
msgstr "Codec :"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:276
|
||||
#: dashboard/qml/SettingsPage.qml:285
|
||||
#, kde-format
|
||||
msgctxt "automatic codec setup"
|
||||
msgid "Auto"
|
||||
msgstr "Automatique"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:280
|
||||
#: dashboard/qml/SettingsPage.qml:289
|
||||
#, kde-format
|
||||
msgid "H.264"
|
||||
msgstr "H.264"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:284
|
||||
#: dashboard/qml/SettingsPage.qml:293
|
||||
#, kde-format
|
||||
msgid "H.265"
|
||||
msgstr "H.265"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:288
|
||||
#: dashboard/qml/SettingsPage.qml:297
|
||||
#, kde-format
|
||||
msgid "AV1"
|
||||
msgstr "AV1"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:323
|
||||
#, kde-format
|
||||
msgid "Custom adb location"
|
||||
msgstr "Spécifier l'emplacement d'adb"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:334
|
||||
#, kde-format
|
||||
msgid "Adb location:"
|
||||
msgstr "Emplacement d'adb"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:343
|
||||
#, kde-format
|
||||
msgctxt "browse a file to choose the adb binary"
|
||||
msgid "Browse"
|
||||
msgstr "Parcourir"
|
||||
|
||||
#: dashboard/qml/SteamLaunchOptions.qml:8
|
||||
#, kde-format
|
||||
msgid ""
|
||||
|
||||
Reference in New Issue
Block a user