Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ba22cbb authored by Devin Moore's avatar Devin Moore Committed by Automerger Merge Worker
Browse files

fakeservicemanager: Don't accept null binders for addService am: 5f6ded88

parents e4432b8f 5f6ded88
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ sp<IBinder> ServiceManager::checkService( const String16& name) const {
status_t ServiceManager::addService(const String16& name, const sp<IBinder>& service,
                                bool /*allowIsolated*/,
                                int /*dumpsysFlags*/) {
    if (service == nullptr) {
        return UNEXPECTED_NULL;
    }
    mNameToService[name] = service;
    return NO_ERROR;
}
+6 −0
Original line number Diff line number Diff line
@@ -50,6 +50,12 @@ TEST(AddService, HappyHappy) {
        IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT), OK);
}

TEST(AddService, SadNullBinder) {
    auto sm = new ServiceManager();
    EXPECT_EQ(sm->addService(String16("foo"), nullptr, false /*allowIsolated*/,
        IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT), android::UNEXPECTED_NULL);
}

TEST(AddService, HappyOverExistingService) {
    auto sm = new ServiceManager();
    EXPECT_EQ(sm->addService(String16("foo"), getBinder(), false /*allowIsolated*/,