Settings: Add option to enable USBNet from GUI (rooted kernels)

This commit is contained in:
Nicolas Mailloux 2024-01-14 19:23:46 +00:00
parent 27974b5e97
commit 7ceed8d988
3 changed files with 190 additions and 161 deletions

View file

@ -124,6 +124,7 @@ settings::settings(QWidget *parent) :
ui->securitySettingsBtn->setIcon(QIcon(":/resources/lock.png"));
ui->securitySettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
ui->usbNetworkingCheckBox->hide();
ui->requestLeaseBtn->hide();
ui->usbmsBtn->hide();
ui->label_4->hide();
@ -412,10 +413,15 @@ settings::settings(QWidget *parent) :
if(checkconfig("/opt/inkbox_genuine") == true) {
// Enforcing security policy if the user has not rooted the device
if(checkconfig("/external_root/opt/root/rooted") == true) {
ui->usbNetworkingCheckBox->show();
if(checkconfig("/external_root/boot/flags/USBNET_ENABLE")) {
ui->usbNetworkingCheckBox->click();
}
ui->requestLeaseBtn->show();
ui->label_4->show();
}
else {
ui->usbNetworkingCheckBox->hide();
ui->requestLeaseBtn->hide();
ui->label_4->hide();
}
@ -1163,3 +1169,15 @@ void settings::on_headerBtn_clicked()
log("'Home' button clicked", className);
ui->settingsStackedWidget->setCurrentIndex(0);
}
void settings::on_usbNetworkingCheckBox_toggled(bool checked)
{
if(checked) {
writeFile("/external_root/boot/flags/USBNET_ENABLE", "true");
writeFile("/opt/ibxd", "usbnet_start\n");
}
else {
writeFile("/external_root/boot/flags/USBNET_ENABLE", "false");
writeFile("/opt/ibxd", "usbnet_stop\n");
}
}

View file

@ -90,6 +90,7 @@ private slots:
void on_systemSettingsBtn_clicked();
void on_securitySettingsBtn_clicked();
void on_headerBtn_clicked();
void on_usbNetworkingCheckBox_toggled(bool checked);
signals:
void showToast(QString messageToDisplay);

View file

@ -200,8 +200,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>457</width>
<height>610</height>
<width>461</width>
<height>636</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -407,8 +407,8 @@ Save &amp;&amp; Quit
<rect>
<x>0</x>
<y>0</y>
<width>419</width>
<height>387</height>
<width>423</width>
<height>738</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@ -931,28 +931,29 @@ Save &amp;&amp; Quit
</property>
<item>
<layout class="QGridLayout" name="gridLayout_24">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_12">
<item row="5" column="0">
<layout class="QGridLayout" name="gridLayout_7">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2">
<widget class="QPushButton" name="resetBtn">
<property name="font">
<font>
<bold>true</bold>
</font>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Reset</string>
<string>System info</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_8">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -964,16 +965,112 @@ Save &amp;&amp; Quit
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<item row="0" column="2">
<widget class="QPushButton" name="showSystemInfoBtn">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Reset this device</string>
<string>Show</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<item row="9" column="0">
<layout class="QGridLayout" name="checkOtaUpdateGridLayout">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="2">
<widget class="QPushButton" name="checkOtaUpdateBtn">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Check</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="checkOtaUpdateLabel">
<property name="text">
<string>Check for updates</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="11" column="0">
<spacer name="verticalSpacer_8">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="2" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Request DHCP lease</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="requestLeaseBtn">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Request</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="0">
<layout class="QGridLayout" name="gridLayout_14">
<property name="bottomMargin">
<number>0</number>
@ -1015,7 +1112,53 @@ Save &amp;&amp; Quit
</item>
</layout>
</item>
<item row="1" column="0">
<item row="3" column="0">
<widget class="QCheckBox" name="darkModeCheckBox">
<property name="text">
<string>Enable night mode</string>
</property>
</widget>
</item>
<item row="4" column="0">
<layout class="QGridLayout" name="gridLayout_12">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2">
<widget class="QPushButton" name="resetBtn">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Reset this device</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<property name="bottomMargin">
<number>0</number>
@ -1066,88 +1209,7 @@ Save &amp;&amp; Quit
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="2">
<widget class="QPushButton" name="requestLeaseBtn">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Request</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Request DHCP lease</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QGridLayout" name="gridLayout_7">
<property name="bottomMargin">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>System info</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="showSystemInfoBtn">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Show</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0">
<layout class="QGridLayout" name="gridLayout_19">
<property name="bottomMargin">
<number>0</number>
@ -1186,14 +1248,7 @@ Save &amp;&amp; Quit
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="darkModeCheckBox">
<property name="text">
<string>Enable night mode</string>
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QCheckBox" name="autoCheckUpdatesBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@ -1206,46 +1261,7 @@ Save &amp;&amp; Quit
</property>
</widget>
</item>
<item row="8" column="0">
<layout class="QGridLayout" name="checkOtaUpdateGridLayout">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="2">
<widget class="QPushButton" name="checkOtaUpdateBtn">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Check</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="checkOtaUpdateLabel">
<property name="text">
<string>Check for updates</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<item row="7" column="0">
<layout class="QGridLayout" name="gridLayout_18">
<property name="bottomMargin">
<number>0</number>
@ -1275,18 +1291,12 @@ Save &amp;&amp; Quit
</item>
</layout>
</item>
<item row="10" column="0">
<spacer name="verticalSpacer_8">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="0" column="0">
<widget class="QCheckBox" name="usbNetworkingCheckBox">
<property name="text">
<string>Enable USB networking</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</widget>
</item>
</layout>
</item>