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

Commit a87bb3c9 authored by Devin Moore's avatar Devin Moore Committed by Gerrit Code Review
Browse files

Merge changes from topic "sensorservice_fuzzer"

* changes:
  sensorservice: Adding fuzzer
  fakeservicemanager: Add a clear() method
  fakeservicemanager: Don't accept null binders for addService
parents b465bea9 ca9c28df
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line 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,
status_t ServiceManager::addService(const String16& name, const sp<IBinder>& service,
                                bool /*allowIsolated*/,
                                bool /*allowIsolated*/,
                                int /*dumpsysFlags*/) {
                                int /*dumpsysFlags*/) {
    if (service == nullptr) {
        return UNEXPECTED_NULL;
    }
    mNameToService[name] = service;
    mNameToService[name] = service;
    return NO_ERROR;
    return NO_ERROR;
}
}
@@ -103,4 +106,8 @@ std::vector<IServiceManager::ServiceDebugInfo> ServiceManager::getServiceDebugIn
    std::vector<IServiceManager::ServiceDebugInfo> ret;
    std::vector<IServiceManager::ServiceDebugInfo> ret;
    return ret;
    return ret;
}
}

void ServiceManager::clear() {
    mNameToService.clear();
}
}  // namespace android
}  // namespace android
+3 −0
Original line number Original line Diff line number Diff line
@@ -64,6 +64,9 @@ public:


    std::vector<IServiceManager::ServiceDebugInfo> getServiceDebugInfo() override;
    std::vector<IServiceManager::ServiceDebugInfo> getServiceDebugInfo() override;


    // Clear all of the registered services
    void clear();

private:
private:
    std::map<String16, sp<IBinder>> mNameToService;
    std::map<String16, sp<IBinder>> mNameToService;
};
};
+15 −0
Original line number Original line Diff line number Diff line
@@ -50,6 +50,12 @@ TEST(AddService, HappyHappy) {
        IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT), OK);
        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) {
TEST(AddService, HappyOverExistingService) {
    auto sm = new ServiceManager();
    auto sm = new ServiceManager();
    EXPECT_EQ(sm->addService(String16("foo"), getBinder(), false /*allowIsolated*/,
    EXPECT_EQ(sm->addService(String16("foo"), getBinder(), false /*allowIsolated*/,
@@ -58,6 +64,15 @@ TEST(AddService, HappyOverExistingService) {
        IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT), OK);
        IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT), OK);
}
}


TEST(AddService, HappyClearAddedService) {
    auto sm = new ServiceManager();
    EXPECT_EQ(sm->addService(String16("foo"), getBinder(), false /*allowIsolated*/,
        IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT), OK);
    EXPECT_NE(sm->getService(String16("foo")), nullptr);
    sm->clear();
    EXPECT_EQ(sm->getService(String16("foo")), nullptr);
}

TEST(GetService, HappyHappy) {
TEST(GetService, HappyHappy) {
    auto sm = new ServiceManager();
    auto sm = new ServiceManager();
    sp<IBinder> service = getBinder();
    sp<IBinder> service = getBinder();
+2 −1
Original line number Original line Diff line number Diff line
@@ -21,9 +21,10 @@ package {
    default_applicable_licenses: ["frameworks_native_license"],
    default_applicable_licenses: ["frameworks_native_license"],
}
}


cc_library_shared {
cc_library {
    name: "libsensor",
    name: "libsensor",


    host_supported: true,
    cflags: [
    cflags: [
        "-Wall",
        "-Wall",
        "-Werror",
        "-Werror",
+2 −1
Original line number Original line Diff line number Diff line
@@ -7,7 +7,7 @@ package {
    default_applicable_licenses: ["frameworks_native_license"],
    default_applicable_licenses: ["frameworks_native_license"],
}
}


cc_library_shared {
cc_library {
    name: "libsensorserviceaidl",
    name: "libsensorserviceaidl",
    srcs: [
    srcs: [
        "EventQueue.cpp",
        "EventQueue.cpp",
@@ -15,6 +15,7 @@ cc_library_shared {
        "SensorManager.cpp",
        "SensorManager.cpp",
        "utils.cpp",
        "utils.cpp",
    ],
    ],
    host_supported: true,
    cflags: [
    cflags: [
        "-Wall",
        "-Wall",
        "-Werror",
        "-Werror",
Loading