Commit graph

54018 commits

Author SHA1 Message Date
Tom Cherry
1a75a8cd4b liblog: remove memset() before recv().
This is unneeded, since we're already checking the length returned by
recv() and log_msg that is read for validity.

It costs ~4% of CPU with `logcat -s` and ~2% of CPU when running
simpleperf for 1 second on walleye on master.

Bug: 144311420
Test: logcat works, simpleperf doesn't show memset() costing as much.
Change-Id: I986e7e96518774034340f1b1201a2071a904e3bb
2019-11-19 10:10:37 -08:00
Tom Cherry
7d16aedc47 Merge "liblog: simplify logd 'command' functions and struct logger" 2019-11-18 21:47:16 +00:00
Treehugger Robot
fe983b6681 Merge "ziptool: fix unknown long options." 2019-11-18 15:47:59 +00:00
Tom Cherry
9156c534e0 liblog: simplify logd 'command' functions and struct logger
There are a set of functions, such as android_logger_get_log_size()
and android_logger_get_prune_list() that talk to the logd command
socket to perform their activities.  There's a transport abstraction
layer that handles these symbols to optionally route them to other
transports, originally designed for pstore or local logger; however
these functions fundamentally only make sense for logd.

Ideally, these functions would be removed and new functions would be
added that do not depend on struct logger_list or struct logger and
more clearly indicate that they only work with logd.  For example:

android_logger_get_size(struct logger*) could be
logd_get_buffer_size(log_id_t log_id).  We would remove the need to
'open' the struct logger and make it clear that it only operates on
logd.

Since liblog is an llndk library however, we cannot change or remove
these symbols.  Since these symbols are not frequently used, it seems
acceptable to keep them as is and not introduce improved versions.
We, however, do want to simplify the code that handles them and this
change removes the transport abstraction layer that handles them.
They retain the behavior that unless the struct logger_list was opened
for logd, that the functions return -EINVAL.

The one exception to this is android_logger_clear().  If the struct
logger provided to this function was opened from a struct logger_list
that used pstore for its mode argument, this function will clear the
entire pstore log.  This function does not respect the 'logId'
parameter of the struct logger, since that would not be possible.

This change removes this android_logger_clear() behavior and makes it
strictly for logd, for symmetry with the rest of the functions and due
to the lack of clarity regarding the 'logId' parameter of its input.
The only caller of this function, logcat, will clear pstore directly.

struct logger was built to encapsulate the information needed to
connect to a logger device from the old kernel logger.  Now that we
only support reading from pstore and from logd, there is much less
information needed to be captured.  Specifically, we only need to know
the log_id and whether or not it was opened as part of a pstore or
logd 'list'.

Test: liblog-unit-test
Test: logcat -c/-g/-G/-p/-P/-S work
Test: logcat -c works with -L
Test: logcat -g/-G/-p/-P/-S continue to fail with -L
Change-Id: I2c549b6f8539de94510e223949ab209ecc40e2d0
2019-11-18 07:16:40 -08:00
Tom Cherry
c9c8318db6 Merge "liblog: return 0 from android_logger_list_read() when recv() returns 0" 2019-11-18 14:37:54 +00:00
Elliott Hughes
2ab5a70b9f ziptool: fix unknown long options.
Previously an unknown long option would cause a crash as we ran off the
end of the array.

Test: `ziptool unzip --unknown`
Change-Id: I7a7b6ac4a0fa157c111f936e837c20143cef9e28
2019-11-16 11:18:50 -08:00
Tom Cherry
b8bacea818 liblog: return 0 from android_logger_list_read() when recv() returns 0
We used to do this, but it got lost while refactoring this code.

Bug: 144311420
Test: we see "unexpected EOF!" instead of "unexpected length" from logcat
Change-Id: I7858d0a774a9eac63e5547ee67e85ef8fb0c682d
2019-11-15 16:48:01 -08:00
Nikita Ioffe
dc4bd2714c Merge "Add a very basic userspace reboot watchdog" 2019-11-15 15:21:19 +00:00
David Anderson
a487793fc7 Merge "libsnapshot: Add a helper for handling data wipes in recovery." 2019-11-15 04:27:59 +00:00
Tom Cherry
bc1d0b09cc Merge "init: make CheckPropertyTriggers() more efficient" 2019-11-14 23:37:30 +00:00
Nikita Ioffe
82a431eb2f Add a very basic userspace reboot watchdog
Watchdog is just a forked process that is going to fall back to the
full reboot in case device wasn't able to boot in given amount of time.

Currently this amount is hard-coded to 1 minute, but in the future it
will be controlled by a read-only property.

Also added sync calls before and after tearing down services.

Test: adb reboot userspace
Bug: 135984674
Change-Id: Ie6053c9446a6761deae6dc104036bb35b09ef0e2
2019-11-14 23:10:54 +00:00
Tom Cherry
2ebe95ff2a Merge "liblog: cleanup opaque type usage" 2019-11-14 23:07:09 +00:00
Nikita Ioffe
c5282e4c6b Merge "Add sysprops for start & end of userspace reboot" 2019-11-14 21:50:59 +00:00
Tom Cherry
828db1a901 liblog: cleanup opaque type usage
There's a lot of unnecessary boilerplate around these opaque types,
and this change simplifies it.

Test: liblog-unit-tests
Change-Id: I0c4e133037fd5f04157ac22175181a6a496e18c4
2019-11-14 10:40:42 -08:00
Tom Cherry
1efc4849d7 init: make CheckPropertyTriggers() more efficient
Previously CheckPropertyTriggers() tried to do the entire property
triggers check with one loop.  However, that would require calling
GetProperty() on all properties for all triggers just in case the
property that is being set is used by a given trigger.

This change first checks that the property being set exists in each
trigger and that its value is set such that the trigger would be
triggered, only then does it check that other property triggers are
set to the right value.

Bug: 143922756
Test: boot
Test: substantially fewer GetProperty() calls from
      CheckPropertyTriggers()

Change-Id: I0228cf47328b31963eaf3fc689fb60f711532df4
2019-11-14 09:19:07 -08:00
Tianjie Xu
bace5995f1 Merge "Handle the reboot in the recovery user mode" 2019-11-14 05:03:03 +00:00
Treehugger Robot
afce590601 Merge "fastbootd: exporting CPU ABI info" 2019-11-14 04:51:37 +00:00
Treehugger Robot
e40d2b1a84 Merge "Add support for freezer cgroup" 2019-11-14 01:42:55 +00:00
Nikita Ioffe
c0df1874ad Add sysprops for start & end of userspace reboot
There will be useful in debugging/logging events to statsd.

Also as part of this CL, sys.init.userspace_reboot.in_progress property
is now used as a mean of synchronization. It is set directly in
DoUserspaceReboot, to make sure that all the setprop actions triggered
by userspace-reboot-requested were processed.

Test: adb reboot userspace
Test: adb shell getprop sys.init.userspace_reboot.last_started
Test: adb shell getprop sys.init.userspace_reboot.last_finished
Bug: 135984674
Change-Id: I9debcd4f058e790855200d5295344dafb30e496a
2019-11-14 01:38:05 +00:00
Tianjie Xu
b6d7ea15b7 Handle the reboot in the recovery user mode
We have switched to "/system/bin/reboot" to perform the reboot. But
accessing the shell for user build under recovery is not allowed by
sepolicy. So adding a special routine to handle this reboot case.

Bug: 141247819
Test: run `adb reboot` in user mode recovery
Change-Id: Ia37438e52c67fd2bd54e923a0fea5817a1455a08
2019-11-13 14:23:09 -08:00
Treehugger Robot
8e2f75e319 Merge "libziparchive: fix -Wimplicit-int-float-conversion" 2019-11-13 22:21:38 +00:00
Treehugger Robot
b34291bcb6 Merge "init: make triggering shutdown from vendor_init better" 2019-11-13 21:59:38 +00:00
Nick Desaulniers
4e7507ffc2 libziparchive: fix -Wimplicit-int-float-conversion
The value of uncompressed may not be precisely representable when
implicitly casted to an IEEE 754 single precision float.

Assuming the code doesn't need a precise compression ratio, accept the
potential imprecision via explicit cast.

system/core/libziparchive/unzip.cpp:114:68: error: implicit conversion
from 'int64_t' (aka 'long') to 'float' may lose precision
[-Werror,-Wimplicit-int-float-conversion]
  return static_cast<float>(100LL * (uncompressed - compressed)) / uncompressed;
                                                                 ~ ^~~~~~~~~~~~

Change-Id: If46cfa4eb2bb16a7491e52bb5d1c212ed5d59079
Bug: 139945549
Test: lunch hikey960-userdebug && mm
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-11-13 13:04:22 -08:00
Tom Cherry
18278d2e9c init: make triggering shutdown from vendor_init better
Previously, we assumed that TriggerShutdown() should never be called
from vendor_init and used property service as a back up in case it
ever did.  We have since then found out that vendor_init may indeed
call TriggerShutdown() and we want to make it just as strict as it is
in init, wherein it will immediately start the shutdown sequence
without executing any further commands.

Test: init unit tests, trigger shuttdown from init and vendor_init
Change-Id: I1f44dae801a28269eb8127879a8b7d6adff6f353
2019-11-13 12:41:34 -08:00
Marco Ballesio
726a68cb40 Add support for freezer cgroup
Adds the freezer cgroup to process groups

Change-Id: Ib7a8dbe776ff156ff3827b9a659365384f3e6ac8
Bug: 143308662
Test: manual - frozen processes aren't scheduled for execution until
unfrozen
2019-11-13 20:21:07 +00:00
Tom Cherry
e91c76b210 Merge "init: check property type in host_init_verifier" 2019-11-13 18:41:17 +00:00
Treehugger Robot
02359c6d96 Merge "Use PLOG and TEMP_FAILURE_RETRY for uevent socket errors" 2019-11-13 16:50:46 +00:00
Elliott Hughes
2ba8c4b0af Merge "Ignore nullptr in native_handle_close()." 2019-11-13 16:04:22 +00:00
Tom Cherry
edad2bf9b6 Use PLOG and TEMP_FAILURE_RETRY for uevent socket errors
Use TEMP_FAILURE_RETRY() for recvmsg() to prevent failing
unnecessarily from EINTR.  Use PLOG(ERROR) in ueventd to display the
actual error if reading from the uevent socket does fail.

Test: build
Change-Id: I64a22698ce6ffc7573f75b57803551c7b6940e30
2019-11-13 07:21:42 -08:00
Tom Cherry
47cdf6c078 Merge "Move init and ueventd scripts from / to /system/etc" 2019-11-13 14:36:47 +00:00
Bowgo Tsai
33da5c9493 fastbootd: exporting CPU ABI info
CPU ABI info, e.g., arm64-v8a, can be useful to determine image
compatibility, prior to flash. Adding this info in fastbootd.

Bug: 74445765
Test: fastboot getvar cpu-abi # arm64-v8a
Change-Id: Ied494b646c551320295956b7890c0102fdb88382
2019-11-13 17:22:22 +08:00
Treehugger Robot
563a73e7f7 Merge "Rename # vndk tag to # llndk" 2019-11-13 06:36:36 +00:00
Jiyong Park
b2542d2942 Rename # vndk tag to # llndk
The APIs that are tagged with # vndk are actually for LLNDK libraries.
Although LLNDK is part of VNDK, calling those APIs 'vndk' has given
users a wrong perception that the APIs don't need to be kept stable
because that's the norm for most of the VNDK libraries that are not
LLNDK.

In order to eliminate the misunderstanding, rename the tag to 'llndk' so
that people introducing new such API will realize what they are signing
themselves up for.

Bug: 143765505
Test: m
Merged-In: Iae2acdf1ff4097a64a5c6280797c66abb1d5a5e6
(cherry picked from commit 0e957b82c8)
Change-Id: Iae2acdf1ff4097a64a5c6280797c66abb1d5a5e6
2019-11-13 14:32:44 +09:00
Elliott Hughes
7e42484610 Ignore nullptr in native_handle_close().
Just like native_handle_delete().

Bug: http://b/143898343
Test: new test
Change-Id: I373067aa6c2b03548b218c7011bdbf23bd71f260
2019-11-12 20:23:55 -08:00
Treehugger Robot
46f9698a11 Merge "libsparse: fix memory leak in output_file_close()" 2019-11-13 02:05:22 +00:00
Treehugger Robot
08c9ceaef8 Merge "unzip/zipinfo: use float percentages like the RI." 2019-11-12 23:27:28 +00:00
Elliott Hughes
008759711f unzip/zipinfo: use float percentages like the RI.
Test: my new test runner, specifically developed for ziptool
Change-Id: I1237d02daaf2939eebc4fd5ec19ccdd0de291ad5
2019-11-12 13:53:43 -08:00
Raman Tenneti
5fff3877a1 Merge "Revert "Delay initial accept() until server initialized"" 2019-11-12 18:58:32 +00:00
Raman Tenneti
b71b5af783 Revert "Delay initial accept() until server initialized"
This reverts commit 4ad4a11aa8.

Reason for revert: BUG: 144355953

Change-Id: Icb3d87e1f697ff60fc1262798cb19be8705e3740
2019-11-12 18:57:51 +00:00
Raman Tenneti
6657c5d71f Merge "Revert "Support socket activation of adb server"" 2019-11-12 18:56:27 +00:00
Raman Tenneti
c77904e3c5 Revert "Support socket activation of adb server"
This reverts commit 4456b5fc15.

Reason for revert: Device boot failure BUG: 144355953

Change-Id: I539400fa2422bd4d6e396634c629a928cd2ac398
2019-11-12 18:55:29 +00:00
Raman Tenneti
0117aabea0 Merge "Revert "fix 'adb shell'"" 2019-11-12 18:54:27 +00:00
Raman Tenneti
4932ada048 Revert "fix 'adb shell'"
This reverts commit cc6d793310.

Reason for revert: Device boot failure. Conflicts while reverting dancol's CL.

Change-Id: Ic6929f20a60369b6f88f3caa22258e52d700f485
2019-11-12 18:52:12 +00:00
Tom Cherry
b5f2ec06f5 init: check property type in host_init_verifier
We have all of the 'type' information for properties available during
build time, so let's check this when setting properties in init.

Test: setprop apexd.status bad results in:
host_init_verifier: Command 'setprop apexd.status bad'
(out/soong/.intermediates/system/core/rootdir/init.rc/android_x86_core/init.rc:927)
failed: Property type check failed, value doesn't match expected type
'enum starting ready'
host_init_verifier: Failed to parse init script
'out/soong/.intermediates/system/core/rootdir/init.rc/android_x86_core/init.rc'
with 1 errors
Test: CF builds without that error

Change-Id: Iaad07747c09f4a10b2b816c455d6e8a485357ab9
2019-11-12 10:19:21 -08:00
Maciej Żenczykowski
1d284004af Merge "fix 'adb shell'" 2019-11-12 12:16:24 +00:00
Maciej Żenczykowski
cc6d793310 fix 'adb shell'
fcntl uses FD_CLOEXEC not O_CLOEXEC

Test: adb shell now works on cuttlefish
Bug: 144313654
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5dbac5a46cbc9d24f8622076a3a553028ba648db
2019-11-12 04:09:07 -08:00
Robin Hsu
48c9f6196f libsparse: fix memory leak in output_file_close()
Fix memory leak in output_file_close():
Arguable whose resposibility to free structs allocated inside a file
struct (the caller or the library function), but the following protocol
(i.e. this fix) would better prevent memory leaks:
1) output_file_close() function will free those structs inside a file struct,
   right before closing the file.
   * Note: those structs are originally allocated by other libsparse function.
2) If the caller wants to clean up those struct inside a file struct,
   it may.  Just free those structs, and set the pointer to NULL.
   Afterward, when file_close()'s are called, they won't be free'ed twice.

Bug: 142483439
Test: verified by script MemLeak_LastCmd.sh (attached in Bugnizer)
Change-Id: I8bb9f7c9f7d19268663e2830d1a90d27bd5f99bd
Signed-off-by: Robin Hsu <robinhsu@google.com>
2019-11-12 18:52:29 +08:00
Treehugger Robot
d9381651ee Merge "Delay initial accept() until server initialized" 2019-11-12 03:45:51 +00:00
Daniel Colascione
d7052824d4 Merge "Support socket activation of adb server" 2019-11-12 02:27:02 +00:00
Treehugger Robot
a8f3081663 Merge "libcutils: remove unused socket_set_receive_timeout()." 2019-11-11 17:03:37 +00:00