From 77d9a7b2581bb7068cac9b2c2d42144eb8b712ce Mon Sep 17 00:00:00 2001
From: backslashxx <118538522+backslashxx@users.noreply.github.com>
Date: Tue, 29 Oct 2024 00:08:06 +0800
Subject: [PATCH] manager: unofficial build
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- disable updates
- warn and inform that this is not an official build.
- also 🍉 emoji as promised
- also update setup.sh for automated builds
- add 'magic' on apk filename
---
 kernel/setup.sh                               |  2 +-
 manager/app/build.gradle.kts                  |  4 +-
 .../java/me/weishu/kernelsu/ui/screen/Home.kt | 39 +++++++++++++++----
 .../me/weishu/kernelsu/ui/screen/Settings.kt  | 17 +-------
 .../me/weishu/kernelsu/ui/util/Downloader.kt  |  3 +-
 manager/app/src/main/res/values/strings.xml   |  5 ++-
 6 files changed, 41 insertions(+), 29 deletions(-)

diff --git a/kernel/setup.sh b/kernel/setup.sh
index e688dbaf3ae5..fa35377026b0 100755
--- a/kernel/setup.sh
+++ b/kernel/setup.sh
@@ -39,7 +39,7 @@ perform_cleanup() {
 # Sets up or update KernelSU environment
 setup_kernelsu() {
     echo "[+] Setting up KernelSU..."
-    test -d "$GKI_ROOT/KernelSU" || git clone https://github.com/tiann/KernelSU && echo "[+] Repository cloned."
+    test -d "$GKI_ROOT/KernelSU" || git clone https://github.com/backslashxx/KernelSU && echo "[+] Repository cloned."
     cd "$GKI_ROOT/KernelSU"
     git stash && echo "[-] Stashed current changes."
     if [ "$(git status | grep -Po 'v\d+(\.\d+)*' | head -n1)" ]; then
diff --git a/manager/app/build.gradle.kts b/manager/app/build.gradle.kts
index 1f98e4a1ba62..43e9ae538ce7 100644
--- a/manager/app/build.gradle.kts
+++ b/manager/app/build.gradle.kts
@@ -68,7 +68,7 @@ android {
     applicationVariants.all {
         outputs.forEach {
             val output = it as BaseVariantOutputImpl
-            output.outputFileName = "KernelSU_${managerVersionName}_${managerVersionCode}-$name.apk"
+            output.outputFileName = "KernelSU_${managerVersionName}_${managerVersionCode}-magic-$name.apk"
         }
         kotlin.sourceSets {
             getByName(name) {
@@ -133,4 +133,4 @@ dependencies {
     implementation(libs.androidx.webkit)
 
     implementation(libs.lsposed.cxx)
-}
\ No newline at end of file
+}
diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt
index 71ddc63d3e57..01beb69d5038 100644
--- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt
+++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt
@@ -96,12 +96,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
                     stringResource(id = R.string.grant_root_failed)
                 )
             }
-            val checkUpdate =
-                LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
-                    .getBoolean("check_update", true)
-            if (checkUpdate) {
-                UpdateCard()
-            }
+            Unofficial()
             InfoCard()
             DonateCard()
             LearnMoreCard()
@@ -405,7 +400,7 @@ private fun InfoCard() {
             val managerVersion = getManagerVersion(context)
             InfoCardItem(
                 stringResource(R.string.home_manager_version),
-                "${managerVersion.first} (${managerVersion.second})"
+                "${managerVersion.first}-magic 🪄 (${managerVersion.second})"
             )
 
             Spacer(Modifier.height(16.dp))
@@ -417,6 +412,34 @@ private fun InfoCard() {
     }
 }
 
+@Composable
+fun Unofficial() {
+    val uriHandler = LocalUriHandler.current
+    val url = stringResource(R.string.home_unofficial_kernelsu_announce)
+
+    ElevatedCard {
+
+        Row(modifier = Modifier
+            .fillMaxWidth()
+            .clickable {
+                uriHandler.openUri(url)
+            }
+            .padding(24.dp), verticalAlignment = Alignment.CenterVertically) {
+            Column {
+                Text(
+                    text = stringResource(R.string.home_unofficial_kernelsu),
+                    style = MaterialTheme.typography.titleSmall
+                )
+                Spacer(Modifier.height(4.dp))
+                Text(
+                    text = stringResource(R.string.home_unofficial_kernelsu_body),
+                    style = MaterialTheme.typography.bodyMedium
+                )
+            }
+        }
+    }
+}
+
 fun getManagerVersion(context: Context): Pair<String, Long> {
     val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)!!
     val versionCode = PackageInfoCompat.getLongVersionCode(packageInfo)
@@ -444,4 +467,4 @@ private fun WarningCardPreview() {
             MaterialTheme.colorScheme.outlineVariant,
             onClick = {})
     }
-}
\ No newline at end of file
+}
diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt
index fe6b8786f335..827f0daf6d72 100644
--- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt
+++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt
@@ -172,21 +172,6 @@ fun SettingScreen(navigator: DestinationsNavigator) {
             }
 
             val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
-            var checkUpdate by rememberSaveable {
-                mutableStateOf(
-                    prefs.getBoolean("check_update", true)
-                )
-            }
-            SwitchItem(
-                icon = Icons.Filled.Update,
-                title = stringResource(id = R.string.settings_check_update),
-                summary = stringResource(id = R.string.settings_check_update_summary),
-                checked = checkUpdate
-            ) {
-                prefs.edit().putBoolean("check_update", it).apply()
-                checkUpdate = it
-            }
-
             var enableWebDebugging by rememberSaveable {
                 mutableStateOf(
                     prefs.getBoolean("enable_web_debugging", false)
@@ -483,4 +468,4 @@ private fun TopBar(
 @Composable
 private fun SettingsPreview() {
     SettingScreen(EmptyDestinationsNavigator)
-}
\ No newline at end of file
+}
diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/util/Downloader.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/util/Downloader.kt
index bdf8496633fd..6991897ea855 100644
--- a/manager/app/src/main/java/me/weishu/kernelsu/ui/util/Downloader.kt
+++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/util/Downloader.kt
@@ -62,7 +62,8 @@ fun download(
 }
 
 fun checkNewVersion(): LatestVersionInfo {
-    val url = "https://api.github.com/repos/tiann/KernelSU/releases/latest"
+    // disable updates
+    val url = "https://127.0.0.1/repos/tiann/KernelSU/releases/latest"
     // default null value if failed
     val defaultValue = LatestVersionInfo()
     runCatching {
diff --git a/manager/app/src/main/res/values/strings.xml b/manager/app/src/main/res/values/strings.xml
index c930c942df87..530766ec984f 100644
--- a/manager/app/src/main/res/values/strings.xml
+++ b/manager/app/src/main/res/values/strings.xml
@@ -48,6 +48,9 @@
     <string name="safe_mode">Safe mode</string>
     <string name="reboot_to_apply">Reboot to take effect</string>
     <string name="module_magisk_conflict">Modules are unavailable due to a conflict with Magisk!</string>
+    <string name="home_unofficial_kernelsu">🍉 Unofficial Build</string>
+    <string name="home_unofficial_kernelsu_announce">https://github.com/tiann/KernelSU/issues/1705</string>
+    <string name="home_unofficial_kernelsu_body">Non-GKI support ended; see announcement.</string>
     <string name="home_learn_kernelsu">Learn KernelSU</string>
     <string name="home_learn_kernelsu_url">https://kernelsu.org/guide/what-is-kernelsu.html</string>
     <string name="home_click_to_learn_kernelsu">Learn how to install KernelSU and use modules</string>
@@ -134,4 +137,4 @@
     <string name="selected_lkm">Selected LKM: %s</string>
     <string name="save_log">Save logs</string>
     <string name="log_saved">Logs saved</string>
-</resources>
\ No newline at end of file
+</resources>