Add mmd skeleton

Setting up memory management skeleton with:
- A flag to guard the daemon from running
- A main method that exits early if the feature flag is disabled
- PREUPLOAD config for formatting build and cpp files

Using mm_daemon target name to avoid build failures with cuttlefish due
to similar host tool named mmd.

Bug: 375432464
Test: m mm_daemon; adb push and verify log message

Change-Id: I271f3043df39d3a72ff1ce38e8fca64e0cc7ccef
diff --git a/.clang-format b/.clang-format
new file mode 120000
index 0000000..973b2fa
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1 @@
+../../../build/soong/scripts/system-clang-format
\ No newline at end of file
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..8dc0bdc
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,38 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_binary {
+    name: "mm_daemon",
+    srcs: [
+        "mmd.cpp",
+    ],
+    defaults: [
+        "aconfig_lib_cc_shared_link.defaults",
+    ],
+    shared_libs: [
+        "liblog",
+        "server_configurable_flags",
+    ],
+    static_libs: [
+        "mmd_flags_c_lib",
+    ],
+    cflags: [
+        "-Wall",
+        "-Werror",
+        "-Wextra",
+    ],
+    stem: "mmd",
+}
+
+aconfig_declarations {
+    name: "mmd_flags",
+    package: "android.mmd.flags",
+    container: "system",
+    srcs: ["flags.aconfig"],
+}
+
+cc_aconfig_library {
+    name: "mmd_flags_c_lib",
+    aconfig_declarations: "mmd_flags",
+}
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..343633c
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,6 @@
+[Builtin Hooks]
+clang_format = true
+bpfmt = true
+
+[Builtin Hooks Options]
+clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
\ No newline at end of file
diff --git a/flags.aconfig b/flags.aconfig
new file mode 100644
index 0000000..0a5eba8
--- /dev/null
+++ b/flags.aconfig
@@ -0,0 +1,9 @@
+package: "android.mmd.flags"
+container: "system"
+
+flag {
+  name: "mmd_enabled"
+  namespace: "system_performance"
+  description: "This flag controls whether Memory Management Daemon is enabled"
+  bug: "370509309"
+}
\ No newline at end of file
diff --git a/mmd.cpp b/mmd.cpp
new file mode 100644
index 0000000..0e45cec
--- /dev/null
+++ b/mmd.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#define LOG_TAG "mmd"
+
+#include <android_mmd_flags.h>
+#include <log/log.h>
+
+using android::mmd::flags::mmd_enabled;
+
+int main() {
+    if (!mmd_enabled()) {
+        ALOGI("Memory Management Daemon is not enabled, exiting");
+        return 0;
+    }
+    ALOGI("Memory Management Daemon finished running");
+    return 0;
+}
\ No newline at end of file