Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.
feat(android): mirroring through Elevated wakes the phone's screen (#82)
Bee0d5e844cbb6e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 17c00b5..a5518d0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,10 @@ change things that need a step from you, and its notes say so.debugging. It runs while the cable is in. The PC only starts NectarLink'sown helper, on the phone that asked([#70](https://github.com/thtbee/nectarlink/issues/70)).+- **Mirroring wakes the phone's screen.** With Elevated, starting mirroring+ from the PC turns the phone's screen on if it's off, so the phone can stay+ in a pocket; a locked phone shows its lock screen in the window+ ([#82](https://github.com/thtbee/nectarlink/issues/82)).- **The PC app on Linux**, for Ubuntu 24.04 or newer, Debian 13, Fedora 40or newer and other distributions from 2024 on, as a `.deb`, an `.rpm`,an AppImage or a tarball. It does what the Windows app does: notifications withdiff --git a/android/app/src/main/kotlin/app/nectarlink/android/elevated/Elevated.kt b/android/app/src/main/kotlin/app/nectarlink/android/elevated/Elevated.ktindex a730e4e..674116b 100644--- a/android/app/src/main/kotlin/app/nectarlink/android/elevated/Elevated.kt+++ b/android/app/src/main/kotlin/app/nectarlink/android/elevated/Elevated.kt@@ -801,6 +801,18 @@ object Elevated {return send(writer, "B ${b64(text)} ${html?.let(b64).orEmpty()}")}+ /**+ * Wakes the screen when it's off, as the power key would (the lock screen+ * shows if the phone is locked). Mirroring otherwise waits for someone to+ * turn the screen on by hand (#82).+ */+ fun wakeScreen(): Boolean {+ val writer = input ?: return false+ val power = context.getSystemService(android.os.PowerManager::class.java)+ if (power?.isInteractive != false) return true+ return send(writer, "K ${KeyEvent.KEYCODE_WAKEUP}")+ }+/** Turns the physical screen panel off or back on while mirroring. */fun setScreenOff(off: Boolean): Boolean {screenOffRequested = offdiff --git a/android/app/src/main/kotlin/app/nectarlink/android/mirror/MirrorService.kt b/android/app/src/main/kotlin/app/nectarlink/android/mirror/MirrorService.ktindex ccd94ba..8f939ba 100644--- a/android/app/src/main/kotlin/app/nectarlink/android/mirror/MirrorService.kt+++ b/android/app/src/main/kotlin/app/nectarlink/android/mirror/MirrorService.kt@@ -158,6 +158,8 @@ class MirrorService : Service() {// The helper's socket: off the main thread, where Android refuses// network calls (and the phone then asked for screen-capture consent).val (initW, initH, initDpi) = ScreenEncoder.computeScreenSize(this@MirrorService, request.maxSize)+ // With the screen off (phone in a pocket) there's nothing to show yet.+ app.nectarlink.android.elevated.Elevated.wakeScreen()val codec = ScreenEncoder.selectCodec("h264")val socket = app.nectarlink.android.elevated.Elevated.openScreen(initW,