diff --git a/.github/workflows/build-kernel-a12.yml b/.github/workflows/build-kernel-a12.yml index 7ecfb7283185..d656711d0a4b 100644 --- a/.github/workflows/build-kernel-a12.yml +++ b/.github/workflows/build-kernel-a12.yml @@ -92,8 +92,12 @@ jobs: echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem fi - - name: Setup mutex for uploading - uses: ben-z/gh-action-mutex@v1.0-alpha-7 + - name: Bot session cache + id: bot_session_cache + uses: actions/cache@v3 + with: + path: scripts/ksubot.session + key: ${{ runner.os }}-bot-session - name: Build boot images run: | diff --git a/.github/workflows/build-kernel-a13.yml b/.github/workflows/build-kernel-a13.yml index efe7ba5a3a89..338e5c1fa621 100644 --- a/.github/workflows/build-kernel-a13.yml +++ b/.github/workflows/build-kernel-a13.yml @@ -115,8 +115,12 @@ jobs: echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem fi - - name: Setup mutex for uploading - uses: ben-z/gh-action-mutex@v1.0-alpha-7 + - name: Bot session cache + id: bot_session_cache + uses: actions/cache@v3 + with: + path: scripts/ksubot.session + key: ${{ runner.os }}-bot-session - name: Build boot images run: | diff --git a/.github/workflows/build-kernel-a14.yml b/.github/workflows/build-kernel-a14.yml index 3640bf7165bf..74131818dc2b 100644 --- a/.github/workflows/build-kernel-a14.yml +++ b/.github/workflows/build-kernel-a14.yml @@ -76,8 +76,12 @@ jobs: echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem fi - - name: Setup mutex for uploading - uses: ben-z/gh-action-mutex@v1.0-alpha-7 + - name: Bot session cache + id: bot_session_cache + uses: actions/cache@v3 + with: + path: scripts/ksubot.session + key: ${{ runner.os }}-bot-session - name: Build boot images run: | diff --git a/.github/workflows/build-kernel-arcvm.yml b/.github/workflows/build-kernel-arcvm.yml index 367d0e3c25e5..567d533c164d 100644 --- a/.github/workflows/build-kernel-arcvm.yml +++ b/.github/workflows/build-kernel-arcvm.yml @@ -115,6 +115,14 @@ jobs: name: kernel-ARCVM-${{ matrix.arch }}-${{ matrix.version }} path: "${{ env.file_path }}" + - name: Bot session cache + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) || github.ref_type == 'tag' }} + id: bot_session_cache + uses: actions/cache@v3 + with: + path: scripts/ksubot.session + key: ${{ runner.os }}-bot-session + - name: Post to Telegram if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) || github.ref_type == 'tag' }} env: diff --git a/.github/workflows/build-kernel-wsa.yml b/.github/workflows/build-kernel-wsa.yml index 967edbbc15a3..cdd43bc2d81f 100644 --- a/.github/workflows/build-kernel-wsa.yml +++ b/.github/workflows/build-kernel-wsa.yml @@ -109,6 +109,14 @@ jobs: name: kernel-WSA-${{ matrix.arch }}-${{ matrix.version }} path: "${{ env.file_path }}" + - name: Bot session cache + if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.ref_type == 'tag' + id: bot_session_cache + uses: actions/cache@v3 + with: + path: scripts/ksubot.session + key: ${{ runner.os }}-bot-session + - name: Post to Telegram if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.ref_type == 'tag' env: diff --git a/.github/workflows/build-manager.yml b/.github/workflows/build-manager.yml index 42d8035c5472..67ddb34af536 100644 --- a/.github/workflows/build-manager.yml +++ b/.github/workflows/build-manager.yml @@ -102,9 +102,13 @@ jobs: name: manager path: manager/app/build/outputs/apk/release/*.apk - - name: Setup mutex for uploading - uses: ben-z/gh-action-mutex@v1.0-alpha-7 + - name: Bot session cache if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true' + id: bot_session_cache + uses: actions/cache@v3 + with: + path: scripts/ksubot.session + key: ${{ runner.os }}-bot-session - name: Upload to telegram if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true' diff --git a/.github/workflows/build-su.yml b/.github/workflows/build-su.yml index 8c4068dd6b2e..4c92611170dc 100644 --- a/.github/workflows/build-su.yml +++ b/.github/workflows/build-su.yml @@ -37,9 +37,13 @@ jobs: with: name: su path: ./userspace/su/libs - - name: Setup mutex for uploading - uses: ben-z/gh-action-mutex@v1.0-alpha-7 + - name: Bot session cache if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true' + id: bot_session_cache + uses: actions/cache@v3 + with: + path: scripts/ksubot.session + key: ${{ runner.os }}-bot-session - name: Upload to telegram if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true' env: diff --git a/.github/workflows/gki-kernel.yml b/.github/workflows/gki-kernel.yml index 52b2815da569..d7bf1f423060 100644 --- a/.github/workflows/gki-kernel.yml +++ b/.github/workflows/gki-kernel.yml @@ -157,7 +157,7 @@ jobs: - name: Make working directory clean to avoid dirty working-directory: android-kernel run: | - sed -i '/^rfkill_/d' common/android/abi_gki_protected_exports_* + sed -i '/^rfkill_/d' common/android/abi_gki_protected_exports_* || echo "No protected exports!" git config --global user.email "bot@kernelsu.org" git config --global user.name "KernelSUBot" cd common/ && git add -A && git commit -a -m "Add KernelSU" diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt index 61a46f2aca00..2ba822b24bb4 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt @@ -150,6 +150,7 @@ private fun ModuleList( val changelogText = stringResource(R.string.module_changelog) val downloadingText = stringResource(R.string.module_downloading) val startDownloadingText = stringResource(R.string.module_start_downloading) + val fetchChangeLogFailed = stringResource(R.string.module_changelog_failed) val dialogHost = LocalDialogHost.current val snackBarHost = LocalSnackbarHost.current @@ -161,36 +162,48 @@ private fun ModuleList( downloadUrl: String, fileName: String ) { - val changelog = dialogHost.withLoading { + val changelogResult = dialogHost.withLoading { withContext(Dispatchers.IO) { - OkHttpClient().newCall( - okhttp3.Request.Builder().url(changelogUrl).build() - ).execute().body!!.string() + runCatching { + OkHttpClient().newCall( + okhttp3.Request.Builder().url(changelogUrl).build() + ).execute().body!!.string() + } } } - if (changelog.isNotEmpty()) { - // changelog is not empty, show it and wait for confirm - val confirmResult = dialogHost.showConfirm( - changelogText, - content = changelog, - markdown = true, - confirm = updateText, - ) - - if (confirmResult != ConfirmResult.Confirmed) { - return + val showToast: suspend (String) -> Unit = {msg-> + withContext(Dispatchers.Main) { + Toast.makeText( + context, + msg, + Toast.LENGTH_SHORT + ).show() } } - withContext(Dispatchers.Main) { - Toast.makeText( - context, - startDownloadingText.format(module.name), - Toast.LENGTH_SHORT - ).show() + val changelog = changelogResult.getOrElse { + showToast(fetchChangeLogFailed.format(it.message)) + return + }.ifBlank { + showToast(fetchChangeLogFailed.format(module.name)) + return + } + + // changelog is not empty, show it and wait for confirm + val confirmResult = dialogHost.showConfirm( + changelogText, + content = changelog, + markdown = true, + confirm = updateText, + ) + + if (confirmResult != ConfirmResult.Confirmed) { + return } + showToast(startDownloadingText.format(module.name)) + val downloading = downloadingText.format(module.name) withContext(Dispatchers.IO) { download( diff --git a/manager/app/src/main/res/values-zh-rCN/strings.xml b/manager/app/src/main/res/values-zh-rCN/strings.xml index d9676d269455..cbf0fa7d7416 100644 --- a/manager/app/src/main/res/values-zh-rCN/strings.xml +++ b/manager/app/src/main/res/values-zh-rCN/strings.xml @@ -101,4 +101,5 @@ 同步在线规则 模版保存失败! 剪切板为空! + 获取更新日志失败:%s \ No newline at end of file diff --git a/manager/app/src/main/res/values/strings.xml b/manager/app/src/main/res/values/strings.xml index a42e5af098f7..3f7adb82d8b8 100644 --- a/manager/app/src/main/res/values/strings.xml +++ b/manager/app/src/main/res/values/strings.xml @@ -103,4 +103,5 @@ Sync online templates Failed to save template Clipboard is empty! + Fetch changelog failed: %s diff --git a/scripts/ksubot.py b/scripts/ksubot.py index a2fb1822d19e..45c9c2bd0eff 100644 --- a/scripts/ksubot.py +++ b/scripts/ksubot.py @@ -73,7 +73,9 @@ async def main(): print("[-] No files to upload") exit(1) print("[+] Logging in Telegram with bot") - async with await TelegramClient(session=None, api_id=API_ID, api_hash=API_HASH).start(bot_token=BOT_TOKEN) as bot: + script_dir = os.path.dirname(os.path.abspath(sys.argv[0])) + session_dir = os.path.join(script_dir, "ksubot.session") + async with await TelegramClient(session=session_dir, api_id=API_ID, api_hash=API_HASH).start(bot_token=BOT_TOKEN) as bot: caption = [""] * len(files) caption[-1] = get_caption() print("[+] Caption: ") @@ -83,7 +85,6 @@ async def main(): print("[+] Sending") await bot.send_file(entity=CHAT_ID, file=files, caption=caption, reply_to=MESSAGE_THREAD_ID, parse_mode="markdown") print("[+] Done!") - await bot.log_out() if __name__ == "__main__": try: diff --git a/website/docs/repos.json b/website/docs/repos.json index 3600b6611910..d088bc437763 100644 --- a/website/docs/repos.json +++ b/website/docs/repos.json @@ -523,5 +523,26 @@ "kernel_name": "kernel_xiaomi_sm8350", "kernel_link": "https://github.com/supechicken/kernel_xiaomi_sm8350", "devices": " Xiaomi 11T Pro (vili)" + }, + { + "maintainer": "Vaz15k", + "maintainer_link": "https://github.com/Vaz15k", + "kernel_name": "kernelSU-A70q", + "kernel_link": "https://github.com/Vaz15k/kernelSU-A70q", + "devices": "Samsung Galaxy A70 ( A705MN / A705FN )" + }, + { + "maintainer": "whyakari", + "maintainer_link": "https://github.com/whyakari", + "kernel_name": "android_kernel_xiaomi_ginkgo", + "kernel_link": "https://github.com/whyakari/android_kernel_xiaomi_ginkgo", + "devices": "non-GKI ginkgo" + }, + { + "maintainer": "wulan17", + "maintainer_link": "https://github.com/wulan17", + "kernel_name": "android_kernel_xiaomi_mt6765", + "kernel_link": "https://github.com/Mayuri-Chan/android_kernel_xiaomi_mt6765/tree/10-ksu", + "devices": "Redmi 6/6A (cereus/cactus)" } -] \ No newline at end of file +]