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

Commit aa923f91 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...

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

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2308644



Change-Id: I097a12e461886e057cd24d40e213848aca1f97e5
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 139fa4c2 ac2bc826
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*/,