From f2060610c0e8723fda7c68a01e04fcbf6c8b26f1 Mon Sep 17 00:00:00 2001 From: Kangping Dong Date: Mon, 28 Aug 2023 21:54:35 +0800 Subject: [PATCH] [Thread] add ot-daemon to com.android.tethering ot-daemon is a dependency of the new Thread feature. This commit add the ot-daemon binary and init rc file to the Tethering module. Note that the ot-daemon service is default disabled and versioned init rc file is used to ensure that this service won't be started before Android U. This is expected to increase the size of "com.android.tethering.capex" by around 400 KB. Manual verification: 1. on Android T (33) CF device, the ot-daemon service is not started after device boots; It reports service not found error when trying to start the ot-daemon service with adb shell command "start ot-daemon" 2. on Android U (34) CF device, the ot-daemon service is not started after device boots; It can be started with shell comamnd "start ot-daemon" but then failed because of missing sepolicy rules as expected Test: see above manual verification note Bug: 296211911 Change-Id: I222e2bbcc2ad0be2beec9f5f3406e7144d314370 --- Tethering/apex/Android.bp | 6 +++++- thread/apex/Android.bp | 29 +++++++++++++++++++++++++++++ thread/apex/ot-daemon.34rc | 24 ++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 thread/apex/Android.bp create mode 100644 thread/apex/ot-daemon.34rc diff --git a/Tethering/apex/Android.bp b/Tethering/apex/Android.bp index bb3dc24caa..13653d8f12 100644 --- a/Tethering/apex/Android.bp +++ b/Tethering/apex/Android.bp @@ -96,6 +96,7 @@ apex { }, binaries: [ "clatd", + "ot-daemon", ], canned_fs_config: "canned_fs_config", bpfs: [ @@ -111,7 +112,10 @@ apex { apps: [ "ServiceConnectivityResources", ], - prebuilts: ["current_sdkinfo"], + prebuilts: [ + "ot-daemon.init.34rc", + "current_sdkinfo", + ], manifest: "manifest.json", key: "com.android.tethering.key", // Indicates that pre-installed version of this apex can be compressed. diff --git a/thread/apex/Android.bp b/thread/apex/Android.bp new file mode 100644 index 0000000000..28854f2a4c --- /dev/null +++ b/thread/apex/Android.bp @@ -0,0 +1,29 @@ +// +// Copyright (C) 2023 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. +// + +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +// Versioned ot-daemon init file which will be processed by the system on 34+ devices. +// See https://android.googlesource.com/platform/system/core/+/HEAD/init/README.md#versioned-rc-files-within-apexs +// for details of versioned rc files. +prebuilt_etc { + name: "ot-daemon.init.34rc", + src: "ot-daemon.34rc", + filename: "init.34rc", + installable: false, +} diff --git a/thread/apex/ot-daemon.34rc b/thread/apex/ot-daemon.34rc new file mode 100644 index 0000000000..1eb1294d52 --- /dev/null +++ b/thread/apex/ot-daemon.34rc @@ -0,0 +1,24 @@ +# Copyright (C) 2023 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. + +service ot-daemon /apex/com.android.tethering/bin/ot-daemon -I thread-wpan --auto-attach=0 threadnetwork_hal://binder?none + interface aidl ot_daemon + disabled + oneshot + updatable + class main + user thread_network + group thread_network inet system + seclabel u:r:ot_daemon:s0 + override