OSDN Git Service

memtrack: Add androis.hardware.memtrack@1.0-service
authorRuchi Kandoi <kandoiruchi@google.com>
Fri, 30 Sep 2016 00:51:52 +0000 (17:51 -0700)
committerRuchi Kandoi <kandoiruchi@google.com>
Tue, 11 Oct 2016 02:16:54 +0000 (19:16 -0700)
Bug: 31180823
Change-Id: I712d5b041fd13e85f57dc400cc0c48c9d9ee2f36
Signed-off-by: Ruchi Kandoi<kandoiruchi@google.com>
memtrack/1.0/default/Android.bp
memtrack/1.0/default/service.cpp [new file with mode: 0644]

index a235729..c6ab6b9 100644 (file)
@@ -28,3 +28,21 @@ cc_library_shared {
     ],
 
 }
+
+cc_binary {
+    relative_install_path: "hw",
+    name: "android.hardware.memtrack@1.0-service",
+    srcs: ["service.cpp"],
+
+    shared_libs: [
+        "liblog",
+        "libbase",
+        "libdl",
+        "libutils",
+        "libhardware",
+        "libhidl",
+        "libhwbinder",
+        "android.hardware.memtrack@1.0",
+    ],
+
+}
diff --git a/memtrack/1.0/default/service.cpp b/memtrack/1.0/default/service.cpp
new file mode 100644 (file)
index 0000000..63ac695
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 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 "android.hardware.memtrack@1.0-service"
+#include <utils/Log.h>
+
+#include <iostream>
+#include <unistd.h>
+
+#include <android/hardware/memtrack/1.0/IMemtrack.h>
+
+#include <hidl/IServiceManager.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+#include <utils/Errors.h>
+#include <utils/StrongPointer.h>
+
+using android::sp;
+
+using android::hardware::IPCThreadState;
+using android::hardware::ProcessState;
+
+using android::hardware::memtrack::V1_0::IMemtrack;
+
+int main() {
+    const char instance[] = "memtrack";
+    android::sp<IMemtrack> service = IMemtrack::getService(instance, true);
+    if (service.get() == nullptr) {
+        ALOGE("IMemtrack::getService returned NULL, exiting");
+        return -1;
+    }
+    LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
+    service->registerAsService(instance);
+
+    ProcessState::self()->setThreadPoolMaxThreadCount(0);
+    ProcessState::self()->startThreadPool();
+    IPCThreadState::self()->joinThreadPool();
+}