Commit Graph

9488 Commits

Author SHA1 Message Date
Steven Moreland
7402f8c51b Merge "getBlobAshmemSize -> getOpenAshmemSize" am: b146c8bedb am: ab8578378d am: 4ef3dc86b8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1854070

Change-Id: I13d8848ed6cc4823555af1db46f5e186c292a63e
2021-10-14 18:17:56 +00:00
Hao Ke
0cdb183ba9 Merge "Add “@throws BadParcelableException” to the JavaDoc of new API methods that throw the exception." am: d6f306117a am: ce08bacce0 am: 956294ef72
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1857934

Change-Id: I234e7606d9e2f948df596dd75aa7664a878bfa69
2021-10-14 18:17:38 +00:00
Steven Moreland
b146c8bedb Merge "getBlobAshmemSize -> getOpenAshmemSize" 2021-10-14 17:43:16 +00:00
Hao Ke
d6f306117a Merge "Add “@throws BadParcelableException” to the JavaDoc of new API methods that throw the exception." 2021-10-14 17:30:43 +00:00
Hao Ke
f98489f1c0 Add “@throws BadParcelableException” to the JavaDoc of new API methods that throw the exception.
Test: atest -d android.os.cts.ParcelTest
Bug: b/203004511
Change-Id: I24bf7314e63015d46ab478ec8c44ecf22857bac2
2021-10-14 15:31:37 +00:00
Steven Moreland
4760ca91de getBlobAshmemSize -> getOpenAshmemSize
This API returns the total size of all ashmem memory that is in FDs that
is owned by a Parcel object. It was renamed a while ago, but the name
was never updated in Java.

Bug: 202029388
Test: atest android.app.NotificationTest
Change-Id: Icc428063083110952cf3951721d69cbb919429b1
2021-10-13 11:01:35 -07:00
Bernardo Rufino
c8c4599806 Merge "Add range-based Parcel.hasFileDescriptors(offset, length)" am: ef5365a7f6 am: bdfc59ce7b am: 6437028c2e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1849458

Change-Id: I63e398a9690bba3e47c2f5f2c26281d604f1c62b
2021-10-13 16:21:52 +00:00
Bernardo Rufino
ef5365a7f6 Merge "Add range-based Parcel.hasFileDescriptors(offset, length)" 2021-10-13 15:34:32 +00:00
Michael Wright
579d71a68d Merge "Update haptics OWNERS" am: 0c3e42ebd3 am: 187ec0f00f am: c912019c5a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1853474

Change-Id: I9f3a3b4587324009bcd3cd81012624a686d09be9
2021-10-12 22:51:58 +00:00
Michael Wright
313839a2d9 Update haptics OWNERS
Change-Id: I265d27cdb721616bf56c3b34c9d239b3e962e98c
2021-10-12 14:29:03 +00:00
Bernardo Rufino
172c97db77 Add range-based Parcel.hasFileDescriptors(offset, length)
To be used by lazy values in bundle. I ended up opening up as public API
for apps to use it too because I saw no reason not to, can change if
folks prefer it to be @hide though.

Test: atest -d android.os.cts.ParcelTest android.os.cts.BundleTest android.os.BundleTest android.os.ParcelTest
Bug: 195622897
Change-Id: I7bf580f94313669fe67998b32b2723544c594cde
2021-10-08 15:11:32 +01:00
Xin Li
c03b0fa033 Merge "Merge Android 12" 2021-10-07 23:50:15 +00:00
Treehugger Robot
0fda0ff863 Merge "Improve Bundle/PersistableBundle docs" am: 9a2a261abd am: 509a70ea06 am: ab6e8374b5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1846255

Change-Id: Ie6f1e908dc212142f3ed46075c932eebb400ca35
2021-10-07 14:58:46 +00:00
Treehugger Robot
509a70ea06 Merge "Improve Bundle/PersistableBundle docs" am: 9a2a261abd
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1846255

Change-Id: I22cff9303a22273617bce75ddc361f59d4799e9d
2021-10-07 14:29:04 +00:00
Bernardo Rufino
40e22dc991 Improve Bundle/PersistableBundle docs
around equals(), hashCode(), toString()

Test: TH passes
Bug: 122589814
Bug: 62611412
Bug: 122589479
Change-Id: Ia644e437f9b5642228c2a7138b0518f73ef2996c
2021-10-06 15:25:33 +00:00
Treehugger Robot
7b03023777 Merge "Avoid full unparcelling where possible in Bundle" am: 3ad4ecc296 am: 3aaf984908 am: cb329ca948
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1842226

Change-Id: Ib1f1a23a5e3fcac9691db094f79e63b4415546b3
2021-10-06 12:55:15 +00:00
Treehugger Robot
3aaf984908 Merge "Avoid full unparcelling where possible in Bundle" am: 3ad4ecc296
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1842226

Change-Id: I0aef93d99d83f20b22753e8e1d41cfb5c4b5cdce
2021-10-06 12:25:47 +00:00
Treehugger Robot
3ad4ecc296 Merge "Avoid full unparcelling where possible in Bundle" 2021-10-06 12:06:59 +00:00
Bernardo Rufino
8e6a8db691 Merge "Change defusing for lazy bundles" am: fdd1771a4a am: 3f3c3a02c2 am: 104767cc75
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1842142

Change-Id: I0e82653ac77ce4940a0690c12e74478be197f5ee
2021-10-06 09:21:01 +00:00
Bernardo Rufino
3f3c3a02c2 Merge "Change defusing for lazy bundles" am: fdd1771a4a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1842142

Change-Id: Ia156038712d6a25acfea8aaa6ac1d257afa95345
2021-10-06 08:57:27 +00:00
Bernardo Rufino
fdd1771a4a Merge "Change defusing for lazy bundles" 2021-10-06 08:43:17 +00:00
Bernardo Rufino
9e26212dac Avoid full unparcelling where possible in Bundle
and put a warning where it's not possible. This is to make sure we know
when to touch bundles provided by apps.

In this CL:
* deepCopy() now doesn't deserialize lazy objects before copying. It
  doesn't copy them either, it merely passes them into the new map as
  the same reference. This works because we implemented fine-grained
  locking into each lazy value, so concurrent access won't be a problem.
  Furthermore, LazyValue caches the deserialized object, so we'd still
  honor the contract of deepCopy() that "Other types of objects (such
  as Parcelable or Serializable) are referenced as-is and not copied in
  any way". I had to perform one extra check in the synchronized block
  in LazyValue to guarantee this (double-checked locking), I explain
  that in the comments.
* Removed filterValues() and codepaths that used it. This was created
  with the purpose of removing items whose classes weren't available to
  the system to prevent crashes coming from full deserialization. This
  is not a concern anymore with lazy bundle, hence we can remove the
  codepaths altogether (see email for more details).
* Put warnings in javadoc of getMap() and PeristableBundle().

Test: Boots
Test: atest -d android.os.cts.ParcelTest android.os.cts.BundleTest android.os.BundleTest android.os.ParcelTest
Bug: 195622897
Change-Id: I14bb6a7874814f42cbcc6b5fd372c42752aa74c8
2021-10-05 13:39:36 +01:00
Bernardo Rufino
0c5074ede7 Change defusing for lazy bundles
With lazy bundle, exceptions thrown by deserialization of custom items
moved from being thrown in initializeFromParcelLocked() (when the bundle
is first touched) to being thrown in getValueAt() (whenever the item is
retrieved), which means they were escaping the defuse logic that caught
those exceptions. So, now also catching these exceptions in
getValueAt(), however, here we can be much less drastic, instead of
erasing the bundle, we can simply remove the bad element.

This also means we don't need to log wtf in initializeFromParcelLocked()
if sShouldDefuse = true but the bundle is not marked as defusable, since
touching the bundle doesn't carry the same consequences as before
go/lazy-bundle. So, I moved that log to unparcel(itemwise = true), ie.
whenever the entire bundle is deserialized on purpose.

Now, 2 types of defusing can happen:
1. If the (custom) item we're retrieving caused the exception, we'll
   remove the item and return null.
2. If the exception was raised during partial deserialization, that is,
   during the read of the map and its basic types (while skipping custom
   types), the map will be left empty. I believe only manually written
   parcels would cause this type of exception and if an exception is
   raised here it will also be raised in the final destination too,
   afaict. Because of this, we can now touch app-provided bundles
   without fear of clobbering the data on its way to the final
   destination.

Following conversation on previous CL, narrowed exception raised in case
of unknown type to be BadParcelableException.

Test: atest -d android.os.cts.ParcelTest android.os.cts.BundleTest android.os.BundleTest android.os.ParcelTest
Bug: 195622897
Change-Id: I4746140f63482a9ea475aac25897a447737393e4
2021-10-05 11:40:13 +01:00
Steven Moreland
406c497da3 Merge "Parcel: obtain(IBinder) as API" am: e869287a7b am: 9a7bbf9367 am: e3ebe8abee
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1817684

Change-Id: Ie2c3c682cbc068f130c3485b7f9416d4e720e11c
2021-10-04 21:40:44 +00:00
Steven Moreland
9a7bbf9367 Merge "Parcel: obtain(IBinder) as API" am: e869287a7b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1817684

Change-Id: I2655c1c2b74b0501912fa4e90f5655db682b2932
2021-10-04 21:14:21 +00:00
Steven Moreland
e869287a7b Merge "Parcel: obtain(IBinder) as API" 2021-10-04 20:55:08 +00:00
Steven Moreland
c861533254 Parcel: obtain(IBinder) as API
There are two main usecases for this:
- provide an alternative route to implement features like markSensitive
  (which requires only 1 function call per class, rather than a
    function call and flag per transaction type)
- support RPC format transactions

Bug: 175814583
Test: atest android.os.ParcelTest, boot, manual
Change-Id: Ibaacc27a125a31e18d4b5889d05d12cc18d05624
2021-10-01 14:51:18 -07:00
Bernardo Rufino
ac52200025 Merge "Correct Parcel value types" am: 861d2e12cb am: e9ffc7f08f am: 633ca9c492
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1838973

Change-Id: I7f2369e7406517ee39d2738f25e44f6c29a4c637
2021-10-01 10:23:59 +00:00
Bernardo Rufino
e9ffc7f08f Merge "Correct Parcel value types" am: 861d2e12cb
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1838973

Change-Id: I0ad34ad29a54cf58ac37ec347a59b45a59959ea1
2021-10-01 09:58:17 +00:00
Bernardo Rufino
5539926c4a Correct Parcel value types
* Bundle supports types char, char[], short[], float[] which were
  falling back to serializable handling in Parcel because readValue()
  didn't have specific support for those types. Adding support in Parcel
  to avoid the need for length-prefixing and to improve performance.
  Curiously some of those had read/write methods already.
* Updated Bundle to just pull the types above from the map since those
  won't be lazy values anymore.
* We were missing a few custom type containers in our list of
  length-prefixed types and we were listing Bundle unnecessarily as
  length-prefixed since Bundle itself is already length-prefixed and
  copies the correspondent section of the parcel internally.

Test: atest -d android.os.cts.ParcelTest android.os.cts.BundleTest android.os.BundleTest android.os.ParcelTest
Bug: 195622897
Change-Id: I1e15d59d883311685ffa32ece1f5a00e01bf6aea
2021-10-01 09:07:49 +01:00
Hao Ke
07db24f4a8 Merge "Adding typed Parcel read/write APIs." am: d3199a6084 am: e01e2ae588 am: 79d1a62a0a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1832336

Change-Id: Ib386f0af652288ed0108efce683009f6fbbddbd6
2021-09-30 21:59:12 +00:00
Hao Ke
e01e2ae588 Merge "Adding typed Parcel read/write APIs." am: d3199a6084
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1832336

Change-Id: I8a2341eef230f078c53b31a03478fa30e3774147
2021-09-30 21:31:36 +00:00
Hao Ke
d3199a6084 Merge "Adding typed Parcel read/write APIs." 2021-09-30 21:13:54 +00:00
Steven Moreland
9063197cdb Merge "Parcel: markForBinder -> obtain(IBinder)" am: fb7a6db2a2 am: 73c85c59f7 am: 2a607b900b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1840654

Change-Id: Idc36af3bc12bf730207a0c37991a908baa0a6f27
2021-09-30 18:45:41 +00:00
Steven Moreland
73c85c59f7 Merge "Parcel: markForBinder -> obtain(IBinder)" am: fb7a6db2a2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1840654

Change-Id: Ibde592b1d34c2e7143c961c7d2e2029d0fbfd82f
2021-09-30 18:16:37 +00:00
Steven Moreland
fb7a6db2a2 Merge "Parcel: markForBinder -> obtain(IBinder)" 2021-09-30 17:59:47 +00:00
Sam Gilbert
c17751421a Merge "Fix writeToParcel parameter nullability" am: 55fb62a515 am: 182a0a144e am: 12da16335e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1840533

Change-Id: I19a572cd3767746546c7f5c02bbb3b1d9481303a
2021-09-30 17:42:14 +00:00
Sam Gilbert
182a0a144e Merge "Fix writeToParcel parameter nullability" am: 55fb62a515
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1840533

Change-Id: Ieabc166af0086501cc638cffa7dc6f5960f67172
2021-09-30 17:24:46 +00:00
Sam Gilbert
55fb62a515 Merge "Fix writeToParcel parameter nullability" 2021-09-30 17:08:19 +00:00
Hao Ke
8a86e7d51e Adding typed Parcel read/write APIs.
Description:

Added replacements of `readList`, `readParcelable` and
`readParcelableCreator` APIs.

To avoid unexpected types of objects being unparcelled,
ideally clients would use the readTypedXXX() methods that
take the parcelable creator. However, this won’t be an option
for use cases involving deserializing children objects
inherited from non-final parcelable or serializable objects.
Currently out of ~4k parcelable classes, only ~1.5k
are marked as “final” in the platform. Hence it would be
necessary to introduce new replacements that take
an extra Class<T> parameter and before deserializing
we check that the class written on the wire is the
same or a descendant from the one provided as argument.

Doing so could enhance the security of Parcel deserialization,
More details can be found at go/safer-parcel.

Test: atest -d android.os.cts.ParcelTest
Bug: 195622897
Change-Id: Ie9a4cb4c3d6f1805b14df7b703aef43e2993d459
2021-09-30 16:31:16 +00:00
Bernardo Rufino
18e5be7b98 Merge "Log.wtf in mismatch + tests" am: 1cdbc7cbd1 am: d60218eb45 am: 5d32036b41
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1837194

Change-Id: If1fa51158bfa1dd5fa901d907aea72a6c8379ddc
2021-09-30 11:04:34 +00:00
Bernardo Rufino
d60218eb45 Merge "Log.wtf in mismatch + tests" am: 1cdbc7cbd1
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1837194

Change-Id: I185410ce82ca057b6767d5ca0ff0368f046a1dff
2021-09-30 10:31:03 +00:00
Steven Moreland
8c15362858 Parcel: markForBinder -> obtain(IBinder)
So that the API more closely matches intended usage, as requested.

Bug: 175814583
Test: aidl_integration_test
Change-Id: I2fb5f2d5059d7f9cd9e034a4d0d2e7aa63692067
2021-09-29 16:17:45 -07:00
Sam Gilbert
e3e9e3f6d4 Fix writeToParcel parameter nullability
Test: Existing tests
Bug: 144855352
Change-Id: Id3e0de043eee77e1dadf3b4db5d6d4bddd9e8247
2021-09-29 13:54:34 -04:00
Bernardo Rufino
95ace87925 Log.wtf in mismatch + tests
Log mismatches as wtf to be able track those. Also added unit tests
around kindofEquals() and r/w mismatches.

Test: atest -d android.os.cts.ParcelTest android.os.cts.BundleTest android.os.BundleTest android.os.ParcelTest
Bug: 195622897
Change-Id: I361dd144b23975eedc8b19ed65457a1c5405936e
2021-09-29 13:51:43 +01:00
Martijn Coenen
09c663fd4a Merge "Fix race condition around CE storage becoming available." into sc-qpr1-dev am: d172b787d3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15879518

Change-Id: Ie35ae63d9cdcf0442ab216bfee52e61a1f1c7d23
2021-09-24 07:44:41 +00:00
Martijn Coenen
d172b787d3 Merge "Fix race condition around CE storage becoming available." into sc-qpr1-dev 2021-09-24 07:32:13 +00:00
Martijn Coenen
1db2e74252 Merge "Run a GC after killing a UID due to binder proxy limit." into sc-qpr1-dev am: 745bc36216
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15889363

Change-Id: I8431c90f63f11016f6ad592284c3599cfbed3203
2021-09-24 07:14:57 +00:00
Treehugger Robot
78cb6529fc Merge "VintfObject.getHalNamesAndVersions report AIDL version number." am: c39842abd9 am: 6b6d1da5f3 am: 2480509575
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1832955

Change-Id: If6021e99ed3fe3f21207a65abc2cb432763ad79a
2021-09-24 01:55:07 +00:00
Yifan Hong
bd38ae368e Merge "Add owners for VINTF." am: ec854a738f am: 8804125b5b am: f729ceacbf
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1835453

Change-Id: Ic99ead4a59f1c3f89aaffd64110f536b09b08ab1
2021-09-24 01:54:52 +00:00