From 9996936a55dc1b277e7da569eee8cec0438711d3 Mon Sep 17 00:00:00 2001 From: Akash Yadav Date: Fri, 18 Sep 2026 12:48:33 +0000 Subject: [PATCH 1/2] style: spotless reformat, no functional change --- .../androidide/assets/AssetsInstaller.kt | 104 +++++++++--------- 1 file changed, 54 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/com/itsaky/androidide/assets/AssetsInstaller.kt b/app/src/main/java/com/itsaky/androidide/assets/AssetsInstaller.kt index 18c881ffe7..43febf0a99 100644 --- a/app/src/main/java/com/itsaky/androidide/assets/AssetsInstaller.kt +++ b/app/src/main/java/com/itsaky/androidide/assets/AssetsInstaller.kt @@ -10,59 +10,63 @@ import java.nio.file.Path * Helper class to install assets for the IDE. */ sealed interface AssetsInstaller { + companion object { + /** + * Whether to use bundled assets installer or not. If `true`, bundled assets installer will + * be used. + * + * This is `true` for non-debug builds and for `instrumentation` builds. When updating this + * value, please update the corresponding value in `AndroidModuleConf.kt`. + */ + @Suppress("SimplifyBooleanWithConstants", "KotlinConstantConditions") + private val USE_BUNDLED_ASSETS = !BuildConfig.DEBUG || BuildConfig.BUILD_TYPE == "instrumentation" - companion object { + /** + * The current assets installer. + */ + internal val CURRENT_INSTALLER = if (USE_BUNDLED_ASSETS) BundledAssetsInstaller else SplitAssetsInstaller + } - /** - * Whether to use bundled assets installer or not. If `true`, bundled assets installer will - * be used. - * - * This is `true` for non-debug builds and for `instrumentation` builds. When updating this - * value, please update the corresponding value in `AndroidModuleConf.kt`. - */ - @Suppress("SimplifyBooleanWithConstants", "KotlinConstantConditions") - private val USE_BUNDLED_ASSETS = !BuildConfig.DEBUG || BuildConfig.BUILD_TYPE == "instrumentation" + /** + * Called before installing assets. + * + * @param context The application context. + * @param stagingDir The staging directory for the assets. + */ + suspend fun preInstall( + context: Context, + stagingDir: Path, + ) - /** - * The current assets installer. - */ - internal val CURRENT_INSTALLER = if (USE_BUNDLED_ASSETS) BundledAssetsInstaller else SplitAssetsInstaller - } + /** + * Called to install assets. + * + * @param context The application context. + * @param stagingDir The staging directory for the assets. + * @param cpuArch The CPU architecture of the device. + * @param entryName The name of the entry to install. + */ + @WorkerThread + suspend fun doInstall( + context: Context, + stagingDir: Path, + cpuArch: CpuArch, + entryName: String, + ) - /** - * Called before installing assets. - * - * @param context The application context. - * @param stagingDir The staging directory for the assets. - */ - suspend fun preInstall(context: Context, stagingDir: Path) + /** + * Called after installing assets. + */ + suspend fun postInstall( + context: Context, + stagingDir: Path, + ) - /** - * Called to install assets. - * - * @param context The application context. - * @param stagingDir The staging directory for the assets. - * @param cpuArch The CPU architecture of the device. - * @param entryName The name of the entry to install. - */ - @WorkerThread - suspend fun doInstall( - context: Context, - stagingDir: Path, - cpuArch: CpuArch, - entryName: String, - ) - - /** - * Called after installing assets. - */ - suspend fun postInstall(context: Context, stagingDir: Path) - - /** - * Returns the expected size (in bytes) of the given entry. - * - * @param entryName The name of the entry whose size is requested. - * @return The expected size in bytes, or 0 if unknown. - */ - fun expectedSize(entryName: String): Long + /** + * Returns the expected size (in bytes) of the given entry. + * + * @param entryName The name of the entry whose size is requested. + * @return The expected size in bytes, or 0 if unknown. + */ + fun expectedSize(entryName: String): Long } From ba10a6e1abd34c0b38534222bad90b30c0c267a4 Mon Sep 17 00:00:00 2001 From: Akash Yadav Date: Fri, 18 Sep 2026 12:50:32 +0000 Subject: [PATCH 2/2] ADFA-6151: Add a profileable build variant for on-device memory profiling --- app/build.gradle.kts | 10 ++++++++++ .../com/itsaky/androidide/assets/AssetsInstaller.kt | 7 ++++++- .../androidide/plugins/conf/AndroidModuleConf.kt | 8 +++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 7aca06befa..ae1826fb1e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -89,6 +89,13 @@ android { release { manifestPlaceholders["sentryDsn"] = glitchtipDsn } + create("profileable") { + initWith(getByName("release")) + isProfileable = true + matchingFallbacks += "release" + manifestPlaceholders["sentryDsn"] = glitchtipDsn + signingConfig = signingConfigs.getByName("debug") + } } testOptions { @@ -118,6 +125,9 @@ android { getByName("androidTest") { manifest.srcFile("src/androidTest/AndroidManifest.xml") } + getByName("profileable") { + java.srcDir("src/release/java") + } } lint { diff --git a/app/src/main/java/com/itsaky/androidide/assets/AssetsInstaller.kt b/app/src/main/java/com/itsaky/androidide/assets/AssetsInstaller.kt index 43febf0a99..422cb543cd 100644 --- a/app/src/main/java/com/itsaky/androidide/assets/AssetsInstaller.kt +++ b/app/src/main/java/com/itsaky/androidide/assets/AssetsInstaller.kt @@ -19,7 +19,12 @@ sealed interface AssetsInstaller { * value, please update the corresponding value in `AndroidModuleConf.kt`. */ @Suppress("SimplifyBooleanWithConstants", "KotlinConstantConditions") - private val USE_BUNDLED_ASSETS = !BuildConfig.DEBUG || BuildConfig.BUILD_TYPE == "instrumentation" + private val USE_BUNDLED_ASSETS = + when (BuildConfig.BUILD_TYPE) { + "instrumentation" -> true + "profileable" -> false + else -> !BuildConfig.DEBUG + } /** * The current assets installer. diff --git a/composite-builds/build-logic/plugins/src/main/java/com/itsaky/androidide/plugins/conf/AndroidModuleConf.kt b/composite-builds/build-logic/plugins/src/main/java/com/itsaky/androidide/plugins/conf/AndroidModuleConf.kt index f354555e43..0cbb8e3e2a 100644 --- a/composite-builds/build-logic/plugins/src/main/java/com/itsaky/androidide/plugins/conf/AndroidModuleConf.kt +++ b/composite-builds/build-logic/plugins/src/main/java/com/itsaky/androidide/plugins/conf/AndroidModuleConf.kt @@ -54,6 +54,7 @@ private val disableCoreLibDesugaringForModules = * The name of the build type used for automated testing. */ private const val INSTRUMENTATION_BUILD_TYPE = "instrumentation" +private const val PROFILEABLE_BUILD_TYPE = "profileable" /** * Whether the given variant has bundled assets or not. @@ -61,7 +62,12 @@ private const val INSTRUMENTATION_BUILD_TYPE = "instrumentation" * This is `true` for non-debug builds and for [INSTRUMENTATION_BUILD_TYPE] builds. When updating this * value, please update the corresponding value in `AssetsInstaller.kt` in `:app` module. */ -internal fun hasBundledAssets(variant: Variant): Boolean = !variant.debuggable || variant.buildType == INSTRUMENTATION_BUILD_TYPE +internal fun hasBundledAssets(variant: Variant): Boolean = + when (variant.buildType) { + INSTRUMENTATION_BUILD_TYPE -> true + PROFILEABLE_BUILD_TYPE -> false + else -> !variant.debuggable + } fun Project.configureAndroidModule(coreLibDesugDep: Provider) { var isAppModule = plugins.hasPlugin("com.android.application")