Loading libs/fakeservicemanager/ServiceManager.cpp +7 −0 Original line number Original line Diff line number Diff line Loading @@ -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; } } Loading Loading @@ -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 libs/fakeservicemanager/include/fakeservicemanager/ServiceManager.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -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; }; }; Loading libs/fakeservicemanager/test_sm.cpp +15 −0 Original line number Original line Diff line number Diff line Loading @@ -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*/, Loading @@ -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(); Loading libs/sensor/Android.bp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -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", Loading services/sensorservice/aidl/Android.bp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -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", Loading @@ -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 Loading
libs/fakeservicemanager/ServiceManager.cpp +7 −0 Original line number Original line Diff line number Diff line Loading @@ -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; } } Loading Loading @@ -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
libs/fakeservicemanager/include/fakeservicemanager/ServiceManager.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -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; }; }; Loading
libs/fakeservicemanager/test_sm.cpp +15 −0 Original line number Original line Diff line number Diff line Loading @@ -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*/, Loading @@ -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(); Loading
libs/sensor/Android.bp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -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", Loading
services/sensorservice/aidl/Android.bp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -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", Loading @@ -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