@@ -466,7 +466,7 @@ def make_package(args):
466466 if exists (service_main ) or exists (service_main + 'o' ):
467467 service = True
468468
469- service_names = []
469+ service_data = []
470470 base_service_class = args .service_class_name .split ('.' )[- 1 ]
471471 for sid , spec in enumerate (args .services ):
472472 spec = spec .split (':' )
@@ -476,8 +476,18 @@ def make_package(args):
476476
477477 foreground = 'foreground' in options
478478 sticky = 'sticky' in options
479+ foreground_type_option = next ((s for s in options if s .startswith ('foregroundServiceType' )), None )
480+ foreground_type = None
481+ if foreground_type_option :
482+ parts = foreground_type_option .split ('=' , 1 )
483+ if len (parts ) != 2 or not parts [1 ]:
484+ raise ValueError (
485+ 'Missing value for `foregroundServiceType` option. '
486+ 'Expected format: foregroundServiceType=location'
487+ )
488+ foreground_type = parts [1 ]
479489
480- service_names .append (name )
490+ service_data .append (( name , foreground_type ) )
481491 service_target_path = \
482492 'src/main/java/{}/Service{}.java' .format (
483493 args .package .replace ("." , "/" ),
@@ -541,10 +551,10 @@ def make_package(args):
541551 render_args = {
542552 "args" : args ,
543553 "service" : service ,
544- "service_names " : service_names ,
554+ "service_data " : service_data ,
545555 "android_api" : android_api ,
546556 "debug" : "debug" in args .build_mode ,
547- "native_services" : args .native_services
557+ "native_services" : args .native_services ,
548558 }
549559 if is_sdl_bootstrap ():
550560 render_args ["url_scheme" ] = url_scheme
0 commit comments