Merge "Give ContextHub HAL access to AOC version" into main
diff --git a/gcam_app/sepolicy/product/private/debug_camera_app.te b/gcam_app/sepolicy/product/private/debug_camera_app.te
index 0449bc0..9d4643d 100644
--- a/gcam_app/sepolicy/product/private/debug_camera_app.te
+++ b/gcam_app/sepolicy/product/private/debug_camera_app.te
@@ -1,5 +1,4 @@
# GCANext and GCAEng.
-# b/363018500
typeattribute debug_camera_app coredomain;
userdebug_or_eng(`
diff --git a/input/gia/aidl/compatibility_matrix.xml b/input/gia/aidl/compatibility_matrix.xml
new file mode 100644
index 0000000..1a348ea
--- /dev/null
+++ b/input/gia/aidl/compatibility_matrix.xml
@@ -0,0 +1,10 @@
+<compatibility-matrix type="framework" version="1.0">
+ <hal format="aidl" optional="true">
+ <name>com.google.input.gia.core</name>
+ <interface>
+ <name>IGiaService</name>
+ <instance>default</instance>
+ </interface>
+ <version>1</version>
+ </hal>
+</compatibility-matrix>
\ No newline at end of file
diff --git a/input/gia/aidl/manifest.xml b/input/gia/aidl/manifest.xml
new file mode 100644
index 0000000..98303c8
--- /dev/null
+++ b/input/gia/aidl/manifest.xml
@@ -0,0 +1,10 @@
+<manifest type="device" version="1.0">
+ <hal format="aidl" optional="true">
+ <name>com.google.input.gia.core</name>
+ <interface>
+ <name>IGiaService</name>
+ <instance>default</instance>
+ </interface>
+ <version>1</version>
+ </hal>
+</manifest>
\ No newline at end of file
diff --git a/input/gia/gia.mk b/input/gia/gia.mk
new file mode 100644
index 0000000..ea079ca
--- /dev/null
+++ b/input/gia/gia.mk
@@ -0,0 +1,11 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/input/gia/sepolicy
+
+PRODUCT_PACKAGES += gia
+PRODUCT_PACKAGES += com.google.input.gia.giaservicemanager
+
+PRODUCT_SOONG_NAMESPACES += vendor/google/interfaces
+PRODUCT_SOONG_NAMESPACES += vendor/google/input/gia/core
+PRODUCT_SOONG_NAMESPACES += vendor/google/input/gia/core-servicemanager
+
+DEVICE_MANIFEST_FILE += device/google/gs-common/input/gia/aidl/manifest.xml
+DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE += device/google/gs-common/input/gia/aidl/compatibility_matrix.xml
diff --git a/input/gia/sepolicy/attributes b/input/gia/sepolicy/attributes
new file mode 100644
index 0000000..1d61ad3
--- /dev/null
+++ b/input/gia/sepolicy/attributes
@@ -0,0 +1,2 @@
+# This macro produces: define hal_gia, hal_gia_client, hal_gia_server
+hal_attribute(gia)
diff --git a/input/gia/sepolicy/file_contexts b/input/gia/sepolicy/file_contexts
new file mode 100644
index 0000000..99d6857
--- /dev/null
+++ b/input/gia/sepolicy/file_contexts
@@ -0,0 +1,2 @@
+# chmod +x in SEPolicy language
+/vendor/bin/gia u:object_r:gia_exec:s0
diff --git a/input/gia/sepolicy/gia.te b/input/gia/sepolicy/gia.te
new file mode 100644
index 0000000..2c84e7c
--- /dev/null
+++ b/input/gia/sepolicy/gia.te
@@ -0,0 +1,18 @@
+# SEPolicies for GIA (Google Input interface Abstraction layer)
+type gia, domain;
+type gia_exec, exec_type, vendor_file_type, file_type;
+
+# Macro transferring gia_exec to the gia domain
+init_daemon_domain(gia)
+
+# let this domain use the hal service
+hal_client_domain(gia, hal_gia)
+# allow binder communication with service_manager
+binder_use(gia)
+
+# let this domain serve the hal service
+hal_server_domain(gia, hal_gia)
+
+# allow gia for accessing touch related system file-nodes
+allow gia sysfs_touch_gti:dir r_dir_perms;
+allow gia sysfs_touch_gti:file rw_file_perms;
diff --git a/input/gia/sepolicy/hal_gia.te b/input/gia/sepolicy/hal_gia.te
new file mode 100644
index 0000000..b75c9fb
--- /dev/null
+++ b/input/gia/sepolicy/hal_gia.te
@@ -0,0 +1,8 @@
+# allow binder connection from client to server
+binder_call(hal_gia_client, hal_gia_server)
+
+# allow client to find the service & allow server to register the service
+hal_attribute_service(hal_gia, hal_gia_service)
+
+# allow binder communication from server to service_manager
+binder_use(hal_gia_server)
diff --git a/input/gia/sepolicy/service.te b/input/gia/sepolicy/service.te
new file mode 100644
index 0000000..aed1135
--- /dev/null
+++ b/input/gia/sepolicy/service.te
@@ -0,0 +1,2 @@
+# Declares GIA related services
+type hal_gia_service, hal_service_type, protected_service, service_manager_type;
diff --git a/input/gia/sepolicy/service_contexts b/input/gia/sepolicy/service_contexts
new file mode 100644
index 0000000..b1773ec
--- /dev/null
+++ b/input/gia/sepolicy/service_contexts
@@ -0,0 +1,2 @@
+# Attaches GIA services to the cooresponding SEPolicy group
+com.google.input.gia.core.IGiaService/default u:object_r:hal_gia_service:s0
diff --git a/mailbox/Android.bp b/mailbox/Android.bp
new file mode 100644
index 0000000..6969685
--- /dev/null
+++ b/mailbox/Android.bp
@@ -0,0 +1,21 @@
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_binary {
+ name: "dump_mailbox",
+ srcs: ["dump/dump_mailbox.cpp"],
+ init_rc: ["init.mailbox.rc"],
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+ shared_libs: [
+ "libbase",
+ "libdump",
+ "liblog",
+ ],
+ vendor: true,
+ relative_install_path: "dump",
+}
diff --git a/mailbox/dump/dump_mailbox.cpp b/mailbox/dump/dump_mailbox.cpp
new file mode 100644
index 0000000..8f63b30
--- /dev/null
+++ b/mailbox/dump/dump_mailbox.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <dump/pixel_dump.h>
+#include <android-base/file.h>
+
+int main() {
+ std::string outputDir = concatenatePath(BUGREPORT_PACKING_DIR, "mailbox");
+ if (mkdir(outputDir.c_str(), 0777) == -1) {
+ printf("Unable to create folder: %s\n", outputDir.c_str());
+ return 0;
+ }
+
+ copyFile("/sys/kernel/tracing/instances/goog_cpm_mailbox/trace",
+ concatenatePath(outputDir.c_str(), "goog_cpm_mailbox_trace").c_str());
+ copyFile("/sys/kernel/tracing/instances/goog_nq_mailbox/trace",
+ concatenatePath(outputDir.c_str(), "goog_nq_mailbox_trace").c_str());
+
+ return 0;
+}
diff --git a/mailbox/dump/sepolicy/dump_mailbox.te b/mailbox/dump/sepolicy/dump_mailbox.te
new file mode 100644
index 0000000..64f184c
--- /dev/null
+++ b/mailbox/dump/sepolicy/dump_mailbox.te
@@ -0,0 +1,7 @@
+#
+pixel_bugreport(dump_mailbox)
+allow dump_mailbox radio_vendor_data_file:dir create_dir_perms;
+allow dump_mailbox radio_vendor_data_file:file create_file_perms;
+allow dump_mailbox debugfs_tracing_instances:file r_file_perms;
+allow dump_mailbox debugfs_tracing_instances:dir search;
+allow dump_mailbox debugfs_tracing_instances_mailbox:file r_file_perms;
diff --git a/mailbox/dump/sepolicy/file.te b/mailbox/dump/sepolicy/file.te
new file mode 100644
index 0000000..5bb7bc4
--- /dev/null
+++ b/mailbox/dump/sepolicy/file.te
@@ -0,0 +1,2 @@
+#
+type debugfs_tracing_instances_mailbox, sysfs_type, fs_type;
diff --git a/mailbox/dump/sepolicy/file_contexts b/mailbox/dump/sepolicy/file_contexts
new file mode 100644
index 0000000..b9bea15
--- /dev/null
+++ b/mailbox/dump/sepolicy/file_contexts
@@ -0,0 +1 @@
+/vendor/bin/dump/dump_mailbox u:object_r:dump_mailbox_exec:s0
diff --git a/mailbox/dump/sepolicy/genfs_contexts b/mailbox/dump/sepolicy/genfs_contexts
new file mode 100644
index 0000000..0bac5e8
--- /dev/null
+++ b/mailbox/dump/sepolicy/genfs_contexts
@@ -0,0 +1,2 @@
+genfscon tracefs /instances/goog_cpm_mailbox/trace u:object_r:debugfs_tracing_instances_mailbox:s0
+genfscon tracefs /instances/goog_nq_mailbox/trace u:object_r:debugfs_tracing_instances_mailbox:s0
diff --git a/mailbox/init.mailbox.rc b/mailbox/init.mailbox.rc
new file mode 100644
index 0000000..7659290
--- /dev/null
+++ b/mailbox/init.mailbox.rc
@@ -0,0 +1,8 @@
+on property:sys.boot_completed=1
+ chown system system /sys/kernel/tracing/instances/goog_cpm_mailbox
+ chown system system /sys/kernel/tracing/instances/goog_cpm_mailbox/trace
+ write /sys/kernel/tracing/instances/goog_cpm_mailbox/buffer_size_kb 512
+
+ chown system system /sys/kernel/tracing/instances/goog_nq_mailbox
+ chown system system /sys/kernel/tracing/instances/goog_nq_mailbox/trace
+ write /sys/kernel/tracing/instances/goog_nq_mailbox/buffer_size_kb 512
diff --git a/mailbox/mailbox.mk b/mailbox/mailbox.mk
new file mode 100644
index 0000000..aeefb9a
--- /dev/null
+++ b/mailbox/mailbox.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/mailbox/dump/sepolicy
+
+PRODUCT_PACKAGES += dump_mailbox