ThemePickerLeaf: Update for U QPR3

Change-Id: Iadbdb4a5d82b555a2a4a15b800c8fda8bd31a068
diff --git a/Android.bp b/Android.bp
index e76c94c..417fe8e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -15,60 +15,42 @@
  */
 
 filegroup {
-    name: "ThemePickerLeaf_srcs",
-    srcs: [
-        "src/**/*.java",
-        "src/**/*.kt",
-    ],
+    name: "ThemePickerLeaf_src_prod",
+    srcs: ["src_override/com/android/customization/picker/CustomizationPickerApplication.java"],
 }
 
-filegroup {
-    name: "ThemePickerLeaf_src_overrides",
+java_library {
+    name: "ThemePickerLeafOverridesLib",
     srcs: [
         "src_override/**/*.java",
         "src_override/**/*.kt",
     ],
-}
-
-filegroup {
-    name: "ThemePickerLeaf_Manifest",
-    srcs: [
-        "AndroidManifest.xml",
+    exclude_srcs: [":ThemePickerLeaf_src_prod"],
+    libs: [
+        "hilt_android",
+        "ThemePickerLeafLib",
     ],
 }
 
-genrule {
-    name: "ThemePickerLeaf_res",
-    tools: ["soong_zip"],
-    srcs: [
-        "res/**/*",
+java_library {
+    name: "ThemePickerLeafApplicationLib",
+    srcs: [":ThemePickerLeaf_src_prod"],
+    libs: [
+        "hilt_android",
+        "ThemePickerLeafLib",
+        "ThemePickerOverridesLib",
     ],
-    out: ["ThemePickerLeaf_res.zip"],
-    cmd: "INPUTS=($(in)) && "
-        + "RES_DIR=$$(dirname $$(dirname $${INPUTS[0]})) && "
-        + "$(location soong_zip) -o $(out) -C $$RES_DIR -D $$RES_DIR"
 }
 
-genrule {
-    name: "ThemePickerLeaf_res_overrides",
-    tools: ["soong_zip"],
-    srcs: [
-        "res_override/**/*",
-    ],
-    out: ["ThemePickerLeaf_res_overrides.zip"],
-    cmd: "INPUTS=($(in)) && "
-        + "RES_DIR=$$(dirname $$(dirname $${INPUTS[0]})) && "
-        + "$(location soong_zip) -o $(out) -C $$RES_DIR -D $$RES_DIR"
-}
-
-java_defaults {
-    name: "ThemePickerLeaf_defaults",
+android_library {
+    name: "ThemePickerLeafLib",
 
     static_libs: [
         "guava",
         "monet",
         "renderscript_toolkit",
-        "wallpaper-common-deps",
+        "WallpaperPicker2Lib",
+        "ThemePickerLib",
         "SettingsLibSettingsTheme",
         "SystemUI-statsd",
         "styleprotoslite",
@@ -80,27 +62,39 @@
         "hilt_android",
     ],
 
+    srcs: [
+        "src/**/*.java",
+        "src/**/*.kt",
+    ],
+
+    resource_dirs: [
+        "res",
+        "res_override",
+    ],
+
+    manifest: "AndroidManifest-empty.xml",
+}
+
+java_defaults {
+    name: "ThemePickerLeaf_defaults",
+
+    static_libs: [
+        "hilt_android",
+        "ThemePickerLeafLib",
+        "ThemePickerLeafOverridesLib",
+    ],
+
     jni_libs: [
         "librenderscript-toolkit",
     ],
 
-    srcs: [
-        ":WallpaperPicker2_srcs",
-        ":ThemePicker_srcs",
-        ":ThemePickerLeaf_srcs",
-        ":ThemePickerLeaf_src_overrides",
+    required: [
+        "android.software.theme_picker.xml",
+        "default_permissions_com.android.wallpaper.xml",
     ],
 
     use_embedded_native_libs: true,
 
-    resource_zips: [
-        ":WallpaperPicker2_res",
-        ":ThemePicker_res",
-        ":ThemePicker_res_overrides",
-        ":ThemePickerLeaf_res",
-        ":ThemePickerLeaf_res_overrides",
-    ],
-
     optimize: {
         enabled: false,
     },
@@ -111,41 +105,35 @@
     system_ext_specific: true,
 }
 
+prebuilt_etc_xml {
+    name: "default_permissions_com.android.wallpaper.xml",
+    src: "default_permissions_com.android.wallpaper.xml",
+    system_ext_specific: true,
+    filename_from_src: true,
+    sub_dir: "default-permissions",
+}
+
+//
+// Build app code.
+//
 android_app {
     name: "ThemePickerLeaf",
+    package_name: "com.android.wallpaper",
     defaults: ["ThemePickerLeaf_defaults"],
 
     platform_apis: true,
-    manifest: ":ThemePickerLeaf_Manifest",
+    manifest: "AndroidManifest.xml",
     additional_manifests: [
         ":ThemePicker_Manifest",
         ":WallpaperPicker2_Manifest",
     ],
-
-    required: [
-        "privapp_whitelist_com.android.wallpaper.xml",
-        "default_permissions_com.android.wallpaper.xml",
-    ],
     overrides: [
         "ThemePicker",
         "WallpaperCropper",
         "WallpaperPicker",
         "WallpaperPicker2",
     ],
-}
-
-prebuilt_etc_xml {
-    name: "privapp_whitelist_com.android.wallpaper.xml",
-    src: "privapp_whitelist_com.android.wallpaper.xml",
-    system_ext_specific: true,
-    filename_from_src: true,
-    sub_dir: "permissions",
-}
-
-prebuilt_etc_xml {
-    name: "default_permissions_com.android.wallpaper.xml",
-    src: "default_permissions_com.android.wallpaper.xml",
-    system_ext_specific: true,
-    filename_from_src: true,
-    sub_dir: "default-permissions",
+    static_libs: [
+        "ThemePickerLeafApplicationLib",
+    ],
 }
diff --git a/AndroidManifest-empty.xml b/AndroidManifest-empty.xml
new file mode 100644
index 0000000..e2b3605
--- /dev/null
+++ b/AndroidManifest-empty.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          xmlns:tools="http://schemas.android.com/tools"
+          package="com.android.themepicker">
+</manifest>
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index bbcd1af..9400295 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -16,7 +16,6 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     package="com.android.wallpaper">
-    <uses-permission android:name="android.permission.BIND_WALLPAPER" />
     <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
 
     <queries>
diff --git a/privapp_whitelist_com.android.wallpaper.xml b/privapp_whitelist_com.android.wallpaper.xml
deleted file mode 100644
index 79439a3..0000000
--- a/privapp_whitelist_com.android.wallpaper.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2019 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
-  -->
-<permissions>
-    <privapp-permissions package="com.android.wallpaper">
-        <permission name="android.permission.SET_WALLPAPER_COMPONENT"/>
-        <permission name="android.permission.BIND_WALLPAPER"/>
-        <permission name="android.permission.MODIFY_DAY_NIGHT_MODE"/>
-        <permission name="android.permission.CHANGE_OVERLAY_PACKAGES"/>
-        <permission name="android.permission.WRITE_SECURE_SETTINGS" />
-        <permission name="android.permission.READ_WALLPAPER_INTERNAL"/>
-    </privapp-permissions>
-</permissions>
diff --git a/src/org/leafos/customization/module/LeafThemePickerInjector.java b/src/org/leafos/customization/module/LeafThemePickerInjector.java
index 2d4a63a..1584a6f 100644
--- a/src/org/leafos/customization/module/LeafThemePickerInjector.java
+++ b/src/org/leafos/customization/module/LeafThemePickerInjector.java
@@ -22,7 +22,6 @@
 import com.android.customization.model.theme.ThemeBundleProvider;
 import com.android.customization.model.theme.ThemeManager;
 import com.android.customization.module.ThemePickerInjector;
-import com.android.customization.module.logging.ThemesUserEventLogger;
 import com.android.wallpaper.module.CustomizationSections;
 import com.android.wallpaper.picker.di.modules.BackgroundDispatcher;
 import com.android.wallpaper.picker.di.modules.MainDispatcher;
@@ -39,9 +38,9 @@
     @Inject
     public LeafThemePickerInjector(@MainDispatcher CoroutineScope mainScope,
             @MainDispatcher CoroutineDispatcher mainDispatcher,
-            @BackgroundDispatcher CoroutineDispatcher bgDispatcher,
-            ThemesUserEventLogger userEventLogger) {
-        super(mainScope, mainDispatcher, bgDispatcher, userEventLogger);
+            @BackgroundDispatcher CoroutineScope bgScope,
+            @BackgroundDispatcher CoroutineDispatcher bgDispatcher) {
+        super(mainScope, mainDispatcher, bgScope, bgDispatcher);
     }
 
     @Override