Commit Graph

48254 Commits

Author SHA1 Message Date
Tom Cherry 6fd8d3bb1b init: Allow matching empty property values
When we have a property match along with an event trigger, we
currently don't allow matching empty property values, in other words,
properties that are unset.  For example, the below trigger would never
be run:

on zygote-start && property:persist.sys.fuse=""

That doesn't make sense though, it should be possible to match an
empty property value, so this change allows that trigger to match when
persist.sys.fuse is either empty or not set.

This continues to not match a '*' to an empty property, so

on zygote-start && property:persist.sys.fuse=*

will not run if persist.sys.fuse is empty or unset.

Test: the above triggers run appropriately
Change-Id: Ia57de7b96ad352590d0c82ff4ae95060b7361976
2019-08-12 09:31:42 -07:00
Mason Wang 4b8e6b673f Merge "Revert "libcutils: remove unused "jstring.h"."" 2019-08-12 05:21:17 +00:00
Mason Wang 09ba34925f Revert "libcutils: remove unused "jstring.h"."
This reverts commit aa96e8898c.

Reason for revert: It caused BB, and b/139257138 is for your reference

Change-Id: I93f1d0ba0fa43325e2815e9b2de84bb7cb41c457
2019-08-12 02:16:58 +00:00
Treehugger Robot e2adc14803 Merge "libcutils: remove unused "jstring.h"." 2019-08-11 15:39:27 +00:00
Anatol Pomozov 239439b787 Merge "Add header that declares memcpy function" 2019-08-10 01:57:25 +00:00
Anatol Pomozov 7eca57a20e Merge "Add header that defines strerror()" 2019-08-10 01:56:27 +00:00
Anatol Pomazau 60509705e6 Add header that declares memcpy function
It fixes following issue when compiling adb with host libraries:

In file included from core/adb/client/adb_install.cpp:31:
In file included from core/adb/adb.h:30:
In file included from core/adb/socket.h:28:
core/adb/types.h:237:9: error: use of undeclared identifier 'memcpy'; did you mean 'wmemcpy'?
        memcpy(copy->data(), first_block->data() + begin_offset_, copy->size());
        ^~~~~~
        wmemcpy
/usr/include/wchar.h:262:17: note: 'wmemcpy' declared here
extern wchar_t *wmemcpy (wchar_t *__restrict __s1,

Change-Id: I233e533fa7a5e2ed98190e34e32ddbaddc528558
2019-08-09 22:20:15 +00:00
Treehugger Robot 3e59c847cc Merge "Add header that declares atomic primitives" 2019-08-09 21:36:41 +00:00
David Anderson 5b9832748f Merge changes I5e93fcbf,I9d4c8bcf,Icd580aae,I7b2399a4
* changes:
  libsnapshot: Implement merge flow.
  libsnapshot: Unmap COW devices when deleting snapshots.
  libsnapshot: Eliminate per-snapshot flocks.
  libsnapshot: Improve first test-run and test cleanup.
2019-08-09 19:34:52 +00:00
Mark Salyzyn 2edc7a5128 Merge "fs_mgr: overlayfs: dig harder for /dev/root equivalent" 2019-08-09 15:11:54 +00:00
Elliott Hughes aa96e8898c libcutils: remove unused "jstring.h".
Test: treehugger
Change-Id: I56989862a51a6c8785f22f783027d50c42be650c
2019-08-08 17:45:48 -07:00
Songchun Fan 6e861740ff Merge "[adb] Cache features set inside the client process" 2019-08-09 00:40:51 +00:00
Songchun Fan 82834f1264 Merge "[adb] Speed up the streaming install" 2019-08-09 00:38:50 +00:00
Anatol Pomazau fd41f9a579 Add header that defines strerror()
It helps to fix a compilation issue with host libc:

core/base/errors_unix.cpp:25:10: error: use of undeclared identifier 'strerror'
  return strerror(error_code);
         ^

Change-Id: I71d4221cc1bfa6f0cc764b40b6b28159994b8e04
2019-08-08 23:31:36 +00:00
Anatol Pomazau 7b2ff6debc Add header that declares atomic primitives
It fixes a compilation issue:

/fdevent/fdevent_poll.cpp -o core/adb/fdevent/fdevent_poll.cpp.o
In file included from core/adb/fdevent/fdevent_poll.cpp:20:
In file included from core/adb/fdevent/fdevent_poll.h:29:
core/adb/fdevent/fdevent.h:106:10: error: no template named 'atomic' in namespace 'std'
    std::atomic<bool> terminate_loop_ = false;
    ~~~~~^

Change-Id: I5305a69a50e2638f514c5a7d47a9612b8ee38c69
2019-08-08 23:30:42 +00:00
Josh Gao 6c4cfd6af5 Merge changes I4d6bda45,I72576e1f
* changes:
  adb: fix transport acquisition for forward, reverse.
  adb: don't manually construct device selection prefix in forward.
2019-08-08 20:38:15 +00:00
Yurii Zubrytskyi 6eca0e6999 [adb] Speed up the streaming install
1. Use bigger buffer for transfers - 64kb is the default size
   for push, so let it be the same in streaming

2. Use abb when it's available for lower overhead

3. Add a posix_fadvise() on the source APK

4. Increase buffer sizes for the socketpair that's transferring
the data from adbd.

Overall this saves about 25% time for streaming installations
and makes it faster than the legacy push (at last!)

Test: manual
Change-Id: Ieb84284da2058944815e062ef6e4389b842565fa
2019-08-08 12:55:51 -07:00
Tom Cherry ca94d79753 Merge "liblog: Remove stdbool.h from .cpp files" 2019-08-08 19:34:41 +00:00
Elliott Hughes 0c2dab9adf Merge "Remove more dead code." 2019-08-08 19:10:40 +00:00
Mark Salyzyn 31c14e15b9 fs_mgr: overlayfs: dig harder for /dev/root equivalent
Check for A/B /dev/block/by-name/system<slot> and also non-A/B
/dev/block/by-name/system to discover what /dev/root can be when
evaluating candidates for using overlayfs.

This is to handle a misconfigured (or legacy) system-as-root device.
It is recommended that the default fstab specifically mentions the
root mount's device node to prevent going down this path.

Test: adb-remount-test.sh
Bug: 138407617
Change-Id: I3853d203b9376d0f848cb490150ff00cc4ed3d5f
2019-08-08 11:50:36 -07:00
vichang ef0bc63043 Merge "Move ICU .dat" 2019-08-08 11:06:53 +00:00
David Anderson 5312c466b9 libsnapshot: Implement merge flow.
This implements InitiateMerge() and WaitForMerge(). InitiateMerge() is
meant to be called after an update has been marked successful.
WaitForMerge() is designed to be called either: immediately after
InitiateMerge, or during each subsequent boot where merging has not
completed.

InitiateMerge converts each snapshot device to a snapshot-merge device.

WaitForMerge polls each snapshot-merge device until no device reports a
"merging" state. One of the following states can result from this:
 - MergeFailed. This will happen if any device failed to merge, or we
   were unable to poll, or any other system-level failure occurred.
 - MergeNeedsReboot. This will happen if a snapshot-merge device has
   completed merging, but we were unable to clean it up due to something
   holding a resource open.
 - MergeCompleted. This indicates that all snapshots completed merging
   and were cleaned up.

If WaitForMerge() returns MergeCompleted, then all snapshots have been
removed and a new update can begin. GetUpdateState() will return None.

MergeFailed and MergeNeedsReboot, on the other hand, are "sticky". They
indicate a merge is still pending. When called again, WaitForMerge()
will poll again to attempt to make more progress in the merge. For
NeedsReboot, a single reboot will ensure all resources are released and
the next WaitForMerge() will successfully finish cleanup. In the failure
case, it is unlikely the next WaitForMerge will succeed, but we always
retry anyway (there is no harm in doing so, and if we get lucky, the
device can take more OTAs).

Bug: 136678799
Test: libsnapshot_test gtests
Change-Id: I5e93fcbffee1973da5ff76363df12d6317a7a7c7
2019-08-07 18:42:23 -07:00
David Anderson 986095036c libsnapshot: Unmap COW devices when deleting snapshots.
When we stopped unmapping snapshots in DeleteSnapshot, this also stopped
unmapping the COW device. Of course, the caller has no way to unmap this
since it's an implementation detail. Therefore unmap it in
DeleteSnapshot.

This scenario can arise after rewriting or removing a snapshot-merge
device.

Bug: 136678799
Test: manual test
Change-Id: I9d4c8bcfbb95b4454edd1cf0853d51b441e895fa
2019-08-07 18:42:22 -07:00
David Anderson d986fefa3b libsnapshot: Eliminate per-snapshot flocks.
Per-snapshot locks don't solve any problems and add a great deal of
complexity. Instead, refactor the Read/WriteSnapshotStatus methods so
the caller just needs the snapshot name, and is not responsible for
opening a file.

As part of this change, callers of WriteSnapshotStatus must always take
an exclusive flock on the update state file. This is enforced by adding
a helper method to LockedFile to check the lock mode.

Bug: 136678799
Test: libsnapshot_test gtest
Change-Id: Icd580aaec7dfc916b3eed174d86b26688cd2291b
2019-08-07 18:42:22 -07:00
David Anderson 3cb682e369 libsnapshot: Improve first test-run and test cleanup.
This CL fixes a bug where libsnapshot_test failed on the first run. It
also fixes bugs where it could not run if it died in the middle of a
test.

Previously, libsnapshot_test relied on CancelUpdate() to perform
cleanup, which cannot run in certain states. Instead, manually delete
dm devices and COW image files, and forcefully erase any lingering data.

Bug: 136678799
Test: libsnapshot_test gtest
Change-Id: I7b2399a403b387eb47184626e71dcf8674f6ab89
2019-08-07 18:42:21 -07:00
Treehugger Robot d97c946d37 Merge "liblp: refactor MetadataBuilder::NewForUpdate" 2019-08-07 23:54:27 +00:00
Elliott Hughes 1547e4a316 Remove more dead code.
Test: treehugger
Change-Id: I2b7f606241cde2c2743d8021fad00d30f7e0b0de
2019-08-07 14:52:16 -07:00
Tom Cherry d00b3affda liblog: Remove stdbool.h from .cpp files
We're C++ now, so we don't need stdbool.h

Test: build
Change-Id: I2c65f0d3edddaf77256bd0bc3d60378bcfaef180
2019-08-07 14:30:41 -07:00
David Anderson 36acd1d246 Merge "libsnapshot: Don't force-unmap in DeleteSnapshot()." 2019-08-07 20:24:46 +00:00
Yifan Hong 68aae7d748 Merge changes from topic "liblp_virtualab_prepare"
* changes:
  liblp: Expose kDefaultGroup.
  liblp: Add PropertyFetcher.
2019-08-07 19:45:44 +00:00
Yifan Hong 6079cd014a liblp: refactor MetadataBuilder::NewForUpdate
Move the logic for retrofit DAP to its new function. The new flow
in NewForUpdate is:
    metadata = ReadMetadata();
    if (retrofit dap) UpdateMetadataForOtherSuper(metadata)
    return metadata;

Test: liblp_test_static
Change-Id: I6890fff3a7c44ebe2004de96b2ccbe1e8ce37546
2019-08-07 12:44:19 -07:00
Treehugger Robot ef06b4fc7a Merge "fs_mgr: Make kDefaultAndroidDtDir constexpr" 2019-08-07 17:22:37 +00:00
Treehugger Robot b02f9b549c Merge changes from topic "toolbox-modprobe"
* changes:
  toolbox: add modprobe
  libmodprobe: add verbose mode
  libmodprobe: add GetAllDependencies
  libmodprobe: add support to list modules
  libmodprobe: add support for a blacklist
  libmodprobe: support parameters in LoadWithAliases
  libmodprobe: add support to remove modules
  libmodprobe: make name canonical in LoadWithAliases
  libmodprobe: make available in vendor
2019-08-07 17:09:09 +00:00
Yifan Hong 5b4b38cee0 liblp: Expose kDefaultGroup.
kDefaultGroup is the 'default' group that is never deleted
and has no size constraints. During a virtual a/b update,
the following series of action happens:
- move partitions out of groups that will be shrunk / deleted
  (into default)
- shrink / delete these groups
- grow / add other groups
- move those partitions to their destination group.

Otherwise, the metadata is inconsistent.

Bug: 138816109
Test: builds

Change-Id: I57cf4b44dda948377c6b3153756f469caa4652bc
2019-08-06 18:46:47 -07:00
David Anderson aefb3b17fb libsnapshot: Don't force-unmap in DeleteSnapshot().
It is hard to re-use this function in the merge code when it forcefully
unmaps the snapshot, because the snapshot may have been rewritten to be
a dm-linear device. Instead, leave the decision up to the caller.

Bug: 136678799
Test: libsnapshot_test gtest
Change-Id: I03c027c0781696885a5a5654d3049287cc16ecd0
2019-08-06 18:16:04 -07:00
Yifan Hong 04d91871df liblp: Add PropertyFetcher.
Use dependency injection so that GetProperty / GetBoolProperty
can be mocked in tests.

Test: run liblp_test_static
Change-Id: I8efa85fbbd7aebce2541f748f840e512f3729c30
2019-08-06 17:39:37 -07:00
Josh Gao 3346339fcb adb: fix transport acquisition for forward, reverse.
Previously, we were calling acquire_one_transport with all empty
parameters, which would work when only one device is connected, but fail
when there are multiple. We've already acquired a transport and put it
into the socket as part of the forward request, so just use that
directly.

Bug: http://b/136198949
Test: test_device.py with multiple devices connected
Change-Id: I4d6bda45b36b71e418ecd9ead61b7379e68aa19b
2019-08-06 17:01:11 -07:00
Josh Gao da9c767826 adb: don't manually construct device selection prefix in forward.
Use the existing infrastructure instead.

Test: test_adb.py
Test: test_device.py
Change-Id: I72576e1fb922af71852b50ddb3f4cb5c39eb333f
2019-08-06 16:43:34 -07:00
Daniel Norman 0d061b258a Merge "Adds check_interface_{restart,start,stop} check_builtins." 2019-08-06 23:21:29 +00:00
Treehugger Robot f9d5327287 Merge "libsnapshot: correct DeviceInfo paths" 2019-08-06 22:12:53 +00:00
Vic Yang 5caa3e9e1a fs_mgr: Make kDefaultAndroidDtDir constexpr
Change its type from std::string to constexpr char[] so that it does
not need to be constructed at runtime, which pollutes the bss page
unnecessarily.

Bug: 138856262
Test: Along with another fix for libbootloader_message.so, see that bss
      section for libbootloader_message.so is now clean on cuttlefish
      for several processes.

Change-Id: I1c8ff9cfeb25164a352cef89cfa7be889b3d3387
2019-08-06 14:15:33 -07:00
Steve Muckle 64a553451a toolbox: add modprobe
Add an implementation of modprobe based on libmodprobe.

Change-Id: I85ba440766406fe6ca7e90bec204d06632785a66
2019-08-06 13:58:13 -07:00
Steve Muckle ded44c06be libmodprobe: add verbose mode
Change-Id: I2be18320461cd712a4828400b8f29bb5f07c801f
2019-08-06 13:58:13 -07:00
Steve Muckle 781aa78ee2 libmodprobe: add GetAllDependencies
Add a method to retrieve the dependencies (both hard and soft) of a
module.

Change-Id: Ie44ceb3e36856bb1a3e68c5d3c0d55a38deb0ef9
2019-08-06 13:58:13 -07:00
Steve Muckle 012cfa19b0 libmodprobe: add support to list modules
List the known modules with a name matching a given pattern.

Change-Id: I7f6bd1f09a688c66682f94c5837e61d7dc61c1f7
2019-08-06 13:58:13 -07:00
Steve Muckle e31f840a0a libmodprobe: add support for a blacklist
If the blacklist is enabled, blacklisted modules are treated as though
they are not present.

Change-Id: Ie8712f24298e78f92d5028b1ca3a8a3e07a9190a
2019-08-06 13:58:13 -07:00
Steve Muckle 13700a69d3 libmodprobe: support parameters in LoadWithAliases
Add support to specify module parameters in LoadWithAliases. These
parameters will be appended to any which are specified for the module in
modules.options.

Change-Id: I9aff1656ea397826f815b658b3b52c1892748601
2019-08-06 13:58:13 -07:00
Steve Muckle bb58b01574 libmodprobe: add support to remove modules
Add a remove method which will unload a given module from the kernel,
along with any modules it depended on, assuming those modules are now
unused.

Change-Id: Ie66dc153ef1771f50e26421d38d3656e95954780
2019-08-06 13:58:13 -07:00
Steve Muckle 73b2928b94 libmodprobe: make name canonical in LoadWithAliases
Make the module name canonical in LoadWithAliases so it may be used
more easily from outside the class.

Change-Id: I7ee496b77a2beea43a6b68daed7af42660747559
2019-08-06 13:58:13 -07:00
Steve Muckle 4104b8803a libmodprobe: make available in vendor
A toolbox implementation of modprobe will require libmodprobe.

Change-Id: I7790576b828ad8cd5fae0c51926d8da9fb540d30
2019-08-06 13:58:13 -07:00