• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ART Service internal doc
2
3Warning: The contents in this doc can become stale while the code evolves.
4
5## Pre-reboot Dexopt
6
7Pre-reboot Dexopt is a successor of otapreopt, available on Android V+.
8
9### On Mainline update
10
11On Mainline update, `ArtManagerLocal.onApexStaged` is called. The method
12schedules an asynchronous job and returns immediately. Later, when the device is
13idle and charging, the job will be run by the job scheduler.
14
15### On OTA update
16
17On Mainline update, the shell command `pm art on-ota-staged` is called. The
18behavior depends on the platform version and the configuration.
19
20- On Android V
21
22  By default, Pre-reboot Dexopt runs in synchronous mode from the postinstall
23  script while update_engine keeps the snapshot devices mapped. The command
24  blocks until Pre-reboot Dexopt finishes.
25
26- On Android V, with asynchronous mode enabled
27
28  The asynchronous mode can be enabled by
29  `dalvik.vm.pr_dexopt_async_for_ota=true`. In this case, the command schedules
30  an asynchronous job and returns immediately. Later, when the device is idle
31  and charging, the job will be run by the job scheduler. The job uses
32  `snapshotctl` to map snapshot devices.
33
34  Note that this mode has a risk of racing with update_engine on snapshot
35  devices. Particularly, if update_engine wants to unmap snapshot devices, to
36  revoke an OTA update, the job may be running and preventing update_engine from
37  successfully doing so.
38
39- On Android B+
40
41  Pre-reboot Dexopt is always in asynchronous mode. The command schedules an
42  asynchronous job and returns immediately. Later, when the device is idle and
43  charging, the job will be run by the job scheduler. The job will call
44  `UpdateEngine.triggerPostinstall` to ask update_engine to map snapshot
45  devices, and update_engine will call this command again with '--start' through
46  the postinstall script, to notify the job that the snapshot devices are ready.
47
48### On shell command
49
50Pre-reboot Dexopt can be triggered by a shell command `pm art pr-dexopt-job`.
51It is synchronous if called with `--run`, and is asynchronous if called with
52`--schedule`.
53
54Regardless of being synchronous or asynchronous, it always tries to map snapshot
55devices if called with `--slot`. On Android V, it does so through `snapshotctl`,
56and on Android B+, it does so through `UpdateEngine.triggerPostinstall`.
57