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

Commit 5f6ded88 authored by Devin Moore's avatar Devin Moore
Browse files

fakeservicemanager: Don't accept null binders for addService

Parity with the rest of the Service Manager APIs.

Test: atest fakeservicemanager_test
Bug: 259549842
Change-Id: I715590bc4c4f2f434ad93f82c2ba98d40334ef38
parent a3793499
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*/,