Skip to main content

The Startups : Init

Things start up from init.rc. 

If you are interested in learning init language check this link
https://android.googlesource.com/platform/system/core/%2B/master/init/README.md

In stock AOSP this is present in /sytem/core/roodir/
  • This imports : import /init.${ro.zygote}.rc 
    • Based on you devices ro.zygote system property the init.zygote file from the same folder is imported.
init.${ro.zygote}.rc : looks something like..

service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
        When asked to start; run zygote program by running "/system/bin/app_process". The remaining part is arguments to app_process
    class main
            Adds this to main class; So this service would be started whenever this class is started.
      socket zygote stream 660 root system
             Create a zygote socket
        onrestart write /sys/android_power/request_state wake
        onrestart write /sys/power/state on
              When this service is restarted write these values...
          onrestart restart media
          onrestart restart netd
                Restart following services too
            writepid /dev/cpuset/foreground/tasks
                  Write new pid to following path
              In the init.rc file you would see the main class being started on the following actions
                      on property:vold.decrypt=trigger_restart_min_framework
                              class_start main
              on nonencrypted
              class_start main

              etc..
              or reset on
                 on property:vold.decrypt=trigger_reset_main
                        class_reset main
                 on property:vold.decrypt=trigger_shutdown_framework
                        class_reset main

              etc..

              The zygote service can also be restarted if they are marked for restart by some other srvices like...
              service servicemanager /system/bin/servicemanager
              service surfaceflinger /system/bin/surfaceflinger

              etc..(So if service manager or surface flinger dies and rrestars the zygote would also restart)

              P.S Things might vary based on the init.rc files on different devices.

              Comments