Loading cmds/servicemanager/ServiceManager.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -136,6 +136,7 @@ static std::optional<std::string> getVintfUpdatableApex(const std::string& name) updatableViaApex = manifestInstance.updatableViaApex(); return false; // break (libvintf uses opposite convention) }); if (updatableViaApex.has_value()) return true; // break (found match) return false; // continue }); Loading @@ -154,7 +155,7 @@ static std::vector<std::string> getVintfUpdatableInstances(const std::string& ap manifestInstance.interface() + "/" + manifestInstance.instance(); instances.push_back(aname); } return false; // continue return true; // continue (libvintf uses opposite convention) }); return false; // continue }); Loading cmds/servicemanager/test_sm.cpp +52 −2 Original line number Diff line number Diff line Loading @@ -14,13 +14,15 @@ * limitations under the License. */ #include <android-base/properties.h> #include <android-base/strings.h> #include <android/os/BnServiceCallback.h> #include <binder/Binder.h> #include <binder/ProcessState.h> #include <binder/IServiceManager.h> #include <binder/ProcessState.h> #include <cutils/android_filesystem_config.h> #include <gtest/gtest.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include "Access.h" #include "ServiceManager.h" Loading Loading @@ -75,6 +77,11 @@ static sp<ServiceManager> getPermissiveServiceManager() { return sm; } static bool isCuttlefish() { return android::base::StartsWith(android::base::GetProperty("ro.product.vendor.device", ""), "vsoc_"); } TEST(AddService, HappyHappy) { auto sm = getPermissiveServiceManager(); EXPECT_TRUE(sm->addService("foo", getBinder(), false /*allowIsolated*/, Loading Loading @@ -306,6 +313,49 @@ TEST(ListServices, CriticalServices) { EXPECT_THAT(out, ElementsAre("sa")); } TEST(Vintf, UpdatableViaApex) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; auto sm = getPermissiveServiceManager(); std::optional<std::string> updatableViaApex; EXPECT_TRUE(sm->updatableViaApex("android.hardware.camera.provider.ICameraProvider/internal/0", &updatableViaApex) .isOk()); EXPECT_EQ(std::make_optional<std::string>("com.google.emulated.camera.provider.hal"), updatableViaApex); } TEST(Vintf, UpdatableViaApex_InvalidNameReturnsNullOpt) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; auto sm = getPermissiveServiceManager(); std::optional<std::string> updatableViaApex; EXPECT_TRUE(sm->updatableViaApex("android.hardware.camera.provider.ICameraProvider", &updatableViaApex) .isOk()); // missing instance name EXPECT_EQ(std::nullopt, updatableViaApex); } TEST(Vintf, GetUpdatableNames) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; auto sm = getPermissiveServiceManager(); std::vector<std::string> names; EXPECT_TRUE(sm->getUpdatableNames("com.google.emulated.camera.provider.hal", &names).isOk()); EXPECT_EQ(std::vector< std::string>{"android.hardware.camera.provider.ICameraProvider/internal/0"}, names); } TEST(Vintf, GetUpdatableNames_InvalidApexNameReturnsEmpty) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; auto sm = getPermissiveServiceManager(); std::vector<std::string> names; EXPECT_TRUE(sm->getUpdatableNames("non.existing.apex.name", &names).isOk()); EXPECT_EQ(std::vector<std::string>{}, names); } class CallbackHistorian : public BnServiceCallback { Status onRegistration(const std::string& name, const sp<IBinder>& binder) override { registrations.push_back(name); Loading Loading
cmds/servicemanager/ServiceManager.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -136,6 +136,7 @@ static std::optional<std::string> getVintfUpdatableApex(const std::string& name) updatableViaApex = manifestInstance.updatableViaApex(); return false; // break (libvintf uses opposite convention) }); if (updatableViaApex.has_value()) return true; // break (found match) return false; // continue }); Loading @@ -154,7 +155,7 @@ static std::vector<std::string> getVintfUpdatableInstances(const std::string& ap manifestInstance.interface() + "/" + manifestInstance.instance(); instances.push_back(aname); } return false; // continue return true; // continue (libvintf uses opposite convention) }); return false; // continue }); Loading
cmds/servicemanager/test_sm.cpp +52 −2 Original line number Diff line number Diff line Loading @@ -14,13 +14,15 @@ * limitations under the License. */ #include <android-base/properties.h> #include <android-base/strings.h> #include <android/os/BnServiceCallback.h> #include <binder/Binder.h> #include <binder/ProcessState.h> #include <binder/IServiceManager.h> #include <binder/ProcessState.h> #include <cutils/android_filesystem_config.h> #include <gtest/gtest.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include "Access.h" #include "ServiceManager.h" Loading Loading @@ -75,6 +77,11 @@ static sp<ServiceManager> getPermissiveServiceManager() { return sm; } static bool isCuttlefish() { return android::base::StartsWith(android::base::GetProperty("ro.product.vendor.device", ""), "vsoc_"); } TEST(AddService, HappyHappy) { auto sm = getPermissiveServiceManager(); EXPECT_TRUE(sm->addService("foo", getBinder(), false /*allowIsolated*/, Loading Loading @@ -306,6 +313,49 @@ TEST(ListServices, CriticalServices) { EXPECT_THAT(out, ElementsAre("sa")); } TEST(Vintf, UpdatableViaApex) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; auto sm = getPermissiveServiceManager(); std::optional<std::string> updatableViaApex; EXPECT_TRUE(sm->updatableViaApex("android.hardware.camera.provider.ICameraProvider/internal/0", &updatableViaApex) .isOk()); EXPECT_EQ(std::make_optional<std::string>("com.google.emulated.camera.provider.hal"), updatableViaApex); } TEST(Vintf, UpdatableViaApex_InvalidNameReturnsNullOpt) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; auto sm = getPermissiveServiceManager(); std::optional<std::string> updatableViaApex; EXPECT_TRUE(sm->updatableViaApex("android.hardware.camera.provider.ICameraProvider", &updatableViaApex) .isOk()); // missing instance name EXPECT_EQ(std::nullopt, updatableViaApex); } TEST(Vintf, GetUpdatableNames) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; auto sm = getPermissiveServiceManager(); std::vector<std::string> names; EXPECT_TRUE(sm->getUpdatableNames("com.google.emulated.camera.provider.hal", &names).isOk()); EXPECT_EQ(std::vector< std::string>{"android.hardware.camera.provider.ICameraProvider/internal/0"}, names); } TEST(Vintf, GetUpdatableNames_InvalidApexNameReturnsEmpty) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; auto sm = getPermissiveServiceManager(); std::vector<std::string> names; EXPECT_TRUE(sm->getUpdatableNames("non.existing.apex.name", &names).isOk()); EXPECT_EQ(std::vector<std::string>{}, names); } class CallbackHistorian : public BnServiceCallback { Status onRegistration(const std::string& name, const sp<IBinder>& binder) override { registrations.push_back(name); Loading