qml: qeapp: add methods to retrive system bar heights
What changed, and why it matters
This commit adds helper functions to Electrum's mobile QML interface so the app can measure Android status and navigation bar heights. It is a UI/layout change, not a security fix or vulnerability. There is no indication it addresses any security issue.
No security action needed. Treat as routine UI enhancement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces three new methods on QEAppController: enforcesEdgeToEdge(), getStatusBarHeight(), and getNavigationBarHeight(). They use Pyjnius to call Android WindowInsets APIs and return bar heights in dp for QML layout. A profiler decorator is added and a systemSdkVersion variable is cached. No existing behavior is removed or hardened.
Changed components
electrum/gui/qml/qeapp.pyInspect captured patch +50 / −0
diff --git a/electrum/gui/qml/qeapp.py b/electrum/gui/qml/qeapp.py
index 45e9fea..28764c0 100644
--- a/electrum/gui/qml/qeapp.py
+++ b/electrum/gui/qml/qeapp.py
@@ -22,6 +22,7 @@ from electrum.base_crash_reporter import BaseCrashReporter, EarlyExceptionsQueue
from electrum.network import Network
from electrum.plugin import run_hook
from electrum.gui.common_qt.util import get_font_id
+from electrum.util import profiler
from .qeconfig import QEConfig
from .qedaemon import QEDaemon
@@ -60,6 +61,7 @@ if 'ANDROID_DATA' in os.environ:
jString = autoclass('java.lang.String')
jIntent = autoclass('android.content.Intent')
jview = jpythonActivity.getWindow().getDecorView()
+ systemSdkVersion = autoclass('android.os.Build$VERSION').SDK_INT
notification = None
@@ -414,6 +416,54 @@ class QEAppController(BaseCrashReporter, QObject):
self._secureWindow = secure
self.secureWindowChanged.emit()
+ @pyqtSlot(result=bool)
+ def enforcesEdgeToEdge(self) -> bool:
+ if not self.isAndroid():
+ return False
+ return bool(systemSdkVersion >= 35)
+
+ @profiler(min_threshold=0.05)
+ def _getSystemBarHeight(self, bar_type: str) -> int:
+ if not self.enforcesEdgeToEdge():
+ return 0
+ assert systemSdkVersion >= 30, \
+ f"Android WindowInsets unavailable on {systemSdkVersion=}"
+ try:
+ root_insets = jview.getRootWindowInsets()
+ window_insets_type = autoclass('android.view.WindowInsets$Type')
+
+ if bar_type == 'status':
+ ins = root_insets.getInsets(window_insets_type.statusBars())
+ elif bar_type == 'navigation':
+ ins = root_insets.getInsets(window_insets_type.navigationBars())
+ else:
+ raise ValueError(f"Invalid bar_type: {bar_type}")
+
+ # Get the display metrics to convert pixels to dp
+ display_metrics = jpythonActivity.getResources().getDisplayMetrics()
+ density = display_metrics.density
+
+ height = int(max(ins.bottom, ins.right, ins.left, ins.top, 0))
+ if not height > 0:
+ return 0
+
+ # Convert from pixels to dp for QML
+ height_dp = int(height / density)
+
+ self.logger.debug(f"_getSystemBarHeight: {height=}, {height_dp=}, {bar_type=}")
+ return max(0, height_dp)
+ except Exception as e:
+ self.logger.debug(f"{bar_type} fallback due to: {e!r}")
+ return 0
+
+ @pyqtSlot(result=int)
+ def getStatusBarHeight(self) -> int:
+ return self._getSystemBarHeight('status')
+
+ @pyqtSlot(result=int)
+ def getNavigationBarHeight(self) -> int:
+ return self._getSystemBarHeight('navigation')
+
class ElectrumQmlApplication(QGuiApplication):
Why this scored 13/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.