Commit Graph

557 Commits

Author SHA1 Message Date
TreeHugger Robot
619db7fbcd Merge "Use structure aware fuzzing for pngs" 2021-01-20 17:19:02 +00:00
TreeHugger Robot
9f3d2ddbe9 Merge "(A)ImageDecoder: fix sampled dimensions with exif" 2021-01-19 15:00:09 +00:00
Leon Scroggins III
8f7742448f Use structure aware fuzzing for pngs
Bug: 142252770
Bug: 169137236
Bug: 169139756
Test: this

Features built into the PNG format slow down fuzzing (e.g. CRC, encoded
lengths) [1]. Use structure aware fuzzing for PNG to do a better search
through the input space. Add png_mutator.h (unchanged from [2] under the
Apache 2.0 license). Split imagedecoder_fuzzer into two targets: one for
PNGs (since the mutator converts all inputs into PNG), and one for the
other formats.

Move fuzz_imagedecoder.cpp and the corpus/ into the new fuzz/ directory,
to keep fuzzing separate from the libjnigraphics library. Remove
png_test.png from the corpus; structure aware fuzzing will do a better
job of fuzzing PNGs, and the generic one should focus on other formats.

[1] https://github.com/google/fuzzing/blob/master/docs/structure-aware-fuzzing.md
[2] 51356066dc/libpng-1.2.56/png_mutator.h (L1)

Change-Id: I8aebb0d0abfa18793334f2d217b28a51d096123a
2021-01-19 09:57:38 -05:00
Leon Scroggins III
5a5c2ce593 (A)ImageDecoder: fix sampled dimensions with exif
Test: I138ec784a77253c7ae94765d0670e5947d97caf5

Recently (Ib93b0ced09fa3cca4a6681745406355c48158fae), handling exif
moved from SkAndroidCodec to hwui/ImageDecoder. This missed
getSampledDimensions, which reports the sampled dimensions without
taking exif into account. Fix this for both
android.graphics.ImageDecoder and AImageDecoder. Note that in the Java
case, the method is private, and although the method was returning
swapped dimensions in some cases, it gets corrected by
getTargetDimension, so there is no user visible change.

Change-Id: I918328c39d6230ae6ba4cab0733fff0732b39888
2021-01-19 09:57:35 -05:00
TreeHugger Robot
33dcfd49bf Merge "fuzz_imagedecoder: ignore allocation failures" 2021-01-15 18:35:23 +00:00
Leon Scroggins
e2abb20e2b Merge "Build libjnigraphics, imagedecoder_fuzzer on host" 2021-01-15 14:24:34 +00:00
TreeHugger Robot
70fc9865bc Merge "Remove __ANDROID_API__ guards" 2021-01-15 09:51:48 +00:00
Jiyong Park
ab0846e035 Remove __ANDROID_API__ guards
__ANDROID_API__ guards are removed in favor of __INTRODUCED_IN macros.

Currently, __INTRODUCED_IN macro does nothing for these headers (it's
meaningful only to the headers processed by versioner which are limited
to binic headers). The plan is to make the macros to tag the declaration
with the availability attribute. Then, when the min_sdk_version of a
caller is set to an API level that is older than the API level of the
APIs, the compiler will provide them as weak symbols and enforce that
calling the APIs are guarded with a runtime check.

For now, these guards are preventing from making a build system change
to let __ANDROID_API__ track the min_sdk_version property instead of the
sdk_version property. With the build system change, __ANDROID_API__ will
suddenly drop for the native modules where min_sdk_version <
sdk_version, which is the case when the modules are included in APEXes.
As a result, some new APIs will be unavailable at build-time. Dropping
the hand-written guards fixes the problem.

Bug: 163288375
Test: m
Change-Id: I8cafdba77fe358b2dcc9ad33f43c5410c9c27934
2021-01-15 15:59:16 +09:00
TreeHugger Robot
17a32e8072 Merge "Improve AImageDecoder fuzzer" 2021-01-15 05:05:02 +00:00
Leon Scroggins III
ba9a690d26 fuzz_imagedecoder: ignore allocation failures
Bug: 142252770
Bug: 169137236
Bug: 169139756
Test: this

Image decoders may attempt to allocate a large amount of memory
(especially if the encoded image is large). This doesn't necessarily
mean there is a bug. Set allocator_may_return_null = 1 for hwasan so the
fuzzer can continue running.

Change-Id: Ib750a142e28d01144036409786e631dfb783283f
2021-01-14 12:26:51 -05:00
Leon Scroggins III
c72d0fb15d Build libjnigraphics, imagedecoder_fuzzer on host
Bug: 142252770
Bug: 169137236
Bug: 169139756
Test: SANITIZE_HOST=address make imagedecoder_fuzzer

This will allow running the fuzzer much faster in order to find bugs. It
also allows running with ASAN to help find memory leaks.

Some symbols (e.g. ABitmap, AAssetStreamAdaptor) rely on
Android-specific features, so disable them when building on the host.
This still allows using the core features of AImageDecoder.

This requires a change in frameworks/native
(Iefdb4132d6f10f9164be85f4dc6e11883f6fd37e).

Disable detecting ODR violations when building with ASAN (which is how
host builds are built). Without this change, the host detects the
following:

    =================================================================
    ==4072183==ERROR: AddressSanitizer: odr-violation (0x7fb7d52b4100):
      [1] size=80 'vtable for android::VectorImpl' system/core/libutils/VectorImpl.cpp
      [2] size=80 'vtable for android::VectorImpl' system/core/libutils/VectorImpl.cpp
    These globals were registered at these points:
      [1]:
        #0 0x55fefda47e0d in __asan_register_globals /out/llvm-project/compiler-rt/lib/asan/asan_globals.cpp:360:3
        #1 0x7fb7d43aa77b in asan.module_ctor (/usr/local/ssd/android/master/out/host/linux-x86/fuzz/x86_64/imagedecoder_fuzzer/../lib/libhw
ui.so+0x17c677b)

      [2]:
        #0 0x55fefda47e0d in __asan_register_globals /out/llvm-project/compiler-rt/lib/asan/asan_globals.cpp:360:3
        #1 0x7fb7d52a0e6b in asan.module_ctor (/usr/local/ssd/android/master/out/host/linux-x86/fuzz/x86_64/imagedecoder_fuzzer/../lib/libutils.so+0x3de6b)

    ==4072183==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
    SUMMARY: AddressSanitizer: odr-violation: global 'vtable for android::VectorImpl' at system/core/libutils/VectorImpl.cpp
    ==4072183==ABORTING

Change-Id: I0ffc4e90b4083db79fbb12012e2e1284206b43e3
2021-01-14 12:22:05 -05:00
Leon Scroggins III
f63c349053 Improve AImageDecoder fuzzer
Bug: 169137236
Bug: 169139756
Test: this (fuzzer)

Extend the fuzzer to test animations.

Also test a lossless webp, left out of
Ib227639bf8da75f0e8e31e216bc6d1371e24cb75.

Change-Id: I81d35d6fa7d560b33b6a2b5d6c1992cbdd77bc87
2021-01-14 11:57:39 -05:00
Leon Scroggins
335388de8a Merge "Add a corpus of test files" 2021-01-14 15:18:03 +00:00
Leon Scroggins
cdbe8352da Merge "AImageDecoder: Add a fuzz target" 2021-01-14 15:14:13 +00:00
TreeHugger Robot
41903dfea1 Merge "Implement AImageDecoder_setInternallyHandleDisposePrevious" 2021-01-14 06:08:01 +00:00
Leon Scroggins III
cc60f0d733 Add a corpus of test files
Bug: 142252770
Bug: 169137236
Bug: 169139756
Test: This (fuzzer)

Attempt to cover the types supported by AImageDecoder:
- jpeg (progressive and baseline)
- png
- webp (animated and non-animated)
  - should maybe include lossless, too?
- gif
- ico (embedded png and bmp)
- bmp
- wbmp
- heif
- various dng formats

These files are either already checked into CTS or Skia.

Change-Id: Ib227639bf8da75f0e8e31e216bc6d1371e24cb75
2021-01-13 12:09:19 -05:00
Leon Scroggins III
140f5086ee AImageDecoder: Add a fuzz target
Bug: 142252770
Bug: 169137236
Bug: 169139756
Test: This (fuzzer)

Use the bytes to create an image file and decode it.

To run:

$ SANITIZE_TARGET=hwaddress make imagedecoder_fuzzer
$ adb root
$ adb sync data
$ adb shell /data/fuzz/arm64/imagedecoder_fuzzer/imagedecoder_fuzzer

Call startThreadPool() to support HEIF. Otherwise HEIF decodes may time
out on binder IPC calls. This is similar to a fix for skia_dm in
https://skia-review.googlesource.com/c/skia/+/108141.

Change-Id: I434730a74c5ff97437526065c41af3f54fae3335
2021-01-13 12:09:18 -05:00
Leon Scroggins III
c2ebc2bcf3 Implement AImageDecoder_setInternallyHandleDisposePrevious
Bug: 160984428
Test: I00682f201a52f894b0e1335c00c4368ce675a805

Also fix a bug caught by the new test. If the current frame is the first
in a series of one or more RestorePrevious frames, fPriorFrame should be
set to |currentFrame - 1|. Otherwise SkCodec will decode the required
frame. This is wasted work, since the prior frame should already be
prepared (either by AImageDecoder or by the client).

Change-Id: I1fb9f91dc66fd3121f187b9a91c15f625eb17f8d
2021-01-13 12:09:18 -05:00
Leon Scroggins
3c7bdeacaf Merge "Implement AImageDecoder_resultToString" 2021-01-08 18:47:50 +00:00
Leon Scroggins
14c70a7793 Merge changes from topics "FrameInfo", "_advanceFrame"
* changes:
  Implement FrameInfo methods on AImageDecoder
  Implement AImageDecoder _advanceFrame and _rewind
2021-01-08 17:08:27 +00:00
TreeHugger Robot
dfb9559362 Merge "Add TEST_MAPPING to run WebView CTS/GTS tests in presubmit." 2021-01-08 14:47:59 +00:00
Leon Scroggins III
946f8d41bc Implement AImageDecoder_resultToString
Bug: 160984428
Test: I118eaa99cd65b70dbfb2c8a7731c714564911a34
Change-Id: Iac444b04521056ae6f08cf7bbf12a79a80698c4c
2021-01-08 09:37:22 -05:00
Anna Malova
4d7d9603e9 Add TEST_MAPPING to run WebView CTS/GTS tests in presubmit.
Bug: 173406791
Test: cd frameworks/base/core/java/android/webkit && atest --test-mapping
Change-Id: Ic75336a7067faf2c9ec10c8b7089eee48b2ec89d
2021-01-08 12:33:56 +00:00
Chris Forbes
6e73857c79 Merge "thermal: Add AThermal_getThermalHeadroom" 2021-01-07 00:05:41 +00:00
TreeHugger Robot
709933c162 Merge "Handle EXIF orientation in hwui/ImageDecoder" 2021-01-06 23:08:50 +00:00
Leon Scroggins III
0621313fe6 Implement FrameInfo methods on AImageDecoder
Bug: 160984428
Test: If47d475233f6b9973abf68029b63a610ff47cdae

- AImageDecoder_getFrameInfo
- AImageDecoderFrameInfo_create
- AImageDecoderFrameInfo_delete
- AImageDecoderFrameInfo_getDuration
- AImageDecoderFrameInfo_getFrameRect
- AImageDecoderFrameInfo_getDisposeOp
- AImageDecoderFrameInfo_getBlendOp
- AImageDecoderFrameInfo_hasAlphaWithinBounds

These allow querying for information specific to a single frame in an
encoded image.

Change-Id: I6ce5665e9c25aed23f99ce88290e520d68fcb60e
2021-01-06 13:53:20 -05:00
Jeff Sharkey
c29ea55465 Merge "Fix OWNERS for graphics" am: 9193da7db1 am: d6b927581d am: 76b29b2b5d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1540385

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie0da0ca2b9ddd9763c76d05f5922fe4febffe95f
2021-01-05 23:20:14 +00:00
John Reck
97dd9f1623 Fix OWNERS for graphics
core/java/android/graphics doesn't exist, so neither
does core/android/graphics/OWNERS

Fix the include path to point to the graphics source of truth
as /graphics/java/android/graphics/OWNERS

Test: this
Change-Id: I5a1e6edbc82df5e3b2979753a6d7329707c55d88
2021-01-05 16:05:50 -05:00
Leon Scroggins III
139145be80 Handle EXIF orientation in hwui/ImageDecoder
Bug: 160984428
Test: AImageDecoderTest#testRespectOrientation
       ImageDecoderTest#testRespectOrientation
      Ieda439910ae52e609f0710d424503616d99ae5c7
      I23caef26b4c82173c758dd0ce7fb6f04e4154588
      I345a13d20776a007052d32e74fa42865b42f726d

It is possible to create an animated image with an exif orientation.
Using kRespect, there is no clean way to handle the orientation plus
compositing frames. Switch ImageDecoder to use kIgnore (the default).

Depends on a change in Skia (https://review.skia.org/344762) to make
SkAnimatedImage handle the orientation even with kIgnore.

Change-Id: Ib93b0ced09fa3cca4a6681745406355c48158fae
2021-01-05 12:37:47 -05:00
Leon Scroggins III
b26aebc325 Implement AImageDecoder _advanceFrame and _rewind
Bug: 160984428
Test: Iae7d274b69999c471fd5610c6ef4d148cca81bec

Disallow AImageDecoder_set* methods after the first frame, since
changing the settings would interfere with blending and caching for
kRestorePrevious frames.

Add a cache (and a state machine) for handling kRestorePrevious frames.

Follow-on to Ib93b0ced09fa3cca4a6681745406355c48158fae - support using
a matrix for unpremul + orientation (the orientation was previously
handled by a matrix internally in SkAndroidCodec).

Change-Id: I7c32ede013fa83f1fe95c35778c33278ca6fe6a3
2021-01-05 12:37:47 -05:00
Chong Zhang
366ef60790 Merge "transcoding: move MediaTranscodeManager to apex" 2020-12-23 03:28:03 +00:00
Daniel Norman
4209c4bc3f Merge "Updates noparent to only apply to the per-file files." am: ea8ca4b88a am: 96acd833fc am: f15eb86be0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1535381

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7d16d3b3d878c698bd0fc650bc25dc50c41e5bbc
2020-12-23 00:01:53 +00:00
Daniel Norman
94a2752536 Updates noparent to only apply to the per-file files.
This is needed to fix invalid OWNERS for other files in this directory.

Test: n/a
Change-Id: I5d6d4b8c578ba066cf968cb719b6dd29693f017b
2020-12-22 20:35:04 +00:00
Chong Zhang
864d0b7220 transcoding: move MediaTranscodeManager to apex
bug: 159172726
test: builds; presubmit; manual testing transcoding locally.
Change-Id: I727912a04cf4f7f03fdf5fa0a74e522f69dca66f
2020-12-22 19:34:46 +00:00
Chris Forbes
1900bef116 thermal: Add AThermal_getThermalHeadroom
Bug: b/168612028
Change-Id: I8f192b50f74b1666beeab3ad546c9e3b25842187
2020-12-16 16:04:43 -08:00
Jeff Sharkey
0ab7007631 resolve merge conflicts of 358f0d4fc8 to master
Bug: 174932174
Test: I solemnly swear I tested this conflict resolution.
Exempt-From-Owner-Approval: refactoring with team leads buy-in
Change-Id: I9262a08ffc1ccede8e519d0eed90ed2bfcf0232c
2020-12-08 11:01:05 -07:00
Jeff Sharkey
52b9862f87 Improve OWNERS coverage across frameworks/base/.
As general background, OWNERS files expedite code reviews by helping
code authors quickly find relevant reviewers, and they also ensure
that stakeholders are involved in code changes in their areas.

Some teams under frameworks/base/ have been using OWNERS files
successfully for many years, and we're ready to expand them to cover
more areas.  Here's the historical coverage statistics for the last
two years of changes before these new OWNERS changes land:

-- 56% of changes are fully covered by OWNERS
-- 17% of changes are partially covered by OWNERS
-- 25% of changes have no OWNERS coverage

Working closely with team leads, we've now identified clear OWNERS on
a per-package basis, and we're using "include" directives whenever
possible to to simplify future maintenance.  With this extensive
effort, we've now improved our coverage as follows:

-- 98% of changes are fully covered by OWNERS
-- 1% of changes are partially covered by OWNERS
-- 1% of changes have no OWNERS coverage

This specific change is automatically generated by a script that
identifies relevant "include" directives.

Bug: 174932174
Test: manual
Exempt-From-Owner-Approval: refactoring with team leads buy-in
Merged-In: I3480ddf2fe7ba3dfb922b459d4da01fa17a2c813
Change-Id: I3480ddf2fe7ba3dfb922b459d4da01fa17a2c813
2020-12-08 08:36:28 -07:00
Chong Zhang
c4be44372d Merge "Add AActivityManager UidImportance test" 2020-12-04 17:15:45 +00:00
Chong Zhang
cb95b8375b Merge "Add ActivityManager UidImportanceListener to libandroid" 2020-12-04 17:15:45 +00:00
Chong Zhang
e6bcd1bbb1 Add AActivityManager UidImportance test
Add a gtest that runs as root to test receving UidImportance
updates.

bug: 172942349
bug: 159172726

Change-Id: I2c6ee84f09afd1638c53e502e288f23bd8717a9b
2020-12-02 09:24:42 -08:00
Vasiliy Telezhnikov
6b237640fa Add API to WebView functor to support overlays
This CL adds api that exposes SurfaceControl to allow webview to
submit ASurfaceTransaction synchronously with hwui draw.

Test: just new API stubs, nothing to test.
Change-Id: I3a70ad12d04e5a1655887faf3782426a9131a999
2020-11-25 13:11:10 -05:00
Yiwei Zhang
7d8bb8a465 Adding AHardwareBuffer_getId to libandroid
Bug: 163615119
Test: atest AHardwareBufferTest
Change-Id: I95339f326125183ab4b57c22011bbe034c11a33d
2020-11-19 00:06:46 +00:00
Chong Zhang
8af87925ea Add ActivityManager UidImportanceListener to libandroid
Add UidImportanceListener methods to libandroid for native apex use.

bug: 172942349
bug: 159172726
bug: 146507383

test: updated mediatranscoding's UidPolicy locally to use the new api,
and passed mediatranscodingservice unit tests.

Change-Id: I7ca76f057a83b5bcd634deb2408784d7b93e46fc
2020-11-18 08:57:03 -08:00
Marin Shalamanov
41ffa8dd06 Add shouldBeSeamless param to Surface.setFrameRate
This CL adds a new parameter shouldBeSeamless to the existing
setFrameRate APIs. This parameter indicates whether the desired
refresh rate should be achieved only seamlessly or also switches
with visual interruptions for the user are allowed. The default
value of the new parameter is "true".

Test: atest SetFrameRateTest
Test: atest RefreshRateConfigsTest
Test: atest libsurfaceflinger_unittest
Bug: 161776961
Change-Id: Ic2446d278e4f57fe507d30a0a18ef7b85909da4b
2020-11-17 11:53:14 +01:00
Chong Zhang
06dbe5bf2c Add APermissionManager_checkPermission to libandroid
And allow IActivityManager#checkPermission to be used by native code.

bug: 172283477
bug: 159172726
Change-Id: I582fb918ac3ddc2289ef0040a4391db407673692
2020-11-06 01:49:55 +00:00
Colin Cross
2e21e9b289 Merge "Make the connection between implementation and llndk_library explicit" am: 3e7b21c1b6 am: 2cbc12ba3e am: e0f4fce861 am: 7eebf2a93a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1465666

Change-Id: I9c4e659cf8c47d63d808079c4bffad77b9764b4b
2020-10-23 20:14:54 +00:00
Vishnu Nair
ce1a648484 Allow creating child surfaces from BlastBufferQueue
App such as Chrome create child surfaces and parent them to
surfaces provided by SurfaceView. When we enable the blast
adapter for SurfaceView, the IGBP returned to the app is
created in the client and SurfaceFlinger does not know about it.
When the app creates a child surface and provides the IGBP as the
parent surface identifier, SF fails to validate the IGBP and the
surface is not created. This can be avoid if the client creates the
child surface from the SV SurfaceControl but we still need to
support existing APIs.

To fix this, when we create a Surface from the adapter, pass in
the handle of the Blast SurfaceControl. When calling
ASurfaceControl_createFromWindow, use this handle to identify
the parent.

Bug: 168917217
Test: adb shell settings put global use_blast_adapter_sv 1 & launch chrome
Change-Id: I879b411c47e8558397516bd7b7278813e79e005f
2020-10-22 18:03:22 -07:00
Colin Cross
27f13787e1 Make the connection between implementation and llndk_library explicit
Instead of assuming a module with the .llndk suffix exists, add an
llndk_stubs property to every cc_library module that has a
corresponding llndk_library.  Also rename the llndk_library to have
an explicit .llndk suffix.

Bug: 170784825
Test: no changes to build.ninja (excluding comments) or Android-${TARGET_PRODUCT}.mk
Change-Id: I5f0b9d92162b532b1e6e8752ac3e130759cde08c
2020-10-19 13:37:57 -07:00
TreeHugger Robot
377af5a74f Merge "Implement AImageDecoder_getRepeatCount" 2020-10-14 17:21:17 +00:00
Leon Scroggins
429fc8c1a5 Merge "Implement AImageDecoder_isAnimated" 2020-10-13 15:00:43 +00:00