Handle empty service list

This commit is contained in:
Alessandro Astone 2022-08-29 12:14:30 +02:00 committed by Erfan Abdi
parent bcf3debcc1
commit fc82bf10f4
1 changed files with 6 additions and 2 deletions

View File

@ -583,8 +583,10 @@ cdef class ServiceManager:
return None
cdef char** services = cgbinder.gbinder_servicemanager_list_sync(self._sm)
services_list = []
i = 0
if services == NULL:
return services_list
i = 0
while services[i] != NULL:
services_list.append(services[i].decode())
i += 1
@ -674,8 +676,10 @@ cdef void service_manager_get_service_func(cgbinder.GBinderServiceManager* sm, c
cdef bint service_manager_list_func(cgbinder.GBinderServiceManager* sm, char** services, void* user_data) with gil:
services_list = []
i = 0
if services == NULL:
return services_list
i = 0
while services[i] != NULL:
services_list.append(services[i].decode())
i += 1