Revert "bluetooth: abandon app local certificate"

-----

Revert "fixup! bluetooth: abandon app local certificate"

This reverts commit 8faa68bca758a7a3a8147744a8ff9d01d2f4d70f.

Revert "fixup! bluetooth: abandon app local certificate"

This reverts commit 4ced7fa2e1b9dbcbb6a8ad71cc507611ba08f428.

Revert "fixup! bluetooth: abandon app local certificate"

This reverts commit 5d2632ad83e4566064f3d3fbd6af5b60fa00b71c.

Change-Id: I830ced10f2a954a3fb46737957fa18f24704b0e5

Revert "bluetooth: abandon app local certificate"

This reverts commit 00cecba4b5d276c555cd26dfc5394a9fbfd33b6e.

Change-Id: I78565c429760fa0d1d234c82a2a8e033ae3e1928

-----

Change-Id: Ide9328420d53dfb63eea39432d247d679360ed9d
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
diff --git a/android/BluetoothLegacyMigration/Android.bp b/android/BluetoothLegacyMigration/Android.bp
index 786264e..b755fa0 100644
--- a/android/BluetoothLegacyMigration/Android.bp
+++ b/android/BluetoothLegacyMigration/Android.bp
@@ -9,6 +9,6 @@
     srcs: [ "BluetoothLegacyMigration.kt" ],
 
     // Must match Bluetooth.apk certificate because of sharedUserId
-    certificate: "bluetooth",
+    certificate: ":com.android.bluetooth.certificate",
     platform_apis: true,
 }
diff --git a/android/app/Android.bp b/android/app/Android.bp
index 7c65bf2..2e71dcc 100644
--- a/android/app/Android.bp
+++ b/android/app/Android.bp
@@ -90,7 +90,7 @@
         ":bluetooth-proto-enums-java-gen",
     ],
     aaptflags: [ "--custom-package", "com.android.bluetooth" ],
-    certificate: "bluetooth",
+    certificate: ":com.android.bluetooth.certificate",
 
     jarjar_rules: ":bluetooth-jarjar-rules",
 
@@ -195,3 +195,8 @@
         " --minApiLevel 33",
     out: ["com/android/bluetooth/BluetoothStatsLog.java"],
 }
+
+android_app_certificate {
+    name: "com.android.bluetooth.certificate",
+    certificate: "certs/com.android.bluetooth"
+}
diff --git a/android/app/certs/com.android.bluetooth.pk8 b/android/app/certs/com.android.bluetooth.pk8
new file mode 100644
index 0000000..c6ea434
--- /dev/null
+++ b/android/app/certs/com.android.bluetooth.pk8
Binary files differ
diff --git a/android/app/certs/com.android.bluetooth.x509.pem b/android/app/certs/com.android.bluetooth.x509.pem
new file mode 100644
index 0000000..396d7c9
--- /dev/null
+++ b/android/app/certs/com.android.bluetooth.x509.pem
@@ -0,0 +1,36 @@
+-----BEGIN CERTIFICATE-----
+MIIGOzCCBCOgAwIBAgIUEiZapaWZVSter06CJMf2kHi8PIswDQYJKoZIhvcNAQEL
+BQAwgasxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQH
+DA1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKDAdBbmRyb2lkMRAwDgYDVQQLDAdBbmRy
+b2lkMScwJQYDVQQDDB5jb20uYW5kcm9pZC5ibHVldG9vdGguc2VydmljZXMxIjAg
+BgkqhkiG9w0BCQEWE2FuZHJvaWRAYW5kcm9pZC5jb20wIBcNMjIwMzE1MDAzNjAz
+WhgPNDc2MDAyMDkwMDM2MDNaMIGrMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2Fs
+aWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4GA1UECgwHQW5kcm9p
+ZDEQMA4GA1UECwwHQW5kcm9pZDEnMCUGA1UEAwweY29tLmFuZHJvaWQuYmx1ZXRv
+b3RoLnNlcnZpY2VzMSIwIAYJKoZIhvcNAQkBFhNhbmRyb2lkQGFuZHJvaWQuY29t
+MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsVlq9pozUREGlb8u8Y0A
+fYwPs5OuavNx/EsX03aTjmAXUfSOMAewqzUXDIRjw8UQvOW63utaZ0go9osDPzNf
+VEftmGxW/AUC+HWGaLDQfCYO3ficPPOS7xpEhGZERNbnhvh5qX0NBt6mJygsfpOm
+RPThbi6Ig2Brxh1eqVYqRkTjhNFKD6gCd1PdMmUSF88xEYaZWvTkET89Zh38lLza
+2x/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MWBTbFpxOI929QdcV+X1Lz8A8BZz0faXfZ2Z9usctu
+W2FtZge3tsJ07z7kuhNdbnm2yQVfd0FqiJsapUjlhgcdFVoDWPuqOfWAoG31ble6
+eiNnxfjiCckPWyciIE6lw97nvavGjlUacH5qVG86hOWU7xyBgeQ0PH4e+Nxr50yU
+A0GMxni1gefZFG8qEPdNRuDT1QdqDGh/8Ea11GEUMXdAxk0UzqyAtLDr6MbwK6lV
+mqmeueFdogdjvQ3mXe94
+-----END CERTIFICATE-----
diff --git a/android/app/certs/key.pem b/android/app/certs/key.pem
new file mode 100644
index 0000000..5f7d1bc
--- /dev/null
+++ b/android/app/certs/key.pem
@@ -0,0 +1,52 @@
+-----BEGIN PRIVATE KEY-----
+MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCxWWr2mjNREQaV
+vy7xjQB9jA+zk65q83H8SxfTdpOOYBdR9I4wB7CrNRcMhGPDxRC85bre61pnSCj2
+iwM/M19UR+2YbFb8BQL4dYZosNB8Jg7d+Jw885LvGkSEZkRE1ueG+HmpfQ0G3qYn
+KCx+k6ZE9OFuLoiDYGvGHV6pVipGROOE0UoPqAJ3U90yZRIXzzERhpla9OQRPz1m
+HfyUvNrbH/B81mYJIBW6s3DUp/01B9ixoYfAyyOu9PKEb3dNNhfNEEXMA7ZaUGLD
+pHS1CvxlblcIz1ijoBLQpeJTRlbA5fGEZ2vfys13uP2dm2kXBaY3WSB5v++kR+rR
+iW5r0HK5RGd8lm7YrhNsVqa7KOKEi2trZko60U08N66CAowKS5nPpZTwUKgwSmer
+k/ZqDE04YBrvKdd03N6T3w3dMZfyq18SAK/q/K4zSBqQnoP2czjeewKbUuQH8kDQ
+JpxbJHOWNosvULhLjdrMQ5jI45v3ghOeRkJAa0ffeTHNqbI8shnftUXj6/rJNfJI
+sHM6eF46zm4EgOiFUm4jzfxsuFl/x7mYiueOIrCyYTFeJC+CJ1vC9koLP2fxhPiJ
+SFY/HgVb4Y9yK9my+wQJ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r5DHt3EnQ/8p2n
+lv601GEBY2RUhGaOWmcfWtWKAFJB0SXaen7lTCkL3lnIIv65mxNDdQBXsahg5B/f
+50UCggEALYTJLCNlGo8JcEos/UfJ0wYZoQL8jv2mem/x8P0G/0YLRam4NlNiwJyx
+SP2gSuSiSh8XudlFjAm6/cencriVcvpIXFpEjrqhW99cB1WnLTH/KgNSwrcbwKUe
+TkdUx0nDzpwNlBcxFWZONMM2PIbw1vsHgxmMVJUkWFjalCjspgMPYD3+aQ38Cm4r
+ijMF6HOfo8pPq0GTlNy6mI9YsLPsp3H16YkTTSWjE9R7cIde3H8WmTnVnUTH4K8R
+KjtGoLgVf02wncdxGmWNcvPLfRkin+r9V4fp2b06evB2Gq07vxcDzky3P1Hgyixj
+MGM6YXLym/x1WxR7mOQvAwpSJ093EA==
+-----END PRIVATE KEY-----
diff --git a/apex/Android.bp b/apex/Android.bp
index 87eedb2..2527a73 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -23,7 +23,7 @@
     systemserverclasspath_fragments: ["com.android.btservices-systemserverclasspath-fragment"],
     compat_configs: ["bluetooth-compat-config"],
     key: "com.android.btservices.key",
-    certificate: "bluetooth",
+    certificate: ":com.android.btservices.certificate",
     updatable: false,
     compressible: false,
 }
@@ -58,7 +58,7 @@
         "privapp_allowlist_com.android.bluetooth.xml",
     ],
     key: "com.android.btservices.key",
-    certificate: "bluetooth",
+    certificate: ":com.android.btservices.certificate",
     updatable: false,
     compressible: false,
 }
@@ -69,6 +69,11 @@
     private_key: "com.android.btservices.pem",
 }
 
+android_app_certificate {
+    name: "com.android.btservices.certificate",
+    certificate: "com.android.btservices",
+}
+
 sdk {
     name: "btservices-module-sdk",
     bootclasspath_fragments: ["com.android.btservices-bootclasspath-fragment"],
diff --git a/framework/tests/stress/Android.bp b/framework/tests/stress/Android.bp
index dea516e..f176be0 100644
--- a/framework/tests/stress/Android.bp
+++ b/framework/tests/stress/Android.bp
@@ -28,5 +28,5 @@
     test_suites: [
         "general-tests",
     ],
-    certificate: "bluetooth",
+    certificate: ":com.android.bluetooth.certificate",
 }
diff --git a/service/tests/Android.bp b/service/tests/Android.bp
index 4848480..5225038 100644
--- a/service/tests/Android.bp
+++ b/service/tests/Android.bp
@@ -59,7 +59,7 @@
         "libbluetooth_jni",
     ],
     compile_multilib: "both",
-    certificate: "bluetooth",
+    certificate: ":com.android.bluetooth.certificate",
 
     min_sdk_version: "current",