Loading cmds/servicemanager/test_sm.cpp +13 −8 Original line number Diff line number Diff line Loading @@ -27,11 +27,14 @@ #include "Access.h" #include "ServiceManager.h" using android::sp; using android::Access; using android::BBinder; using android::IBinder; using android::ServiceManager; using android::sp; using android::base::EndsWith; using android::base::GetProperty; using android::base::StartsWith; using android::binder::Status; using android::os::BnServiceCallback; using android::os::IServiceManager; Loading Loading @@ -77,9 +80,11 @@ static sp<ServiceManager> getPermissiveServiceManager() { return sm; } static bool isCuttlefish() { return android::base::StartsWith(android::base::GetProperty("ro.product.vendor.device", ""), "vsoc_"); // Determines if test device is a cuttlefish phone device static bool isCuttlefishPhone() { auto device = GetProperty("ro.product.vendor.device", ""); auto product = GetProperty("ro.product.vendor.name", ""); return StartsWith(device, "vsoc_") && EndsWith(product, "_phone"); } TEST(AddService, HappyHappy) { Loading Loading @@ -314,7 +319,7 @@ TEST(ListServices, CriticalServices) { } TEST(Vintf, UpdatableViaApex) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; if (!isCuttlefishPhone()) GTEST_SKIP() << "Skipping non-Cuttlefish-phone devices"; auto sm = getPermissiveServiceManager(); std::optional<std::string> updatableViaApex; Loading @@ -326,7 +331,7 @@ TEST(Vintf, UpdatableViaApex) { } TEST(Vintf, UpdatableViaApex_InvalidNameReturnsNullOpt) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; if (!isCuttlefishPhone()) GTEST_SKIP() << "Skipping non-Cuttlefish-phone devices"; auto sm = getPermissiveServiceManager(); std::optional<std::string> updatableViaApex; Loading @@ -337,7 +342,7 @@ TEST(Vintf, UpdatableViaApex_InvalidNameReturnsNullOpt) { } TEST(Vintf, GetUpdatableNames) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; if (!isCuttlefishPhone()) GTEST_SKIP() << "Skipping non-Cuttlefish-phone devices"; auto sm = getPermissiveServiceManager(); std::vector<std::string> names; Loading @@ -348,7 +353,7 @@ TEST(Vintf, GetUpdatableNames) { } TEST(Vintf, GetUpdatableNames_InvalidApexNameReturnsEmpty) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; if (!isCuttlefishPhone()) GTEST_SKIP() << "Skipping non-Cuttlefish-phone devices"; auto sm = getPermissiveServiceManager(); std::vector<std::string> names; Loading Loading
cmds/servicemanager/test_sm.cpp +13 −8 Original line number Diff line number Diff line Loading @@ -27,11 +27,14 @@ #include "Access.h" #include "ServiceManager.h" using android::sp; using android::Access; using android::BBinder; using android::IBinder; using android::ServiceManager; using android::sp; using android::base::EndsWith; using android::base::GetProperty; using android::base::StartsWith; using android::binder::Status; using android::os::BnServiceCallback; using android::os::IServiceManager; Loading Loading @@ -77,9 +80,11 @@ static sp<ServiceManager> getPermissiveServiceManager() { return sm; } static bool isCuttlefish() { return android::base::StartsWith(android::base::GetProperty("ro.product.vendor.device", ""), "vsoc_"); // Determines if test device is a cuttlefish phone device static bool isCuttlefishPhone() { auto device = GetProperty("ro.product.vendor.device", ""); auto product = GetProperty("ro.product.vendor.name", ""); return StartsWith(device, "vsoc_") && EndsWith(product, "_phone"); } TEST(AddService, HappyHappy) { Loading Loading @@ -314,7 +319,7 @@ TEST(ListServices, CriticalServices) { } TEST(Vintf, UpdatableViaApex) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; if (!isCuttlefishPhone()) GTEST_SKIP() << "Skipping non-Cuttlefish-phone devices"; auto sm = getPermissiveServiceManager(); std::optional<std::string> updatableViaApex; Loading @@ -326,7 +331,7 @@ TEST(Vintf, UpdatableViaApex) { } TEST(Vintf, UpdatableViaApex_InvalidNameReturnsNullOpt) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; if (!isCuttlefishPhone()) GTEST_SKIP() << "Skipping non-Cuttlefish-phone devices"; auto sm = getPermissiveServiceManager(); std::optional<std::string> updatableViaApex; Loading @@ -337,7 +342,7 @@ TEST(Vintf, UpdatableViaApex_InvalidNameReturnsNullOpt) { } TEST(Vintf, GetUpdatableNames) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; if (!isCuttlefishPhone()) GTEST_SKIP() << "Skipping non-Cuttlefish-phone devices"; auto sm = getPermissiveServiceManager(); std::vector<std::string> names; Loading @@ -348,7 +353,7 @@ TEST(Vintf, GetUpdatableNames) { } TEST(Vintf, GetUpdatableNames_InvalidApexNameReturnsEmpty) { if (!isCuttlefish()) GTEST_SKIP() << "Skipping non-Cuttlefish devices"; if (!isCuttlefishPhone()) GTEST_SKIP() << "Skipping non-Cuttlefish-phone devices"; auto sm = getPermissiveServiceManager(); std::vector<std::string> names; Loading