From 57b33e9142d5351eb60aa3f7f3c9e3ac60f817a9 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Sat, 16 Sep 2023 23:48:00 -0400 Subject: [PATCH 1/6] android: Remove benchmark module --- Source/Android/benchmark/.gitignore | 1 - Source/Android/benchmark/build.gradle | 71 ------------------- .../benchmark/src/main/AndroidManifest.xml | 6 -- .../benchmark/BaselineProfileGenerator.kt | 43 ----------- .../com/dolphin/benchmark/StartupBenchmark.kt | 40 ----------- 5 files changed, 161 deletions(-) delete mode 100644 Source/Android/benchmark/.gitignore delete mode 100644 Source/Android/benchmark/build.gradle delete mode 100644 Source/Android/benchmark/src/main/AndroidManifest.xml delete mode 100644 Source/Android/benchmark/src/main/java/com/dolphin/benchmark/BaselineProfileGenerator.kt delete mode 100644 Source/Android/benchmark/src/main/java/com/dolphin/benchmark/StartupBenchmark.kt diff --git a/Source/Android/benchmark/.gitignore b/Source/Android/benchmark/.gitignore deleted file mode 100644 index 796b96d1c4..0000000000 --- a/Source/Android/benchmark/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/Source/Android/benchmark/build.gradle b/Source/Android/benchmark/build.gradle deleted file mode 100644 index 13a94f5621..0000000000 --- a/Source/Android/benchmark/build.gradle +++ /dev/null @@ -1,71 +0,0 @@ -import com.android.build.api.dsl.ManagedVirtualDevice - -plugins { - id 'com.android.test' - id 'org.jetbrains.kotlin.android' -} - -android { - namespace 'com.dolphin.benchmark' - compileSdk 33 - - compileOptions { - sourceCompatibility = "11" - targetCompatibility = "11" - } - - kotlinOptions { - jvmTarget = "11" - } - - defaultConfig { - minSdk 23 - targetSdk 33 - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - testOptions { - managedDevices { - devices { - pixel6Api31 (ManagedVirtualDevice) { - device = "Pixel 6" - apiLevel = 31 - systemImageSource = "aosp" - } - } - } - } - - buildTypes { - // This benchmark buildType is used for benchmarking, and should function like your - // release build (for example, with minification on). It's signed with a debug key - // for easy local/CI testing. - benchmark { - signingConfig signingConfigs.debug - matchingFallbacks = ['release'] - debuggable true - proguardFiles getDefaultProguardFile( - 'proguard-android-optimize.txt'), - 'proguard-rules.pro' - minifyEnabled true - shrinkResources true - } - } - - targetProjectPath = ":app" - experimentalProperties["android.experimental.self-instrumenting"] = true -} - -dependencies { - implementation 'androidx.test.ext:junit:1.1.5' - implementation 'androidx.test.espresso:espresso-core:3.5.1' - implementation 'androidx.test.uiautomator:uiautomator:2.2.0' - implementation 'androidx.benchmark:benchmark-macro-junit4:1.1.1' -} - -androidComponents { - beforeVariants(selector().all()) { - enabled = buildType == "benchmark" - } -} diff --git a/Source/Android/benchmark/src/main/AndroidManifest.xml b/Source/Android/benchmark/src/main/AndroidManifest.xml deleted file mode 100644 index 8f83f3238c..0000000000 --- a/Source/Android/benchmark/src/main/AndroidManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/BaselineProfileGenerator.kt b/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/BaselineProfileGenerator.kt deleted file mode 100644 index 366a22ab6a..0000000000 --- a/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/BaselineProfileGenerator.kt +++ /dev/null @@ -1,43 +0,0 @@ -package com.dolphin.benchmark - -import androidx.benchmark.macro.ExperimentalBaselineProfilesApi -import androidx.benchmark.macro.junit4.BaselineProfileRule -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner -import androidx.test.uiautomator.UiSelector -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@OptIn(ExperimentalBaselineProfilesApi::class) -@RunWith(AndroidJUnit4ClassRunner::class) -class BaselineProfileGenerator { - - @get:Rule - val rule = BaselineProfileRule() - - @Test - fun generate() = rule.collectBaselineProfile( - packageName = "org.dolphinemu.dolphinemu.benchmark", - profileBlock = { - pressHome() - startActivityAndWait() - - // Dismiss analytics dialog due to issue with finding button - device.pressBack() - - // Navigate through activities that don't require games - // TODO: Make all activities testable without having games available - // TODO: Use resource strings to support more languages - - // Navigate to the Settings Activity - val settings = device.findObject(UiSelector().description("Settings")) - settings.clickAndWaitForNewWindow(30_000) - - // Go through settings and to the User Data Activity - val config = device.findObject(UiSelector().textContains("Config")) - config.click() - val userData = device.findObject(UiSelector().textContains("User Data")) - userData.clickAndWaitForNewWindow(30_000) - }, - ) -} diff --git a/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/StartupBenchmark.kt b/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/StartupBenchmark.kt deleted file mode 100644 index 5ae5d40f6b..0000000000 --- a/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/StartupBenchmark.kt +++ /dev/null @@ -1,40 +0,0 @@ -package com.dolphin.benchmark - -import androidx.benchmark.macro.BaselineProfileMode -import androidx.benchmark.macro.CompilationMode -import androidx.benchmark.macro.StartupMode -import androidx.benchmark.macro.StartupTimingMetric -import androidx.benchmark.macro.junit4.MacrobenchmarkRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -class StartupBenchmark { - @get:Rule - val benchmarkRule = MacrobenchmarkRule() - - @Test - fun startupBaselineProfileDisabled() = startup( - CompilationMode.Partial(baselineProfileMode = BaselineProfileMode.Disable, warmupIterations = 1) - ) - - @Test - fun startupBaselineProfile() = startup( - CompilationMode.Partial(baselineProfileMode = BaselineProfileMode.Require, warmupIterations = 1) - ) - - private fun startup(compilationMode: CompilationMode) = benchmarkRule.measureRepeated( - packageName = "org.dolphinemu.dolphinemu.benchmark", - metrics = listOf(StartupTimingMetric()), - iterations = 10, - compilationMode = compilationMode, - startupMode = StartupMode.COLD, - setupBlock = { - pressHome() - } - ) { - startActivityAndWait() - } -} From 001089dbf4a81febfd58c02b540e393616916283 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Sat, 16 Sep 2023 23:49:22 -0400 Subject: [PATCH 2/6] android: Convert gradle files to kotlin gradle dsl --- Source/Android/app/build.gradle | 221 ------------------ Source/Android/app/build.gradle.kts | 216 +++++++++++++++++ Source/Android/build.gradle | 6 - Source/Android/build.gradle.kts | 12 + .../{settings.gradle => settings.gradle.kts} | 6 +- 5 files changed, 232 insertions(+), 229 deletions(-) delete mode 100644 Source/Android/app/build.gradle create mode 100644 Source/Android/app/build.gradle.kts delete mode 100644 Source/Android/build.gradle create mode 100644 Source/Android/build.gradle.kts rename Source/Android/{settings.gradle => settings.gradle.kts} (85%) diff --git a/Source/Android/app/build.gradle b/Source/Android/app/build.gradle deleted file mode 100644 index eeb7b31a95..0000000000 --- a/Source/Android/app/build.gradle +++ /dev/null @@ -1,221 +0,0 @@ -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' - id 'org.jetbrains.kotlin.plugin.serialization' version "1.8.21" -} - -task copyProfile (type: Copy) { - description('Copies a generated baseline profile text file from managed device to src/main in the app module.') - from(project(':benchmark').file('build/outputs/managed_device_android_test_additional_output/pixel6Api31')) - into('src/main') - include('BaselineProfileGenerator_generate-baseline-prof.txt') - rename('BaselineProfileGenerator_generate-baseline-prof', 'baseline-prof') -} - -android { - compileSdkVersion 33 - ndkVersion "25.2.9519653" - - viewBinding.enabled = true - - compileOptions { - // Flag to enable support for the new language APIs - coreLibraryDesugaringEnabled true - - sourceCompatibility = "17" - targetCompatibility = "17" - } - - kotlinOptions { - jvmTarget = '17' - } - - lint { - // This is important as it will run lint but not abort on error - // Lint has some overly obnoxious "errors" that should really be warnings - abortOnError false - - //Uncomment disable lines for test builds... - //disable 'MissingTranslation' - //disable 'ExtraTranslation' - } - - defaultConfig { - applicationId "org.dolphinemu.dolphinemu" - minSdkVersion 21 - targetSdkVersion 33 - - versionCode(getBuildVersionCode()) - - versionName "${getVersion()}" - - buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\"" - buildConfigField "String", "BRANCH", "\"${getBranch()}\"" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - signingConfigs { - release { - if (project.hasProperty('keystore')) { - storeFile file(project.property('keystore')) - storePassword project.property('storepass') - keyAlias project.property('keyalias') - keyPassword project.property('keypass') - } - } - } - - // Define build types, which are orthogonal to product flavors. - buildTypes { - // Signed by release key, allowing for upload to Play Store. - release { - if (project.hasProperty('keystore')) { - signingConfig signingConfigs.release - } - - resValue 'string', 'app_name_suffixed', 'Dolphin Emulator' - minifyEnabled true - shrinkResources true - proguardFiles getDefaultProguardFile( - 'proguard-android-optimize.txt'), - 'proguard-rules.pro' - - preBuild.dependsOn copyProfile - } - - // Signed by debug key disallowing distribution on Play Store. - // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build. - debug { - resValue 'string', 'app_name_suffixed', 'Dolphin Debug' - applicationIdSuffix ".debug" - versionNameSuffix '-debug' - jniDebuggable true - } - - benchmark { - resValue 'string', 'app_name_suffixed', 'Dolphin Benchmark' - signingConfig signingConfigs.debug - matchingFallbacks = ['release'] - debuggable false - applicationIdSuffix ".benchmark" - versionNameSuffix '-benchmark' - proguardFiles getDefaultProguardFile( - 'proguard-android-optimize.txt'), - 'proguard-rules.pro' - minifyEnabled true - shrinkResources true - } - } - - externalNativeBuild { - cmake { - path "../../../CMakeLists.txt" - version "3.22.1+" - } - } - namespace 'org.dolphinemu.dolphinemu' - - defaultConfig { - externalNativeBuild { - cmake { - arguments "-DANDROID_STL=c++_static", "-DCMAKE_BUILD_TYPE=RelWithDebInfo" - // , "-DENABLE_GENERIC=ON" - abiFilters "arm64-v8a", "x86_64" //, "armeabi-v7a", "x86" - - // Remove the line below if you want to build the C++ unit tests - //targets "main", "hook_impl", "main_hook", "gsl_alloc_hook", "file_redirect_hook" - } - } - } - - packagingOptions { - jniLibs.useLegacyPackaging = true - } -} - -dependencies { - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3' - - implementation 'androidx.core:core-ktx:1.10.1' - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.exifinterface:exifinterface:1.3.6' - implementation 'androidx.cardview:cardview:1.0.0' - implementation 'androidx.recyclerview:recyclerview:1.3.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.lifecycle:lifecycle-viewmodel:2.6.1' - implementation 'androidx.fragment:fragment:1.6.0' - implementation 'androidx.slidingpanelayout:slidingpanelayout:1.2.0' - implementation 'com.google.android.material:material:1.9.0' - implementation 'androidx.core:core-splashscreen:1.0.1' - implementation 'androidx.preference:preference:1.2.0' - implementation 'androidx.profileinstaller:profileinstaller:1.3.1' - - // Kotlin extensions for lifecycle components - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' - implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1' - - // Android TV UI libraries. - implementation 'androidx.leanback:leanback:1.0.0' - implementation 'androidx.tvprovider:tvprovider:1.0.0' - - // For REST calls - implementation 'com.android.volley:volley:1.2.1' - - // For loading game covers from disk and GameTDB - implementation 'io.coil-kt:coil:2.2.2' - - // For loading custom GPU drivers - implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1" - - implementation 'com.nononsenseapps:filepicker:4.2.1' -} - -def getVersion() { - def versionNumber = '0.0' - - try { - versionNumber = 'git describe --always --long'.execute([], project.rootDir).text - .trim() - .replaceAll(/(-0)?-[^-]+$/, "") - } catch (Exception e) { - logger.error(e + ': Cannot find git, defaulting to dummy version number') - } - - return versionNumber -} - -def getBuildVersionCode() { - try { - def versionNumber = 'git rev-list --first-parent --count HEAD'.execute([], project.rootDir).text - .trim() - return Integer.valueOf(versionNumber) - } catch (Exception e) { - logger.error(e + ': Cannot find git, defaulting to dummy version number') - } - - return 1 -} - -def getGitHash() { - try { - def gitHash = 'git rev-parse HEAD'.execute([], project.rootDir).text.trim() - return gitHash - } catch (Exception e) { - logger.error(e + ': Cannot find git, defaulting to dummy build hash') - } - - return 0 -} - -def getBranch() { - try { - def branch = 'git rev-parse --abbrev-ref HEAD'.execute([], project.rootDir).text.trim() - return branch - } catch (Exception e) { - logger.error(e + ': Cannot find git, defaulting to dummy build hash') - } - - return 'master' -} diff --git a/Source/Android/app/build.gradle.kts b/Source/Android/app/build.gradle.kts new file mode 100644 index 0000000000..86f2afe47d --- /dev/null +++ b/Source/Android/app/build.gradle.kts @@ -0,0 +1,216 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") + kotlin("plugin.serialization") version "1.8.21" +} + +@Suppress("UnstableApiUsage") +android { + compileSdkVersion = "android-33" + ndkVersion = "25.2.9519653" + + buildFeatures { + viewBinding = true + } + + compileOptions { + // Flag to enable support for the new language APIs + isCoreLibraryDesugaringEnabled = true + + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = "17" + } + + lint { + // This is important as it will run lint but not abort on error + // Lint has some overly obnoxious "errors" that should really be warnings + abortOnError = false + + //Uncomment disable lines for test builds... + //disable "MissingTranslation" + //disable "ExtraTranslation" + } + + defaultConfig { + applicationId = "org.dolphinemu.dolphinemu" + minSdk = 21 + targetSdk = 33 + + versionCode = getBuildVersionCode() + + versionName = getGitVersion() + + buildConfigField("String", "GIT_HASH", "\"${getGitHash()}\"") + buildConfigField("String", "BRANCH", "\"${getBranch()}\"") + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + signingConfigs { + create("release") { + if (project.hasProperty("keystore")) { + storeFile = file(project.property("keystore")!!) + storePassword = project.property("storepass").toString() + keyAlias = project.property("keyalias").toString() + keyPassword = project.property("keypass").toString() + } + } + } + + // Define build types, which are orthogonal to product flavors. + buildTypes { + // Signed by release key, allowing for upload to Play Store. + release { + if (project.hasProperty("keystore")) { + signingConfig = signingConfigs.getByName("release") + } + + resValue("string", "app_name_suffixed", "Dolphin Emulator") + isMinifyEnabled = true + isShrinkResources = true + proguardFiles( + getDefaultProguardFile("proguard-android.txt"), + "proguard-rules.pro" + ) + } + + // Signed by debug key disallowing distribution on Play Store. + // Attaches "debug" suffix to version and package name, allowing installation alongside the release build. + debug { + resValue("string", "app_name_suffixed", "Dolphin Debug") + applicationIdSuffix = ".debug" + versionNameSuffix = "-debug" + isJniDebuggable = true + } + } + + externalNativeBuild { + cmake { + path = file("../../../CMakeLists.txt") + version = "3.22.1+" + } + } + namespace = "org.dolphinemu.dolphinemu" + + defaultConfig { + externalNativeBuild { + cmake { + arguments("-DANDROID_STL=c++_static", "-DCMAKE_BUILD_TYPE=RelWithDebInfo") + // , "-DENABLE_GENERIC=ON" + abiFilters("arm64-v8a", "x86_64") //, "armeabi-v7a", "x86" + + // Remove the line below if you want to build the C++ unit tests + //targets "main", "hook_impl", "main_hook", "gsl_alloc_hook", "file_redirect_hook" + } + } + } + + packaging { + jniLibs.useLegacyPackaging = true + } +} + +dependencies { + coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3") + + implementation("androidx.core:core-ktx:1.10.1") + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("androidx.exifinterface:exifinterface:1.3.6") + implementation("androidx.cardview:cardview:1.0.0") + implementation("androidx.recyclerview:recyclerview:1.3.0") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + implementation("androidx.lifecycle:lifecycle-viewmodel:2.6.1") + implementation("androidx.fragment:fragment:1.6.0") + implementation("androidx.slidingpanelayout:slidingpanelayout:1.2.0") + implementation("com.google.android.material:material:1.9.0") + implementation("androidx.core:core-splashscreen:1.0.1") + implementation("androidx.preference:preference:1.2.0") + implementation("androidx.profileinstaller:profileinstaller:1.3.1") + + // Kotlin extensions for lifecycle components + implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1") + implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1") + + // Android TV UI libraries. + implementation("androidx.leanback:leanback:1.0.0") + implementation("androidx.tvprovider:tvprovider:1.0.0") + + // For REST calls + implementation("com.android.volley:volley:1.2.1") + + // For loading game covers from disk and GameTDB + implementation("io.coil-kt:coil:2.2.2") + + // For loading custom GPU drivers + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1") + + implementation("com.nononsenseapps:filepicker:4.2.1") +} + +fun getGitVersion(): String { + try { + return ProcessBuilder("git", "describe", "--always", "--long") + .directory(project.rootDir) + .redirectOutput(ProcessBuilder.Redirect.PIPE) + .redirectError(ProcessBuilder.Redirect.PIPE) + .start().inputStream.bufferedReader().use { it.readText() } + .trim() + .replace(Regex("(-0)?-[^-]+$"), "") + } catch (e: Exception) { + logger.error("Cannot find git, defaulting to dummy version number") + } + + return "0.0" +} + +fun getBuildVersionCode(): Int { + try { + return Integer.valueOf( + ProcessBuilder("git", "rev-list", "--first-parent", "--count", "HEAD") + .directory(project.rootDir) + .redirectOutput(ProcessBuilder.Redirect.PIPE) + .redirectError(ProcessBuilder.Redirect.PIPE) + .start().inputStream.bufferedReader().use { it.readText() } + .trim() + ) + } catch (e: Exception) { + logger.error("Cannot find git, defaulting to dummy version code") + } + + return 1 +} + +fun getGitHash(): String { + try { + return ProcessBuilder("git", "rev-parse", "HEAD") + .directory(project.rootDir) + .redirectOutput(ProcessBuilder.Redirect.PIPE) + .redirectError(ProcessBuilder.Redirect.PIPE) + .start().inputStream.bufferedReader().use { it.readText() } + .trim() + } catch (e: Exception) { + logger.error("Cannot find git, defaulting to dummy git hash") + } + + return "0" +} + +fun getBranch(): String { + try { + return ProcessBuilder("git", "rev-parse", "--abbrev-ref", "HEAD") + .directory(project.rootDir) + .redirectOutput(ProcessBuilder.Redirect.PIPE) + .redirectError(ProcessBuilder.Redirect.PIPE) + .start().inputStream.bufferedReader().use { it.readText() } + .trim() + } catch (e: Exception) { + logger.error("Cannot find git, defaulting to dummy git hash") + } + + return "master" +} diff --git a/Source/Android/build.gradle b/Source/Android/build.gradle deleted file mode 100644 index e8343673c7..0000000000 --- a/Source/Android/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -plugins { - id 'com.android.application' version '8.0.2' apply false - id 'com.android.library' version '8.0.2' apply false - id 'org.jetbrains.kotlin.android' version '1.8.21' apply false -} diff --git a/Source/Android/build.gradle.kts b/Source/Android/build.gradle.kts new file mode 100644 index 0000000000..5a40522457 --- /dev/null +++ b/Source/Android/build.gradle.kts @@ -0,0 +1,12 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + id("com.android.application") version "8.0.2" apply false + id("com.android.library") version "8.0.2" apply false + id("org.jetbrains.kotlin.android") version "1.8.21" apply false +} + +buildscript { + repositories { + google() + } +} diff --git a/Source/Android/settings.gradle b/Source/Android/settings.gradle.kts similarity index 85% rename from Source/Android/settings.gradle rename to Source/Android/settings.gradle.kts index 698c7c15b2..1fb82df416 100644 --- a/Source/Android/settings.gradle +++ b/Source/Android/settings.gradle.kts @@ -5,6 +5,8 @@ pluginManagement { mavenCentral() } } + +@Suppress("UnstableApiUsage") dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { @@ -12,5 +14,5 @@ dependencyResolutionManagement { mavenCentral() } } -include ':app' -include ':benchmark' + +include(":app") From 7d4db6603b5b2969d49771ff8ef2b83e9a933846 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Sat, 16 Sep 2023 23:50:23 -0400 Subject: [PATCH 3/6] android: Update AGP to 8.2.0 Also updates gradle to 8.2 as that is the minimum required version for AGP 8.2.0 --- Source/Android/build.gradle.kts | 4 ++-- Source/Android/gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Android/build.gradle.kts b/Source/Android/build.gradle.kts index 5a40522457..1ecafb96f1 100644 --- a/Source/Android/build.gradle.kts +++ b/Source/Android/build.gradle.kts @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.0.2" apply false - id("com.android.library") version "8.0.2" apply false + id("com.android.application") version "8.2.0" apply false + id("com.android.library") version "8.2.0" apply false id("org.jetbrains.kotlin.android") version "1.8.21" apply false } diff --git a/Source/Android/gradle/wrapper/gradle-wrapper.properties b/Source/Android/gradle/wrapper/gradle-wrapper.properties index cfe4843ea4..03c675731f 100644 --- a/Source/Android/gradle/wrapper/gradle-wrapper.properties +++ b/Source/Android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Dec 08 14:08:30 EST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From c5d81c100683836608ee42b74a878a890fe9c099 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Mon, 18 Sep 2023 15:49:57 -0400 Subject: [PATCH 4/6] android: Regenerate baseline profile module for AGP 8.2.0 --- Source/Android/.gitignore | 3 +- Source/Android/app/build.gradle.kts | 2 + Source/Android/benchmark/.gitignore | 1 + Source/Android/benchmark/build.gradle.kts | 52 +++++++++++++++++++ .../benchmark/src/main/AndroidManifest.xml | 1 + .../BaselineProfileGenerator.kt | 44 ++++++++++++++++ .../baselineprofile/StartupBenchmarks.kt | 46 ++++++++++++++++ Source/Android/build.gradle.kts | 2 + Source/Android/settings.gradle.kts | 1 + 9 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 Source/Android/benchmark/.gitignore create mode 100644 Source/Android/benchmark/build.gradle.kts create mode 100644 Source/Android/benchmark/src/main/AndroidManifest.xml create mode 100644 Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/BaselineProfileGenerator.kt create mode 100644 Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/StartupBenchmarks.kt diff --git a/Source/Android/.gitignore b/Source/Android/.gitignore index 3fbf1ea2ff..2cef59b3ec 100644 --- a/Source/Android/.gitignore +++ b/Source/Android/.gitignore @@ -39,4 +39,5 @@ tasks.xml build/ *.so *.iml -build.properties \ No newline at end of file +build.properties +baseline-prof.txt diff --git a/Source/Android/app/build.gradle.kts b/Source/Android/app/build.gradle.kts index 86f2afe47d..f5b281690f 100644 --- a/Source/Android/app/build.gradle.kts +++ b/Source/Android/app/build.gradle.kts @@ -2,6 +2,7 @@ plugins { id("com.android.application") id("org.jetbrains.kotlin.android") kotlin("plugin.serialization") version "1.8.21" + id("androidx.baselineprofile") } @Suppress("UnstableApiUsage") @@ -115,6 +116,7 @@ android { } dependencies { + "baselineProfile"(project(":benchmark")) coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3") implementation("androidx.core:core-ktx:1.10.1") diff --git a/Source/Android/benchmark/.gitignore b/Source/Android/benchmark/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/Source/Android/benchmark/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/Source/Android/benchmark/build.gradle.kts b/Source/Android/benchmark/build.gradle.kts new file mode 100644 index 0000000000..0065dadb0f --- /dev/null +++ b/Source/Android/benchmark/build.gradle.kts @@ -0,0 +1,52 @@ +import com.android.build.api.dsl.ManagedVirtualDevice + +plugins { + id("com.android.test") + id("org.jetbrains.kotlin.android") + id("androidx.baselineprofile") +} + +android { + namespace = "org.dolphinemu.baselineprofile" + compileSdk = 34 + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = "17" + } + + defaultConfig { + minSdk = 28 + targetSdk = 34 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + targetProjectPath = ":app" + + testOptions.managedDevices.devices { + create("pixel6Api31") { + device = "Pixel 6" + apiLevel = 31 + systemImageSource = "google" + } + } +} + +// This is the configuration block for the Baseline Profile plugin. +// You can specify to run the generators on a managed devices or connected devices. +baselineProfile { + managedDevices += "pixel6Api31" + useConnectedDevices = false +} + +dependencies { + implementation("androidx.test.ext:junit:1.1.5") + implementation("androidx.test.espresso:espresso-core:3.5.1") + implementation("androidx.test.uiautomator:uiautomator:2.2.0") + implementation("androidx.benchmark:benchmark-macro-junit4:1.2.2") +} diff --git a/Source/Android/benchmark/src/main/AndroidManifest.xml b/Source/Android/benchmark/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..cc947c5679 --- /dev/null +++ b/Source/Android/benchmark/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/BaselineProfileGenerator.kt b/Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/BaselineProfileGenerator.kt new file mode 100644 index 0000000000..9bf621d6c1 --- /dev/null +++ b/Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/BaselineProfileGenerator.kt @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.baselineprofile + +import androidx.benchmark.macro.junit4.BaselineProfileRule +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.LargeTest +import androidx.test.uiautomator.UiSelector +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +@LargeTest +class BaselineProfileGenerator { + + @get:Rule + val rule = BaselineProfileRule() + + @Test + fun generate() { + rule.collect("org.dolphinemu.dolphinemu") { + pressHome() + startActivityAndWait() + + // Dismiss analytics dialog due to issue with finding button + device.pressBack() + + // Navigate through activities that don't require games + // TODO: Make all activities testable without having games available (or use homebrew) + // TODO: Use resource strings to support more languages + + // Navigate to the Settings Activity + val settings = device.findObject(UiSelector().description("Settings")) + settings.clickAndWaitForNewWindow(30_000) + + // Go through settings and to the User Data Activity + val config = device.findObject(UiSelector().textContains("Config")) + config.click() + val userData = device.findObject(UiSelector().textContains("User Data")) + userData.clickAndWaitForNewWindow(30_000) + } + } +} diff --git a/Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/StartupBenchmarks.kt b/Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/StartupBenchmarks.kt new file mode 100644 index 0000000000..359a3df584 --- /dev/null +++ b/Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/StartupBenchmarks.kt @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.baselineprofile + +import androidx.benchmark.macro.BaselineProfileMode +import androidx.benchmark.macro.CompilationMode +import androidx.benchmark.macro.StartupMode +import androidx.benchmark.macro.StartupTimingMetric +import androidx.benchmark.macro.junit4.MacrobenchmarkRule +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.LargeTest +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +@LargeTest +class StartupBenchmarks { + + @get:Rule + val rule = MacrobenchmarkRule() + + @Test + fun startupCompilationNone() = + benchmark(CompilationMode.None()) + + @Test + fun startupCompilationBaselineProfiles() = + benchmark(CompilationMode.Partial(BaselineProfileMode.Require)) + + private fun benchmark(compilationMode: CompilationMode) { + rule.measureRepeated( + packageName = "org.dolphinemu.dolphinemu", + metrics = listOf(StartupTimingMetric()), + compilationMode = compilationMode, + startupMode = StartupMode.COLD, + iterations = 10, + setupBlock = { + pressHome() + }, + measureBlock = { + startActivityAndWait() + } + ) + } +} diff --git a/Source/Android/build.gradle.kts b/Source/Android/build.gradle.kts index 1ecafb96f1..730a0b458e 100644 --- a/Source/Android/build.gradle.kts +++ b/Source/Android/build.gradle.kts @@ -3,6 +3,8 @@ plugins { id("com.android.application") version "8.2.0" apply false id("com.android.library") version "8.2.0" apply false id("org.jetbrains.kotlin.android") version "1.8.21" apply false + id("com.android.test") version "8.2.0" apply false + id("androidx.baselineprofile") version "1.2.0" apply false } buildscript { diff --git a/Source/Android/settings.gradle.kts b/Source/Android/settings.gradle.kts index 1fb82df416..1a68f74a48 100644 --- a/Source/Android/settings.gradle.kts +++ b/Source/Android/settings.gradle.kts @@ -16,3 +16,4 @@ dependencyResolutionManagement { } include(":app") +include(":benchmark") From 5d2e3de57679e4559da164989dbd8505944f90b7 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Mon, 18 Sep 2023 15:56:28 -0400 Subject: [PATCH 5/6] android Update dependencies --- Source/Android/app/build.gradle.kts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Source/Android/app/build.gradle.kts b/Source/Android/app/build.gradle.kts index f5b281690f..0330eb7322 100644 --- a/Source/Android/app/build.gradle.kts +++ b/Source/Android/app/build.gradle.kts @@ -117,26 +117,25 @@ android { dependencies { "baselineProfile"(project(":benchmark")) - coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3") + coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4") - implementation("androidx.core:core-ktx:1.10.1") + implementation("androidx.core:core-ktx:1.12.0") implementation("androidx.appcompat:appcompat:1.6.1") implementation("androidx.exifinterface:exifinterface:1.3.6") implementation("androidx.cardview:cardview:1.0.0") - implementation("androidx.recyclerview:recyclerview:1.3.0") + implementation("androidx.recyclerview:recyclerview:1.3.2") implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("androidx.lifecycle:lifecycle-viewmodel:2.6.1") - implementation("androidx.fragment:fragment:1.6.0") + implementation("androidx.fragment:fragment-ktx:1.6.2") implementation("androidx.slidingpanelayout:slidingpanelayout:1.2.0") - implementation("com.google.android.material:material:1.9.0") + implementation("com.google.android.material:material:1.10.0") implementation("androidx.core:core-splashscreen:1.0.1") - implementation("androidx.preference:preference:1.2.0") + implementation("androidx.preference:preference-ktx:1.2.1") implementation("androidx.profileinstaller:profileinstaller:1.3.1") // Kotlin extensions for lifecycle components - implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1") - implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1") + implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2") + implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.2") // Android TV UI libraries. implementation("androidx.leanback:leanback:1.0.0") @@ -146,7 +145,7 @@ dependencies { implementation("com.android.volley:volley:1.2.1") // For loading game covers from disk and GameTDB - implementation("io.coil-kt:coil:2.2.2") + implementation("io.coil-kt:coil:2.5.0") // For loading custom GPU drivers implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1") From 93a5df3b9229490e782c3c290be133c81877b5b3 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Mon, 18 Sep 2023 16:04:44 -0400 Subject: [PATCH 6/6] android: Compile and target Android 14 --- Source/Android/app/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Android/app/build.gradle.kts b/Source/Android/app/build.gradle.kts index 0330eb7322..0e436b55b9 100644 --- a/Source/Android/app/build.gradle.kts +++ b/Source/Android/app/build.gradle.kts @@ -7,7 +7,7 @@ plugins { @Suppress("UnstableApiUsage") android { - compileSdkVersion = "android-33" + compileSdkVersion = "android-34" ndkVersion = "25.2.9519653" buildFeatures { @@ -39,7 +39,7 @@ android { defaultConfig { applicationId = "org.dolphinemu.dolphinemu" minSdk = 21 - targetSdk = 33 + targetSdk = 34 versionCode = getBuildVersionCode()