gralloc: Read debug properties in allocator process

This change resolves selinux denials caused by system processes
reading vendor debug properties via gralloc. The debug properties
are read and parsed in the allocator process, then propagated
through the BufferManager

CRs-Fixed: 2619084
Change-Id: I5175a7848cdcd2671bd16ee11721066a921f3d79
diff --git a/gralloc/QtiAllocator.cpp b/gralloc/QtiAllocator.cpp
index 529889f..1a04237 100644
--- a/gralloc/QtiAllocator.cpp
+++ b/gralloc/QtiAllocator.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -30,6 +30,7 @@
 #define DEBUG 0
 #include "QtiAllocator.h"
 
+#include <cutils/properties.h>
 #include <log/log.h>
 #include <vendor/qti/hardware/display/mapper/3.0/IQtiMapper.h>
 #include <vendor/qti/hardware/display/mapper/4.0/IQtiMapper.h>
@@ -40,6 +41,26 @@
 #include "QtiMapper4.h"
 #include "gr_utils.h"
 
+static void get_properties(gralloc::GrallocProperties *props) {
+  char property[PROPERTY_VALUE_MAX];
+  property_get("vendor.gralloc.use_system_heap_for_sensors", property, "1");
+  if (!(strncmp(property, "0", PROPERTY_VALUE_MAX))) {
+    props->use_system_heap_for_sensors = false;
+  }
+
+  property_get("vendor.gralloc.disable_ubwc", property, "0");
+  if (!(strncmp(property, "1", PROPERTY_VALUE_MAX)) ||
+      !(strncmp(property, "true", PROPERTY_VALUE_MAX))) {
+    props->ubwc_disable = true;
+  }
+
+  property_get("vendor.gralloc.disable_ahardware_buffer", property, "0");
+  if (!(strncmp(property, "1", PROPERTY_VALUE_MAX)) ||
+      !(strncmp(property, "true", PROPERTY_VALUE_MAX))) {
+    props->ahardware_buffer_disable = true;
+  }
+}
+
 namespace vendor {
 namespace qti {
 namespace hardware {
@@ -54,7 +75,10 @@
 using gralloc::Error;
 
 QtiAllocator::QtiAllocator() {
+  gralloc::GrallocProperties properties;
+  get_properties(&properties);
   buf_mgr_ = BufferManager::GetInstance();
+  buf_mgr_->SetGrallocDebugProperties(properties);
 }
 
 // Methods from ::android::hardware::graphics::allocator::V2_0::IAllocator follow.