Split the source code into an android_library

So that it can be used by both the official app and test targets.

Bug: 319448897
Test: build and local deployment
Change-Id: Ica67332921d5cd481d794b0fdf45c099ab86cd5c
diff --git a/packages/CredentialManager/Android.bp b/packages/CredentialManager/Android.bp
index 991fe41..c292b502 100644
--- a/packages/CredentialManager/Android.bp
+++ b/packages/CredentialManager/Android.bp
@@ -7,19 +7,14 @@
     default_applicable_licenses: ["frameworks_base_license"],
 }
 
-android_app {
-    name: "CredentialManager",
-    defaults: ["platform_app_defaults"],
-    certificate: "platform",
+android_library {
+    name: "CredentialManager-handheld",
+
+    platform_apis: true,
+
     srcs: ["src/**/*.kt"],
     resource_dirs: ["res"],
 
-    dex_preopt: {
-        profile_guided: true,
-        //TODO: b/312357299 - Update baseline profile
-        profile: "profile.txt.prof",
-    },
-
     static_libs: [
         "CredentialManagerShared",
         "PlatformComposeCore",
@@ -42,6 +37,23 @@
         "androidx.recyclerview_recyclerview",
         "kotlinx-coroutines-core",
     ],
+}
+
+android_app {
+    name: "CredentialManager",
+    defaults: ["platform_app_defaults"],
+    certificate: "platform",
+
+    dex_preopt: {
+        profile_guided: true,
+        //TODO: b/312357299 - Update baseline profile
+        profile: "profile.txt.prof",
+    },
+
+    // Do not add new dependencies here. Add to CredentialManager-handheld instead.
+    static_libs: [
+        "CredentialManager-handheld",
+    ],
 
     platform_apis: true,
     privileged: true,