aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Campbell <leecam@google.com>2016-01-20 17:22:48 -0800
committerLee Campbell <leecam@google.com>2016-01-20 17:22:48 -0800
commit3ae37fef7ae4256b43c1d54c8c7a878a668d57cb (patch)
tree3c2e98275f7485810b31cd803508df6441c3df5b
parent88e00453a7f05a6919d6d8e0209ed936fe8904cc (diff)
downloadperipheralmanager-3ae37fef7ae4256b43c1d54c8c7a878a668d57cb.tar.gz
peripheralman: Barebones client and daemon.
Add barebones client, daemon and Android.mk files Change-Id: I5eea0da35ffa6ec6e03a0add1e9b1d2e397f38bf TEST: Services starts on the emulator
-rw-r--r--Android.mk17
-rw-r--r--README3
-rw-r--r--client/Android.mk60
-rw-r--r--client/peripheral_manager_client.cc31
-rw-r--r--client/peripheral_manager_client_unittest.cc26
-rw-r--r--daemon/Android.mk77
-rw-r--r--daemon/main.cc53
-rw-r--r--include/peripheralmanager/peripheral_manager_client.h40
8 files changed, 307 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..178cb8a
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2015 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 $(call all-subdir-makefiles)
diff --git a/README b/README
new file mode 100644
index 0000000..00d0c95
--- /dev/null
+++ b/README
@@ -0,0 +1,3 @@
+PeripheralManager
+
+TODO(leecam): Write this file
diff --git a/client/Android.mk b/client/Android.mk
new file mode 100644
index 0000000..4495558
--- /dev/null
+++ b/client/Android.mk
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2015 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+libperipheralman_CommonCFlags := -Wall -Werror -Wno-unused-parameter
+libperipheralman_CommonCFlags += -Wno-sign-promo # for libchrome
+libperipheralman_CommonCIncludes := $(LOCAL_PATH)/../include
+libperipheralman_CommonSharedLibraries := \
+ libbrillo \
+ libchrome \
+
+# libperipheralman shared library
+# ========================================================
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libperipheralman
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_CFLAGS := $(libperipheralman_CommonCFlags)
+LOCAL_C_INCLUDES := $(libperipheralman_CommonCIncludes)
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include
+LOCAL_SHARED_LIBRARIES := $(libperipheralman_CommonSharedLibraries)
+LOCAL_SRC_FILES := \
+ peripheral_manager_client.cc \
+
+include $(BUILD_SHARED_LIBRARY)
+
+# libperipheralman_tests executable
+# ========================================================
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libperipheralman_tests
+ifdef BRILLO
+ LOCAL_MODULE_TAGS := debug
+endif
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_CFLAGS := $(libperipheralman_CommonCFlags)
+LOCAL_C_INCLUDES := $(libperipheralman_CommonCIncludes)
+LOCAL_STATIC_LIBRARIES := libgtest libBionicGtestMain
+LOCAL_SHARED_LIBRARIES := \
+ $(libperipheralman_CommonSharedLibraries) \
+ libperipheralman \
+
+LOCAL_SRC_FILES := \
+ peripheral_manager_client_unittest.cc \
+
+include $(BUILD_NATIVE_TEST)
diff --git a/client/peripheral_manager_client.cc b/client/peripheral_manager_client.cc
new file mode 100644
index 0000000..7cd1431
--- /dev/null
+++ b/client/peripheral_manager_client.cc
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2015 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 <peripheralmanager/peripheral_manager_client.h>
+
+namespace android {
+namespace {
+} // namespace
+
+PeripheralManagerClient::PeripheralManagerClient() {}
+
+PeripheralManagerClient::~PeripheralManagerClient() {}
+
+bool PeripheralManagerClient::Init() {
+ return true;
+}
+
+} // namespace android
diff --git a/client/peripheral_manager_client_unittest.cc b/client/peripheral_manager_client_unittest.cc
new file mode 100644
index 0000000..e75af24
--- /dev/null
+++ b/client/peripheral_manager_client_unittest.cc
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2015 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 <peripheralmanager/peripheral_manager_client.h>
+
+#include "gtest/gtest.h"
+
+namespace android {
+
+TEST(PeripheralManagerClient, Init) {
+}
+
+} // namespace android
diff --git a/daemon/Android.mk b/daemon/Android.mk
new file mode 100644
index 0000000..73ca216
--- /dev/null
+++ b/daemon/Android.mk
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2015 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+peripheralman_CommonCFlags := -Wall -Werror -Wno-unused-parameter
+peripheralman_CommonCFlags += -Wno-sign-promo # for libchrome
+peripheralman_CommonCIncludes := \
+ $(LOCAL_PATH)/../include \
+ external/gtest/include \
+
+peripheralman_CommonSharedLibraries := \
+ libbrillo \
+ libchrome \
+
+# peripheralman executable
+# ========================================================
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := peripheralman
+LOCAL_REQUIRED_MODULES := peripheralman.rc
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_CFLAGS := $(peripheralman_CommonCFlags)
+LOCAL_STATIC_LIBRARIES := libperipheralman_internal
+LOCAL_SHARED_LIBRARIES := \
+ $(peripheralman_CommonSharedLibraries) \
+
+LOCAL_SRC_FILES := main.cc
+
+include $(BUILD_EXECUTABLE)
+
+# peripheralman.rc script
+# ========================================================
+
+ifdef INITRC_TEMPLATE
+include $(CLEAR_VARS)
+LOCAL_MODULE := peripheralman.rc
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_INITRCD)
+
+include $(BUILD_SYSTEM)/base_rules.mk
+
+$(LOCAL_BUILT_MODULE): $(INITRC_TEMPLATE)
+ $(call generate-initrc-file,peripheralman,,)
+endif
+
+# libperipheralman_internal static lib
+# ========================================================
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libperipheralman_internal
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_CFLAGS := $(peripheralman_CommonCFlags)
+LOCAL_C_INCLUDES := $(peripheralman_CommonCIncludes)
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include
+LOCAL_SHARED_LIBRARIES := \
+ $(peripheralman_CommonSharedLibraries) \
+ libbrillo \
+
+LOCAL_SRC_FILES := \
+# peripheral_manager.cc \
+
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/daemon/main.cc b/daemon/main.cc
new file mode 100644
index 0000000..76b03c3
--- /dev/null
+++ b/daemon/main.cc
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2015 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 <sysexits.h>
+
+#include <base/logging.h>
+#include <base/macros.h>
+#include <brillo/daemons/daemon.h>
+#include <brillo/flag_helper.h>
+
+namespace {
+
+class PeripheralManagerDaemon : public brillo::Daemon {
+ public:
+ PeripheralManagerDaemon() = default;
+ ~PeripheralManagerDaemon() override = default;
+
+ private:
+ // brillo::Daemon:
+ int OnInit() override {
+ int result = brillo::Daemon::OnInit();
+ if (result != EX_OK)
+ return result;
+
+ // TODO(leecam): Startup PeripheralManager Here
+
+ LOG(INFO) << "Initialization complete";
+ return EX_OK;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(PeripheralManagerDaemon);
+};
+
+} // namespace
+
+int main(int argc, char *argv[]) {
+ brillo::FlagHelper::Init(argc, argv, "Peripheral management daemon");
+ logging::InitLogging(logging::LoggingSettings());
+ return PeripheralManagerDaemon().Run();
+}
diff --git a/include/peripheralmanager/peripheral_manager_client.h b/include/peripheralmanager/peripheral_manager_client.h
new file mode 100644
index 0000000..e54f234
--- /dev/null
+++ b/include/peripheralmanager/peripheral_manager_client.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+#ifndef SYSTEM_PERIPHERALMANAGER_INCLUDE_PERIPHERAL_MANAGER_H_
+#define SYSTEM_PERIPHERALMANAGER_INCLUDE_PERIPHERAL_MANAGER_H_
+
+#include <base/macros.h>
+
+namespace android {
+
+// Used to communicate with the peripheral manager.
+class PeripheralManagerClient {
+ public:
+ PeripheralManagerClient();
+ ~PeripheralManagerClient();
+
+ // Initializes the object, returning true on success. Must be called before
+ // any other methods.
+ bool Init();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PeripheralManagerClient);
+};
+
+} // namespace android
+
+#endif // SYSTEM_PERIPHERALMANAGER_INCLUDE_PERIPHERAL_MANAGER_H_