diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-15 02:09:27 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-15 02:09:27 +0000 |
commit | a868c221f12fec002355f0c506835e4c82d3f76d (patch) | |
tree | 18ce4c5ddff1e76c4dbc8ac93c4560ed46f62f61 | |
parent | d036dbfbc0d7f610b3ee4604829578d9a7027a21 (diff) | |
parent | f8b9e7c6cf0cd52a218016c8f5afb134cfdcbf6d (diff) | |
download | hwservicemanager-android12-mainline-resolv-release.tar.gz |
Snap for 7550930 from f8b9e7c6cf0cd52a218016c8f5afb134cfdcbf6d to mainline-resolv-releaseandroid-mainline-12.0.0_r94android-mainline-12.0.0_r80android-mainline-12.0.0_r65android-mainline-12.0.0_r52android-mainline-12.0.0_r35android-mainline-12.0.0_r16android-mainline-12.0.0_r124android-mainline-12.0.0_r108android12-mainline-resolv-release
Change-Id: Ia3041ccb85665737f2e5b1988bfdce27eb5b84b7
l--------- | .clang-format | 1 | ||||
-rw-r--r-- | Android.bp | 17 | ||||
-rw-r--r-- | MODULE_LICENSE_APACHE2 | 0 | ||||
-rw-r--r-- | PREUPLOAD.cfg | 2 | ||||
-rw-r--r-- | ServiceManager.cpp | 48 | ||||
-rw-r--r-- | TokenManager.cpp | 2 | ||||
-rw-r--r-- | Vintf.cpp | 2 | ||||
-rw-r--r-- | hwservicemanager.rc | 2 | ||||
-rw-r--r-- | service.cpp | 5 |
9 files changed, 73 insertions, 6 deletions
diff --git a/.clang-format b/.clang-format new file mode 120000 index 0000000..ddcf5a2 --- /dev/null +++ b/.clang-format @@ -0,0 +1 @@ +../../build/soong/scripts/system-clang-format
\ No newline at end of file @@ -12,6 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. +package { + default_applicable_licenses: ["system_hwservicemanager_license"], +} + +// Added automatically by a large-scale-change +// http://go/android-license-faq +license { + name: "system_hwservicemanager_license", + visibility: [":__subpackages__"], + license_kinds: [ + "SPDX-license-identifier-Apache-2.0", + ], + license_text: [ + "NOTICE", + ], +} + cc_defaults { name: "hwservicemanager_defaults", cflags: [ diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29..0000000 --- a/MODULE_LICENSE_APACHE2 +++ /dev/null diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg new file mode 100644 index 0000000..6b7fd71 --- /dev/null +++ b/PREUPLOAD.cfg @@ -0,0 +1,2 @@ +[Builtin Hooks] +clang_format = true diff --git a/ServiceManager.cpp b/ServiceManager.cpp index 85d4974..283b054 100644 --- a/ServiceManager.cpp +++ b/ServiceManager.cpp @@ -255,7 +255,12 @@ static void tryStartService(const std::string& fqName, const std::string& name) << " is not registered, trying to start it as a lazy HAL."; std::thread([=] { - (void)SetProperty("ctl.interface_start", fqName + "/" + name); + if (!SetProperty("ctl.interface_start", fqName + "/" + name)) { + LOG(INFO) << "Tried to start " << fqName << "/" << name + << " as a lazy service, but was unable to. Usually this happens when a " + "service is not installed, but if the service is intended to be used as a " + "lazy service, then it may be configured incorrectly."; + } }).detach(); } @@ -347,6 +352,8 @@ bool ServiceManager::addImpl(const std::string& name, } } + const std::string childFqName = interfaceChain[0]; + // Detect duplicate registration if (interfaceChain.size() > 1) { // second to last entry should be the highest base class other than IBase. @@ -358,7 +365,6 @@ bool ServiceManager::addImpl(const std::string& name, // - bad configuration (service installed on device multiple times) // - race between death notification and a new service being registered // (previous logs should indicate a separate problem) - const std::string childFqName = interfaceChain[0]; pid_t newServicePid = IPCThreadState::self()->getCallingPid(); pid_t oldServicePid = hidlService->getDebugPid(); LOG(WARNING) << "Detected instance of " << childFqName << " (pid: " << newServicePid @@ -375,7 +381,6 @@ bool ServiceManager::addImpl(const std::string& name, // 2). IBar::getService(X) // assuming that IBar is declared in the device manifest and there // is also not an IBaz extends IFoo and there is no race. - const std::string childFqName = interfaceChain[0]; const HidlService *hidlService = lookup(childFqName, name); if (hidlService != nullptr) { const sp<IBase> remove = hidlService->getService(); @@ -387,6 +392,43 @@ bool ServiceManager::addImpl(const std::string& name, } } + // Detect missing manifest entries of superclass, when subclass in manifest. + { + // Ideally we could require all HALs registered with hwservicemanager to + // be in the VINTF manifest. However, this would prevent tests from + // running, and we would need another method of registering them (AIDL + // servicemanager gets around this because only certain objects are + // VINTF objects). So, for HIDL, we rely on VTS. + // + // When registering a HAL, in the client process, it checks to make sure + // that the last (leaf) class in the chain is in the VINTF manifest and + // fails. However, this fails to take into account parent classes. If + // parent classes are associated with certain VTS tests, then those VTS + // tests will not run until vts_treble_vintf_vendor_test fails and the + // failures are fixed (namely adding this into a manifest). + // + // So, here we make sure that if something is in the manifest, all of + // its parent classes are. + using ::android::hardware::getTransport; + if (vintf::Transport::EMPTY != getTransport(childFqName, name)) { + bool parentsInManifest = true; + + // skip over latest, and check over all interfaces except the base + // interface (android.hidl.base is never in the manifest) + for (size_t i = 1; i + 1 < interfaceChain.size(); i++) { + if (vintf::Transport::EMPTY == getTransport(interfaceChain[i], name)) { + LOG(ERROR) << childFqName << "/" << name + << " is in the VINTF manifest, but its superclass " + << interfaceChain[i] << " is not. Refusing to register."; + parentsInManifest = false; + } + } + if (!parentsInManifest) { + return false; + } + } + } + for(size_t i = 0; i < interfaceChain.size(); i++) { const std::string fqName = interfaceChain[i]; diff --git a/TokenManager.cpp b/TokenManager.cpp index 378ee16..8c0acfc 100644 --- a/TokenManager.cpp +++ b/TokenManager.cpp @@ -18,6 +18,8 @@ #include "TokenManager.h" +#include <fcntl.h> + #include <functional> #include <log/log.h> #include <openssl/hmac.h> @@ -67,7 +67,7 @@ vintf::Transport getTransport(const std::string &interfaceName, const std::strin } LOG(INFO) << __FUNCTION__ << ": Cannot find entry " << fqName.string() << "/" << instanceName - << " in either framework or device manifest."; + << " in either framework or device VINTF manifest."; return vintf::Transport::EMPTY; } diff --git a/hwservicemanager.rc b/hwservicemanager.rc index b09ac11..2a70afd 100644 --- a/hwservicemanager.rc +++ b/hwservicemanager.rc @@ -7,6 +7,6 @@ service hwservicemanager /system/bin/hwservicemanager onrestart class_restart main onrestart class_restart hal onrestart class_restart early_hal - writepid /dev/cpuset/system-background/tasks + task_profiles ServiceCapacityLow HighPerformance class animation shutdown critical diff --git a/service.cpp b/service.cpp index 9dd1aee..3fc1391 100644 --- a/service.cpp +++ b/service.cpp @@ -143,6 +143,9 @@ int main() { // we log this and why we care about this at all. setProcessHidlReturnRestriction(HidlReturnRestriction::ERROR_IF_UNCHECKED); + // TODO(b/36424585): make fatal + ProcessState::self()->setCallRestriction(ProcessState::CallRestriction::ERROR_IF_NOT_ONEWAY); + sp<ServiceManager> manager = new ServiceManager(); setRequestingSid(manager, true); @@ -160,7 +163,7 @@ int main() { sp<BHwBinder> service = static_cast<BHwBinder*>(binder.get()); // local binder object IPCThreadState::self()->setTheContextObject(service); // Then tell the kernel - ProcessState::self()->becomeContextManager(nullptr, nullptr); + ProcessState::self()->becomeContextManager(); int rc = property_set("hwservicemanager.ready", "true"); if (rc) { |