hikey: hikey960: Add memtrack HAL am: 4cb6c2b774 am: 1704ebc750 am: acf1c74dab
am: 71a273a877

Change-Id: Ia9300991f22e1444be3524612a9771fddba01a10
diff --git a/device-common.mk b/device-common.mk
index a7f5369..38feb32 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -57,6 +57,11 @@
     android.hardware.graphics.allocator@2.0-impl \
     android.hardware.graphics.mapper@2.0-impl
 
+# Memtrack
+PRODUCT_PACKAGES += memtrack.default \
+    android.hardware.memtrack@1.0-service \
+    android.hardware.memtrack@1.0-impl
+
 PRODUCT_PACKAGES +=	TIInit_11.8.32.bts \
 			wl18xx-fw-4.bin \
 			wl18xx-conf.bin
diff --git a/manifest.xml b/manifest.xml
index 95a1fe7..aa16a8c 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -27,6 +27,15 @@
         </interface>
     </hal>
     <hal format="hidl">
+        <name>android.hardware.memtrack</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IMemtrack</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
         <name>android.hardware.wifi.supplicant</name>
         <transport>hwbinder</transport>
         <version>1.0</version>
diff --git a/sepolicy/hal_memtrack.te b/sepolicy/hal_memtrack.te
new file mode 100644
index 0000000..c2da124
--- /dev/null
+++ b/sepolicy/hal_memtrack.te
@@ -0,0 +1,11 @@
+type debugfs_kgsl, debugfs_type, fs_type;
+
+allow domain debugfs_kgsl:dir search;
+
+allow hal_memtrack debugfs_kgsl:dir search;
+allow hal_memtrack debugfs_kgsl:file { open read getattr };
+
+# Memtrack reads proc/<pid>/cmdline to check if process is surfaceflinger.
+# Grant access if that's the case; don't log denials for other processes.
+allow hal_memtrack surfaceflinger:file read;
+dontaudit hal_memtrack { domain -surfaceflinger}:file read;