From ea1ac861349ca1a1cd52af20b39c0795f415713c Mon Sep 17 00:00:00 2001 From: Koen J Date: Sat, 19 Oct 2024 07:37:12 +0200 Subject: [PATCH 1/4] Updated submodules and implemented timer to make sync connect requests less frequent upon failure. --- .../futo/platformplayer/states/StateSync.kt | 29 ++++++++++++++----- app/src/stable/assets/sources/bilibili | 2 +- app/src/stable/assets/sources/bitchute | 2 +- app/src/stable/assets/sources/dailymotion | 2 +- app/src/stable/assets/sources/spotify | 2 +- app/src/stable/assets/sources/youtube | 2 +- app/src/unstable/assets/sources/bilibili | 2 +- app/src/unstable/assets/sources/bitchute | 2 +- app/src/unstable/assets/sources/dailymotion | 2 +- app/src/unstable/assets/sources/spotify | 2 +- app/src/unstable/assets/sources/youtube | 2 +- dep/polycentricandroid | 2 +- 12 files changed, 33 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/futo/platformplayer/states/StateSync.kt b/app/src/main/java/com/futo/platformplayer/states/StateSync.kt index a8b76152..7c05d20d 100644 --- a/app/src/main/java/com/futo/platformplayer/states/StateSync.kt +++ b/app/src/main/java/com/futo/platformplayer/states/StateSync.kt @@ -53,7 +53,8 @@ class StateSync { private var _connectThread: Thread? = null private var _started = false private val _sessions: MutableMap = mutableMapOf() - private val _lastConnectTimes: MutableMap = mutableMapOf() + private val _lastConnectTimesMdns: MutableMap = mutableMapOf() + private val _lastConnectTimesIp: MutableMap = mutableMapOf() //TODO: Should sync mdns and casting mdns be merged? //TODO: Decrease interval that devices are updated //TODO: Send less data @@ -148,7 +149,21 @@ class StateSync { for (connectPair in addressesToConnect) { try { val syncDeviceInfo = SyncDeviceInfo(connectPair.first, arrayOf(connectPair.second), PORT) - connect(syncDeviceInfo) + + val now = System.currentTimeMillis() + val lastConnectTime = synchronized(_lastConnectTimesIp) { + _lastConnectTimesIp[connectPair.first] ?: 0 + } + + //Connect once every 30 seconds, max + if (now - lastConnectTime > 30000) { + synchronized(_lastConnectTimesIp) { + _lastConnectTimesIp[connectPair.first] = now + } + + Logger.i(TAG, "Attempting to connect to authorized device by last known IP '${connectPair.first}' with pkey=${connectPair.first}") + connect(syncDeviceInfo) + } } catch (e: Throwable) { Logger.i(TAG, "Failed to connect to " + connectPair.first, e) } @@ -222,14 +237,14 @@ class StateSync { if (authorized && !isConnected(pkey)) { val now = System.currentTimeMillis() - val lastConnectTime = synchronized(_lastConnectTimes) { - _lastConnectTimes[pkey] ?: 0 + val lastConnectTime = synchronized(_lastConnectTimesMdns) { + _lastConnectTimesMdns[pkey] ?: 0 } //Connect once every 30 seconds, max if (now - lastConnectTime > 30000) { - synchronized(_lastConnectTimes) { - _lastConnectTimes[pkey] = now + synchronized(_lastConnectTimesMdns) { + _lastConnectTimesMdns[pkey] = now } Logger.i(TAG, "Found device authorized device '${name}' with pkey=$pkey, attempting to connect") @@ -237,7 +252,7 @@ class StateSync { try { connect(syncDeviceInfo) } catch (e: Throwable) { - Logger.e(TAG, "Failed to connect to $pkey", e) + Logger.i(TAG, "Failed to connect to $pkey", e) } } } diff --git a/app/src/stable/assets/sources/bilibili b/app/src/stable/assets/sources/bilibili index 31490e10..5809463f 160000 --- a/app/src/stable/assets/sources/bilibili +++ b/app/src/stable/assets/sources/bilibili @@ -1 +1 @@ -Subproject commit 31490e10f9ef661d6365c0cf4d0fcedf9d807a69 +Subproject commit 5809463f3dc2fd81fb92740ede467e271b5ca0c3 diff --git a/app/src/stable/assets/sources/bitchute b/app/src/stable/assets/sources/bitchute index 872bfa2d..4309c580 160000 --- a/app/src/stable/assets/sources/bitchute +++ b/app/src/stable/assets/sources/bitchute @@ -1 +1 @@ -Subproject commit 872bfa2d758317c4d0989d309966e85ceb4fcb29 +Subproject commit 4309c58008b92bdf2905ef05bf9129b50eab1edd diff --git a/app/src/stable/assets/sources/dailymotion b/app/src/stable/assets/sources/dailymotion index 069aa3d3..6dc9ba2b 160000 --- a/app/src/stable/assets/sources/dailymotion +++ b/app/src/stable/assets/sources/dailymotion @@ -1 +1 @@ -Subproject commit 069aa3d31a35559e45c1fe1ea1eb2a94d3b5d120 +Subproject commit 6dc9ba2b61ed885ec48e06e319ba75fe9bff942c diff --git a/app/src/stable/assets/sources/spotify b/app/src/stable/assets/sources/spotify index 4d554e93..b94d5a50 160000 --- a/app/src/stable/assets/sources/spotify +++ b/app/src/stable/assets/sources/spotify @@ -1 +1 @@ -Subproject commit 4d554e93882d29542cb05d2956f4b2484d7df27f +Subproject commit b94d5a5091ae0929d82c703868616158607a4436 diff --git a/app/src/stable/assets/sources/youtube b/app/src/stable/assets/sources/youtube index 35b56d38..95ae01d5 160000 --- a/app/src/stable/assets/sources/youtube +++ b/app/src/stable/assets/sources/youtube @@ -1 +1 @@ -Subproject commit 35b56d380a9ae6ef85ba8ec16cecb0a86d4efa1d +Subproject commit 95ae01d5358328583fc3a3b59a2a0ca9d06301d2 diff --git a/app/src/unstable/assets/sources/bilibili b/app/src/unstable/assets/sources/bilibili index 31490e10..5809463f 160000 --- a/app/src/unstable/assets/sources/bilibili +++ b/app/src/unstable/assets/sources/bilibili @@ -1 +1 @@ -Subproject commit 31490e10f9ef661d6365c0cf4d0fcedf9d807a69 +Subproject commit 5809463f3dc2fd81fb92740ede467e271b5ca0c3 diff --git a/app/src/unstable/assets/sources/bitchute b/app/src/unstable/assets/sources/bitchute index 872bfa2d..4309c580 160000 --- a/app/src/unstable/assets/sources/bitchute +++ b/app/src/unstable/assets/sources/bitchute @@ -1 +1 @@ -Subproject commit 872bfa2d758317c4d0989d309966e85ceb4fcb29 +Subproject commit 4309c58008b92bdf2905ef05bf9129b50eab1edd diff --git a/app/src/unstable/assets/sources/dailymotion b/app/src/unstable/assets/sources/dailymotion index 069aa3d3..6dc9ba2b 160000 --- a/app/src/unstable/assets/sources/dailymotion +++ b/app/src/unstable/assets/sources/dailymotion @@ -1 +1 @@ -Subproject commit 069aa3d31a35559e45c1fe1ea1eb2a94d3b5d120 +Subproject commit 6dc9ba2b61ed885ec48e06e319ba75fe9bff942c diff --git a/app/src/unstable/assets/sources/spotify b/app/src/unstable/assets/sources/spotify index 4d554e93..b94d5a50 160000 --- a/app/src/unstable/assets/sources/spotify +++ b/app/src/unstable/assets/sources/spotify @@ -1 +1 @@ -Subproject commit 4d554e93882d29542cb05d2956f4b2484d7df27f +Subproject commit b94d5a5091ae0929d82c703868616158607a4436 diff --git a/app/src/unstable/assets/sources/youtube b/app/src/unstable/assets/sources/youtube index dda3c6c7..95ae01d5 160000 --- a/app/src/unstable/assets/sources/youtube +++ b/app/src/unstable/assets/sources/youtube @@ -1 +1 @@ -Subproject commit dda3c6c71948be5e40b1704895eacf796753e953 +Subproject commit 95ae01d5358328583fc3a3b59a2a0ca9d06301d2 diff --git a/dep/polycentricandroid b/dep/polycentricandroid index a7063a30..f7d58c6c 160000 --- a/dep/polycentricandroid +++ b/dep/polycentricandroid @@ -1 +1 @@ -Subproject commit a7063a300c40dd2310325716f2300ac9259f47aa +Subproject commit f7d58c6ca6de151c11bd4ecc48a7de81bdc36d8a From 0b4ab46563d768943817ee3abb4353556f4845df Mon Sep 17 00:00:00 2001 From: Koen J Date: Sun, 20 Oct 2024 07:46:41 +0200 Subject: [PATCH 2/4] Added aws s3 cp for releasing artifacts. --- deploy-playstore.sh | 2 +- deploy-stable.sh | 14 ++++++++++++++ deploy-unstable.sh | 10 ++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/deploy-playstore.sh b/deploy-playstore.sh index 78aeb590..5d31fcfb 100644 --- a/deploy-playstore.sh +++ b/deploy-playstore.sh @@ -15,7 +15,7 @@ touch $DOCUMENT_ROOT/maintenance.file # Swap over the content echo "Deploying content..." -cp ./app/build/outputs/bundle/playstoreRelease/app-playstore-release.aab $DOCUMENT_ROOT/app-playstore-release.aab +aws s3 cp ./app/build/outputs/bundle/playstoreRelease/app-playstore-release.aab s3://artifacts-grayjay-app/app-playstore-release.aab # Notify Cloudflare to wipe the CDN cache echo "Purging Cloudflare cache for zone $CLOUDFLARE_ZONE_ID..." diff --git a/deploy-stable.sh b/deploy-stable.sh index ba965acf..09de7833 100644 --- a/deploy-stable.sh +++ b/deploy-stable.sh @@ -27,6 +27,20 @@ echo $VERSION > $DOCUMENT_ROOT/version.txt mkdir -p $DOCUMENT_ROOT/changelogs git tag -l --format='%(contents)' $VERSION > $DOCUMENT_ROOT/changelogs/$VERSION +aws s3 cp ./app/build/outputs/apk/stable/release/app-stable-x86_64-release.apk s3://artifacts-grayjay-app/app-x86_64-release.apk +aws s3 cp ./app/build/outputs/apk/stable/release/app-stable-arm64-v8a-release.apk s3://artifacts-grayjay-app/app-arm64-v8a-release.apk +aws s3 cp ./app/build/outputs/apk/stable/release/app-stable-armeabi-v7a-release.apk s3://artifacts-grayjay-app/app-armeabi-v7a-release.apk +aws s3 cp ./app/build/outputs/apk/stable/release/app-stable-universal-release.apk s3://artifacts-grayjay-app/app-universal-release.apk +aws s3 cp ./app/build/outputs/apk/stable/release/app-stable-x86-release.apk s3://artifacts-grayjay-app/app-x86-release.apk +aws s3 cp ./app/build/outputs/apk/stable/release/app-stable-arm64-v8a-release.apk s3://artifacts-grayjay-app/app-release.apk + +VERSION=$(git describe --tags) +echo $VERSION > ./version.txt +git tag -l --format='%(contents)' $VERSION > ./changelog.txt + +aws s3 cp ./version.txt s3://artifacts-grayjay-app/version.txt +aws s3 cp ./changelog.txt s3://artifacts-grayjay-app/changelogs/$VERSION + # Notify Cloudflare to wipe the CDN cache echo "Purging Cloudflare cache for zone $CLOUDFLARE_ZONE_ID..." curl -X POST "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/purge_cache" \ diff --git a/deploy-unstable.sh b/deploy-unstable.sh index 856a5406..7ac97441 100644 --- a/deploy-unstable.sh +++ b/deploy-unstable.sh @@ -23,6 +23,16 @@ cp ./app/build/outputs/apk/unstable/release/app-unstable-x86-release.apk $DOCUME cp ./app/build/outputs/apk/unstable/release/app-unstable-arm64-v8a-release.apk $DOCUMENT_ROOT/app-release-unstable.apk git describe --tags > $DOCUMENT_ROOT/version-unstable.txt +aws s3 cp ./app/build/outputs/apk/unstable/release/app-unstable-x86_64-release.apk s3://artifacts-grayjay-app/app-x86_64-release-unstable.apk +aws s3 cp ./app/build/outputs/apk/unstable/release/app-unstable-arm64-v8a-release.apk s3://artifacts-grayjay-app/app-arm64-v8a-release-unstable.apk +aws s3 cp ./app/build/outputs/apk/unstable/release/app-unstable-armeabi-v7a-release.apk s3://artifacts-grayjay-app/app-armeabi-v7a-release-unstable.apk +aws s3 cp ./app/build/outputs/apk/unstable/release/app-unstable-universal-release.apk s3://artifacts-grayjay-app/app-universal-release-unstable.apk +aws s3 cp ./app/build/outputs/apk/unstable/release/app-unstable-x86-release.apk s3://artifacts-grayjay-app/app-x86-release-unstable.apk +aws s3 cp ./app/build/outputs/apk/unstable/release/app-unstable-arm64-v8a-release.apk s3://artifacts-grayjay-app/app-release-unstable.apk + +git describe --tags > ./version-unstable.txt +aws s3 cp ./version-unstable.txt s3://artifacts-grayjay-app/version-unstable.txt + # Notify Cloudflare to wipe the CDN cache echo "Purging Cloudflare cache for zone $CLOUDFLARE_ZONE_ID..." curl -X POST "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/purge_cache" \ From 5139acc7f17377106dcee9d844a2b05337987313 Mon Sep 17 00:00:00 2001 From: Koen Date: Mon, 21 Oct 2024 23:19:15 +0000 Subject: [PATCH 3/4] Update LICENSE.md --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 38414394..7f159cf7 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -16,7 +16,7 @@ Notwithstanding the above, you may not remove or obscure any functionality in th You may not alter, remove, or obscure any licensing, copyright, or other notices of the Licensor in the software. Any use of the Licensor’s trademarks is subject to applicable law. ## Patents -If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company. +If you make any written claim that the software infringes or contributes to infringement of any patent, your license for the software granted under these terms ends immediately. If your company makes such a claim, your license ends immediately for work on behalf of your company. ## Notices You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms. If you modify the software, you must include in any modified copies of the software a prominent notice stating that you have modified the software, such as but not limited to, a statement in a readme file or an in-application about section. From 2bcd59cbfae6e97af26ece2083ed95022b4076fb Mon Sep 17 00:00:00 2001 From: Koen Date: Mon, 21 Oct 2024 23:20:54 +0000 Subject: [PATCH 4/4] Update LICENSE.md --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 7f159cf7..2cc664ad 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -# Grayjay Core License 1.0 +# Source First License 1.1 ## Acceptance By using the software, you agree to all of the terms and conditions below.