From 0672ea20abd833feabb7fd0efa22ced99393ee1a Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Sat, 29 Apr 2023 13:45:28 +0200 Subject: [PATCH] qml: implement toggle for android SECURE_FLAG and add marker to wizard pages that should be secured. --- contrib/android/Dockerfile | 2 +- .../gui/qml/components/wizard/WCConfirmSeed.qml | 2 ++ .../gui/qml/components/wizard/WCCreateSeed.qml | 2 ++ .../gui/qml/components/wizard/WCHaveMasterKey.qml | 1 + electrum/gui/qml/components/wizard/WCHaveSeed.qml | 1 + electrum/gui/qml/components/wizard/WCImport.qml | 1 + electrum/gui/qml/components/wizard/Wizard.qml | 7 +++++++ .../gui/qml/components/wizard/WizardComponent.qml | 1 + electrum/gui/qml/qeapp.py | 14 ++++++++++++++ 9 files changed, 30 insertions(+), 1 deletion(-) diff --git a/contrib/android/Dockerfile b/contrib/android/Dockerfile index 35cd9ed90..08e887caf 100644 --- a/contrib/android/Dockerfile +++ b/contrib/android/Dockerfile @@ -180,7 +180,7 @@ RUN cd /opt \ && git remote add accumulator https://github.com/accumulator/python-for-android \ && git fetch --all \ # commit: from branch accumulator/electrum_20210421d (note: careful with force-pushing! see #8162) - && git checkout "087fc3c583d46bfb2dec54878ddea508afb27de6^{commit}" \ + && git checkout "052b9f7945bae557347fa4a4b418040d9da9eaff^{commit}" \ && python3 -m pip install --no-build-isolation --no-dependencies --user -e . # build env vars diff --git a/electrum/gui/qml/components/wizard/WCConfirmSeed.qml b/electrum/gui/qml/components/wizard/WCConfirmSeed.qml index ac7a0c8ff..b5979b290 100644 --- a/electrum/gui/qml/components/wizard/WCConfirmSeed.qml +++ b/electrum/gui/qml/components/wizard/WCConfirmSeed.qml @@ -8,6 +8,8 @@ import ".." import "../controls" WizardComponent { + securePage: true + valid: false function checkValid() { diff --git a/electrum/gui/qml/components/wizard/WCCreateSeed.qml b/electrum/gui/qml/components/wizard/WCCreateSeed.qml index 905f4c49b..f2e76f230 100644 --- a/electrum/gui/qml/components/wizard/WCCreateSeed.qml +++ b/electrum/gui/qml/components/wizard/WCCreateSeed.qml @@ -7,6 +7,8 @@ import org.electrum 1.0 import "../controls" WizardComponent { + securePage: true + valid: seedtext.text != '' function apply() { diff --git a/electrum/gui/qml/components/wizard/WCHaveMasterKey.qml b/electrum/gui/qml/components/wizard/WCHaveMasterKey.qml index 9c8fde40f..cf6452432 100644 --- a/electrum/gui/qml/components/wizard/WCHaveMasterKey.qml +++ b/electrum/gui/qml/components/wizard/WCHaveMasterKey.qml @@ -9,6 +9,7 @@ import "../controls" WizardComponent { id: root + securePage: true valid: false diff --git a/electrum/gui/qml/components/wizard/WCHaveSeed.qml b/electrum/gui/qml/components/wizard/WCHaveSeed.qml index f8bd211e6..6b76bd5b1 100644 --- a/electrum/gui/qml/components/wizard/WCHaveSeed.qml +++ b/electrum/gui/qml/components/wizard/WCHaveSeed.qml @@ -9,6 +9,7 @@ import "../controls" WizardComponent { id: root + securePage: true valid: false diff --git a/electrum/gui/qml/components/wizard/WCImport.qml b/electrum/gui/qml/components/wizard/WCImport.qml index 8a5aca37f..879a5c652 100644 --- a/electrum/gui/qml/components/wizard/WCImport.qml +++ b/electrum/gui/qml/components/wizard/WCImport.qml @@ -8,6 +8,7 @@ import "../controls" WizardComponent { id: root + securePage: true valid: false diff --git a/electrum/gui/qml/components/wizard/Wizard.qml b/electrum/gui/qml/components/wizard/Wizard.qml index 5df89f842..e034a1489 100644 --- a/electrum/gui/qml/components/wizard/Wizard.qml +++ b/electrum/gui/qml/components/wizard/Wizard.qml @@ -2,6 +2,8 @@ import QtQuick 2.6 import QtQuick.Layouts 1.0 import QtQuick.Controls 2.1 +import org.electrum 1.0 + import "../controls" ElDialog { @@ -141,6 +143,11 @@ ElDialog { _setWizardData({}) } + Binding { + target: AppController + property: 'secureWindow' + value: pages.contentChildren[pages.currentIndex].securePage + } } ColumnLayout { diff --git a/electrum/gui/qml/components/wizard/WizardComponent.qml b/electrum/gui/qml/components/wizard/WizardComponent.qml index df633c2f3..f7ffd4ec0 100644 --- a/electrum/gui/qml/components/wizard/WizardComponent.qml +++ b/electrum/gui/qml/components/wizard/WizardComponent.qml @@ -11,6 +11,7 @@ Pane { property bool valid property bool last: false property string title: '' + property bool securePage: false leftPadding: constants.paddingXLarge rightPadding: constants.paddingXLarge diff --git a/electrum/gui/qml/qeapp.py b/electrum/gui/qml/qeapp.py index 694700cce..e670f1087 100644 --- a/electrum/gui/qml/qeapp.py +++ b/electrum/gui/qml/qeapp.py @@ -67,6 +67,7 @@ class QEAppController(BaseCrashReporter, QObject): sendingBugreport = pyqtSignal() sendingBugreportSuccess = pyqtSignal(str) sendingBugreportFailure = pyqtSignal(str) + secureWindowChanged = pyqtSignal() def __init__(self, qedaemon: 'QEDaemon', plugins: 'Plugins'): BaseCrashReporter.__init__(self, None, None, None) @@ -79,6 +80,7 @@ class QEAppController(BaseCrashReporter, QObject): self._crash_user_text = '' self._app_started = False self._intent = '' + self._secureWindow = False # set up notification queue and notification_timer self.user_notification_queue = queue.Queue() @@ -295,6 +297,18 @@ class QEAppController(BaseCrashReporter, QObject): return jview.performHapticFeedback(jHfc.VIRTUAL_KEY) + @pyqtProperty(bool, notify=secureWindowChanged) + def secureWindow(self): + return self._secureWindow + + @secureWindow.setter + def secureWindow(self, secure): + if not self.isAndroid(): + return + if self._secureWindow != secure: + jpythonActivity.setSecureWindow(secure) + self._secureWindow = secure + self.secureWindowChanged.emit() class ElectrumQmlApplication(QGuiApplication):