@@ -11,6 +11,8 @@ import kotlinx.coroutines.Dispatchers
1111import kotlinx.coroutines.delay
1212import kotlinx.coroutines.flow.first
1313import kotlinx.coroutines.launch
14+ import android.widget.Toast
15+ import com.sameerasw.airsync.BuildConfig
1416import org.json.JSONObject
1517
1618/* *
@@ -513,8 +515,17 @@ object WebSocketMessageHandler {
513515
514516 val macName = data.optString(" name" , " " )
515517 val isPlus = data.optBoolean(" isPlusSubscription" , false )
518+ val macVersion = data.optString(" version" , " 2.0.0" )
516519
517- Log .d(TAG , " Processing macInfo - name: '$macName ', isPlus: $isPlus " )
520+ Log .d(TAG , " Processing macInfo - name: '$macName ', isPlus: $isPlus , version: '$macVersion '" )
521+
522+ // Version compatibility check
523+ val minVersion = BuildConfig .MIN_MAC_APP_VERSION
524+ if (isVersionOutdated(macVersion, minVersion)) {
525+ launch(Dispatchers .Main ) {
526+ Toast .makeText(context, " Mac app is outdated ($macVersion < $minVersion ). Please update the mac app and reconnect." , Toast .LENGTH_LONG ).show()
527+ }
528+ }
518529
519530 val savedAppPackagesJson = data.optJSONArray(" savedAppPackages" )
520531 val savedPackages = mutableSetOf<String >()
@@ -857,4 +868,23 @@ object WebSocketMessageHandler {
857868 Log .d(TAG , " Request to refresh ADB ports received" )
858869 SyncManager .sendDeviceInfoNow(context)
859870 }
871+
872+ private fun isVersionOutdated (current : String , min : String ): Boolean {
873+ return try {
874+ val currentParts = current.split(" ." ).map { it.toInt() }
875+ val minParts = min.split(" ." ).map { it.toInt() }
876+
877+ val maxLen = maxOf(currentParts.size, minParts.size)
878+ for (i in 0 until maxLen) {
879+ val currentPart = if (i < currentParts.size) currentParts[i] else 0
880+ val minPart = if (i < minParts.size) minParts[i] else 0
881+
882+ if (currentPart < minPart) return true
883+ if (currentPart > minPart) return false
884+ }
885+ false
886+ } catch (e: Exception ) {
887+ false
888+ }
889+ }
860890}
0 commit comments