Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/upstream' into trunk
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/ci.yml
#	.github/workflows/release_update.yml
#	README.md
  • Loading branch information
Goooler committed Dec 7, 2023
2 parents 9e8f912 + f4425d9 commit 96bb04e
Show file tree
Hide file tree
Showing 63 changed files with 12,078 additions and 103 deletions.
45 changes: 45 additions & 0 deletions baseline-profile/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import com.android.build.api.dsl.ManagedVirtualDevice

plugins {
id 'com.android.test'
id 'androidx.baselineprofile'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'app.lawnchair.baseline'

defaultConfig {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

targetProjectPath = ":"

flavorDimensions += ["app", "recents"]
productFlavors {
lawn { dimension = "app" }
withQuickstep { dimension = "recents" }
}

testOptions.managedDevices.devices {
pixel6Api33(ManagedVirtualDevice) {
device = "Pixel 6"
apiLevel = 33
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 += "pixel6Api33"
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'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package app.lawnchair.baseline

import androidx.benchmark.macro.junit4.BaselineProfileRule
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

/**
* This test class generates a basic startup baseline profile for the target package.
*
* We recommend you start with this but add important user flows to the profile to improve their performance.
* Refer to the [baseline profile documentation](https://d.android.com/topic/performance/baselineprofiles)
* for more information.
*
* You can run the generator with the Generate Baseline Profile run configuration,
* or directly with `generateBaselineProfile` Gradle task:
* ```
* ./gradlew :lawnchair:generateReleaseBaselineProfile -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile
* ```
* The run configuration runs the Gradle task and applies filtering to run only the generators.
*
* Check [documentation](https://d.android.com/topic/performance/benchmarking/macrobenchmark-instrumentation-args)
* for more information about available instrumentation arguments.
*
* After you run the generator, you can verify the improvements running the [StartupBenchmarks] benchmark.
*
* When using this class to generate a baseline profile, only API 33+ or rooted API 26+ are supported.
**/
@RunWith(AndroidJUnit4::class)
@LargeTest
class BaselineProfileGenerator {

@get:Rule
val rule = BaselineProfileRule()

@Test
fun generate() {
rule.collect(Constants.PACKAGE_NAME) {
// This block defines the app's critical user journey. Here we are interested in
// optimizing for app startup. But you can also navigate and scroll
// through your most important UI.

// Start default activity for your app
pressHome()
startActivityAndWait()

// TODO Write more interactions to optimize advanced journeys of your app.
// For example:
// 1. Wait until the content is asynchronously loaded
// 2. Scroll the feed content
// 3. Navigate to detail screen

// Check UiAutomator documentation for more information how to interact with the app.
// https://d.android.com/training/testing/other-components/ui-automator
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package app.lawnchair.baseline

object Constants {
val PACKAGE_NAME = "app.lawnchair"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package app.lawnchair.baseline

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

/**
* This test class benchmarks the speed of app startup.
* Run this benchmark to verify how effective a Baseline Profile is.
* It does this by comparing [CompilationMode.None], which represents the app with no Baseline
* Profiles optimizations, and [CompilationMode.Partial], which uses Baseline Profiles.
*
* Run this benchmark to see startup measurements and captured system traces for verifying
* the effectiveness of your Baseline Profiles. You can run it directly from Android
* Studio as an instrumentation test, or run all benchmarks with this Gradle task:
* ```
* ./gradlew :baseline-profile:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=Macrobenchmark
* ```
*
* You should run the benchmarks on a physical device, not an Android emulator, because the
* emulator doesn't represent real world performance and shares system resources with its host.
*
* For more information, see the [Macrobenchmark documentation](https://d.android.com/macrobenchmark#create-macrobenchmark)
* and the [instrumentation arguments documentation](https://d.android.com/topic/performance/benchmarking/macrobenchmark-instrumentation-args).
**/
@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 = Constants.PACKAGE_NAME,
metrics = listOf(StartupTimingMetric()),
compilationMode = compilationMode,
startupMode = StartupMode.COLD,
iterations = 10,
setupBlock = {
pressHome()
},
measureBlock = {
startActivityAndWait()

// TODO Add interactions to wait for when your app is fully drawn.
// The app is fully drawn when Activity.reportFullyDrawn is called.
// For Jetpack Compose, you can use ReportDrawn, ReportDrawnWhen and ReportDrawnAfter
// from the AndroidX Activity library.

// Check the UiAutomator documentation for more information on how to
// interact with the app.
// https://d.android.com/training/testing/other-components/ui-automator
},
)
}
}
23 changes: 14 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id 'com.android.application' version "8.2.0"
id 'com.android.library' version "8.2.0" apply false
id 'org.jetbrains.kotlin.android' version "1.9.20"
id 'org.jetbrains.kotlin.plugin.parcelize' version "1.9.20"
id 'org.jetbrains.kotlin.plugin.serialization' version "1.9.20"
id "com.google.devtools.ksp" version "1.9.20-1.0.14"
id 'com.android.test' version '8.2.0' apply false
id 'androidx.baselineprofile' version '1.2.2'
id 'org.jetbrains.kotlin.android' version "1.9.21"
id 'org.jetbrains.kotlin.plugin.parcelize' version "1.9.21"
id 'org.jetbrains.kotlin.plugin.serialization' version "1.9.21"
id "com.google.devtools.ksp" version "1.9.21-1.0.15"
id 'com.google.protobuf' version "0.9.4"
id 'app.cash.licensee' version "1.8.0"
id 'dev.rikka.tools.refine' version "4.4.0"
id 'org.gradle.android.cache-fix' version '3.0'
id 'com.diffplug.spotless' version '6.23.2'
id 'com.diffplug.spotless' version '6.23.3'
}

allprojects {
Expand Down Expand Up @@ -74,7 +76,7 @@ allprojects {

ext {
FRAMEWORK_PREBUILTS_DIR = "$rootDir/prebuilts/libs"
daggerVersion = '2.48.1'
daggerVersion = '2.49'

addFrameworkJar = { String name ->
def frameworkJar = new File(FRAMEWORK_PREBUILTS_DIR, name)
Expand Down Expand Up @@ -157,7 +159,7 @@ android {
}

composeOptions {
kotlinCompilerExtensionVersion = "1.5.4"
kotlinCompilerExtensionVersion = "1.5.6"
}

final def keystorePropertiesFile = rootProject.file("keystore.properties")
Expand Down Expand Up @@ -361,12 +363,15 @@ dependencies {

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'

implementation 'androidx.profileinstaller:profileinstaller:1.3.1'
baselineProfile projects.baselineProfile

implementation "androidx.dynamicanimation:dynamicanimation:1.0.0"
implementation "androidx.recyclerview:recyclerview:1.3.2"
implementation "androidx.preference:preference-ktx:1.2.1"

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.1'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2'
implementation 'com.github.ChickenHook:RestrictionBypass:2.2'
implementation 'dev.rikka.tools.refine:runtime:4.4.0'

Expand Down Expand Up @@ -433,7 +438,7 @@ ksp {
spotless {
kotlin {
ktlint()
target("lawnchair/src/**/*.kt")
target("lawnchair/src/**/*.kt", "baseline-profile/src/**/*.kt")
}
}

Expand Down
51 changes: 51 additions & 0 deletions lawnchair/res/layout-v30/task_desktop.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<com.android.quickstep.views.DesktopTaskView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="true"
android:clipToOutline="true"
android:defaultFocusHighlightEnabled="false"
android:focusable="true">

<View
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<!--
TODO(b249371338): DesktopTaskView extends from TaskView. TaskView expects TaskThumbnailView
and IconView with these ids to be present. Need to refactor RecentsView to accept child
views that do not inherint from TaskView only or create a generic TaskView that have
N number of tasks.
-->
<com.android.quickstep.views.TaskThumbnailView
android:id="@+id/snapshot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />

<com.android.quickstep.views.IconView
android:id="@+id/icon"
android:layout_width="@dimen/task_thumbnail_icon_size"
android:layout_height="@dimen/task_thumbnail_icon_size"
android:focusable="false"
android:importantForAccessibility="no" />

</com.android.quickstep.views.DesktopTaskView>
1 change: 1 addition & 0 deletions lawnchair/res/values-af-rZA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
<string name="label">Etiket</string>
<string name="hide_from_drawer">Versteek uit App-laai</string>
<string name="suggestion_pref_screen_title">Voorstelle</string>
<string name="show_suggested_apps_at_drawer_top">Show suggested apps at drawer top</string>
<!-- Bug reporting -->
<string name="lawnchair_bug_report">Lawnchair Bug Report</string>
<string name="crash_report_notif_title">%1$s het omgeval</string>
Expand Down
1 change: 1 addition & 0 deletions lawnchair/res/values-am-rET/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
<string name="label">Label</string>
<string name="hide_from_drawer">Hide from App Drawer</string>
<string name="suggestion_pref_screen_title">Suggestions</string>
<string name="show_suggested_apps_at_drawer_top">Show suggested apps at drawer top</string>
<!-- Bug reporting -->
<string name="lawnchair_bug_report">Lawnchair Bug Report</string>
<string name="crash_report_notif_title">%1$s Crashed</string>
Expand Down
1 change: 1 addition & 0 deletions lawnchair/res/values-ar-rSA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@
<string name="label">العلامة</string>
<string name="hide_from_drawer">إخفاء من قائمة التطبيقات</string>
<string name="suggestion_pref_screen_title">اقتراحات</string>
<string name="show_suggested_apps_at_drawer_top">Show suggested apps at drawer top</string>
<!-- Bug reporting -->
<string name="lawnchair_bug_report">تقرير الأخطاء Lawnchair</string>
<string name="crash_report_notif_title">%1$s توقف عن العمل</string>
Expand Down
1 change: 1 addition & 0 deletions lawnchair/res/values-b+sr+Latn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@
<string name="label">Oznaka</string>
<string name="hide_from_drawer">Sakrij sa liste aplikacija</string>
<string name="suggestion_pref_screen_title">Predlozi</string>
<string name="show_suggested_apps_at_drawer_top">Show suggested apps at drawer top</string>
<!-- Bug reporting -->
<string name="lawnchair_bug_report">Izveštaj o grešci u Lawnchairu</string>
<string name="crash_report_notif_title">%1$s je otkazao</string>
Expand Down
1 change: 1 addition & 0 deletions lawnchair/res/values-bn-rBD/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
<string name="label">নাম</string>
<string name="hide_from_drawer">অ্যাপ ড্রয়ার থেকে লুকান</string>
<string name="suggestion_pref_screen_title">পরামর্শ</string>
<string name="show_suggested_apps_at_drawer_top">Show suggested apps at drawer top</string>
<!-- Bug reporting -->
<string name="lawnchair_bug_report">Lawnchair বাগ রিপোর্ট</string>
<string name="crash_report_notif_title">%1$s সমস্যা হয়েছে</string>
Expand Down
3 changes: 2 additions & 1 deletion lawnchair/res/values-ca-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
<!-- SearchProviderPreferences -->
<!-- search_provider -->
<string name="search_provider_app_search">Buscar aplicacions</string>
<string name="search_provider_sponsored_description">%1$s &amp; Lawnchair have a revenue share agreement.\n\nSearching with %1$s helps support Lawnchair.</string>
<string name="search_provider_sponsored_description">%1$s &amp; Lawnchair té un acord de compartir els ingressos.\n\nBuscant amb %1$s ajuda a finançar Lawnchair.</string>
<string name="app_label">Aplicació</string>
<string name="website_label">Lloc web</string>
<string name="qsb_search_provider_app_required">Aplicació necessària.</string>
Expand Down Expand Up @@ -362,6 +362,7 @@
<string name="label">Etiqueta</string>
<string name="hide_from_drawer">Oculta del calaix d\'aplicacions</string>
<string name="suggestion_pref_screen_title">Suggeriments</string>
<string name="show_suggested_apps_at_drawer_top">Mostrar les aplicacions suggerides al calaix de dalt</string>
<!-- Bug reporting -->
<string name="lawnchair_bug_report">Informa un error de Lawnchair</string>
<string name="crash_report_notif_title">%1$s ha deixat de funcionar</string>
Expand Down
1 change: 1 addition & 0 deletions lawnchair/res/values-cs-rCZ/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@
<string name="label">Popisek</string>
<string name="hide_from_drawer">Skrýt v seznamu aplikací</string>
<string name="suggestion_pref_screen_title">Návrhy</string>
<string name="show_suggested_apps_at_drawer_top">Show suggested apps at drawer top</string>
<!-- Bug reporting -->
<string name="lawnchair_bug_report">Hlášení o chybě v Lawnchair</string>
<string name="crash_report_notif_title">%1$s přestal fungovat</string>
Expand Down
1 change: 1 addition & 0 deletions lawnchair/res/values-da-rDK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
<string name="label">Label</string>
<string name="hide_from_drawer">Hide from App Drawer</string>
<string name="suggestion_pref_screen_title">Suggestions</string>
<string name="show_suggested_apps_at_drawer_top">Show suggested apps at drawer top</string>
<!-- Bug reporting -->
<string name="lawnchair_bug_report">Lawnchair Bug Report</string>
<string name="crash_report_notif_title">%1$s Crashed</string>
Expand Down
1 change: 1 addition & 0 deletions lawnchair/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
<string name="label">Titel</string>
<string name="hide_from_drawer">Aus der App-Übersicht ausblenden</string>
<string name="suggestion_pref_screen_title">Vorschläge</string>
<string name="show_suggested_apps_at_drawer_top">Vorschläge oben in der App-Übersicht anzeigen</string>
<!-- Bug reporting -->
<string name="lawnchair_bug_report">Lawnchair-Fehlerbericht</string>
<string name="crash_report_notif_title">%1$s abgestürzt</string>
Expand Down
Loading

0 comments on commit 96bb04e

Please sign in to comment.