Do Android init property triggers always happen on boot and if so when exactly?

Do Android init property triggers always happen on boot and if so when exactly?



Documentation from Google on Android init at https://android.googlesource.com/platform/system/core/+/oreo-release/init/README.md says the following



An Action can have multiple property triggers but may only have one
event trigger.



For example: on boot && property:a=b defines an action that is only
executed when the ‘boot’ event trigger happens and the property a
equals b.


on boot && property:a=b



on property:a=b && property:c=d defines an action that is executed
at three times:


on property:a=b && property:c=d



In the first example the on boot trigger seems to be a necessary condition for the action to be executed at boot. However in the second example no on boot trigger is used yet the documentation says the action will still be executed on boot anyway.


on boot


on boot



So it seems only one of two statements is true:


property


property


boot



If the second statement is true then is it specifically the boot phase and not say late-init?


boot


late-init




1 Answer
1



I decided to just go ahead and run some tests. The evidence shows that the documentation is correct about what happens but lacking in detail as to why.



The first example on boot && property:a=b will execute during boot when init fires boot event. Note that not all properties are initialized at the same time and as such this may affect their availability during the various boot events. Also note that this example won't run when the property changes. The main confusion is that properties in init are both events and states, where as the init phases are only events.


on boot && property:a=b


boot



The second example runs during boot, but it is not related to the boot event! It runs when the property is first initialized at boot. Also as described it runs when either property changes to the declared value and the other property condition is true.


boot



Test results:


on boot
exec /system/bin/echo "Trigger test A"



Run when init fires "boot" event during boot


on late-init
exec /system/bin/echo "Trigger test B"



Run when init fires "late-init" event during boot


on property:persist.testing=1
exec /system/bin/echo "Trigger test C"



Run when property is loaded from filesystem persisted properties during boot, also runs when property transitions to the specified value


on boot && property:persist.testing=1
exec /system/bin/echo "Trigger test D"



Not run during boot process (persist property is not available at that time), does not run when the property transitions to the specified value


on post-fs-data && property:persist.testing=1
exec /system/bin/echo "Trigger test E"



Not run during boot process (persist property is not available at that time), does not run when the property transitions to the specified value


on property:ro.build.type=eng
exec /system/bin/echo "Trigger test F"



Run during boot process when this particular property is first loaded


on boot && property:ro.build.type=eng
exec /system/bin/echo "Trigger test G"



Run during boot process when init fires "boot" event (property was available at that time)


on post-fs-data && property:ro.build.type=eng
exec /system/bin/echo "Trigger test H"



Run during boot process twice when init fires "post-fs-data" event, once when data is mounted prior to decryption and once when data is mounted after decryption


on late-init && property:ro.build.type=eng
exec /system/bin/echo "Trigger test I"



Not run during boot process (property is not available at that time)



Historical evidence:


01-20 20:33:14.986 0 0 I init : processing action (late-init) from (/init.rc:270)
01-20 20:33:15.001 0 0 I init : starting service 'exec 1 (/system/bin/echo Trigger test B)'...
01-20 20:33:15.652 0 0 I init : processing action (post-fs-data) from (/init.rc:373)
01-20 20:33:15.841 0 0 I init : processing action (ro.build.type=eng && post-fs-data) from (/vendor/etc/init/hw/init.device.log.rc:69)
01-20 20:33:15.841 0 0 I init : starting service 'exec 11 (/system/bin/echo Trigger test H)'...
01-20 20:33:17.025 0 0 I init : processing action (boot) from (/init.rc:556)
01-20 20:33:17.250 0 0 I init : processing action (boot) from (/vendor/etc/init/hw/init.device.log.rc:48)
01-20 20:33:17.251 0 0 I init : starting service 'exec 14 (/system/bin/echo Trigger test A)'...
01-20 20:33:17.301 0 0 I init : processing action (ro.build.type=eng && boot) from (/vendor/etc/init/hw/init.device.log.rc:66)
01-20 20:33:17.301 0 0 I init : starting service 'exec 15 (/system/bin/echo Trigger test G)'...
01-20 20:33:17.361 0 0 I init : processing action (enable_property_trigger) from (<Builtin Action>:0)
01-20 20:33:17.386 0 0 I init : processing action (ro.build.type=eng) from (/vendor/etc/init/hw/init.device.log.rc:63)
01-20 20:33:17.388 0 0 I init : starting service 'exec 16 (/system/bin/echo Trigger test F)'...
01-20 20:33:19.272 0 0 I init : processing action (vold.decrypt=trigger_post_fs_data) from (/init.rc:671)
01-20 20:33:19.272 0 0 I init : processing action (post-fs-data) from (/init.rc:373)
01-20 20:33:19.495 0 0 I init : processing action (ro.build.type=eng && post-fs-data) from (/vendor/etc/init/hw/init.device.log.rc:69)
01-20 20:33:19.495 0 0 I init : starting service 'exec 21 (/system/bin/echo Trigger test H)'...
01-20 12:33:19.880 0 0 I init : processing action (persist.testing=1) from (/vendor/etc/init/hw/init.device.log.rc:54)
01-20 12:33:19.881 0 0 I init : starting service 'exec 24 (/system/bin/echo Trigger test C)'...
08-27 14:25:06.256 0 0 I init : processing action (persist.testing=1) from (/vendor/etc/init/hw/init.device.log.rc:54)
08-27 14:25:06.257 0 0 I init : starting service 'exec 29 (/system/bin/echo Trigger test C)'...






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)