82 Commits

Author SHA1 Message Date
Stephen Hines
39fa5efb15 Prefer = delete in place of DISALLOW_COPY_AND_ASSIGN.
Clang-tidy expects modernized code to prefer deleting copy constructors
and assignment operators to legacy macros.

/disk/android_trees/aosp-master-plus-llvm/frameworks/base/cmds/idmap2/tests/ResultTests.cpp:263:3: error: prefer deleting copy constructor and assignment operator over using macro 'DISALLOW_COPY_AND_ASSIGN' [modernize-replace-disal low-copy-and-assign-macro,-warnings-as-errors]
  DISALLOW_COPY_AND_ASSIGN(NoCopyContainer);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Bug: http://b/155835175
Test: mm in idmap2
Change-Id: I3bb29b48a478a67cbda959f47b271ccf8543a768
2020-08-22 10:08:56 -07:00
Stephen Hines
328a29cc48 Add back missing tidy_checks, since tidy_checks_as_errors isn't enough
I unfortunately missed in the original testing that
`tidy_checks_as_errors` isn't sufficient by itself. Instead we need to
have both places with the same variables. A future change will make
Soong expand `tidy_checks_as_errors` into both locations appropriately.

Bug: 119328308
Test: WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=*,-readability-*,-google-readability-*,-google-runtime-references,-cppcoreguidelines-*,-modernize-*,-llvm-*,-bugprone-narrowing-conversions,-misc-non-private-member-variables-in-classes,-misc-unused-parameters,-hicpp-*,-fuchsia-* mm
Change-Id: If69f69bf7861ba3569756270381f3f737366f2f0
Merged-In: If69f69bf7861ba3569756270381f3f737366f2f0
(cherry picked from commit 56af59395e0cdcebeb9b01813f752cc22468c4c0)
2020-06-09 00:15:34 -07:00
Stephen Hines
ab17065423 Use tidy_checks_as_errors list instead of -warnings-as-errors=*
This fixes a build break due to new code from
http://ag/I96f970e82b5243be01b205ac2cb6ab249c6100bc that inadvertently
triggers some false positives with other clang-tidy flags. Builds that
use a wider set of tidy flags (as specified in the test below) will
break since `-warnings-as-errors=*` turns all warnings into errors,
rather than just the ones that were specified as part of this
Android.bp. The preferred way of checking this is to use
`tidy_checks_as_errors`

Bug: 119328308
Test: WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=*,-readability-*,-google-readability-*,-google-runtime-references,-cppcoreguidelines-*,-modernize-*,-llvm-*,-bugprone-narrowing-conversions,-misc-non-private-member-variables-in-classes,-misc-unused-parameters,-hicpp-*,-fuchsia-* mm
Change-Id: I941b3c89402e2cfa290b3829e2ac8ff7ea67ca3d
Merged-In: I941b3c89402e2cfa290b3829e2ac8ff7ea67ca3d
(cherry picked from commit 0bc64543270b16e1953b399dc73fa739132a6e5f)
2020-06-09 00:15:27 -07:00
Treehugger Robot
6982a7dc69 Merge "Fix idmap2 uninitialized variables" 2020-03-24 01:47:12 +00:00
Ryan Mitchell
a7b7de59e0 Fix idmap2 uninitialized variables
Some primitives were not initialized to a default value causing
--ignore-overlayable and --verbose to default to true.

Bug: 148181123
Test: idmap2_tests
Change-Id: If87ba76b7d24803f46b71ef36befa12f25916680
Merged-In: Ic9dbd3e9a768beb39ac677ff294b0fca5ee8f9d2
2020-03-24 01:02:38 +00:00
Chih-Hung Hsieh
db84f188ee Allow bugprone-* warnings until they are all fixed.
Test: WITH_TIDY=1 make checkbuild
Change-Id: I93e9526d66ab9ac88672ccd77eb409603482ea47
2020-03-03 20:09:15 -08:00
Jooyung Han
f452968ae8 Use optional for nullable types
AIDL generates optional<T> for nullable T types for C++, which is more
efficient and idomatic and easy to use.

Bug: 144773267
Test: build/flash/boot
Merged-In: I90cf2ce1193c479179687d71a5c1416f6cdf0b16
Change-Id: I90cf2ce1193c479179687d71a5c1416f6cdf0b16
(cherry picked from commit ff7f4279bd7fa33577f5f4d46aa9de322fb625d4)

Exempt-From-Owner-Approval: CP from master
2020-02-27 03:05:19 +00:00
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