Browse Source

qml: add config setting to allow screenshots

On Android, we disallow screenshots on screens where the seed is visible.
(The seed is extremely sensitive data that should not be stored digitally without
significant precautions but it's also cumbersome to write down or memorise, so
some people instinctively just try to take a screenshot of it when creating a wallet.)
We do this by using the built-in OS mechanism of setting FLAG_SECURE on the window.
However, on some devices with custom ROMs (one report from LineageOS, one from /e/OS),
unsetting FLAG_SECURE crashes the application for some reason.

As a workaround, this commit adds a config setting into the Preferences,
to disable this mechanism and just always allow screenshots.
(note that you can get into the qml Preferences before creating/opening any wallet)

ref https://github.com/spesmilo/electrum/issues/8522
master
SomberNight 2 years ago
parent
commit
0dae17339d
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 19
      electrum/gui/qml/components/Preferences.qml
  2. 2
      electrum/gui/qml/qeapp.py
  3. 10
      electrum/gui/qml/qeconfig.py
  4. 1
      electrum/simple_config.py

19
electrum/gui/qml/components/Preferences.qml

@ -368,6 +368,24 @@ Pane {
wrapMode: Text.Wrap
}
}
RowLayout {
Layout.columnSpan: 2
Layout.fillWidth: true
spacing: 0
Switch {
id: alwaysAllowScreenshots
onCheckedChanged: {
if (activeFocus)
Config.alwaysAllowScreenshots = checked
}
}
Label {
Layout.fillWidth: true
text: qsTr('Always allow screenshots')
wrapMode: Text.Wrap
}
}
}
}
@ -392,6 +410,7 @@ Pane {
useTrampolineRouting.checked = !Config.useGossip
useFallbackAddress.checked = Config.useFallbackAddress
enableDebugLogs.checked = Config.enableDebugLogs
alwaysAllowScreenshots.checked = Config.alwaysAllowScreenshots
useRecoverableChannels.checked = Config.useRecoverableChannels
syncLabels.checked = AppController.isPluginEnabled('labels')
}

2
electrum/gui/qml/qeapp.py

@ -327,6 +327,8 @@ class QEAppController(BaseCrashReporter, QObject):
def secureWindow(self, secure):
if not self.isAndroid():
return
if self.config.GUI_QML_ALWAYS_ALLOW_SCREENSHOTS:
return
if self._secureWindow != secure:
jpythonActivity.setSecureWindow(secure)
self._secureWindow = secure

10
electrum/gui/qml/qeconfig.py

@ -169,6 +169,16 @@ class QEConfig(AuthMixin, QObject):
self.config.GUI_ENABLE_DEBUG_LOGS = enable
self.enableDebugLogsChanged.emit()
alwaysAllowScreenshotsChanged = pyqtSignal()
@pyqtProperty(bool, notify=alwaysAllowScreenshotsChanged)
def alwaysAllowScreenshots(self):
return self.config.GUI_QML_ALWAYS_ALLOW_SCREENSHOTS
@alwaysAllowScreenshots.setter
def alwaysAllowScreenshots(self, enable):
self.config.GUI_QML_ALWAYS_ALLOW_SCREENSHOTS = enable
self.alwaysAllowScreenshotsChanged.emit()
useRecoverableChannelsChanged = pyqtSignal()
@pyqtProperty(bool, notify=useRecoverableChannelsChanged)
def useRecoverableChannels(self):

1
electrum/simple_config.py

@ -1105,6 +1105,7 @@ This will result in longer routes; it might increase your fees and decrease the
GUI_QML_USER_KNOWS_PRESS_AND_HOLD = ConfigVar('user_knows_press_and_hold', default=False, type_=bool)
GUI_QML_ADDRESS_LIST_SHOW_TYPE = ConfigVar('address_list_show_type', default=1, type_=int)
GUI_QML_ADDRESS_LIST_SHOW_USED = ConfigVar('address_list_show_used', default=False, type_=bool)
GUI_QML_ALWAYS_ALLOW_SCREENSHOTS = ConfigVar('android_always_allow_screenshots', default=False, type_=bool)
BTC_AMOUNTS_DECIMAL_POINT = ConfigVar('decimal_point', default=DECIMAL_POINT_DEFAULT, type_=int)
BTC_AMOUNTS_FORCE_NZEROS_AFTER_DECIMAL_POINT = ConfigVar(

Loading…
Cancel
Save