1// Copyright (C) 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package {
16    // See: http://go/android-license-faq
17    default_applicable_licenses: ["Android-Apache-2.0"],
18}
19
20min_launcher3_sdk_version = "31"
21
22// Targets that don't inherit framework aconfig libs (i.e., those that don't set
23// `platform_apis: true`) must manually link them.
24java_defaults {
25    name: "launcher-non-platform-apis-defaults",
26    static_libs: [
27        "android.os.flags-aconfig-java",
28        "android.appwidget.flags-aconfig-java",
29        "com.android.window.flags.window-aconfig-java",
30    ],
31}
32
33// Common source files used to build launcher (java and kotlin)
34// All sources are split so they can be reused in many other libraries/apps in other folders
35
36// Main Launcher source, excluding the build config
37filegroup {
38    name: "launcher-src",
39    srcs: [
40        "src/**/*.java",
41        "src/**/*.kt",
42    ],
43}
44
45// Main Launcher source for compose, excluding the build config
46filegroup {
47    name: "launcher-compose-enabled-src",
48    srcs: [
49        "compose/facade/enabled/*.kt",
50        "compose/facade/core/*.kt",
51        "compose/features/**/*.kt",
52    ],
53}
54
55filegroup {
56    name: "launcher-compose-disabled-src",
57    srcs: [
58        "compose/facade/core/*.kt",
59        "compose/facade/disabled/*.kt",
60    ],
61}
62
63// Source code for quickstep build, on top of launcher-src
64filegroup {
65    name: "launcher-quickstep-src",
66    srcs: [
67        "quickstep/src/**/*.kt",
68        "quickstep/src/**/*.java",
69    ],
70    device_common_srcs: [
71        ":launcher-quickstep-processed-protolog-src",
72    ],
73}
74
75// Launcher ProtoLog support
76filegroup {
77    name: "launcher-quickstep-unprocessed-protolog-src",
78    srcs: [
79        "quickstep/src_protolog/**/*.java",
80    ],
81}
82
83java_library {
84    name: "launcher-quickstep_protolog-groups",
85    srcs: [
86        "quickstep/src_protolog/**/*.java",
87    ],
88    static_libs: [
89        "protolog-group",
90        "androidx.annotation_annotation",
91        "com_android_launcher3_flags_lib",
92    ],
93}
94
95java_genrule {
96    name: "launcher-quickstep-processed-protolog-src",
97    srcs: [
98        ":protolog-impl",
99        ":launcher-quickstep-unprocessed-protolog-src",
100        ":launcher-quickstep_protolog-groups",
101    ],
102    tools: ["protologtool"],
103    cmd: "$(location protologtool) transform-protolog-calls " +
104        "--protolog-class com.android.internal.protolog.common.ProtoLog " +
105        "--loggroups-class com.android.quickstep.util.QuickstepProtoLogGroup " +
106        "--loggroups-jar $(location :launcher-quickstep_protolog-groups) " +
107        "--viewer-config-file-path /system_ext/etc/launcher.quickstep.protolog.pb " +
108        "--output-srcjar $(out) " +
109        "$(locations :launcher-quickstep-unprocessed-protolog-src)",
110    out: ["launcher.quickstep.protolog.srcjar"],
111}
112
113java_genrule {
114    name: "gen-launcher.quickstep.protolog.pb",
115    srcs: [
116        ":launcher-quickstep-unprocessed-protolog-src",
117        ":launcher-quickstep_protolog-groups",
118    ],
119    tools: ["protologtool"],
120    cmd: "$(location protologtool) generate-viewer-config " +
121        "--protolog-class com.android.internal.protolog.common.ProtoLog " +
122        "--loggroups-class com.android.quickstep.util.QuickstepProtoLogGroup " +
123        "--loggroups-jar $(location :launcher-quickstep_protolog-groups) " +
124        "--viewer-config-type proto " +
125        "--viewer-config $(out) " +
126        "$(locations :launcher-quickstep-unprocessed-protolog-src)",
127    out: ["launcher.quickstep.protolog.pb"],
128}
129
130prebuilt_etc {
131    name: "launcher.quickstep.protolog.pb",
132    system_ext_specific: true,
133    src: ":gen-launcher.quickstep.protolog.pb",
134    filename_from_src: true,
135}
136
137// Source code for quickstep dagger
138filegroup {
139    name: "launcher-quickstep-dagger",
140    srcs: [
141        "quickstep/dagger/**/*.java",
142        "quickstep/dagger/**/*.kt",
143    ],
144}
145
146// Source code for quickstep build with compose enabled, on top of launcher-src
147filegroup {
148    name: "launcher-quickstep-compose-enabled-src",
149    srcs: [
150        "quickstep/compose/facade/core/*.kt",
151        "quickstep/compose/facade/enabled/*.kt",
152        "quickstep/compose/features/**/*.kt",
153    ],
154}
155
156filegroup {
157    name: "launcher-quickstep-compose-disabled-src",
158    srcs: [
159        "quickstep/compose/facade/core/*.kt",
160        "quickstep/compose/facade/disabled/*.kt",
161    ],
162}
163
164// Alternate source when quickstep is not included
165filegroup {
166    name: "launcher-src_no_quickstep",
167    srcs: [
168        "src_no_quickstep/**/*.java",
169        "src_no_quickstep/**/*.kt",
170    ],
171}
172
173// Default build config for Launcher3
174filegroup {
175    name: "launcher-build-config",
176    srcs: [
177        "src_build_config/**/*.java",
178    ],
179}
180
181// Proguard files for Launcher3
182filegroup {
183    name: "launcher-proguard-rules",
184    srcs: ["proguard.flags"],
185}
186
187// Opt-in configuration for Launcher3 code depending on Jetpack Compose.
188soong_config_module_type {
189    name: "launcher_compose_java_defaults",
190    module_type: "java_defaults",
191    config_namespace: "ANDROID",
192    bool_variables: ["release_enable_compose_in_launcher"],
193    properties: [
194        "srcs",
195        "static_libs",
196    ],
197}
198
199// Opt-in configuration for Launcher Quickstep code depending on Jetpack Compose.
200soong_config_bool_variable {
201    name: "release_enable_compose_in_launcher",
202}
203
204soong_config_module_type {
205    name: "quickstep_compose_java_defaults",
206    module_type: "java_defaults",
207    config_namespace: "ANDROID",
208    bool_variables: ["release_enable_compose_in_launcher"],
209    properties: [
210        "srcs",
211        "static_libs",
212    ],
213}
214
215soong_config_module_type {
216    name: "launcher_compose_tests_java_defaults",
217    module_type: "java_defaults",
218    config_namespace: "ANDROID",
219    bool_variables: ["release_enable_compose_in_launcher"],
220    properties: [
221        "static_libs",
222    ],
223}
224
225launcher_compose_java_defaults {
226    name: "launcher_compose_defaults",
227    soong_config_variables: {
228        release_enable_compose_in_launcher: {
229            srcs: [
230                ":launcher-compose-enabled-src",
231            ],
232
233            // Compose dependencies
234            static_libs: [
235                "androidx.compose.runtime_runtime",
236                "androidx.compose.material3_material3",
237            ],
238
239            // By default, Compose is disabled and we compile the ComposeFacade
240            // in compose/launcher3/facade/disabled/.
241            conditions_default: {
242                srcs: [
243                    ":launcher-compose-disabled-src",
244                ],
245                static_libs: [],
246            },
247        },
248    },
249}
250
251quickstep_compose_java_defaults {
252    name: "quickstep_compose_defaults",
253    soong_config_variables: {
254        release_enable_compose_in_launcher: {
255            srcs: [
256                ":launcher-quickstep-compose-enabled-src",
257            ],
258
259            // Compose dependencies
260            static_libs: [
261                "androidx.compose.runtime_runtime",
262                "androidx.compose.material3_material3",
263            ],
264
265            // By default, Compose is disabled and we compile the ComposeFacade
266            // in compose/quickstep/facade/disabled/.
267            conditions_default: {
268                srcs: [
269                    ":launcher-quickstep-compose-disabled-src",
270                ],
271                static_libs: [],
272            },
273        },
274    },
275}
276
277launcher_compose_tests_java_defaults {
278    name: "launcher_compose_tests_defaults",
279    soong_config_variables: {
280        release_enable_compose_in_launcher: {
281            // Compose dependencies
282            static_libs: [
283                "androidx.compose.runtime_runtime",
284                "androidx.compose.ui_ui-test-junit4",
285                "androidx.compose.ui_ui-test-manifest",
286            ],
287
288            conditions_default: {
289                static_libs: [],
290            },
291        },
292    },
293}
294
295android_library {
296    name: "launcher-aosp-tapl",
297    libs: [
298        "framework-statsd.stubs.module_lib",
299    ],
300    static_libs: [
301        "androidx.annotation_annotation",
302        "androidx.test.runner",
303        "androidx.test.rules",
304        "androidx.test.uiautomator_uiautomator",
305        "androidx.preference_preference",
306        "SystemUISharedLib",
307        "//frameworks/libs/systemui:animationlib",
308        "//frameworks/libs/systemui:contextualeducationlib",
309        "launcher-testing-shared",
310    ],
311    srcs: [
312        "tests/tapl/**/*.java",
313        "tests/tapl/**/*.kt",
314    ],
315    resource_dirs: [],
316    manifest: "tests/tapl/AndroidManifest.xml",
317    platform_apis: true,
318}
319
320java_library_static {
321    name: "launcher_log_protos_lite",
322    srcs: [
323        "protos/*.proto",
324        "protos_overrides/*.proto",
325    ],
326    sdk_version: "current",
327    proto: {
328        type: "lite",
329        local_include_dirs: [
330            "protos",
331            "protos_overrides",
332        ],
333    },
334    static_libs: ["libprotobuf-java-lite"],
335}
336
337java_library_static {
338    name: "launcher_quickstep_log_protos_lite",
339    srcs: [
340        "quickstep/protos_overrides/*.proto",
341    ],
342    sdk_version: "current",
343    proto: {
344        type: "lite",
345        local_include_dirs: [
346            "quickstep/protos_overrides",
347        ],
348    },
349    static_libs: [
350        "libprotobuf-java-lite",
351        "launcher_log_protos_lite",
352    ],
353}
354
355java_library {
356    name: "LauncherPluginLib",
357
358    static_libs: ["PluginCoreLib"],
359
360    srcs: ["src_plugins/**/*.java"],
361
362    sdk_version: "current",
363    min_sdk_version: min_launcher3_sdk_version,
364}
365
366// Library with all the dependencies for building Launcher3
367android_library {
368    name: "Launcher3ResLib",
369    defaults: [
370        "launcher_compose_defaults",
371    ],
372    srcs: [],
373    resource_dirs: ["res"],
374    static_libs: [
375        "LauncherPluginLib",
376        "launcher_quickstep_log_protos_lite",
377        "androidx-constraintlayout_constraintlayout",
378        "androidx.recyclerview_recyclerview",
379        "androidx.dynamicanimation_dynamicanimation",
380        "androidx.fragment_fragment",
381        "androidx.preference_preference",
382        "androidx.slice_slice-view",
383        "androidx.cardview_cardview",
384        "androidx.window_window",
385        "com.google.android.material_material",
386        "//frameworks/libs/systemui:iconloader_base",
387        "//frameworks/libs/systemui:view_capture",
388        "//frameworks/libs/systemui:animationlib",
389        "//frameworks/libs/systemui:contextualeducationlib",
390        "//frameworks/libs/systemui:msdl",
391        "SystemUI-statsd",
392        "launcher-testing-shared",
393        "androidx.lifecycle_lifecycle-common-java8",
394        "androidx.lifecycle_lifecycle-extensions",
395        "androidx.lifecycle_lifecycle-runtime-ktx",
396        "kotlinx_coroutines_android",
397        "kotlinx_coroutines",
398        "com_android_launcher3_flags_lib",
399        "com_android_wm_shell_flags_lib",
400        "dagger2",
401        "jsr330",
402        "com_android_systemui_shared_flags_lib",
403    ],
404    manifest: "AndroidManifest-common.xml",
405    sdk_version: "current",
406    min_sdk_version: min_launcher3_sdk_version,
407    lint: {
408        baseline_filename: "lint-baseline.xml",
409    },
410}
411
412//
413// Build rule for Launcher3 app.
414//
415android_app {
416    name: "Launcher3",
417    defaults: ["launcher-non-platform-apis-defaults"],
418
419    static_libs: [
420        "Launcher3ResLib",
421    ],
422    srcs: [
423        ":launcher-src",
424        ":launcher-src_no_quickstep",
425        ":launcher-build-config",
426    ],
427
428    optimize: {
429        proguard_flags_files: [":launcher-proguard-rules"],
430        // Proguard is disable for testing. Derivarive prjects to keep proguard enabled
431        enabled: false,
432    },
433
434    sdk_version: "current",
435    min_sdk_version: min_launcher3_sdk_version,
436    target_sdk_version: "current",
437    plugins: ["dagger2-compiler"],
438    privileged: true,
439    system_ext_specific: true,
440
441    overrides: [
442        "Home",
443        "Launcher2",
444    ],
445    required: ["privapp_whitelist_com.android.launcher3"],
446
447    jacoco: {
448        include_filter: ["com.android.launcher3.**"],
449    },
450    additional_manifests: [
451        "AndroidManifest-common.xml",
452    ],
453    lint: {
454        baseline_filename: "lint-baseline.xml",
455    },
456}
457
458// Library with all the dependencies for building quickstep
459android_library {
460    name: "QuickstepResLib",
461    srcs: [],
462    resource_dirs: [
463        "quickstep/res",
464    ],
465    libs: [
466        "framework-statsd.stubs.module_lib",
467    ],
468    static_libs: [
469        "Launcher3ResLib",
470        "lottie",
471        "SystemUISharedLib",
472        "SettingsLibSettingsTheme",
473        "dagger2",
474        "protolog-group",
475    ],
476    manifest: "quickstep/AndroidManifest.xml",
477    min_sdk_version: "current",
478}
479
480// Library with all the source code and dependencies for building Launcher Go
481android_library {
482    name: "Launcher3GoLib",
483    defaults: [
484        "launcher_compose_defaults",
485        "quickstep_compose_defaults",
486    ],
487    srcs: [
488        ":launcher-src",
489        ":launcher-quickstep-src",
490        ":launcher-quickstep-dagger",
491        "go/quickstep/src/**/*.java",
492        "go/quickstep/src/**/*.kt",
493    ],
494    resource_dirs: [
495        "go/quickstep/res",
496    ],
497    // Note the ordering here is important when it comes to resource
498    // overriding. We want the most specific resource overrides defined
499    // in QuickstepResLib to take precendece, so it should be the final
500    // dependency. See b/205278434 for how this can go wrong.
501    static_libs: [
502        "QuickstepResLib",
503        "androidx.room_room-runtime",
504    ],
505    plugins: [
506        "androidx.room_room-compiler-plugin",
507        "dagger2-compiler",
508    ],
509    manifest: "quickstep/AndroidManifest.xml",
510    additional_manifests: [
511        "go/AndroidManifest.xml",
512        "AndroidManifest-common.xml",
513    ],
514    min_sdk_version: "current",
515    // TODO(b/319712088): re-enable use_resource_processor
516    use_resource_processor: false,
517}
518
519// Library with all the source code and dependencies for building Quickstep
520android_library {
521    name: "Launcher3QuickStepLib",
522    defaults: [
523        "launcher_compose_defaults",
524        "quickstep_compose_defaults",
525    ],
526    srcs: [
527        ":launcher-src",
528        ":launcher-quickstep-src",
529        ":launcher-quickstep-dagger",
530        ":launcher-build-config",
531    ],
532    resource_dirs: [],
533    libs: [
534        "framework-statsd.stubs.module_lib",
535    ],
536    // Note the ordering here is important when it comes to resource
537    // overriding. We want the most specific resource overrides defined
538    // in QuickstepResLib to take precendece, so it should be the final
539    // dependency. See b/208647810 for how this can go wrong.
540    static_libs: [
541        "SystemUI-statsd",
542        "QuickstepResLib",
543    ],
544    manifest: "quickstep/AndroidManifest.xml",
545    platform_apis: true,
546    plugins: ["dagger2-compiler"],
547    min_sdk_version: "current",
548    // TODO(b/319712088): re-enable use_resource_processor
549    use_resource_processor: false,
550}
551
552// Build rule for Quickstep app.
553android_app {
554    name: "Launcher3QuickStep",
555    static_libs: ["Launcher3QuickStepLib"],
556    optimize: {
557        proguard_flags_files: [":launcher-proguard-rules"],
558        enabled: true,
559        shrink_resources: true,
560    },
561
562    platform_apis: true,
563    min_sdk_version: "current",
564    target_sdk_version: "current",
565
566    privileged: true,
567    system_ext_specific: true,
568    overrides: [
569        "Home",
570        "Launcher2",
571        "Launcher3",
572    ],
573    required: [
574        "privapp_whitelist_com.android.launcher3",
575        "launcher.quickstep.protolog.pb",
576    ],
577
578    resource_dirs: ["quickstep/res"],
579
580    additional_manifests: [
581        "quickstep/AndroidManifest-launcher.xml",
582        "AndroidManifest-common.xml",
583    ],
584
585    manifest: "quickstep/AndroidManifest.xml",
586    jacoco: {
587        include_filter: ["com.android.launcher3.*"],
588    },
589
590}
591
592// Build rule for Launcher3 Go app with quickstep for Android Go devices.
593// Note that the following two rules are exactly same, and should
594// eventually be merged into a single target
595android_app {
596    name: "Launcher3Go",
597    static_libs: ["Launcher3GoLib"],
598    resource_dirs: [],
599
600    platform_apis: true,
601    min_sdk_version: "current",
602    target_sdk_version: "current",
603
604    optimize: {
605        proguard_flags_files: ["proguard.flags"],
606        enabled: true,
607        shrink_resources: true,
608    },
609
610    privileged: true,
611    system_ext_specific: true,
612    overrides: [
613        "Home",
614        "Launcher2",
615        "Launcher3",
616        "Launcher3QuickStep",
617    ],
618    required: ["privapp_whitelist_com.android.launcher3"],
619
620    additional_manifests: [
621        "go/AndroidManifest.xml",
622        "go/AndroidManifest-launcher.xml",
623        "AndroidManifest-common.xml",
624    ],
625
626    manifest: "quickstep/AndroidManifest.xml",
627    jacoco: {
628        include_filter: ["com.android.launcher3.*"],
629    },
630}
631
632android_app {
633    name: "Launcher3QuickStepGo",
634    static_libs: ["Launcher3GoLib"],
635    resource_dirs: [],
636
637    platform_apis: true,
638    min_sdk_version: "current",
639    target_sdk_version: "current",
640
641    optimize: {
642        proguard_flags_files: ["proguard.flags"],
643        enabled: true,
644        shrink_resources: true,
645    },
646
647    privileged: true,
648    system_ext_specific: true,
649    overrides: [
650        "Home",
651        "Launcher2",
652        "Launcher3",
653        "Launcher3QuickStep",
654    ],
655    required: ["privapp_whitelist_com.android.launcher3"],
656
657    additional_manifests: [
658        "go/AndroidManifest.xml",
659        "go/AndroidManifest-launcher.xml",
660        "AndroidManifest-common.xml",
661    ],
662
663    manifest: "quickstep/AndroidManifest.xml",
664    jacoco: {
665        include_filter: ["com.android.launcher3.*"],
666    },
667}
668