diff options
author | Ralph Nathan <ralphnathan@google.com> | 2015-12-03 23:56:12 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-12-03 23:56:12 +0000 |
commit | dacda1b57cb4c04f296bf6c511ccb7e55b59d111 (patch) | |
tree | b4e99d1cc907cf9845a9a14b9e99b8271c421347 | |
parent | 7d031f277875cbc61f72584e958dc6e685338141 (diff) | |
parent | 6eb09da358e241055155f2ef1886f3a6c684df4a (diff) | |
download | common-dacda1b57cb4c04f296bf6c511ccb7e55b59d111.tar.gz |
Merge "Move service example from device/generic/brillo."
-rw-r--r-- | service_example/Android.mk | 39 | ||||
-rw-r--r-- | service_example/init.testservice.rc.example | 4 | ||||
-rw-r--r-- | service_example/testservice.cpp | 31 |
3 files changed, 74 insertions, 0 deletions
diff --git a/service_example/Android.mk b/service_example/Android.mk new file mode 100644 index 0000000..50eb925 --- /dev/null +++ b/service_example/Android.mk @@ -0,0 +1,39 @@ +# Copyright 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) + +include $(CLEAR_VARS) +LOCAL_MODULE := testservice +LOCAL_REQUIRED_MODULES := init.testservice.rc +LOCAL_SRC_FILES := testservice.cpp +LOCAL_SHARED_LIBRARIES := libc libbase +LOCAL_CFLAGS := -Werror +include $(BUILD_EXECUTABLE) + +ifdef INITRC_TEMPLATE +include $(CLEAR_VARS) +LOCAL_MODULE := init.testservice.rc +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_INITRCD) + +include $(BUILD_SYSTEM)/base_rules.mk + +.PHONY: $(LOCAL_BUILT_MODULE) +$(LOCAL_BUILT_MODULE): my_args := arg1 arg2 +$(LOCAL_BUILT_MODULE): my_groups := inet +$(LOCAL_BUILT_MODULE): $(INITRC_TEMPLATE) + $(call generate-initrc-file,testservice,$(my_args),\ + $(my_groups)) +endif diff --git a/service_example/init.testservice.rc.example b/service_example/init.testservice.rc.example new file mode 100644 index 0000000..572d5f3 --- /dev/null +++ b/service_example/init.testservice.rc.example @@ -0,0 +1,4 @@ +service testservice /system/bin/testservice + class main + user system + group system diff --git a/service_example/testservice.cpp b/service_example/testservice.cpp new file mode 100644 index 0000000..1e579b3 --- /dev/null +++ b/service_example/testservice.cpp @@ -0,0 +1,31 @@ +/* + * Copyright 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. + */ + +#define LOG_TAG "testservice" + +#include <unistd.h> + +#include <base/logging.h> + +int main(int argc __unused, char **argv __unused) { + LOG(INFO) << "starting"; + while (1) { + LOG(INFO) << "loop iteration"; + sleep(5); + } + LOG(INFO) << "exiting"; + return 0; +} |