Commit Graph

58660 Commits

Author SHA1 Message Date
Elliott Hughes 884cedc770 Don't #include <utils/Debug.h> from <utils/Flattenable.h>.
It's not used, and shouldn't be used.

Also switch to `#pragma once`.

Test: treehugger
Change-Id: I464d3de1b0e1d536cea06362e6c73fddaad967d1
2020-08-17 10:14:16 -07:00
Tom Cherry 0398117a9a Merge "Reland: "liblog: use a blocking socket for sending messages to logd""" 2020-08-13 15:15:57 +00:00
Tom Cherry 7ef8bca1f9 Merge changes I40fe9b79,I4b6f8331
* changes:
  logd: SerializedLogBuffer: never wait for a reader during prune/clear
  logd: always wake 'wrapped' readers on prune
2020-08-12 22:44:42 +00:00
Tom Cherry 3932a9c074 logd: SerializedLogBuffer: never wait for a reader during prune/clear
Previously, chatty had logic that would skip a certain number of log
entries to satify pruning, but otherwise keep the reader connected.
This was a best-effort attempt at helping pruning and had additional
logic that handled further disruptions, if logd's memory was 2x the
allotted memory.

The new logic has two components:
1) memcpy() each individual log message in FlushTo() such that there
are no references to the underlying log data without a lock held.
Note, that this memcpy is completely negligible for performance.
2) In Prune(), immediately delete all log chunks required to reduce
memory to the allotted amount, which is now safe given 1).  If readers
will lose logs, continue to print a warning.

This additionally makes the Clear() logic deterministic.  It was
previously best effort in chatty, but will immediately and always
clear all logs for SerializedLogBuffer.

Bug: 163617910
Test: logging unit tests
Test: Prune() immediately frees buffers during high log pressure
Test: Clear() immediately frees buffers during high log pressure
Change-Id: I40fe9b791312af3dc256b166e5c34425f4ca51ac
2020-08-12 12:49:56 -07:00
Treehugger Robot 1173476551 Merge "Fix non-existent module error" 2020-08-12 19:49:18 +00:00
Treehugger Robot b9edfee8a2 Merge "charger: Avoid a couple string constructions" 2020-08-12 19:29:49 +00:00
Tom Cherry c5282c2121 Reland: "liblog: use a blocking socket for sending messages to logd""
This reverts commit b1eb731197.

Test: post-submit failure now passes
Change-Id: Iabbd18ad8403dd30aa07dd73e42fcc5b233b0222
2020-08-12 10:51:27 -07:00
Tom Cherry d0e8451d59 logd: always wake 'wrapped' readers on prune
See the comment in the code for more details.  'wrapped' readers are
uncommon and error prone, and this change makes them more reliable.
Its side effect is that wrapped readers will wake more often, but
they'll still be batched to a large degree.

Bug: 163617910
Test: logging unit tests
Test: logcat --wrap does the right thing
Change-Id: I4b6f8331ff7854787c97f821b2a5bf8d7da321c6
2020-08-12 10:42:44 -07:00
Tom Cherry 0df0fcbb9d Merge "logd: add a test that logd ignores SIGPIPE" 2020-08-12 17:18:57 +00:00
Yo Chiang 78ee4c1005 Fix non-existent module error
TARGET module init_vendor requires non-existent TARGET module: init_first_stage

Module `init_first_stage` is skipped (not defined) on ASAN builds.

Bug: 163802658
Test: TH
Change-Id: I5aa030dfaa59a21511a7112ff89f8a5d8b8dc735
2020-08-12 16:27:08 +00:00
Greg Kaiser 8763fd26fb charger: Avoid a couple string constructions
With a couple recent changes to APIs taking a const std::string&,
instead of a const char *, we switch to directly passing in a
reference to our string.

Test: TreeHugger
Change-Id: Id9f832dd5e3def28cfeaa0d3cda7da323332b16c
2020-08-12 07:03:50 -07:00
Treehugger Robot 546cf270ab Merge "Add failure logs in __ashmem_open_locked()" 2020-08-11 23:04:28 +00:00
Tom Cherry cadeec102c Merge "Revert "liblog: use a blocking socket for sending messages to logd"" 2020-08-11 22:17:41 +00:00
Tom Cherry b1eb731197 Revert "liblog: use a blocking socket for sending messages to logd"
This reverts commit 4af349b072.

Reason for revert: post submit test logs too much fails after this
Bug: 163611679

Change-Id: If9939f3c9864dad67536d0c5481f662b9d07c58e
2020-08-11 22:15:09 +00:00
Treehugger Robot d81e1d3483 Merge "liblog: remove android_lookupEventTag" 2020-08-11 19:05:35 +00:00
Yifan Hong 333149339b Merge changes from topic "charger_soong"
* changes:
  charger: Add tests for loading animation resources
  charger: Move built-in resources to /system
  charger: Load default resources from /system
2020-08-11 18:51:31 +00:00
Tom Cherry 175366df44 liblog: remove android_lookupEventTag
This function has been marked deprecated for quite some time, has no
users, and isn't in liblog.map.txt.

Test: build
Change-Id: Ic3bf47c780b18a5d4f1e997b9265be76049fb824
2020-08-11 09:20:18 -07:00
Elliott Hughes 7298ba0992 Merge "libsparse: Fix overflow of merged sparse chunk length" 2020-08-11 15:19:01 +00:00
Tom Cherry d731184c38 Merge "liblog: use a blocking socket for sending messages to logd" 2020-08-11 15:13:02 +00:00
Hyeongseok Kim e8d02c50d7 libsparse: Fix overflow of merged sparse chunk length
Merging sparse chunk can make sparse map block bigger than 4GiB,
that can't be covered by unsigned integer type. Fix this by
changing unsigned int to uint64_t type.

Test: sparse build
Bug: 162808120
Change-Id: Id4d3f88f9d531c25c3937c99b2c81efb915605ee
Signed-off-by: Hyeongseok Kim <hyeongseok@gmail.com>
Cc: hyeongseok.kim <hyeongseok.kim@lge.com>
2020-08-11 08:34:28 +09:00
Tom Cherry 4af349b072 liblog: use a blocking socket for sending messages to logd
liblog uses a non-blocking socket for sending messages to logd as a
performance/reliability trade-off, favoring not blocking processes
when they log over reliably tracking all logs.

This change asserts that the above is the wrong trade-off: that log
relability is more important than slight delays when logging. Further
points to consider:

1) The new logd implementation without chatty has lower latency and
less variance in its ::Log() function.
2) liblog also writes to /dev/pmsg0 and this call is already blocking.
3) Logging is already expensive and excess spam must be eliminated
regardless.

Bug: 151654749
Bug: 155922578
Bug: 160314220
Test: No messages are dropped by this socket
Change-Id: I163b7d51aa73a10978850f1868cb9fc4bf9ead1b
2020-08-10 15:56:15 -07:00
Eric Biggers 9b6922b5df Merge "fs_mgr: use __ANDROID_API_Q__ instead of pre_gki_level" 2020-08-10 22:35:21 +00:00
Tom Cherry c486371741 Merge "logd: document the decision to use compression instead of chatty" 2020-08-10 21:47:39 +00:00
Hridya Valsaraju 9a147033f8 Add failure logs in __ashmem_open_locked()
Bug: 160984921
Test: build, boot
Change-Id: I754c961289828463af6de905d8b057b4350f5f07
2020-08-10 14:14:13 -07:00
Tom Cherry edc1ba6a1d logd: document the decision to use compression instead of chatty
Open README.compression.md in a markdown viewer for details.

Test: vscode and gitiles render this correctly
Change-Id: Iaa0093dc565b5c6bb016c9e97248375f0906d0c8
2020-08-10 11:53:51 -07:00
Eric Biggers 75ebdd9c7c fs_mgr: use __ANDROID_API_Q__ instead of pre_gki_level
The name "pre_gki_level" is causing some confusion because not all
devices launching with Android R are subject to the GKI requirement.
(See b/161563110#comment11.)  E.g., devices that use a 4.14-based kernel
are exempt from GKI.  However, the encryption requirements still apply.

Just use __ANDROID_API_Q__ directly instead.

No change in behavior.

Change-Id: I4242745ccc9f88e084a1adfab5796daa9bc59b6e
2020-08-10 11:43:52 -07:00
Elliott Hughes 2cfea97ba3 Merge "Add second batch of fuzzers for libutils" 2020-08-10 15:40:44 +00:00
Treehugger Robot 52c8422ea1 Merge "Add uptimeNanos to SystemClock" 2020-08-08 01:04:09 +00:00
Yifan Hong c2bed97e10 charger: Add tests for loading animation resources
Bug: 143907179
Test: run it

Change-Id: I1b1dfe4947210932c674657689e396ae909013c2
2020-08-07 17:07:09 -07:00
Yifan Hong 5109c8ce04 charger: Move built-in resources to /system
Convert rules to build charger resources to Soong
assuming BOARD_CHARGER_NO_UI is not set. As of now,
no devices in the source tree sets this variable. Also,
these images should be installed to the system image
regardless of this variable.

This change moves battery_fail and battery_scale to
/system/etc/res/images/charger.

Test: build and inspect system/etc/res/images/charger
Fixes: 143907179
Change-Id: Idccf5631371c7520cbfcfa6e92d1e88d0f3f95e7
2020-08-07 17:07:09 -07:00
Yifan Hong abda7153fe charger: Load default resources from /system
When charger resources are missing from /product, before this change,
images are loaded from /res/images/charger. After this change, charger
first checks if the resource exists at that location, and if not, use
resource under /system/etc/res/images/charger.

On devices that uses resources from /product, this change has no effect.
On devices that uses resources from /res,
- if an old image is mounted at /, charger continues to load resources
  from /res.
- if a new image is mounted at /, that is, battery_fail and
  battery_scale may not exist under /res, charger loads them from /system.
  There are no font files installed by modules defined here, so any
  device-specific font files stay at /res.

Also create virtual function wrappers over minui APIs to be mocked
later.

See next change on moving battery_scale and battery_fail images to
/system.

Test: build and inspect system/etc/res/images/charger
Bug: 143907179
Change-Id: I4895b9602274fa4a1ebb4d7d3b842622b81b7b51
2020-08-07 17:07:09 -07:00
Jooyung Han ccab04e5b5 Merge "Fix the order for boot scripts scanning" 2020-08-07 23:21:55 +00:00
Dylan Katz 7168f2726e Add second batch of fuzzers for libutils
This adds fuzzers for:
- CallStack
- Looper
- LruCache
- Printer
- ProcessCallStack
- PropertyMap
- RWLock
- RefBase
- StopWatch.
Test: Ran each fuzzer for 10 minutes. Rough coverage est. (likely far below actual value): 10.97%

Signed-off-by: Dylan Katz <dylan.katz@leviathansecurity.com>
Change-Id: I2f9f35c18b13338c282fb7f9c3ea4099ecb2c56f
2020-08-07 15:36:39 -07:00
Suprabh Shukla a55ef96ea7 Add uptimeNanos to SystemClock
Test: system/core/libutils/SystemClock_test.cpp

Bug: 162791194
Change-Id: I0e3ea2004146eb7442c89bb35a9f3a2171d9c4b8
2020-08-07 14:36:07 -07:00
Yifan Hong 0198ce0ca7 Merge "Fix allowlist for unreliable pinning." 2020-08-07 17:57:13 +00:00
Yifan Hong 75d5e98401 Merge "libsnapshot_test: skip global setup on non-VAB devices." 2020-08-07 17:57:00 +00:00
Treehugger Robot 2666aaba84 Merge "logd: consolidate command handling and fix an error check" 2020-08-07 17:41:14 +00:00
Tom Cherry 9b77d73744 logd: add a test that logd ignores SIGPIPE
Now that libsysutils sockets do not ignore SIGPIPE, logd itself must
ignore it and we therefore add a test that it is ignored properly.

Test: this test passes
Test: this test fails if logd doesn't ignore SIGPIPE
Change-Id: I65474967f40291a7abd11cfd279c8cde2d2bca14
2020-08-07 10:27:37 -07:00
Tom Cherry 94b299ab43 logd: consolidate command handling and fix an error check
Consolidate command handling for commands that take a buffer ID as
their first argument.  Further use ParseUint instead of atoi(), since
atoi("bad string") returns `0` is the same as LOG_ID_MAIN.

Test: these commands are handled property
Test: `echo -n 'getLogSize ignoreme!\0' | nc -U /dev/socket/logd`
      returns an error
Change-Id: I3e84a6157e16f4c110681da453e1ae1a920da7c4
2020-08-07 09:48:16 -07:00
Treehugger Robot 4b3229b216 Merge "Delete fiemap_image_test_presubmit" 2020-08-07 02:23:13 +00:00
Jooyung Han f7c2585f6d Fix the order for boot scripts scanning
To support "override" services, we need to scan partitions from least
speicific to most specific.

Bug: 163021585
Test: m
Change-Id: I26a6de4f7fb571c60038e803137a4b1c237792fd
2020-08-07 10:44:14 +09:00
Yifan Hong 17ed9c4fb6 Merge changes from topic "healthd_test"
* changes:
  Add libhealthd_charger_test to presubmit.
  Convert healthd_test to Soong
  Fix AnimationParser remove_prefix test
2020-08-07 00:38:50 +00:00
Yifan Hong f0cb5a04f3 Delete fiemap_image_test_presubmit
No tests are skipped in presubmit now.

Test: presubmit
Fixes: 148874852

Change-Id: Ic0ce7489ff4a92ab90986dd76f836c262f5aa3fc
2020-08-06 17:38:02 -07:00
Yifan Hong a7c00a0943 libsnapshot_test: skip global setup on non-VAB devices.
On non-VAB devices, fake super image creation may fail because it
may not support f2fs file pinning.

Also changes global setup to a testing::Environment object because it is
the recommended way in gtest's guide. SnapshotTestEnvironement::TearDown
is automatically executed before RUN_ALL_TEST returns.

Test: vts_libsnapshot_test
Test: make IsVirtualAbEnabled() return false, then all tests are
skipped.

Bug: 162557082
Change-Id: I1382f9a4ddec146fa2d8cfb21ac66ca22a2e110f
2020-08-06 17:21:50 -07:00
Yifan Hong 900fdf47ce Fix allowlist for unreliable pinning.
When checking IsUnreliablePinningAllowed, the existing code calls
IsTestDir on a value starts with "/data", but IsTestDir expects
metadata_dir_. Fix it.

Also, make subdir checks more robust and add test cases for IsSubdir.

Fixes: 162557082
Test: vts_libsnapshot_test
Test: fiemap_image_test

Change-Id: I495cfae3da11d1e0800b8abf520df10dd9a29dce
2020-08-06 15:02:56 -07:00
Tom Cherry ca0a46aefa Merge "Query log size properties only within logd" 2020-08-06 22:00:29 +00:00
Tom Cherry 39dc221026 Query log size properties only within logd
liblog exposed __android_logger_get_buffer_size() which queries log
size properties, but that should not be a generic library function.
Logd should be the only process that queries these properties and
other processes should query the actual used log sizes from logd via
the android_logger_get_log_*_size() functions.

Also, always use 1MB for log buffer tests, instead of just on host and
various other clean up related to improper types.

Test: log buffers are correctly sized
Merged-In: I9b7c86bf58e569618737afe9097cf1c4d4e61d95
Change-Id: I9b7c86bf58e569618737afe9097cf1c4d4e61d95
2020-08-06 20:32:45 +00:00
Treehugger Robot b96cc0bfd2 Merge "Add the rough toybox version numbers to the docs." 2020-08-06 18:30:15 +00:00
Treehugger Robot 30e542983a Merge "cts: Skip CtsInitTestCases over a native bridge." 2020-08-06 17:31:56 +00:00
Elliott Hughes 60dfa184a7 Add the rough toybox version numbers to the docs.
Bug: https://github.com/landley/toybox/issues/230
Test: treehugger
Change-Id: I007cb2fd5fc4b2258394e7472c12df4acb25ebcc
2020-08-06 10:15:25 -07:00