75 Commits

Author SHA1 Message Date
Ryan Mitchell
b30f65713f Merge "Add requiredSystemPropertyValue support in idmap2" 2019-10-02 16:48:50 +00:00
Gabriel Siqueira
d7fc4f774a Add requiredSystemPropertyValue support in idmap2
Up to Android P, there was this feature were we are able to
define "requiredSystemPropertyValue" in the AndroidManifest.xml
of the RRO apk, so that it will only be loaded if
requiredSystemPropertyValue/requiredSystemPropertyName are matched.

Porting support from idmap
https://android.googlesource.com/platform/frameworks/base/+/master/cmds/idmap/scan.cpp#135

To idmap2
https://android.googlesource.com/platform/frameworks/base/+/master/cmds/idmap2/idmap2/Scan.cpp#175

Bug: 140891738
Change-Id: I47752af93efa4563a60e336c1e1b1ffc081b51ec
2019-09-27 11:35:34 -03:00
Treehugger Robot
a828ee6442 Merge changes from topic "system_ext"
* changes:
  Consider overlay in system_ext as system's
  Support /system_ext partition
2019-09-26 22:18:07 +00:00
Jeongik Cha
3e725f2224 Consider overlay in system_ext as system's
When there is overlay package in system_ext, turn on POLICY_SYSTEM_PARTITION.
In other words, overlay pacakge in /system_ext is considered as system's one

Test: mv vendor/overlay/framework-res__auto_generated_rro.apk system_ext/overlay
      and then check if it works properly.
Bug: 136715327

Change-Id: Ib225368eae41203a8630f4310d26e9cf1afa706a
Merged-In: Ib225368eae41203a8630f4310d26e9cf1afa706a
(cherry picked from commit cba9579158cc70bf8eadb6e8a239e0ab2dc073d2)
2019-09-23 22:01:29 +00:00
Steven Moreland
598bda8624 Host users of libutils trace use libcutils.
Reducing device/host differences. This is now required since libutils
Trace.h always calls the libcutils functions, instead of before where
it only called these functions on device.

Bug: 124524556
Test: build & boot
Change-Id: Ic096ed7caf8ca59292b3427a16c4e2545d12dfd9
2019-09-20 11:27:59 -07:00
Yi Kong
9b00f181da Fix android-cloexec-pipe clang-tidy warning
The upcoming clang-tidy update finds a new instance of
android-cloexec-pipe warning:

FileUtilsTests.cpp:72:13: error: prefer pipe2() with O_CLOEXEC to avoid leaking file descriptors to child processes
ASSERT_EQ(pipe(pipefd), 0);
^~~~~~~~~~~~
pipe2(pipefd, O_CLOEXEC)

Apply the suggested fix by clang-tidy.

Test: build
Bug: 131328001
Exempt-From-Owner-Approval: Cherrypick
Change-Id: Iee772b5c3ed5e2af481e479dab19030f8419290a
Merged-In: Iee772b5c3ed5e2af481e479dab19030f8419290a
(cherry picked from commit f61e2167d5352b63eb34a086cdcb0dfec485bdf0)
(cherry picked from commit 1fa946a2f285283277d75bf741bfef05f6bc9d8e)
2019-08-23 16:46:05 +00:00
Yi Kong
fbafa5162a Disable modernize-use-trailing-return-type clang-tidy check
Upcoming clang update introduced the new modernize-use-trailing-return-type
check which is not useful. Disable this warning for now (even before the
new clang update lands) since clang-tidy doesn't complain about flags it
doesn't know.

Test: build with new clang-tidy
Bug: 131328001
Change-Id: I7fbc10fb9044904f85f9a1ec6cf712ce3cec0a79
Merged-In: I7fbc10fb9044904f85f9a1ec6cf712ce3cec0a79
Exempt-From-Owner-Approval: Trivial, no functionality change
(cherry picked from commit fc8e666d67afef241ddb6491ddc13948c3b837c0)
(cherry picked from commit a0914d81ef9f4d7258f1530dc3bfdd575f6e448d)
2019-08-22 22:33:37 +00:00
Dan Willemsen
d1a5aa6a00 Match src paths with aidl package name
In order for the build system to track updates to the header files
during incremental builds, always specify the src files using the same
path as the package for C++ compilations.

Bug: 112114177
Test: treehugger
Change-Id: I584f43a0386840ce3d066479e9e4035de81da144
2019-06-08 15:43:36 +00:00
Ryan Mitchell
ab3e54dc8a Merge "Fix atoi build errors" into qt-dev
am: 9fe4ba7a43

Change-Id: I9617284d09ec85c699d12045a8761b97b226b795
2019-06-04 08:14:36 -07:00
Ryan Mitchell
7f08644bd7 Fix atoi build errors
Use strtol instead of atoi to check vendor partition version.

Bug: 119390857
Test: manual
Change-Id: I49c5963d8bbc5a803b3ccc0dd41d7bd7f2a42226
2019-06-04 06:05:31 +00:00
Ryan Mitchell
c0874fe247 Merge "Remove stopship for idmap2 vendor sdk checking" into qt-dev
am: f5671d390d

Change-Id: Ie4777d5e7a9f03006b2aef519fc223490ef5bcd2
2019-06-03 13:41:47 -07:00
Ryan Mitchell
56db15b843 Remove stopship for idmap2 vendor sdk checking
Idmap now checks if the version of the vendor partition is greater than
or equal to 29 or a development codename to enable enforcement of
overlayable resources.

Bug: 119390857
Test: manual
Change-Id: Ica25800432993beb7464436d4fba7cb391e621ef
2019-06-03 11:22:36 -07:00
Elliott Hughes
bf42c724dd libidmap2: track libziparchive API change.
Bug: http://b/129068177
Test: treehugger
Change-Id: Id1e855d17cde15b2db37df5e192e2011c60eaebe
2019-05-06 12:22:59 -07:00
Ryan Mitchell
ad4d02fdd9 Fix idmap scan to apply odm and oem policies
idmap2 scan was not allowing oem and odm overlays to fulfill the oem and
odm overlayable policies.

Bug: 129735590
Test: manual
Change-Id: I230f72b37b95a997d32f2ef136b6301d970a413c
2019-04-23 03:09:29 -07:00
Ryan Mitchell
939df096be Add odm and oem policies
This change adds parsing, encoding, and validating of odm and oem
overlayable policies to aapt2, libandroidfw, and idmap2.

Bug: 121033532
Test: aapt2_tests, idmap2_tests
Change-Id: Ifc0d4b6c9f9c37e06b2988abade69dbb277c50c2
2019-04-17 16:07:57 -07:00
Ryan Mitchell
0503fa5614 Do not fail idmap scan if one idmap fails to generate
If one static overlay fails to have its idmap generated, continue
scanning other overlays.

Bug: 130324774
Test: idmap2_tests and manual
Change-Id: I06a74c844ebc81dcfb5b50e8c9a30a68c7e4ffb0
2019-04-15 15:03:06 -07:00
Ryan Mitchell
52e1f7a1ba Run idmap2 static-checks and fix formatting issues
Bug: 130324774
Test: builds
Change-Id: I2cf9d3aa268ffe38e525fadee9d81fc6aefe19b1
2019-04-15 08:48:10 -07:00
TreeHugger Robot
1388c3339d Merge "Fix idmap2 policy concatenation" 2019-04-03 20:04:32 +00:00
Ryan Mitchell
ac791e6557 Fix idmap2 policy concatenation
When printing warning messages while generating idmaps, put the vertical
bar chracater in between the policies.

Bug: none
Test: manual

Change-Id: I8efee753d9ed7ce99ccafd49b6c8744eea031839
2019-04-03 11:02:39 -07:00
TreeHugger Robot
fc98f99c84 Merge "Enable presubmit for idmap2_tests" 2019-04-01 21:57:57 +00:00
Ryan Mitchell
bcc179acf9 Enable presubmit for idmap2_tests
Bug: 128831971
Test: presubmit
Change-Id: Id68d717412045bc2e26abbe1050b3478019a2bea
2019-03-29 14:55:51 -07:00
Ryan Mitchell
482c75b53c Do not run create on successive reboots
Passing policy flags to the Verify command of idmap2 was causing the
command to fail to parse and run create again even when the target and
overlay did not change. This change allows verify in scan to work
correctly again.

Bug: 127860892
Test: confirmed that create is not run on a successive reboot
Change-Id: I7b9c9d81c7aef6b4c80fb8b87a1e929e82fc3b84
2019-03-22 17:17:42 +00:00
TreeHugger Robot
1b41c4b364 Merge "idmap2: move Idmap.h to Result" 2019-03-21 16:38:10 +00:00
Todd Kennedy
358c63f229 Merge "idmap2: clang-format" 2019-03-21 13:43:34 +00:00
TreeHugger Robot
4f155e0564 Merge "OMS: stabilize unit tests" 2019-03-21 01:31:37 +00:00
Mårten Kongstad
cf622490b3 idmap2: clang-format
Test: cmds/idmap2/static-checks.sh
Change-Id: I17a0268058156373e9af1e00a7bcca5a8cc8f100
2019-03-20 13:49:44 -07:00
Mårten Kongstad
ce42490bb5 idmap2: move Idmap.h to Result
Change the signatures of Idmap::FromApkAssets and
Idmap::FromBinaryStream from

  std::unique_ptr<const Idmap> func(..., std::ostream& out_error);

to

  Result<std::unique_ptr<const Idmap>> func(...);

The returned pointer is still a unique pointer to ensure the dynamically
allocated memory is automatically released when no longer used. This
means that using the returned value of either function requires one of
two patterns:

  const auto idmap = func(...);
  if (!idmap) {
    return Error(...);
  }
  (*idmap)->accept(...);

or

  auto result = func(...);
  if (!result) {
    return Error(...);
  }
  const auto idmap = std::move(*result);
  idmap->accept(...);

Note that in the second example, result must be non-const or
the call to std::move(*result) will not compile.

With this change, the entire idmap2 project has been converted to use
Result.

Test: make idmap2_tests
Change-Id: I533f4e03b99645523d94dd5f446ad76fb435f661
2019-03-20 13:45:14 -07:00
TreeHugger Robot
5942b376fd Merge "Fix idmap enforce overlayable bug" 2019-03-20 18:33:36 +00:00
Mårten Kongstad
bf08f0a4eb OMS: stabilize unit tests
- Add hasCode=false to overlay packages as a workaround for b/124375490

- Sprinkle Thread.sleeps in InstallOverlayTests in an attempt to make
  the tests less flakey when executed on emulator

Test: atest OverlayDeviceTests OverlayHostTests
Change-Id: I745a8477ed5e72db572737a0af0e59478893e42b
2019-03-19 15:37:04 -07:00
Ryan Mitchell
2c19bd0bc0 Fix idmap enforce overlayable bug
Idmap2 is not enforcing overlayable on Q overlays and instead on P
overlays. This corrects this behavior.

Test: idmap2_tests
Bug: 128932015
Change-Id: I7e45a965d3b165dae7ed7377d0911afd62f63983
2019-03-19 15:23:15 -07:00
Mårten Kongstad
0c6ff1da4f idmap2: move commands to Result<Unit>
Change the signature of the idmap2 commands (Create, Dump, ...) to
return Result<Unit> instead of bool. This removes the need to pass in an
ostream for error messages: instead, those messages are part of the
returned Result.

Consolidate error messages: texts in Error objects should not be
prefixed with "error:", that is the responsibility of the outer-most
caller (i.e. main()).

Test: make idmap2_tests
Change-Id: I074881b3d1982ea8f4be5752161ac74b14fcba95
2019-03-19 14:26:38 -07:00
TreeHugger Robot
e11bfbe411 Merge changes from topic "idmap-default-policies"
* changes:
  Fix idmap scan to supply correct policies
  Revert "Revert "Enforce a default policy on packages without <overlayable>""
2019-03-11 15:38:09 +00:00
Ryan Mitchell
4c09a4a4f7 Fix idmap scan to supply correct policies
Overlayable policies were not being passed correctly to idmap2 create
from scan. This fixes that and adds better error messages for when
policy failures occur.

Bug: 127860892
Test: manual
Change-Id: I8fae20884a75f4c57a0eb4aafdb4e09da3ebaf93
2019-03-08 09:31:44 -08:00
Ryan Mitchell
b863ca3348 Revert "Revert "Enforce a default policy on packages without <overlayable>""
This reverts commit 6ce5b00f2ac8307ab8cce1deb79e1e39d8b1b8b7.

Bug: 127835630
Test: manual and idmap2_tests
2019-03-07 14:31:54 -08:00
Ryan Mitchell
6ce5b00f2a Revert "Enforce a default policy on packages without <overlayable>"
This reverts commit 48945224bdc298630c76befdb50a31838bdafd8e.

Reason for revert: <b/127835630>

Change-Id: I0bc90c26e5b7d6b4d94704a2a1f92bbc889c025c
2019-03-07 21:58:14 +00:00
Ryan Mitchell
48945224bd Enforce a default policy on packages without <overlayable>
In order to lift the signature/preinstalled install restrictions on overlays,
we must protect packages that have not migrated to <overlayable> from
being overlaid. If a resources is not specified as overlayable and the
overlay does not define an <overlayable>, require the overlay to be
preinstalled or signed with the same signature as the target.

Bug: 121016681
Bug: 125933494
Test: idmap2_tests
Change-Id: I38f520929031b743e4bbe0366a9be55aac5795c5
2019-03-07 16:37:10 +00:00
Yi Kong
974d516e5f Add missing WARN_UNUSED attribute
The upcoming compiler update warns against missing WARN_UNUSED
attribute:

  frameworks/base/cmds/idmap2/libidmap2/Idmap.cpp:58:3: error: function 'Map' should be marked [[nodiscard]] [modernize-use-nodiscard,-warnings-as-errors]
    inline const std::map<TypeId, std::set<std::pair<ResourceId, ResourceId>>>& Map() const {
    ^
    [[nodiscard]]

Test: m checkbuild
Bug: 126457671
Change-Id: Ib006dacbc17446377b2886c73190548f53429a44
2019-03-06 16:22:42 -08:00
Mårten Kongstad
49d835d84e idmap2: switch to improved Result class
Remove the old std::optional based Result class, replace uses with the
new std::variant based Result class.

Test: make idmap2_tests
Change-Id: I401cb36e5af06133a2872d835cf29bfb0b106597
2019-02-27 20:31:51 +00:00
TreeHugger Robot
c28fa88024 Merge "Add rtmitchell to idmap2 OWNERS" 2019-02-20 22:31:40 +00:00
TreeHugger Robot
9091d826bb Merge "Suppress cert-dcl50-cpp tidy warnings." 2019-02-20 22:31:06 +00:00
Ryan Mitchell
110323fed0 Add rtmitchell to idmap2 OWNERS
Change-Id: I8e0b873ef8739aadbb4f3bd6a7c3f4aa1aee58ea
2019-02-20 10:31:08 -08:00
Winson
b410020881 idmap2: add signature policy
Handles the new signature policy for overlayable resources.

Bug: 119402606

Test: idmap2_tests target

Change-Id: I7961e04a879c40c240ed9097bb510addb8b56680
2019-02-15 17:29:48 -08:00
Chih-Hung Hsieh
a20e8a357c Suppress cert-dcl50-cpp tidy warnings.
Bug: 122832439
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,cert-dcl50-cpp
Change-Id: I034ec8c6e6338b38ee4b413e3edac223a01d8764
2019-02-15 23:38:54 +00:00
Mårten Kongstad
4cbb00752b idmap2: add systrace logs
Thanks to the ART team for art/libartbase/base/systrace.h which served
as inspiration for the SYSTRACE macro.

Bug: 119761810
Test: run idmap2_tests on device while capturing systrace
Change-Id: I81112ae8e58daf20ebed33ef8b0f5a0caa4dbc73
2019-02-08 07:28:41 -08:00
Todd Kennedy
0b103de238 Merge "idmap2: fix static checks" 2019-02-07 22:12:04 +00:00
TreeHugger Robot
f5ce5eddae Merge "idmap2: introduce improved Result class" 2019-02-07 19:01:38 +00:00
Mårten Kongstad
9371dc17e4 idmap2: include AndroidManifest.xml in CRCs
The CRCs stored in the idmap file header are copies of the zip file CRC for the
resources.arsc entry in the target and overlay package apks, and are used to
quickly check if either package's contents has changed, which in turn means the
idmap file must be recreated.

With the introduction of named targets, just checking the resources.arsc file is no
longer sufficient: an overlay package could be installed with targetName="a" and
updated to targetName="b". This change is not reflected in the resources.arsc file,
only in the AndroidManifest.xml.

To account for this, update the CRC in the idmap file header from

    CRC(resources.arsc)

to

    CRC(resources.arsc) ^ CRC(AndroidManifest.xml)

Test: make idmap2_tests
Bug: 119761809
Change-Id: Ieb0c6b466ac23eb81a2670a32309fa46ade5c5c8
2019-02-07 17:33:19 +00:00
Mårten Kongstad
aabca6c00f idmap2: fix static checks
Fix two errors detected by static-checks.sh:

  - bpfmt: remove -s flag (sort arrays) since it makes no sense to order
    clang-tidy flags alphabetically: flags must be passed to clang-tidy
    in the order specified to make sense

  - cpplint: allow NOLINT(cert-dcl50-cpp)

Test: cmds/idmap2/static-checks.sh
Change-Id: I6677f8e7504551746edae458acd523e643044c7e
2019-02-07 09:27:16 -08:00
Mårten Kongstad
1e99b1783d idmap2: introduce improved Result class
Add a new version of the Result class that functions like the old
Result, but in case of an error, also encodes a string detailing the
error. This will allow us to write the following type of code:

Result<Foo> CreateFoo() {
    if (...) {
        return Error("errno=%d", errno());
    }
    return Foo(...);
}

auto foo = CreateFoo();
if (!foo) {
    std::cerr << "error: " << foo.GetErrorMessage() << std::endl;
    abort();
}
std::cout << "foo=" << *foo << std::endl;

This commit only adds the new Result class. A later change will replace
uses of the old version.

Test: make idmap2_tests
Change-Id: I674d8a06866402adedf85f8514400f25840d5eda
2019-02-06 16:54:25 -08:00
Ryan Mitchell
198234502b Enforce overlayable API when defined
If a package defines overlayable resources, then do not allow resources
that are not defined as overlayable to be overlaid.

Bug:123600120
Test: idmap2_tests and cts-tradefed run cts -m CtsRROTestCases
Change-Id: I35120a97ccf4650e67c7ba65a60f4f3c51b0e627
2019-02-05 07:56:50 -08:00