Debloat your Android TV, install apps, browse and transfer files on it, all from your phone. Just 3 MB, no tracking, no root, no PC.
Keep only the Bouncy Castle algorithms Kadb uses; fail release builds over 3 MB
jesse-agent-821fd693fad53c6
diff --git a/app/build.gradle.kts b/app/build.gradle.ktsindex ea2e071..3accf87 100644--- a/app/build.gradle.kts+++ b/app/build.gradle.kts@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-3.0-only+import com.android.build.api.artifact.SingleArtifactimport com.android.tools.r8.D8import com.android.tools.r8.D8Commandimport com.android.tools.r8.OutputMode@@ -118,10 +119,35 @@ val dexLabelHelper by tasks.registering(DexLabelHelper::class) {outputDir = layout.buildDirectory.dir("generated/labelHelper/assets")}+/** Fails the build when a release APK grows past the 3 MB budget. CI's `build` and release.yml both assemble release. */+abstract class CheckApkSize : DefaultTask() {+ @get:InputFiles abstract val apkDir: DirectoryProperty+ @get:Input abstract val maxBytes: Property<Long>++ @TaskAction fun check() {+ val apks = apkDir.get().asFile.listFiles { f -> f.extension == "apk" }.orEmpty()+ check(apks.isNotEmpty()) { "no APK in ${apkDir.get().asFile}" }+ for (apk in apks) {+ check(apk.length() <= maxBytes.get()) {+ "${apk.name} is ${apk.length()} bytes, over the ${maxBytes.get()}-byte budget"+ }+ logger.lifecycle("${apk.name}: ${apk.length()} of ${maxBytes.get()} bytes")+ }+ }+}+androidComponents {onVariants { variant ->variant.sources.assets?.addGeneratedSourceDirectory(dexLabelHelper, DexLabelHelper::outputDir)}+ onVariants(selector().withBuildType("release")) { variant ->+ val name = variant.name.replaceFirstChar { it.uppercase() }+ val sizeCheck = tasks.register<CheckApkSize>("check${name}ApkSize") {+ apkDir = variant.artifacts.get(SingleArtifact.APK)+ maxBytes = 3_000_000L+ }+ afterEvaluate { tasks.named("assemble$name") { finalizedBy(sizeCheck) } }+ }}dependencies {diff --git a/app/proguard-rules.pro b/app/proguard-rules.proindex 28ba0ce..265e6a0 100644--- a/app/proguard-rules.pro+++ b/app/proguard-rules.pro@@ -2,11 +2,16 @@# Kadb makes its host certificate through the Bouncy Castle JCA provider, which# registers its algorithms as class-name strings (".../RSA$Mappings") and loads-# them reflectively. R8 can't see those, so it renames or strips them. The-# provider packages are where every by-name lookup points; the crypto they call-# is ordinary code R8 can follow.--keep class org.bouncycastle.jce.provider.** { *; }--keep class org.bouncycastle.jcajce.provider.** { *; }+# them reflectively. R8 can't see those, so it renames or strips them. Kadb asks+# that provider for three things only: SHA256withRSA, RSA keys and X.509+# certificates. These keep exactly those; keeping the whole provider cost+# ~700 KB of the APK. Any other lookup falls through to Kadb's next provider+# (AndroidOpenSSL, then the platform default) rather than failing.+-keep class org.bouncycastle.jcajce.provider.asymmetric.RSA$Mappings { <init>(); }+-keep class org.bouncycastle.jcajce.provider.asymmetric.X509$Mappings { <init>(); }+-keep class org.bouncycastle.jcajce.provider.asymmetric.rsa.DigestSignatureSpi$SHA256 { <init>(); }+-keep class org.bouncycastle.jcajce.provider.asymmetric.rsa.KeyFactorySpi { <init>(); }+-keep class org.bouncycastle.jcajce.provider.asymmetric.x509.CertificateFactory { <init>(); }-dontwarn org.bouncycastle.**# Kadb itself: pairing reaches Conscrypt and hidden APIs by name. Small enough