-
-
Notifications
You must be signed in to change notification settings - Fork 22
feat: AirBridge relay - connect Mac and Android when not on the same network (Android Integration) #102
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
Open
tornado-bunk
wants to merge
27
commits into
sameerasw:main
Choose a base branch
from
tornado-bunk:feat/airbridge-server
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: AirBridge relay - connect Mac and Android when not on the same network (Android Integration) #102
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
f6f2f42
feat: AirBridge relay support and LAN authentication
tornado-bunk 556f7bc
feat: Improved LAN reconnection from relay and connection transport UI
tornado-bunk d419508
Merge branch 'main' into feat/airbridge-server - resolve Android conf…
tornado-bunk 4602eb3
Remove custom HMAC auth, use v3.0.0 native encryption
tornado-bunk 1bf31c3
feat: WebSocket resilience, lightweight keepalive, and plaintext fall…
tornado-bunk 97c4c94
refactor: Floating toolbar animations and CryptoUtil cleanup
tornado-bunk 1cb46ed
feat: Externalize expanded state in AirSyncFloatingToolbar
tornado-bunk cdaee74
fix: no floatingdock
tornado-bunk f8021fc
fix: FAB visibility logic on scroll
tornado-bunk ca24141
feat: improve relay and LAN reconnection logic
tornado-bunk ae92280
feat: Added peer status monitoring and Mac wake handling for AirBridge
tornado-bunk c1a00fb
feat: Peer health status badge
tornado-bunk b5eec36
feat: Peer transport notification for seamless UI switching
tornado-bunk 6751f10
feat: Improved transport synchronization and QuickShare foreground di…
tornado-bunk 9af2bcc
feat: Enhance macWake handling with LAN reconnect retry logic
tornado-bunk 0328afb
feat: Implement adaptive LAN-first probing for relay connections
tornado-bunk 8999d8f
feat: bootstrap LAN-first probing on app restart with active relay
tornado-bunk 6c32f1d
feat: Enhance transport offer handling and candidate extraction for L…
tornado-bunk 4653206
feat: Simplify relay connection label and peer health indicator
tornado-bunk 8321deb
feat: Implement HMAC-SHA256 challenge-response authentication for relay
tornado-bunk 4c98c1b
chore: simplify query parameter parsing logic
tornado-bunk 94e4be3
feat: Refine AirSyncMainScreen UI and URI parsing
tornado-bunk 2cfb4fe
clean: Refactor and optimize logging for AirBridge and transport sync…
tornado-bunk 37e3004
feat: Mark AirBridge Relay as Beta in UI
tornado-bunk 147a6a6
feat: readd URLDecoder import to MainActivity
tornado-bunk 13eae8a
readded removed logs
tornado-bunk e49fb1b
revert: reverted logging for WebSocket decryption failures
tornado-bunk 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ import androidx.compose.ui.res.painterResource | |
| import androidx.compose.ui.unit.dp | ||
| import androidx.core.animation.doOnEnd | ||
| import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen | ||
| import androidx.lifecycle.lifecycleScope | ||
| import androidx.navigation.compose.NavHost | ||
| import androidx.navigation.compose.composable | ||
| import androidx.navigation.compose.rememberNavController | ||
|
|
@@ -54,13 +55,15 @@ import com.sameerasw.airsync.presentation.ui.screens.AirSyncMainScreen | |
| import com.sameerasw.airsync.ui.theme.AirSyncTheme | ||
| import com.sameerasw.airsync.presentation.viewmodel.AirSyncViewModel | ||
| import com.sameerasw.airsync.utils.AdbMdnsDiscovery | ||
| import com.sameerasw.airsync.utils.AirBridgeClient | ||
| import com.sameerasw.airsync.utils.ContentCaptureManager | ||
| import com.sameerasw.airsync.utils.DevicePreviewResolver | ||
| import com.sameerasw.airsync.utils.KeyguardHelper | ||
| import com.sameerasw.airsync.utils.NotesRoleManager | ||
| import com.sameerasw.airsync.utils.PermissionUtil | ||
| import com.sameerasw.airsync.utils.WebSocketUtil | ||
| import kotlinx.coroutines.flow.first | ||
| import kotlinx.coroutines.launch | ||
| import kotlinx.coroutines.runBlocking | ||
| import java.net.URLDecoder | ||
|
|
||
|
|
@@ -348,21 +351,48 @@ class MainActivity : ComponentActivity() { | |
| var pcName: String? = null | ||
| var isPlus = false | ||
| var symmetricKey: String? = null | ||
| var relayUrl: String? = null | ||
| var airBridgePairingId: String? = null | ||
| var airBridgeSecret: String? = null | ||
|
|
||
| data?.let { uri -> | ||
| val urlString = uri.toString() | ||
| val queryPart = urlString.substringAfter('?', "") | ||
| if (queryPart.isNotEmpty()) { | ||
| val params = queryPart.split('?') | ||
| val paramMap = params.associate { | ||
| val parts = it.split('=', limit = 2) | ||
| val key = parts.getOrNull(0) ?: "" | ||
| val value = parts.getOrNull(1) ?: "" | ||
| key to value | ||
| val paramMap = parseAirsyncParams(urlString) | ||
| pcName = paramMap["name"]?.let { android.net.Uri.decode(it) } | ||
| isPlus = paramMap["plus"]?.toBooleanStrictOrNull() ?: false | ||
| symmetricKey = paramMap["key"]?.let { | ||
| android.net.Uri.decode(it) | ||
| } | ||
| relayUrl = paramMap["relay"]?.let { android.net.Uri.decode(it) } | ||
| airBridgePairingId = | ||
| paramMap["pairingId"]?.let { android.net.Uri.decode(it) } | ||
| airBridgeSecret = | ||
| paramMap["secret"]?.let { android.net.Uri.decode(it) } | ||
| } | ||
|
|
||
| if (!relayUrl.isNullOrBlank() && | ||
| !airBridgePairingId.isNullOrBlank() && | ||
| !airBridgeSecret.isNullOrBlank() | ||
| ) { | ||
| lifecycleScope.launch { | ||
| try { | ||
| val ds = DataStoreManager.getInstance(this@MainActivity) | ||
| ds.setAirBridgeRelayUrl(relayUrl!!) | ||
| ds.setAirBridgePairingId(airBridgePairingId!!) | ||
| ds.setAirBridgeSecret(airBridgeSecret!!) | ||
| ds.setAirBridgeEnabled(true) | ||
|
|
||
| // Provide symmetric key to AirBridgeClient immediately so it doesn't | ||
| // refuse connection waiting for a completed LAN handshake first | ||
| if (!symmetricKey.isNullOrEmpty()) { | ||
| AirBridgeClient.updateSymmetricKey(symmetricKey) | ||
| } | ||
|
|
||
| AirBridgeClient.disconnect() | ||
| AirBridgeClient.connect(this@MainActivity) | ||
| } catch (e: Exception) { | ||
| Log.e("MainActivity", "Failed to apply AirBridge QR config: ${e.message}", e) | ||
| } | ||
| pcName = paramMap["name"]?.let { URLDecoder.decode(it, "UTF-8") } | ||
| isPlus = paramMap["plus"]?.toBooleanStrictOrNull() ?: false | ||
| symmetricKey = paramMap["key"] | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -580,6 +610,22 @@ class MainActivity : ComponentActivity() { | |
| return AdbDiscoveryHolder.getDiscoveredServices() | ||
| } | ||
|
|
||
| private fun parseAirsyncParams(urlString: String): Map<String, String> { | ||
| val queryPart = urlString.substringAfter('?', "") | ||
| if (queryPart.isEmpty()) return emptyMap() | ||
|
|
||
| return queryPart.split('?') | ||
| .mapNotNull { raw -> | ||
| if (raw.isBlank()) return@mapNotNull null | ||
| val parts = raw.split('=', limit = 2) | ||
| val key = parts.getOrNull(0)?.trim().orEmpty() | ||
| if (key.isEmpty()) return@mapNotNull null | ||
| val value = parts.getOrNull(1).orEmpty() | ||
| key to value | ||
| } | ||
| .toMap() | ||
|
Comment on lines
+613
to
+626
|
||
| } | ||
|
|
||
| /** | ||
| * Handles intents related to the Notes Role feature. | ||
| * Extracts stylus mode hint and lock screen status from the intent. | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataStoreManager.getInstance(this@MainActivity)stores the passed Context in a static singleton; passing an Activity context risks leaking the Activity. UseapplicationContextwhen callinggetInstance()here (and anywhere else a long-lived singleton is used).