{% include "_versions.html" %}
Android {{ androidPVersionNumber }} supports the dynamic shutdown of Android hardware subsystems when they are not in use or not needed. For example, when a user is not using Wi-Fi, the Wi-Fi subsystems should not be taking up memory, power, or other system resources. In earlier versions of Android, HALs/drivers were kept open on Android devices for the entire duration an Android phone was booted.Implementing dynamic shutdown involves wiring up data flows and executing dynamic processes as detailed in the following sections.
Dynamic shutdown requires information on which processes serve what HAL interfaces (this information may also be useful later in other contexts) as well as not starting processes on boot and not restarting them (until requested again) when they exit.
# some init.rc script associated with the HAL service vendor.some-service-name /vendor/bin/hw/some-binary-service # init language extension, provides information of what service is served # if multiple interfaces are served, they can be specified one on each line interface android.hardware.light@2.0::ILight default # restarted if hwservicemanager dies # would also cause the hal to start early during boot if oneshot wasn't set class hal # will not be restarted if it exits until it is requested to be restarted oneshot # will only be started when requested disabled # ... other properties
Dynamic shutdown also requires the hwservicemanager
to tell
init
to start requested services. In Android {{ androidPVersionNumber }},
init
includes three additional control messages (e.g.
ctl.start
): ctl.interface_start
,
ctl.interface_stop
, and ctl.interface_restart
.
These messages can be used to signal init
to bring up and down
specific hardware interfaces. When a service is requested and it is not
registered, hwservicemanager
will request the service to be
started.
Dynamic shutdown requires multiple policies for deciding when to start a
HAL and when to shutdown a HAL. If a HAL decides to exit for any reason, it
will automatically be restarted when it is needed again using the information
provided in the HAL definition and the infrastructure provided by changes to
init
and hwservicemanager
. This could involve a
couple of different strategies, including: