Commit graph

1414 commits

Author SHA1 Message Date
Dan Shi
e5928b4760 Merge "Add test config to init_tests" 2017-04-04 15:54:44 +00:00
Yongqin Liu
246e3c4c7c init: use read_file and write_file to implement do_copy builtin
this will make the implementation more cleaner,
and has error message output when failed on some operations

also add the O_TRUNC flag explicitly for the open function
called in write_file.

And add more test on read_file and write_file functions

Bug: 36726045
Test: manual with hikey
Test: boot and init tests on bullhead
Test: cast with fugu, per b/36726045

Change-Id: If3c30a2fff58cfece2fcd27e69c30382146e6808
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
2017-04-03 21:33:59 -07:00
Martijn Coenen
c04403fb6e Merge "Restorecon new vndservice_contexts file." into oc-dev
am: 6c2b3e5fd8

Change-Id: Ida2184388171b5d5febd61cd7d6159c3b958d6a9
2017-04-04 03:51:27 +00:00
Martijn Coenen
6c2b3e5fd8 Merge "Restorecon new vndservice_contexts file." into oc-dev 2017-04-04 03:41:48 +00:00
Tom Cherry
16d14d73a6 Merge "init: Use std::string for write_file()" am: 815578cef2 am: 5ff631620e
am: 5981eae421

Change-Id: I3259e0cc0af1079efd9d8a267e6aaeb34c74695c
2017-04-04 02:42:58 +00:00
Treehugger Robot
815578cef2 Merge "init: Use std::string for write_file()" 2017-04-04 02:21:55 +00:00
Christopher Desjardins
def2097993 Merge "Make ueventd error messages indicate where the error is in ueventd script" am: fd72bbe91f am: ec2fb683ff
am: 98900f582b

Change-Id: Ia8efa2fe05da73795e4411d2b16dcaf9813f7b30
2017-04-04 00:04:09 +00:00
TreeHugger Robot
49ab678930 Merge "add shutdown animation" into oc-dev 2017-04-03 23:51:41 +00:00
Treehugger Robot
fd72bbe91f Merge "Make ueventd error messages indicate where the error is in ueventd script" 2017-04-03 23:50:31 +00:00
Tom Cherry
53089aa25c init: Use std::string for write_file()
The content parameter of write_file() previously took a char* that was
then converted to a std::string in WriteStringToFd().  One unfortunate
effect of this, is that it is impossible to write data that contains
'\0' within it, as the new string will only contain characters up
until the '\0'.

This changes write_file() to take an std::string, such that
std::string::size() is used to determine the length of the string,
allowing it to contain null characters.

Also change the path parameter of read_file() and write_file() for
consistency.

Lastly, add a test for handling strings with '\0' in them.

Bug: 36726045
Test: Boot bullhead, run unit tests
Change-Id: Idad60e4228ee2de741ab3ab6a4917065b5e63cd8
2017-04-03 16:41:22 -07:00
Christopher Desjardins
7d3e2c4d4e Make ueventd error messages indicate where the error is in ueventd script
Test: Boot bullhead
Test: Observe errors with file and line number with faulty ueventd.rc

Change-Id: Ieae6151e253f1e6437dfdebd14da4e1e04a45fae
2017-04-03 22:20:55 +00:00
Keun-young Park
33af57e331 Merge "add shutdown animation" am: 8aae1b158a am: e15756a604
am: 8aebd47ca5

Change-Id: I33963010e5402b123510df5e4a63fa85e72b10c4
2017-04-03 19:41:27 +00:00
Keun-young Park
c50b39994d add shutdown animation
- Run shutdown animation during shutdown if surfaceflinger is
  available / running.
- services necessary for animation should be added to animation
  class.
- Keep debugging tools while non-critical services are terminated:
  logd, adbd, tombstoned

bug: 36526187
Test: many reboots

(cherry picked from commit 7830d59500)

Change-Id: I83011e3f843e6b64c56c453a996db738f497877a
2017-04-03 12:38:01 -07:00
Martijn Coenen
7c1e0d84ab Restorecon new vndservice_contexts file.
Bug: 36052864
Test: boots
Change-Id: Ib0a5904ffb8ed2d865ab85adbf4cdefd52e6a27d
2017-04-03 11:08:58 -07:00
Keun-young Park
7830d59500 add shutdown animation
- Run shutdown animation during shutdown if surfaceflinger is
  available / running.
- services necessary for animation should be added to animation
  class.
- Keep debugging tools while non-critical services are terminated:
  logd, adbd, tombstoned

bug: 36526187
Test: many reboots

Change-Id: I758f700a622c6005f3df9f29de2b55270055ad4d
2017-03-31 16:48:20 -07:00
James Hawkins
9bc5c6cd8c Merge "bootstat: Refactor init/utils/boot_clock into base/chrono_utils." am: bc9cb3885b am: 904e8e90a5
am: ea15338c50

Change-Id: I9feb42083a3de7c606e52eb65ed27107345f637a
2017-03-31 20:59:03 +00:00
James Hawkins
bc9cb3885b Merge "bootstat: Refactor init/utils/boot_clock into base/chrono_utils." 2017-03-31 20:47:09 +00:00
Janis Danisevskis
650d22bb53 Make init builtin command installkey respect property updates
init used to block on installkey such that it was unable to
process property events. This lead to a deadlock by which
the Keymaster HAL would wait indefinitely for the
hwservicemanager.ready=true.

This fixes the issue by implementing the builtin in terms of
do_exec, which allows init to stay responsive to properties
while waiting for the child to terminate.

Bug: 36278706
Test: Add a 3s delay into hwservicemanager before it sets the property
      hwservicemanager.ready and the device still boots.

(cherry picked from commit 9cc51728af)

Change-Id: Ia241059d95c610ab01a314969ba23c003333bbba
2017-03-31 09:58:25 -07:00
Tom Cherry
1b8715541f Merge "Make init builtin command installkey respect property updates" am: cf29755e28 am: e58af94ba8
am: 32d30011f5

Change-Id: I3c8bf903f0149d0e58f697320b9311b9460e554f
2017-03-31 16:47:33 +00:00
Tom Cherry
cf29755e28 Merge "Make init builtin command installkey respect property updates" 2017-03-31 16:41:02 +00:00
Wonsik Kim
3428d0c2c0 Merge "Revert "init: use read_file and write_file to implement do_copy builtin"" 2017-03-31 00:22:00 +00:00
Wonsik Kim
395e29472f Revert "init: use read_file and write_file to implement do_copy builtin"
This reverts commit 82bac0de6d.

Change-Id: Ibfdf453bd85ba4fcd1948b78bd22e639a883653e
2017-03-31 00:18:13 +00:00
Wonsik Kim
281531bdcb Revert "init: use read_file and write_file to implement do_copy builtin"
Bug: 36726045
Test: gts-tradefed run gts --abi x86 -m GtsMediaTestCases -t com.google.android.media.gts.MediaCodecCencTest#testCENC_DASH_FMP4_H264_360P_PLAYREADY_CENC
This reverts commit 82bac0de6d.

Change-Id: I3b754f429499daec804a0ad25529294216c39a40
2017-03-30 17:15:17 -07:00
James Hawkins
e78ea77f69 bootstat: Refactor init/utils/boot_clock into base/chrono_utils.
Use this for bootstat and init. This replaces the custom uptime parser in
bootstat.

This is a reland of aosp/338325 with a stubbed implementation for Darwin.

This change also has clang_format fixes (automatic).

Bug: 34352037
Test: chrono_utils_test
Change-Id: I72a62a3ca1ccfc0a4ccc6294ff1776c263144686
2017-03-30 14:24:12 -07:00
Keun-young Park
e41bf08f56 send SIGTERM only once
- Processes capturing SIGTERM signal will not terminate and
  killProcessGroup will timeout after retry. This gives 200ms
  of waiting per such process. Change it to retry only once as
  SIGTERM will keep failing for such process.

bug: 36696408
Test: check time spent in SIGTERM for reboot

(cherry picked from commit 506cb020c8ab080a6765b8300c84d751557ef744)

Change-Id: If080ae3aa00f1614b25cc3f673eeb70c9713ef6e
2017-03-30 14:17:18 -07:00
Keun-young Park
54df8375ba set zero shutdown timeout for eng build
- still it will take time to kill services, < 3 secs in tested device.

bug: 36678028
Test: reboot

(cherry picked from commit 56425ed87e1ad7c63437d67c3b17ed7e2ba8d340)

Change-Id: I75b5843b08cdcdbf67c4fe500aa0dd7302dd44d7
2017-03-30 14:13:42 -07:00
Treehugger Robot
9ead7c4a74 Merge "send SIGTERM only once" 2017-03-30 04:10:41 +00:00
Janis Danisevskis
9cc51728af Make init builtin command installkey respect property updates
init used to block on installkey such that it was unable to
process property events. This lead to a deadlock by which
the Keymaster HAL would wait indefinitely for the
hwservicemanager.ready=true. 

This fixes the issue by implementing the builtin in terms of 
do_exec, which allows init to stay responsive to properties 
while waiting for the child to terminate.

Bug: 36278706
Test: Add a 3s delay into hwservicemanager before it sets the property
      hwservicemanager.ready and the device still boots.

Change-Id: Iaefd31156ca01f3a44b4f85a8bf78beee8dfe224
2017-03-30 00:11:48 +00:00
Keun-young Park
acd55b39fe send SIGTERM only once
- Processes capturing SIGTERM signal will not terminate and
  killProcessGroup will timeout after retry. This gives 200ms
  of waiting per such process. Change it to retry only once as
  SIGTERM will keep failing for such process.

bug: 36696408
Test: check time spent in SIGTERM for reboot
Change-Id: I9b0843614598dd3f97a50b21352046297ed70b6b
2017-03-29 16:33:25 -07:00
TreeHugger Robot
5f12c799a5 Merge changes from topic 'update-verified-priority-bump' into oc-dev
* changes:
  init.rc: launch update_verifier with exec_start
  init: replace property_get with its android::base equivalent
  init: remove unused cutils includes
  init: add exec_start command
2017-03-29 23:12:22 +00:00
Sandeep Patil
7ef60b4ed4 init: consolidate restorecon after selinux initialization in single function
Test: Boot sailfish
Change-Id: I423028f12a84c4e0c12c9bdde52b6d795d45b620
(cherry picked from commit 74df5bab16)
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-03-29 16:01:31 -07:00
Tom Cherry
e249097f6d init: replace property_get with its android::base equivalent
Slowly try to decouple property_service.cpp from the rest of init.

Test: Boot bullhead
Change-Id: I267ae0b057bca0bf657b97cb8bfbb18199282729
(cherry picked from commit ccf23537ee)
2017-03-29 13:34:56 -07:00
Tom Cherry
af5102a4f0 init: remove unused cutils includes
Test: Boot bullhead
Change-Id: I629f9c3863f00fa38f87a68442c2380d28764718
(cherry picked from commit 1ec1bd918c)
2017-03-29 13:34:52 -07:00
Tom Cherry
2d80467165 init: add exec_start command
Exec services may also want to set other service flags such as
priority.  Instead of expanding the exec syntax to handle this, create
a new command, exec_start, that will treat an existing service
definition as an exec service.  The new exec_start command will start
the service then halt init from executing further commands until the
service has exited.

This change additionally encapsulates the waiting_for_exec logic into
ServiceManager and removes the ambiguous 'bool' return value from
Reap() which previously indicated if a Reaped service was an exec
service or not.

Bug: 36511808
Bug: 36102163
Test: Bullhead boots, services run with exec_start as they do exec.

Change-Id: I44f775cf1c1dd81d5c715f44fdc150c651a2c80a
(cherry picked from commit b27004aa05)
2017-03-29 13:34:48 -07:00
Keun-young Park
c4ffa5c47d set zero shutdown timeout for eng build
- still it will take time to kill services, < 3 secs in tested device.

bug: 36678028
Test: reboot
Change-Id: I3f3eb83aede8cd950da12e3fcc259eeaf8517c3b
2017-03-29 12:25:33 -07:00
Treehugger Robot
8772b3686e Merge changes from topic 'exec-start-update-verifier'
* changes:
  init.rc: launch update_verifier with exec_start
  init: add exec_start command
2017-03-29 18:39:32 +00:00
Sandeep Patil
f5b99d4fe2 init: explicitly label all selinux files in rootfs
With system and vendor split, the files under them get labelled
differently as part of b/36527360. These files also include selinux
policy files if the policy is split. In order to consistently label
them, all sepolicy files on rootfs also are labelled with labels
matching to that of the ones in system and vendor. So, this now requires
init to explicitly label *all* selinux files in rootfs after
initializing selinux.

Test: Boot angler and ensure servicemananger continues to work (uses
      /{plat,nonplat}_service_contexts).
Test: Sideloaded OTA to angler to ensure recovery continues to work.
Test: Launch and load a website in Chrome.
Test: Launch camera and take picture, record video.

Change-Id: I4134eae80b5b51f381b549eb18e604cf271f9eb5
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-03-29 10:33:41 -07:00
Sandeep Patil
74df5bab16 init: consolidate restorecon after selinux initialization in single function
Test: Boot sailfish
Change-Id: I423028f12a84c4e0c12c9bdde52b6d795d45b620
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-03-29 10:31:26 -07:00
Tom Cherry
ccf23537ee init: replace property_get with its android::base equivalent
Slowly try to decouple property_service.cpp from the rest of init.

Test: Boot bullhead
Change-Id: I267ae0b057bca0bf657b97cb8bfbb18199282729
2017-03-29 10:07:54 -07:00
Treehugger Robot
20e43a2f2c Merge "init: remove unused cutils includes" 2017-03-29 01:27:19 +00:00
Tom Cherry
1ec1bd918c init: remove unused cutils includes
Test: Boot bullhead
Change-Id: I629f9c3863f00fa38f87a68442c2380d28764718
2017-03-28 16:22:33 -07:00
Dan Shi
bdfd395e47 Add test config to init_tests
Details about test configs changes are tracked in doc
https://docs.google.com/document/d/1EWUjJ7fjy8ge_Nk0YQbFdRp8DSHo3z6GU0R8jLgrAcw/edit#

Bug: 35882476
Test: local test
Change-Id: Ia5ee3b99201e399aa880b77c01a84b6f6650607c
2017-03-27 23:23:11 -07:00
Treehugger Robot
8678872a00 Merge "init: add class_restart" 2017-03-28 04:22:47 +00:00
Treehugger Robot
deb23ba2c1 Merge "init: remove superfluous forward definitions" 2017-03-28 02:22:51 +00:00
Treehugger Robot
88d6b4af16 Merge "init: Fix README.md for writepid" 2017-03-28 01:07:50 +00:00
Tom Cherry
46b6c43b7c init: remove superfluous forward definitions
Test: Boot bullhead
Change-Id: I4a005616a825529bc2ad1b413e51b501f6407cbd
2017-03-27 17:55:37 -07:00
Tom Cherry
b27004aa05 init: add exec_start command
Exec services may also want to set other service flags such as
priority.  Instead of expanding the exec syntax to handle this, create
a new command, exec_start, that will treat an existing service
definition as an exec service.  The new exec_start command will start
the service then halt init from executing further commands until the
service has exited.

This change additionally encapsulates the waiting_for_exec logic into
ServiceManager and removes the ambiguous 'bool' return value from
Reap() which previously indicated if a Reaped service was an exec
service or not.

Bug: 36511808
Bug: 36102163
Test: Bullhead boots, services run with exec_start as they do exec.

Change-Id: I44f775cf1c1dd81d5c715f44fdc150c651a2c80a
2017-03-27 17:41:27 -07:00
Treehugger Robot
3c1568aa13 Merge "init: add support of multiple class names" 2017-03-28 00:39:09 +00:00
Keun-young Park
59cebb6e6f Merge "update shutdown sequence and use shutdown_timeout to cover all wait" 2017-03-27 22:27:30 +00:00
Wei Wang
641ff0a4d8 init: add support of multiple class names
Add support of multiple class names in service, so that related services
can be grouped together. By doing this, we can start/stop some services
for special purpose. For example, early zygote, early boot animation
and etc.

Bug: 36535312
Test: marlin boots with defined classes
Change-Id: Ifeaaf034fd836816e24f3775bece53ea83faada6
2017-03-27 20:59:05 +00:00