Optimize parcelization protocol in RemoteViews and RemoteCollectionItems
By using "squashing", each ApplicationInfo is only written to the parcel once. Subsequent writes write only a single int as a reference. This makes the earlier system with ELIDE_DUPLICATES unnecessary. Squashing relies on testing for equality, and ApplicationInfo does not implement equals, therefore I've added a shared cache based on package name and uid so that we can force all RemoteViews of the same package to use the same ApplicationInfo object. There is also a mechanism to update the ApplicationInfo to a new one (needed for dynamic colors). This saves space for addView calls as well as RemoteCollectionItems usage. After this change, each incremental item in a collection adds 48 bytes as a base (before this was multiple kilobytes). This approach also supports collections with RemoteViews from multiple packages. Each ApplicationInfo in the entire hierarchy is written at most once. Bug: 202831917 Test: locally, atest RemoteViewsTest, atest RemoteViewsFixedCollectionAdapterTest Change-Id: Ie1b1dc8760247aa771451149243efd63d36da368
Loading
Please register or sign in to comment