9
Android Init et. al Ron Munitz - android-4.4_r1 (.a.k.a “KitKat”)

Android Init Process Gotchas (AnDevCon SF 2013, and several other talks)

Embed Size (px)

Citation preview

Page 1: Android Init Process Gotchas (AnDevCon SF 2013, and several other talks)

Android Init et. al Ron Munitz - android-4.4_r1 (.a.k.a “KitKat”)

Page 2: Android Init Process Gotchas (AnDevCon SF 2013, and several other talks)

The init call graph

init init.rc

init.environ.rc

init.<anboot.hw>.rc

import /init.environ.rc - env. variables

import /init.usb.rc - USB configuration - defines Android as the slave on the USB bus - with some mode switching options

import /init.${ro.hardware}.rc - androidboot.hardware

import /init.trace.rc - system wide tracing to the kernel trace buffer

init

Kernel/init/main.c

system/core/init

system/core/rootdir

device/vendor/product/init.hw.rc

init.usb.rc

init.trace.rc

Page 3: Android Init Process Gotchas (AnDevCon SF 2013, and several other talks)

system/core/initREAD: readme.txt

Page 4: Android Init Process Gotchas (AnDevCon SF 2013, and several other talks)

Syntax

● on <trigger> <do stuff>

● service <example> <path> <arguments> user <SomeUser_lets_say_root> group <SomeGroup_lets_say_system> class <start me with the rest of the class> oneshot

Page 5: Android Init Process Gotchas (AnDevCon SF 2013, and several other talks)

Gotcha’s

● Service name MUST not be too long!○ service the_most - OK! :) ○ service the_most_important_service_in_the_world - NOT :(

● Start services at appropriate times (class)● Beware of the critical option

○ 4 crashes in 4 minutes will cause device reboot● Watch for user/group● Unnamed class will assume “default”

Page 6: Android Init Process Gotchas (AnDevCon SF 2013, and several other talks)

Gotcha’s

● Service must be started○ service the_most - OK! :) ○ service the_most_important_service_in_the_world - NOT :(

● Start services at appropriate times (class)● Beware of the critical option

○ 4 crashes in 4 minutes will cause device reboot● Watch for user/group● Unnamed class will assume “default”

Page 7: Android Init Process Gotchas (AnDevCon SF 2013, and several other talks)

Debugging tips

● getprop is a life server○ getprop init.svc.<service_name> tells the status of

the service■ running, stopped,restarting

○ getprop init.action tells the action currently being executed

○ getprop init.command tells the command currently being executed

Page 8: Android Init Process Gotchas (AnDevCon SF 2013, and several other talks)

A note about the readme file

● There is no such thing as “init.conf”. They actually refer to “init.rc”.○ For example, “on boot” is the first trigger called

after the init process loaded the file init.rc

Page 9: Android Init Process Gotchas (AnDevCon SF 2013, and several other talks)

TutorialHello world native service

@see https://github.com/ronubo/AnDevCon/tree/master/aosp_kvm