db845c: Switch gralloc to use gralloc.minigbm_msm instead of gralloc_gbm

Instead of carying our own copy of gralloc_gbm, try to utilize
the minigbm gralloc as it implements gralloc4

Change-Id: I628ff76d3ef7cf441b122bc6f2e49f662b0c7ed5
Signed-off-by: John Stultz <john.stultz@linaro.org>
diff --git a/device-common.mk b/device-common.mk
index fa79ab0..718d398 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -46,22 +46,33 @@
 PRODUCT_PACKAGES += \
     android.hardware.drm@1.3-service.clearkey \
     android.hardware.drm@1.3-service.widevine \
-    android.hardware.graphics.allocator@2.0-impl \
-    android.hardware.graphics.allocator@2.0-service \
-    android.hardware.graphics.composer@2.2-impl \
-    android.hardware.graphics.composer@2.2-service \
-    android.hardware.graphics.mapper@2.0-impl-2.1 \
-    gralloc.gbm \
-    hwcomposer.drm \
     libGLES_mesa
 
 PRODUCT_PROPERTY_OVERRIDES += \
-    ro.hardware.gralloc=gbm \
+    ro.hardware.gralloc=minigbm_msm \
     ro.hardware.hwcomposer=drm \
     debug.sf.no_hw_vsync=1 \
     ro.opengles.version=196608 \
     persist.demo.rotationlock=1
 
+
+#
+# Hardware Composer HAL
+#
+PRODUCT_PACKAGES += \
+    hwcomposer.drm \
+    android.hardware.graphics.composer@2.3-impl \
+    android.hardware.graphics.composer@2.3-service
+
+#
+# Gralloc HAL
+#
+PRODUCT_PACKAGES += \
+    gralloc.minigbm_msm \
+    android.hardware.graphics.allocator@4.0-service.minigbm_msm \
+    android.hardware.graphics.mapper@4.0-impl.minigbm_msm
+
+
 # Use Launcher3QuickStep
 PRODUCT_PACKAGES += Launcher3QuickStep
 
diff --git a/manifest.xml b/manifest.xml
index b5587fa..910ec90 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -49,33 +49,15 @@
         </interface>
     </hal>
     <hal format="hidl">
-        <name>android.hardware.graphics.allocator</name>
-        <transport>hwbinder</transport>
-        <version>2.0</version>
-        <interface>
-            <name>IAllocator</name>
-            <instance>default</instance>
-        </interface>
-    </hal>
-    <hal format="hidl">
         <name>android.hardware.graphics.composer</name>
         <transport>hwbinder</transport>
-        <version>2.2</version>
+        <version>2.3</version>
         <interface>
             <name>IComposer</name>
             <instance>default</instance>
         </interface>
     </hal>
     <hal format="hidl">
-        <name>android.hardware.graphics.mapper</name>
-        <transport arch="32+64">passthrough</transport>
-        <version>2.1</version>
-        <interface>
-            <name>IMapper</name>
-            <instance>default</instance>
-        </interface>
-    </hal>
-    <hal format="hidl">
         <name>android.hardware.keymaster</name>
         <transport>hwbinder</transport>
         <version>3.0</version>
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 6f3906d..6bc4965 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -38,6 +38,7 @@
 /system/bin/tinymix									u:object_r:tinymix_exec:s0
 
 /vendor/bin/hw/android\.hardware\.gatekeeper@1\.0-service\.software			u:object_r:hal_gatekeeper_default_exec:s0
+/vendor/bin/hw/android\.hardware\.graphics\.allocator@4\.0-service\.minigbm_msm		u:object_r:hal_graphics_allocator_default_exec:s0
 /vendor/bin/pd-mapper									u:object_r:pd_mapper_exec:s0
 /vendor/bin/qrtr-cfg									u:object_r:qrtr_exec:s0
 /vendor/bin/qrtr-ns									u:object_r:qrtr_exec:s0
@@ -48,8 +49,11 @@
 /vendor/lib(64)?/dri/.*									u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/hw/gralloc\.gbm\.so							u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/hw/android\.hardware\.health@2\.0-impl-2\.1-cuttlefish\.so		u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/hw/gralloc\.minigbm_msm\.so						u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/hw/android\.hardware\.graphics\.mapper@4\.0-impl\.minigbm_msm\.so	u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/libdrm\.so								u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/libdrm_freedreno\.so							u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/libgbm_mesa\.so							u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/libglapi\.so								u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/libminigbm_gralloc_msm\.so						u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/libqrtr\.so								u:object_r:same_process_hal_file:s0
diff --git a/sepolicy/hal_graphics_composer.te b/sepolicy/hal_graphics_composer.te
index 40dbe25..cc45ebf 100644
--- a/sepolicy/hal_graphics_composer.te
+++ b/sepolicy/hal_graphics_composer.te
@@ -1 +1,3 @@
+allow hal_graphics_composer_server hal_graphics_allocator_default_tmpfs:file read;
+
 gpu_access(hal_graphics_composer_server)
diff --git a/sepolicy/hal_graphics_composer_default.te b/sepolicy/hal_graphics_composer_default.te
index 9c310f6..56e03aa 100644
--- a/sepolicy/hal_graphics_composer_default.te
+++ b/sepolicy/hal_graphics_composer_default.te
@@ -1,3 +1,8 @@
+hal_client_domain(hal_graphics_composer_default, hal_graphics_allocator);
 vndbinder_use(hal_graphics_composer_default)
 
 allow hal_graphics_composer_default self:netlink_kobject_uevent_socket { bind create read };
+
+# Suppress warnings for drm_hwcomposer trying to read some vendor.hwc.*
+# properties as dragonboard never configures these properties.
+dontaudit hal_graphics_composer_default default_prop:file read;
diff --git a/sepolicy/te_macros b/sepolicy/te_macros
index 3123f6b..a50bec1 100644
--- a/sepolicy/te_macros
+++ b/sepolicy/te_macros
@@ -4,6 +4,7 @@
 define(`gpu_access', `
 allow $1 dri_device:dir { open read search };
 allow $1 sysfs_gpu:dir search;
+allow $1 gpu_device:chr_file { getattr ioctl map open read write };
+allow $1 graphics_device:chr_file { getattr };
 allow $1 sysfs_gpu:file { getattr open read };
-dontaudit $1 graphics_device:chr_file getattr;
 ')