7027 Commits

Author SHA1 Message Date
Muhammad Qureshi
ad94425b15 Add flag to stats-log-api-gen for WorkSource.
As part of getting rid of StatsLogInternal and moving every atom to be
logged from a module, this CL addresses 2 issues:
1. Add WorkSource logging to modules.
2. Gate WorkSource logging via a CLI flag to prevent WorkSource methods
from being included in modules that are Mainline modules and can't have
@hide calls.

Bug: 147541828
Test: m
Test: atest android.cts.statsd.atom.UidAtomTests

Change-Id: Icce2f6ed7298be5e5ceebfb05d87e6fa7cd6bdbb
2020-01-17 08:36:52 -08:00
Clark Duvall
ba06b58f51 Merge "Reorder style items in shared libraries" 2020-01-16 23:03:45 +00:00
TreeHugger Robot
a5112ea08a Merge "ProtoLogTool: Fix thread pool leak on code generation exception" 2020-01-16 20:45:10 +00:00
Clark DuVall
18b15bb3a6 Reorder style items in shared libraries
AssetManager2.cpp expects style attribute IDs to be in sorted order when
applying a style (see AssetManager2::GetBag). Shared libraries have a
package ID of 0x00, which will mean any attribute defined in a shared
library will be put before all other attributes. Once the attribute ID
is looked up in the dynamic ref table, the package ID is no longer 0x00,
which means this ID is no longer in sorted order. This messes up the
logic in AssetManager2::GetBag, and results in some style attributes
getting dropped from shared libraries.

This change modifies how aapt2 sorts the style entries, sorting entries
with dynamic IDs after entries with the android framework ID. This means
the entries will still be in sorted order when the IDs are looked up.

Bug: 147674078
Test: TableFlattenerTest.FlattenSharedLibraryWithStyle
Change-Id: Ic4f4004b6d9cecde9325dcdb37f71138857f8236
2020-01-16 12:37:36 -08:00
Adrian Roos
1d75e9c921 ProtoLogTool: Fix thread pool leak on code generation exception
Fixes an issue where the thread pool leaks when code generation
throws an exception (for example because of an invalid log string).

When the thread pool leaks, System.exit() no longer works, because
the JVM waits for all threads to exit - which never happens for the
leaked thread pool.

Test: `ProtoLog.w(LOG_GROUP, new String())` -> make droid should not hang
Change-Id: Ibdae0f1e68441c6fe004398d146f496503ccc4cd
2020-01-16 19:13:13 +00:00
Anton Hansson
b2f709db1d Add <extension-sdk> manifest tag inside <uses-sdk>
This allows apps to specify the minimum versions they need
of extension sdks, and fails install if they aren't met.

There is additional work required to prevent local rollbacks
from triggering a downgrade of SDK versions after an install.

Bug: 137191822
Test: atest PackageParserTest
Exempt-From-Owner-Approval: PS4 was approved
Change-Id: If61ae6c67ceb752bec6876006a29e52b996901e7
2020-01-16 11:59:52 +00:00
Muhammad Qureshi
f29d5c88da Merge "Make writeKeyValuePairs accept Nullable args" 2020-01-16 01:25:22 +00:00
Muhammad Qureshi
996afa633c Make writeKeyValuePairs accept Nullable args
API Review requested to remove unneeded allocations so pass null for
arguments that are empty when writing KeyValuePairs

Bug: 146383532
Test: m
Change-Id: Ic1788f65e8c7f837d6800d59c186519a82882bf7
2020-01-15 13:35:41 -08:00
TreeHugger Robot
ee7c5ccea7 Merge "Allow first uid in attribution chain as primary field" 2020-01-13 23:28:40 +00:00
Clark Duvall
e2bb499531 Merge "Fix serializing dynamic references to proto" 2020-01-13 23:10:50 +00:00
Clark DuVall
e9fedbe223 Fix serializing dynamic references to proto
The is_dynamic bit on references was getting lost when converting to
proto and back. This was preventing bundles from being used as shared
libraries, since layout inflation would fail when it hit a dynamic
reference.

Bug: 146491000
Test: Build a shared library with a layout that has a dynamic reference,
      and attempt to inflate that layout.

Change-Id: Ia0e615670d2ac52f9266e3eec8813af7687d3323
2020-01-13 09:55:53 -08:00
tsaichristine
ed6156442d Allow first uid in attribution chain as primary field
Test: bit statsd_test:*
Bug: 142108433
Change-Id: I6a2f8e6198765d4205dac95e5f54666496b78808
2020-01-13 09:35:38 -08:00
Ryan Mitchell
0252b862de Merge changes from topic "shared-lib-tele-res"
* changes:
  Allow for overlaying dynamic shared libraries
  Assign shared libraries stable package ids
2020-01-13 15:15:57 +00:00
Ryan Mitchell
ee4a564d4f Allow for overlaying dynamic shared libraries
Overlays targeting shared libraries should be loaded into the
resources of every target that depends on the shared library.

Static shared libraries are currently not supported because overlays
should override all versions of static shared libraries and there is
not currently support for an overlay targeting multiple APKs.

Also created a test instrumentation and host test suite for testing
overlays and packages on the system image.

Bug: 140790224
Test: atest OverlayRemountedTest
Change-Id: I20a217b6368d6cf92b2b9f46908fd58012933f72
2020-01-10 23:20:19 +00:00
Automerger Merge Worker
8ba8e66257 Merge "Add liblog as a dependency where libbase is used" am: 5576f58f1b am: cbbfc3c898 am: cb5a358083
Change-Id: I52d917453bf5784b0fcd195d86fa32a31280a9b6
2020-01-10 19:34:34 +00:00
Automerger Merge Worker
6e6e0c50cf Merge "Make extract_package() work for toplevel classes." am: c9c54798f6 am: 3300498502 am: 595272c971
Change-Id: I5878d03ddfdf0fc21bfb1a2a6cd457154c2c69d7
2020-01-10 19:34:09 +00:00
Tom Cherry
5576f58f1b Merge "Add liblog as a dependency where libbase is used" 2020-01-10 16:59:43 +00:00
Tobias Thierer
4effc4b64a Make extract_package() work for toplevel classes.
Before this CL, classes in the unnamed package, such as

L$r8$backportedMethods$utility$Objects$2$checkIndex

(which looks like it is generated by R8 for Objects.checkIndex() calls)
were breaking the build because extract_package was incorrectly assuming
that there would always be a '/' in the identifier string.

Test: Build that previously broke is now working.

Change-Id: Ice78d6b31c4f38a3c9d529bc6156d625d19bcacf
2020-01-10 14:28:21 +00:00
Tom Cherry
1089bdfb43 Add liblog as a dependency where libbase is used
Bug: 119867234
Test: build
Change-Id: Iad0de2cef63aa52bb573e1571efbac1d689e7603
2020-01-09 11:11:28 -08:00
TreeHugger Robot
0b94e6b49e Merge "Use preview_sdk_int for version code checks" 2020-01-09 01:38:35 +00:00
Muhammad Qureshi
b6f32d9fe2 Use preview_sdk_int for version code checks
Don't use Build.VERSION.CODENAME to check for R.
Use Build.VERSION.SDK_INT > Q || (Build.VERSION.SDK_INT == Q &&
        Build.VERSION.PREVIEW_SDK_INT > 0)

Bug: 146235828
Test: m DocumentsUIGoogle

Change-Id: I59e327d4e92d41a93b6bea145b8497fd4f85108c
2020-01-08 16:10:57 -08:00
TreeHugger Robot
916c97b796 Merge "Add option to avoid clobbering visibility of <declare-styleable>" 2020-01-07 22:40:18 +00:00
Donald Chai
94e4a01dec Add option to avoid clobbering visibility of <declare-styleable>
"aapt2 compile" marks styleables as public instead of preserving
information from <public/> or --visibility options.  This behavior can
now be disabled via --preserve-visibility-of-styleables.

Bug: 146649511
Change-Id: Ifb8ab396573d1393df737a59625e79e9cf2494a7
Tested: aapt2_tests
2020-01-07 12:55:52 -08:00
Philip P. Moltmann
9046d82b8f Allow apps to define featureIds in the manifest
Test: CtsAppOpsTestCases (with newly added test for featureIds declared
      in manifest)
Bug: 144997947
Change-Id: I5563ae6861318e4cc1d196e3f6aea378a4dcf748
2020-01-03 10:08:03 -08:00
TreeHugger Robot
314413652a Merge "Rename log_from_module to module" 2020-01-03 10:47:32 +00:00
Muhammad Qureshi
d40b62f4cd Merge "Add --supportQ flag to java StatsLog codegen" 2020-01-03 01:46:03 +00:00
Muhammad Qureshi
167ba844d7 Add --supportQ flag to java StatsLog codegen
Add support to generate Q schema code generation only for modules that
ship to Q.

Bug: 145606209
Test: m
Test: flashes successfully
Test: adb logcat "*:S statsd:*"
Change-Id: I978ac321415f1e8d76e4ec73445894965845aaea
2020-01-02 15:05:52 -08:00
Muhammad Qureshi
bcf6606f46 Rename log_from_module to module
Bug: 145951577
Test: m
Test: flashes successfully
Test: inspect adb logcat "*:S statsd:*"
Change-Id: I4f5fedb63f1d4c743d8dd474f14950c7f36c6999
2020-01-02 14:54:59 -08:00
Muhammad Qureshi
2ee00fb249 Remove dependency on libutils in native autogen
Right now, Q schema generated code has a dependency on libutils.
Turning on R schema for clients will remove libutils as a required
dependency. Once libutils is removed from clients, turning the flag off
again will be complicated as all clients will need to re-include
libutils. To fix this problem, remove dependency on libutils in Q
schema.

Right now, we only use SystemClock.h from libutils in Q schema autogen.
Use timespec from C standard library instead.

Bug: 146808265
Test: m
Test: flashes successfully
Test: adb logcat "*:S statsd:*"
Test: bit statsd_test:*
Change-Id: I00efeab1be351a95083f3b6e2dbc9067849bee20
2020-01-02 14:54:39 -08:00
Muhammad Qureshi
4fdc7fd375 Support new socket schema in native codegen
New code generation implementation is flag guarded by
STATS_SCHEMA_LEGACY

Support for Q schema can be added by passing --supportQ flag in
stats_log_api_gen. (Only needed for statslog_resolv.cpp)

Q schema is supported through StatsEventCompat.

Generated R schema statslog.h:
https://paste.googleplex.com/4986214782337024

Generated R schema statslog.cpp:
https://paste.googleplex.com/4856851575341056

Generated R schema statslog_resolv.h:
https://paste.googleplex.com/6062978921136128

Generated R schema statslog_resolv.cpp:
https://paste.googleplex.com/4752329251225600

Generated Q schema statslog.h:
https://paste.googleplex.com/4766729873915904

Generated Q schema statslog.cpp:
https://paste.googleplex.com/5018563779756032

Generated Q schema statslog_resolv.h:
https://paste.googleplex.com/5338897498243072

Generated Q schema statslog_resolv.cpp:
https://paste.googleplex.com/5191011011657728

Test: m -j
Test: flashes successfully
Test: adb logcat inspection
Change-Id: I5675a80c03ca3fbd5cd4a02c04a4b9cb89ec32ab
2020-01-02 14:54:16 -08:00
Ryan Mitchell
cd78febeac Recognize dynamic res ids as valid
Shared libraries are assigned package id 0. Resource ids that start
with 0x00 are not invalid. This change changes is_valid to accept
dynamic resource ids and adds an is_valid_static method for when
an id must have a non-zero package id.

This also fixes an issue that made layouts in shared libraries that
use internal attributes exclude compiled resource ids from the binay
xml output.

Bug: 146491000
Test: Build a shared library with a layout that uses app attributes
      as well as android attribute and verify that all attributes
      have assigned resource ids using `aapt2 dump xmltree`

Change-Id: Ibc0407c610ffc98d7aaf233c37c065912ab0d516
2019-12-19 18:22:45 +00:00
TreeHugger Robot
a261d615dd Merge "Fix deserialization of @id aliases" 2019-12-18 22:58:06 +00:00
Muhammad Qureshi
0868413c19 Merge "Move statsd metadata from statslog to atoms_info" 2019-12-18 01:44:15 +00:00
Muhammad Qureshi
c8e226610c Move statsd metadata from statslog to atoms_info
Clients don't need to know about statsd metadata. Extract out metadata
from statslog.h/cpp into atoms_info.h/cpp which is only used by statsd.

Generated atoms_info.h: https://paste.googleplex.com/6303016724463616
Generated atoms_info.cpp: https://paste.googleplex.com/5717940978581504

Test: m -j
Test: old metadata in statslog matches the metadata in
atoms_info
Test: Flashes successfully
Test: adb logcat "*:S statsd:*"

Change-Id: I56ef3cc4ea1fbd2cd0130d4e9576b242efb9f627
2019-12-17 12:59:01 -08:00
Automerger Merge Worker
cfb045a481 Merge "Regenerate LocaleDataTables.cpp" am: 6658c31b4e am: ccc64a5aef am: ffbeb382a2
Change-Id: Ic6beb9b8a0374663babf41431e5f59ad7c18f7d0
2019-12-17 14:45:33 +00:00
vichang
6658c31b4e Merge "Regenerate LocaleDataTables.cpp" 2019-12-17 11:28:19 +00:00
Victor Chang
e84c6b50c2 Regenerate LocaleDataTables.cpp
LocaleDataTables.cpp is outdated due to ICU update over the years

Test: ./tools/localedata/extract_icu_data.py $ANDROID_BUILD_TOP
Test: m droid
Change-Id: I21918cc0f50c7347e514dc7b015607e19cffb377
2019-12-16 15:31:09 +00:00
Donald Chai
4abc82859d Fix deserialization of @id aliases
I didn't realize that this was actually a thing, but:

  <resources>
    <item name="id1" type="id"></item>
    <item name="id2" type="id">@id/id1</item>
  </resources>

leads to a resource table which 'aapt dump resources' will render as:

    resource 0x7f030000 com.pkg:id/id1: t=0x03 d=0x00000001 (s=0x0008 r=0x00)
    resource 0x7f030001 com.pkg:id/id2: t=0x01 d=0x7f030000 (s=0x0008 r=0x00)

while 'aapt2 dump resources' printed:

  type id id=03 entryCount=2
    resource 0x7f030000 id/id1
      () (id)
    resource 0x7f030001 id/id2
      () (id)

After this change, it prints:

  type id id=03 entryCount=2
    resource 0x7f030000 id/id1
      () (id)
    resource 0x7f030001 id/id2
      () @id/id1

Bug: 69445910
Change-Id: I0001ff09345434577ac4c1d32f96a781f4190d8d
Tested: manual, see above
2019-12-14 07:29:01 +00:00
TreeHugger Robot
d5cbd092ab Merge "Generate "keep" rules for actionProviderClass and actionViewClass" 2019-12-12 04:36:35 +00:00
TreeHugger Robot
5e68b5c709 Merge "Fix StatsEvent memory usage for pulled events" 2019-12-10 23:18:07 +00:00
Muhammad Qureshi
9e829804e1 Fix StatsEvent memory usage for pulled events
Add usePooledBuffer flag to the Builder which determines whether to reuse
the Buffer's byte array in StatsEvent or use a copy.
The build() function also calls release() on the Buffer
if a copy of the Buffer's byte array is passed to StatsEvent.

Also, for pushed events, release the StatsEvent object and consequently,
the Buffer in StatsLog.write(StatsEvent)

Fixes: 145026572
Fixes: 144126444
Test: bit FrameworksCoreTests:android.util.StatsEventTest
Change-Id: I1cdaf0027b69281cb7cb6f3c8ca923d03829b4dd
2019-12-10 13:27:38 -08:00
TreeHugger Robot
995fbdb659 Merge "Fix aapt2 JavaClassGenerator Maybe#value() call before check" 2019-12-09 19:47:59 +00:00
Muhammad Qureshi
67df8893dd Handle nulls in Java autogeneration
Bug: 143979391
Test: m -j
Change-Id: I93146faa1976cac195c2250832d12ee4a09ae969
2019-12-08 20:40:46 -08:00
Ryan Mitchell
4e19c48a6e Fix aapt2 JavaClassGenerator Maybe#value() call before check
Previous refactor accidentally assumed all attributes would have
resolvable symbols when generating the R class. Restore previous
behavior of calling SkipSymbol before retrieving the attribute
comment.

Bug: 145685954
Test: m TeleService
Change-Id: Ie8e1092556bc0b6a764462ffa0b99a876bcbd70e
2019-12-06 13:05:44 -08:00
satayev
0c637f535c Merge "Move UnsupportedAppUsageProcessor to tools/platform-compat" am: d7dd4ad00c am: cf662a4aac
am: 82993fd505

Change-Id: Ib704126399887b529e091b247dbd936348aeec53
2019-12-05 06:46:57 -08:00
satayev
8899e8f174 Merge "Handle overrideSourcePosition in unsupportedappusageprocessor." am: 168c609085 am: be7b380039
am: 271ca11abe

Change-Id: I05d1a54032c456b9e07674199e334a4d483298f2
2019-12-04 14:44:45 -08:00
Artur Satayev
38deb176b0 Move UnsupportedAppUsageProcessor to tools/platform-compat
Test: diff unsupportedusage_index.csv
Bug: 145132366
Change-Id: I2e03788ba20f5801d6aa429e5daac927966c5bff
Merged-In: I2e03788ba20f5801d6aa429e5daac927966c5bff
2019-12-04 17:54:11 +00:00
Jean-Luc Coelho
181cbfde80 Add "no-proguard-location-reference" flag to aapt2
This fixes relocatability issues with the code shrinkers.

Bug: 144529940
Test: None
Change-Id: I65e08e850193e67dcdf4c533d9e66332714f0c8c
2019-12-02 21:11:08 +00:00
Mathew Inwood
2867ddf511 Handle overrideSourcePosition in unsupportedappusageprocessor.
The property is currently set by the AIDL compiler to indicate the original
position of the annotation in the AIDL file. Use this position in
preference to the annotation position within Java code if it's present.

Also rework the tests to use the google compile-testing library rather than
my crufty javac library. This makes testing failure conditions much nicer.

Bug: 145120552
Test: atest unsupportedappusage-processor-test
Test: m framework-annotation-proc
Change-Id: Icaac9b40672dce028095b578c19950b688506c0d
2019-12-02 11:42:07 +00:00
Izabela Orlowska
5b89b2d320 Use case-sensitive regular expressions in --no-compress-regex
On some windows versions (plus wine) std::regex has issues with the
icase flag (making regex case insensitive). Put the responsibility of
the case sensitivity on the caller.

Fixes: 127793905
Test: wine aapt2_tests.exe -> Util_test
Change-Id: I6775514d3ef43c2c47465bf39ceaf2c195909724
2019-11-27 18:37:09 +00:00