Commit Graph

9629 Commits

Author SHA1 Message Date
Bernardo Rufino
df232c0faf Merge "Deprecate unsafe parcel APIs" am: 9f8b914c9f am: 87b6f365d3 am: 04f4d7aa21
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1890540

Change-Id: I1cedae136129697fcf2df852034eb6c422e6316a
2021-11-17 10:37:31 +00:00
Bernardo Rufino
04f4d7aa21 Merge "Deprecate unsafe parcel APIs" am: 9f8b914c9f am: 87b6f365d3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1890540

Change-Id: If483ab5bd836e3700d67bc7ba6701f5e35a58b57
2021-11-17 10:20:56 +00:00
Bernardo Rufino
9f8b914c9f Merge "Deprecate unsafe parcel APIs" 2021-11-17 09:43:11 +00:00
Yifan Hong
5c940e62c3 Merge "Add ServiceManager.registerForNotifications" am: ce80de5db0 am: 45ddf12cbc am: 3b546f86e0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1883550

Change-Id: Ic5346dff7ffdb0f2d0d8e911cb931db167c7a2b0
2021-11-17 06:12:15 +00:00
Yifan Hong
3b546f86e0 Merge "Add ServiceManager.registerForNotifications" am: ce80de5db0 am: 45ddf12cbc
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1883550

Change-Id: I8f7746e16b1e60fbc29a93dae3046b05f00c212d
2021-11-17 05:55:32 +00:00
Yifan Hong
6a2929d6ce Add ServiceManager.registerForNotifications
Add the API to call into IServiceManager.registerForNotifications.

Test: pass
Change-Id: Ia74d8a1bd5be767a076560bf8ee4af3095b4623a
2021-11-12 19:36:52 -08:00
Bernardo Rufino
36cf3994ed Deprecate unsafe parcel APIs
Deprecate unsafe parcel APIs and point to the safer ones that take the
expected type as parameter. Where applicable also mention the typed ones
that take the creator as argument since those are also more performant.

APIs deprecated here are:
* readMap(Map, ClassLoader)
* readList(List, ClassLoader)
* readHashMap(ClassLoader)
* readArrayList(ClassLoader)
* readArray(ClassLoader)
* readSparseArray(ClassLoader)
* readParcelable(ClassLoader)
* readParcelableCreator(ClassLoader)
* readSerializable()

Test: Builds
Bug: 195622897
Bug: 199275680
Bug: 205985058
Change-Id: Ic41ae13e0d965b1fd346985c77c1eecc605285b2
2021-11-12 17:56:53 +00:00
Donald Chai
b5217cf799 Merge "Fix some obvious typos and copy-paste bugs." am: 1cfd0c7546 am: b78ad69fa0 am: 9378d318f4 am: 13b24677c2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1851673

Change-Id: I426f2f418a371a60a5ed6bf752190536d35dd5c6
2021-11-10 22:46:44 +00:00
Hao Ke
fd018845a0 Merge "Adding typed Parcel readMap and readHashMap APIs." am: c1f406eb81 am: 4c669c6685 am: 9bc154843f am: eb937f4dc2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1882888

Change-Id: I1edee63ffcef1140016e96beab414028ff00eedc
2021-11-10 22:45:49 +00:00
Donald Chai
13b24677c2 Merge "Fix some obvious typos and copy-paste bugs." am: 1cfd0c7546 am: b78ad69fa0 am: 9378d318f4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1851673

Change-Id: I6023e92cb9c6b338f96fbb85c9df51b81286e0a1
2021-11-10 22:24:56 +00:00
Hao Ke
eb937f4dc2 Merge "Adding typed Parcel readMap and readHashMap APIs." am: c1f406eb81 am: 4c669c6685 am: 9bc154843f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1882888

Change-Id: Ica5ee4975ff02abcd126372d6372db4ea3ace057
2021-11-10 22:24:30 +00:00
Donald Chai
1cfd0c7546 Merge "Fix some obvious typos and copy-paste bugs." 2021-11-10 21:16:52 +00:00
Hao Ke
c1f406eb81 Merge "Adding typed Parcel readMap and readHashMap APIs." 2021-11-10 21:14:41 +00:00
Hao Ke
446144c9a8 Adding typed Parcel readMap and readHashMap APIs.
Added typed read API of `readMap` and `readHashMap`,
that takes extra clazz parameters check that the class written
on the wire is the same or a descendant from the one provided
as the key and value arguments.

Doing so could enhance the security of Parcel deserialization,
as it would prevent unexpected types of objects being deserialized.
More details can be found at go/safer-parcel.

Test: atest -d android.os.cts.ParcelTest
Bug: 195622897
Change-Id: Ife9d1d7277b6345a6e11856179c301339b2dc087
2021-11-10 15:45:12 +00:00
Jooyung Han
1d52ea1455 Merge "Parcel: add new methods for interface list/array" am: 2500e149bc am: ef7ca34bbe am: 90d9045ad5 am: ecc29bfce7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1881006

Change-Id: I5f809b781cf8e62624840183659c25ce1bcb31d1
2021-11-10 01:51:11 +00:00
Jooyung Han
ecc29bfce7 Merge "Parcel: add new methods for interface list/array" am: 2500e149bc am: ef7ca34bbe am: 90d9045ad5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1881006

Change-Id: I375c7a2dfe80addbc4cf8dcb1dfcd4455aa31c1a
2021-11-10 01:31:48 +00:00
Jooyung Han
bbacfde150 Parcel: add new methods for interface list/array
New methods are to write a list/array of interface objects and to read
them again.

Basically these methods are quite similar to those for IBinder objects.
But when reading IInterface objects, we need to create an array of the
exact type and need a way of converting IBinder into IInterface value.

Two functional interfaces (newArray and asInterface) are just like
while Parcelable.Creator does. We could pass "Stub" class which is
generated by the AIDL compiler and use reflection to create a typed
array instance and call `asInterface` method. But rather than relying on
reflection, passing `IMyInterface[]::new` and
`IMyInterface.Stub::asInterface` would be simple enough to use.

Bug: 205195901
Test: atest -d android.os.cts.ParcelTest
Change-Id: I275db9ebf52d3b9713fa105d81da3a1d289d96a8
2021-11-09 10:26:29 +09:00
Bernardo Rufino
7e83fa172f Merge "Refactor Bundle for thread-safety of Bundle.hasFileDescriptors()" am: f5cc73d25f am: adcfd2f940 am: f509e2d9b7 am: 7ceb94a294
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1878339

Change-Id: I16160df17d88600d73549e07027a14634fc3ddbb
2021-11-05 19:05:29 +00:00
Roopa Sattiraju
c11076edb3 Merge "Change getEnabledComponentOverrides return type" am: 30cd5df67f am: 3374e0478a am: 27d3253e54 am: 802dd06c6b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1853043

Change-Id: I6f6c146f5ccf98c2d63b5d49e9478eac9922c697
2021-11-05 19:05:07 +00:00
Bernardo Rufino
317e1a51f9 Merge "Improve @hide Parcel.hasFileDescriptors(Object)" am: 41d4be0fef am: e927d812de am: c823dcac51 am: e0c9e8a87c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1878338

Change-Id: Ia8dab5d1475d47d8491d81f2ac81312b550c5727
2021-11-05 19:04:27 +00:00
Steven Moreland
0e2cef8556 Merge "Binder: correction of javadoc formatting" am: a83307fbd8 am: 0784bb4330 am: 7ebf0a92ff am: cd045eb0ff
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1877757

Change-Id: Id40a2d6958a2c4456f0dc299c3c1fadf248b1d29
2021-11-05 18:54:58 +00:00
Bernardo Rufino
7ceb94a294 Merge "Refactor Bundle for thread-safety of Bundle.hasFileDescriptors()" am: f5cc73d25f am: adcfd2f940 am: f509e2d9b7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1878339

Change-Id: I3c96c9db67d902b63cb376f19e642454635fab43
2021-11-05 18:29:50 +00:00
Roopa Sattiraju
802dd06c6b Merge "Change getEnabledComponentOverrides return type" am: 30cd5df67f am: 3374e0478a am: 27d3253e54
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1853043

Change-Id: Icfb0808c72c573d51f4ca16c477bb7b903a9cb20
2021-11-05 18:29:07 +00:00
Bernardo Rufino
f5cc73d25f Merge "Refactor Bundle for thread-safety of Bundle.hasFileDescriptors()" 2021-11-05 17:43:00 +00:00
Roopa Sattiraju
30cd5df67f Merge "Change getEnabledComponentOverrides return type" 2021-11-05 17:33:00 +00:00
Bernardo Rufino
e0c9e8a87c Merge "Improve @hide Parcel.hasFileDescriptors(Object)" am: 41d4be0fef am: e927d812de am: c823dcac51
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1878338

Change-Id: Ifd22d79f5bedb021e59345e9290979fe099be9c4
2021-11-05 15:40:33 +00:00
Bernardo Rufino
41d4be0fef Merge "Improve @hide Parcel.hasFileDescriptors(Object)" 2021-11-05 14:51:18 +00:00
Steven Moreland
cd045eb0ff Merge "Binder: correction of javadoc formatting" am: a83307fbd8 am: 0784bb4330 am: 7ebf0a92ff
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1877757

Change-Id: Iedb0de534dce1df8eb37c6b07a9e5141cc69a09a
2021-11-05 05:53:07 +00:00
Dima
0d9bb37a9a Binder: correction of javadoc formatting
Fixed javadoc formatting, namely references to methods that were typoed and displayed incorrectly in Android Studio.

Change-Id: I190eab35bc7ec6e162cb6d614b2c74523ff86c1c
2021-11-03 08:10:04 +00:00
Bernardo Rufino
7c296d7514 Refactor Bundle for thread-safety of Bundle.hasFileDescriptors()
After aosp/1878338, I realized Bundle.hasFileDescriptors() was accessing
mParcelledData and mMap without a lock. So, to avoid locking
there, I made mParcelledData volatile (since after mParcelledData is
null, it can never be non-null again and mMap is guaranteed to be
non-null). So, moved assignments to mParcelledData to be last wrt mMap
and mParcelledByNative to ensure visibility of those fields.

While refactoring copyInternal(), realized that method was always used
after constructing an uninitialized Bundle, so to avoid mistakes with
objects not properly initialized, I created a constructor in Bundle,
PersistableBundle & BaseBundle that does that copyInternal() did.

Bug: 195622897
Test: atest -d android.os.cts.ParcelTest android.os.cts.BundleTest android.os.BundleTest android.os.ParcelTest
Change-Id: I5c9337496da7ecf87f10370726099dcb247a6789
2021-11-02 11:42:11 +00:00
Bernardo Rufino
31d70842e0 Improve @hide Parcel.hasFileDescriptors(Object)
Addressing Jeff's comment on aosp/1787847 to support List<> in
Parcel.hasFileDescriptor(), also added support for Map (+ArrayMap) and
Object[] that were missing. Made the checks recursive since it's
possible to put nested containers in bundle. Since that's @hide and only
used by bundle, included Parcel as a supported type too and clarified in
the javadoc.

That allowed to clean up Bundle.hasFileDescriptors().

Bug: 195622897
Test: atest -d android.os.cts.ParcelTest android.os.cts.BundleTest android.os.BundleTest android.os.ParcelTest
Change-Id: I6acf358763d8f544fc6ff1a5b0c8bdff567d50be
2021-11-02 10:54:58 +00:00
Hao Ke
c48eeadf56 Merge "Adding typed Parcel read APIs for Serializable." am: bce40e7c6e am: 9a6145139a am: ff54e8149a am: 1c9ca7b8a9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1870153

Change-Id: I33d3078eacec37b33708d6b8c74637f410178435
2021-11-02 03:02:42 +00:00
Hao Ke
1c9ca7b8a9 Merge "Adding typed Parcel read APIs for Serializable." am: bce40e7c6e am: 9a6145139a am: ff54e8149a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1870153

Change-Id: I9a866ff3c3b232199ee311f93a50abe3e92930d0
2021-11-02 02:50:39 +00:00
Hao Ke
bce40e7c6e Merge "Adding typed Parcel read APIs for Serializable." 2021-11-02 02:08:29 +00:00
Bernardo Rufino
28826f285c Merge "Add range-based Parcel.compareData()" am: 98a4a1b8b9 am: e9eb2ecff1 am: dcfad1498f am: bddf602aca
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1854184

Change-Id: Ia79e802b1efb2068bc00cb7266dd5b6ff5433d92
2021-11-01 12:17:16 +00:00
Bernardo Rufino
bddf602aca Merge "Add range-based Parcel.compareData()" am: 98a4a1b8b9 am: e9eb2ecff1 am: dcfad1498f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1854184

Change-Id: Ic4f0f52f688bfa95ffe820103cd59b437edd9132
2021-11-01 12:13:44 +00:00
Bernardo Rufino
98a4a1b8b9 Merge "Add range-based Parcel.compareData()" 2021-11-01 11:27:05 +00:00
Hao Ke
ec4b60c1ad Adding typed Parcel read APIs for Serializable.
Added typed read API of `readSerializable`, that takes
an extra Class<T> parameter to 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,
as it would prevent unexpected types of objects being deserialized.
More details can be found at go/safer-parcel.

Test: atest -d android.os.cts.ParcelTest
Bug: 195622897
Change-Id: I94e48ac7fe8f5d3ba4c54100cb76ce3e4aacdd09
2021-10-29 14:44:32 +00:00
Michael Wright
204a9dfbfb Add constant for SC V2.
Bug: 204295952
Test: N/A
Merged-In: Ieecebfccf9366815c93d620b70aeabc1abcd3ebd
Change-Id: Ieecebfccf9366815c93d620b70aeabc1abcd3ebd
2021-10-28 14:15:47 +00:00
Bernardo Rufino
7e4edf5be1 Add range-based Parcel.compareData()
To be used by lazy value. Now, we also remove getValueParcel() that was
copying the section of the parcel since we don't need that anymore.

Test: atest -d android.os.cts.ParcelTest android.os.cts.BundleTest android.os.BundleTest android.os.ParcelTest
Bug: 195622897
Change-Id: Ic8a0d1b6a268a81df7a1e56fa1e4b307a25210b6
2021-10-28 09:19:34 +01:00
Treehugger Robot
c51af3d298 Merge "Remove bytes matcher from base" am: d3dfca9c68 am: 55a81e6cc0 am: 5ce3ad0bb0 am: df5e60718b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1853038

Change-Id: I19b6e9a4bbee4f556c0fc59e4ce5764844a14667
2021-10-27 20:04:08 +00:00
Treehugger Robot
df5e60718b Merge "Remove bytes matcher from base" am: d3dfca9c68 am: 55a81e6cc0 am: 5ce3ad0bb0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1853038

Change-Id: I029f17d4e31534e2501aa670605d2cee7116a7ea
2021-10-27 20:01:55 +00:00
Treehugger Robot
d3dfca9c68 Merge "Remove bytes matcher from base" 2021-10-27 18:26:37 +00:00
Hao Ke
0a0df3c6bc Merge "Adding typed Parcel read APIs 2" am: 79c9ea52e5 am: 931724fb75 am: f3a5c881eb am: 79f142e30e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1854703

Change-Id: Ie739860e6b4ff455eb4ebc8f957ea8be9c7e1c24
2021-10-27 17:19:58 +00:00
Hao Ke
79f142e30e Merge "Adding typed Parcel read APIs 2" am: 79c9ea52e5 am: 931724fb75 am: f3a5c881eb
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1854703

Change-Id: Ib4ec629792833efc390614444b43a28402e17b3b
2021-10-27 16:59:11 +00:00
Hao Ke
79c9ea52e5 Merge "Adding typed Parcel read APIs 2" 2021-10-27 15:59:41 +00:00
Treehugger Robot
0b0587fd69 Merge "Rename isHandlingTransaction to isDirectlyHandlingTransaction" am: 7eb7f9efaf am: 0a3a353ec0 am: 84dc08e004 am: 1f4f565bf0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1818907

Change-Id: I87ebbeb23a2fbb144b03df8cf8ec0128408374b7
2021-10-25 21:18:03 +00:00
Treehugger Robot
1f4f565bf0 Merge "Rename isHandlingTransaction to isDirectlyHandlingTransaction" am: 7eb7f9efaf am: 0a3a353ec0 am: 84dc08e004
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1818907

Change-Id: I2403dd12f5ef54dd79bf46cc5e1cdb976b7285d2
2021-10-25 21:04:09 +00:00
Hao Ke
4875dd14eb Adding typed Parcel read APIs 2
Added typed read APIs of `readArray`, `readArrayList`,
`readParcelableArray` and `readSparseArray`.

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: Iaba24c35a0c0acc77ae2d22ac77c5a90efd93329
2021-10-23 01:41:42 +00:00
Alice Ryhl
7845ea4a85 Rename isHandlingTransaction to isDirectlyHandlingTransaction
The change in aosp/1806594 is adding a method to the binder ndk called
isHandlingTransaction, but that method behaves differently from this
method when HIDL gets involved, as getCurrentServingCall returns
HWBINDER in that case.

Test: m
Change-Id: Ie2812943d1e98e99a1c361475965a2c75214724a
2021-10-19 08:51:59 +00:00