Android 9 Custom Service crashes with clean AOSP build

cancel
Showing results for 
Search instead for 
Did you mean: 

Android 9 Custom Service crashes with clean AOSP build

Jump to solution
1,329 Views
vinothkumars
Senior Contributor III

Dear NXP,

 

I am working on IMX8QM with Android 9. Custom Service will crash immediately after with clean Android 9 build. 

But, In incremental build is working proper,

        init: Service 'usb-update' (pid 1773) exited with status 0

Build Steps,

     source build/envsetup.sh

     lunch mek_8q_car-userdebug

     make clean 

     make -j6

After flashed, board boot stopped with following "init: Service 'usb-update' (pid 1712) exited with status 1"

logcat output is below:

[ 24.567040] capability: warning: `main' uses 32-bit capabilities (legacy support in use)
[ 26.883154] type=1400 audit(1574312331.560:31): avc: denied { map } for pid=1866 comm="update_engine" path="/dev/event-log-tags" dev="tmpfs" ino=10312 scontext=u:r:update_engine:s0 tcontext=u:object_r:runtime_event_log_tags_file:s0 tclass=file permissive=1
[ 26.905910] type=1400 audit(1574312336.156:32): avc: denied { dac_read_search } for pid=1846 comm="Binder:1846_1" capability=2 scontext=u:r:installd:s0 tcontext=u:r:installd:s0 tclass=capability permissive=1
[ 27.043460] healthd: battery l=85 v=3 t=35.0 h=2 st=2 c=400 fc=4000000 cc=32 chg=a
[ 27.104893] healthd: battery l=85 v=3 t=35.0 h=2 st=2 c=400 fc=4000000 cc=32 chg=a
[ 27.116612] healthd: battery l=85 v=3 t=35.0 h=2 st=2 c=400 fc=4000000 cc=32 chg=a
[ 27.292579] init: Received control message 'interface_start' for 'android.hardware.vibrator@1.0::IVibrator/default' from pid: 1685 (/system/bin/hwservicemanager)
[ 27.307130] init: Could not find service hosting interface android.hardware.vibrator@1.0::IVibrator/default
[ 27.317227] init: Received control message 'interface_start' for 'android.hardware.vibrator@1.0::IVibrator/default' from pid: 1685 (/system/bin/hwservicemanager)
[ 27.332096] init: Could not find service hosting interface android.hardware.vibrator@1.0::IVibrator/default
[ 27.342317] init: Received control message 'interface_start' for 'android.hardware.vibrator@1.0::IVibrator/default' from pid: 1685 (/system/bin/hwservicemanager)
[ 27.356932] init: Could not find service hosting interface android.hardware.vibrator@1.0::IVibrator/default
[ 27.367309] init: Received control message 'interface_start' for 'android.hardware.ir@1.0::IConsumerIr/default' from pid: 1685 (/system/bin/hwservicemanager)
[ 27.381624] init: Could not find service hosting interface android.hardware.ir@1.0::IConsumerIr/default
[ 27.407791] init: processing action (sys.sysctl.extra_free_kbytes=*) from (/init.rc:725)
[ 27.424139] init: Received control message 'interface_start' for 'android.hardware.vr@1.0::IVr/default' from pid: 1685 (/system/bin/hwservicemanager)
[ 38.968372] type=1400 audit(1574312336.156:32): avc: denied { dac_read_search } for pid=1846 comm="Binder:1846_1" capability=2 scontext=u:r:installd:s0 tcontext=u:r:installd:s0 tclass=capability permissive=1
[ 38.973122] init: Received control message 'interface_start' for 'android.hardware.oemlock@1.0::IOemLock/default' from pid: 1685 (/system/bin/hwservicemanager)
[ 38.988474] type=1400 audit(1574312388.664:33): avc: denied { dac_read_search } for pid=1713 comm="Binder:1713_3" capability=2 scontext=u:r:vold:s0 tcontext=u:r:vold:s0 tclass=capability permissive=1
[ 39.001237] init: Could not find service hosting interface android.hardware.oemlock@1.0::IOemLock/default
[ 61.190476] type=1400 audit(1574312388.664:33): avc: denied { dac_read_search } for pid=1713 comm="Binder:1713_3" capability=2 scontext=u:r:vold:s0 tcontext=u:r:vold:s0 tclass=capability permissive=1
[ 61.208394] type=1400 audit(1574312410.888:34): avc: denied { read } for pid=1712 comm="usb-update.sh" name="media_rw" dev="tmpfs" ino=8655 scontext=u:r:usb-update:s0 tcontext=u:object_r:mnt_media_rw_file:s0 tclass=dir permissive=1
[ 61.208567] audit: audit_lost=15 audit_rate_limit=5 audit_backlog_limit=64
[ 61.229117] type=1400 audit(1574312410.888:34): avc: denied { read } for pid=1712 comm="usb-update.sh" name="media_rw" dev="tmpfs" ino=8655 scontext=u:r:usb-update:s0 tcontext=u:object_r:mnt_media_rw_file:s0 tclass=dir permissive=1
[ 61.235811] audit: rate limit exceeded
[ 61.237875] init: Service 'usb-update' (pid 1712) exited with status 1
[ 61.256443] type=1400 audit(1574312410.888:35): avc: denied { open } for pid=1712 comm="usb-update.sh" path="/mnt/media_rw" dev="tmpfs" ino=8655 scontext=u:r:usb-update:s0 tcontext=u:object_r:mnt_media_rw_file:s0 tclass=dir permissive=1
[ 61.287681] type=1400 audit(1574312410.888:35): avc: denied { open } for pid=1712 comm="usb-update.sh" path="/mnt/media_rw" dev="tmpfs" ino=8655 scontext=u:r:usb-update:s0 tcontext=u:object_r:mnt_media_rw_file:s0 tclass=dir permissive=1
[ 61.308656] type=1400 audit(1574312410.888:36): avc: denied { getattr } for pid=2168 comm="usb-update.sh" path="/system/bin/toybox" dev="dm-0" ino=1371 scontext=u:r:usb-update:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1
[ 61.329989] type=1400 audit(1574312410.888:36): avc: denied { getattr } for pid=2168 comm="usb-update.sh" path="/system/bin/toybox" dev="dm-0" ino=1371 scontext=u:r:usb-update:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1
[ 61.351227] type=1400 audit(1574312410.888:37): avc: denied { execute } for pid=2168 comm="usb-update.sh" name="toybox" dev="dm-0" ino=1371 scontext=u:r:usb-update:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1
[ 61.371493] type=1400 audit(1574312410.888:37): avc: denied { execute } for pid=2168 comm="usb-update.sh" name="toybox" dev="dm-0" ino=1371 scontext=u:r:usb-update:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1
[ 61.391676] type=1400 audit(1574312410.888:38): avc: denied { read open } for pid=2168 comm="usb-update.sh" path="/system/bin/toybox" dev="dm-0" ino=1371 scontext=u:r:usb-update:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1
[ 81.762527] healthd: battery l=85 v=3 t=35.0 h=2 st=2 c=400 fc=4000000 cc=32 chg=a
[ 81.896850] healthd: battery l=85 v=3 t=35.0 h=2 st=2 c=400 fc=4000000 cc=32 chg=a

Thanks & Regards,

VinothS,

Regards,
Vinothkumar Sekar
0 Kudos
1 Solution
717 Views
vinothkumars
Senior Contributor III

Hi,

This is the final configuration and it's resolve the clean build issue,

1. give permissive to run the service

BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive

2. start the service from init

# Start the service
   start usb

 # Provide the root permission to the script
 exec - root root vendor -- /vendor/bin/usb.sh

 # start the usb service
 service usb /vendor/bin/usb.sh
 class main
 user root
 group root system
 disabled
 oneshot
 seclabel u:r:usb:s0

3. add in file context,

/vendor/bin/usb.sh       u:object_r:usb_exec:s0

4. Define sepolicy.

type usb, domain;
type usb_exec, exec_type, vendor_file_type, file_type;

init_daemon_domain(usb)

Thanks & Regards,

VinothS,

Regards,
Vinothkumar Sekar

View solution in original post

0 Kudos
4 Replies
718 Views
vinothkumars
Senior Contributor III

Hi,

This is the final configuration and it's resolve the clean build issue,

1. give permissive to run the service

BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive

2. start the service from init

# Start the service
   start usb

 # Provide the root permission to the script
 exec - root root vendor -- /vendor/bin/usb.sh

 # start the usb service
 service usb /vendor/bin/usb.sh
 class main
 user root
 group root system
 disabled
 oneshot
 seclabel u:r:usb:s0

3. add in file context,

/vendor/bin/usb.sh       u:object_r:usb_exec:s0

4. Define sepolicy.

type usb, domain;
type usb_exec, exec_type, vendor_file_type, file_type;

init_daemon_domain(usb)

Thanks & Regards,

VinothS,

Regards,
Vinothkumar Sekar

View solution in original post

0 Kudos
717 Views
vinothkumars
Senior Contributor III

Hi,

Still I am facing the same problem. After clean build service crashed and Android boot also stopped, what was the issue. I need some general information about this.

Thanks & Regards,

VinothS,

Regards,
Vinothkumar Sekar
0 Kudos
717 Views
diegoadrian
NXP Employee
NXP Employee

Hello,

Unfortunately, the custom services are out of our scope of support. Furthermore, you are using a product that is still in pre-production. I have found the following, hope it could be useful for you.

Descripción general de los servicios  |  Android Developers 

I apologize for the inconvenience this may give you.

Best regards,

Diego.

0 Kudos
717 Views
vinothkumars
Senior Contributor III

Thank you Diego.

Thanks & Regards,

VInothS,

Regards,
Vinothkumar Sekar
0 Kudos