Repository navigation
Tell the tablet when the GNOME screen is locked #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1bac16c
Tell the tablet when the GNOME screen is locked
FacuM 9f08af1
Wait for the lock to be reported and keep the locked message on retries
FacuM 11f0259
Bound the lock probe and keep the locked message over other notices
FacuM 2e27702
Keep the lock wait inside its deadline and stop after an unanswered p…
FacuM 12e89fd
Keep at most one lock probe outstanding
FacuM 2509bc5
Wait for the stuck probe to start before counting workers in the test
FacuM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
android/app/src/main/kotlin/com/librestatic/ezdisplay/HostLock.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.librestatic.ezdisplay | ||
|
|
||
| /** Pure rules for a host whose screen is locked (the native layer reports the code `screen_locked`). */ | ||
| object HostLock { | ||
| /** Status code the native layer sets when the host ends the session because its screen is locked. */ | ||
| const val CODE = "screen_locked" | ||
|
|
||
| /** Fixed delay between reconnection attempts while the host is locked. */ | ||
| const val RETRY_MS = 5000L | ||
|
|
||
| /** Whether an ended session carrying [code] means the host's screen is locked. */ | ||
| fun isLocked(code: String?): Boolean = code == CODE | ||
|
|
||
| /** Whether a negotiated stream shows that the host was unlocked: only once a frame has arrived. */ | ||
| fun confirmsUnlock(framesReceived: Long): Boolean = framesReceived > 0 | ||
|
|
||
| /** Whether the connecting and handshake texts may replace the status; the locked message stays up. */ | ||
| fun showsProgress(hostLocked: Boolean): Boolean = !hostLocked | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
android/app/src/test/kotlin/com/librestatic/ezdisplay/HostLockTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.librestatic.ezdisplay | ||
|
|
||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Assert.assertFalse | ||
| import org.junit.Assert.assertTrue | ||
| import org.junit.Test | ||
|
|
||
| class HostLockTest { | ||
| @Test fun onlyTheScreenLockedCodeMeansLocked() { | ||
| assertTrue(HostLock.isLocked("screen_locked")) | ||
| assertFalse(HostLock.isLocked(null)) | ||
| assertFalse(HostLock.isLocked("not_paired")) | ||
| } | ||
|
|
||
| @Test fun connectingTextsDoNotReplaceTheLockedMessage() { | ||
| assertFalse(HostLock.showsProgress(true)) | ||
| assertTrue(HostLock.showsProgress(false)) | ||
| } | ||
|
|
||
| @Test fun aNegotiatedStreamCountsOnlyOnceAFrameArrives() { | ||
| assertFalse(HostLock.confirmsUnlock(0)) | ||
| assertTrue(HostLock.confirmsUnlock(1)) | ||
| } | ||
|
|
||
| @Test fun retriesAreSlowAndFixed() { | ||
| assertEquals(5000L, HostLock.RETRY_MS) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.