OmniLib: Introduce OmniRom SDK

 * omnilib-res app will be installed to system/frameworks for the futur internal ressources add-on
 * OmniLib java_library will be installed to system/frameworks for the futur internal java/aidl add-on
 * The OmniPreference android_library need to be moved outside system/frameworks  because of some nested dependency breakage

Change-Id: I2b9a7bc7f4aa72052ae6600933eb114d2a481b35

omnilib-res: Add allow-reserved-package-id

Thx to the LineageOS team

https://github.com/LineageOS/android_lineage-sdk/blob/lineage-20.0/Android.bp#L44-L49

Change-Id: I07ba56685981a8735bdef5ea75528ec82dd68318
diff --git a/Android.bp b/Android.bp
index 73fb6b6..470a29a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,25 +1,57 @@
-android_library {
-    name: "OmniLib",
-    defaults: [
-        "SettingsLibDefaults",
-        "SettingsLib-search-defaults",
-    ],
-    srcs: [
-        "src/**/*.java",
-    ],
-    required: [
-        "privapp_whitelist_com.android.settings",
-        "settings-platform-compat-config",
-    ],
-    libs: [
-        "androidx.core_core",
-        "androidx.preference_preference",
-    ],
+android_app {
+    name: "omnirom-res",
+    sdk_version: "core_platform",
+    certificate: "platform",
+    manifest: "AndroidManifest.xml",
+
     resource_dirs: ["res"],
+    export_package_resources: true,
+
+    // Disable dexpreopt and verify_uses_libraries check as the app
+    // contains no Java code to be dexpreopted.
+    enforce_uses_libs: false,
+    dex_preopt: {
+        enabled: false,
+    },
+
+    // Soong special-cases omnirom-res to install this alongside
+    // the libraries at /system/framework/omnirom-res.apk.
+
+    // Generate private symbols into the org.omnirom.omnilib.R class
+    // so they are not accessible to 3rd party apps.
+    aaptflags: [
+        "--private-symbols",
+        "org.omnirom.omnilib",
+
+        // Framework doesn't need versioning since it IS the platform.
+        "--no-auto-version",
+
+        // Allow overlay to add resource
+        "--auto-add-overlay",
+
+        // Tell aapt to create "extending (non-application)" resource IDs,
+        // since these resources will be used by many apps.
+        "--allow-reserved-package-id",
+        // Use id 0x3f (one less than app id).
+        "--package-id",
+        "63",
+    ],
 }
 
-android_library {
-    name: "OmniLibCore",
-    platform_apis: true,
-    srcs: ["core/**/*.java"],
+java_library {
+    name: "OmniLib",
+    installable: true,
+    sdk_version: "core_platform",
+
+    srcs: [
+        "src/**/*.java",
+
+        // For the generated R.java and Manifest.java
+        ":omnirom-res{.aapt.srcjar}",
+    ],
+
+    libs: [
+        "framework",
+        "OmniPreference",
+    ],
 }