Resolve aconfig flag deps for Launcher

Only link in framework-declarared aconfig flags for targets that *don't*
reference platform APIs. Targets that do reference platform APIs will
inherit the framework-defined implementation, avoiding runtime classpath
collisions.

Bug: 352519114
Test: m + presubmit
Flag: EXEMPT refactor
Change-Id: I297a3c7929f41b065cc8b9c00d39dfd6ab831c96
diff --git a/Android.bp b/Android.bp
index 13a926b..626610d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -19,6 +19,17 @@
 
 min_launcher3_sdk_version = "30"
 
+// Targets that don't inherit framework aconfig libs (i.e., those that don't set
+// `platform_apis: true`) must manually link them.
+java_defaults {
+    name: "launcher-non-platform-apis-defaults",
+    static_libs: [
+        "android.os.flags-aconfig-java",
+        "android.appwidget.flags-aconfig-java",
+        "com.android.window.flags.window-aconfig-java",
+    ]
+}
+
 // Common source files used to build launcher (java and kotlin)
 // All sources are split so they can be reused in many other libraries/apps in other folders
 
@@ -141,7 +152,6 @@
     static_libs: [
         "LauncherPluginLib",
         "launcher_quickstep_log_protos_lite",
-        "android.os.flags-aconfig-java",
         "androidx-constraintlayout_constraintlayout",
         "androidx.recyclerview_recyclerview",
         "androidx.dynamicanimation_dynamicanimation",
@@ -163,8 +173,6 @@
         "kotlinx_coroutines",
         "com_android_launcher3_flags_lib",
         "com_android_wm_shell_flags_lib",
-        "android.appwidget.flags-aconfig-java",
-        "com.android.window.flags.window-aconfig-java",
     ],
     manifest: "AndroidManifest-common.xml",
     sdk_version: "current",
@@ -179,6 +187,7 @@
 //
 android_app {
     name: "Launcher3",
+    defaults: ["launcher-non-platform-apis-defaults"],
 
     static_libs: [
         "Launcher3ResLib",