4

AppWidgetManager的 Android 文档中,它说

The total Bitmap memory used by the RemoteViews object cannot exceed that required 
to fill the screen 1.5 times, ie. (screen width x screen height x 4 x 1.5) bytes.

但是TransactionTooLargeException的文档说:

The Binder transaction buffer has a limited fixed size, currently 1Mb, which is 
shared by all transactions in progress for the process.

市场上几乎每个 Android 设备的屏幕尺寸都足够大,以至于填充它的位图会超过 1Mb(例如 800 x 600 x 4 = 1,920,000 字节)。我查看了Android平台源代码,它似乎没有使用带有管道或任何深奥的ashmem,只是一个普通的AIDL文件,并且在RemoteViews中,位图对象以正常的方式是Parcelable(它确实下降到本机代码,但它似乎将所有位图像素写入常规包裹)。

那么Android怎么可能超过Binder事务限制呢?是否oneway允许发送更大的数据?

4

2 回答 2

0

Bitmaps是专门处理的。它们位于本机内存中,并且只有引用在包中传递。尝试将位图序列化byte[],我敢打赌它会崩溃。

于 2019-04-13T21:12:42.217 回答
-1

CommonsWare 在评论中回答了这个问题,答案是否定的,文档有误。

同样oneway在您的aidl中使用可能会使您的代码更有可能命中事务太大,因为RPC将在通过活页夹发送的数据被消耗之前立即返回,从而允许您将更多数据推送到活页夹并让您更接近或超过极限。

于 2015-02-11T20:12:01.640 回答