android 蓝牙opp传输,为什么Android通过蓝牙OPP接收时严格限制可接受的文件类型?...

问候stackoverflow.

最近,我正在追踪Android框架中的蓝牙操作机制.我注意到在通过OPP接收文件时,this patch会产生一些文件类型限制.

在com.android.bluetooth.opp包中,Constants.java中有一个固定的白名单

/**

* The MIME type(s) of we could accept from other device.

* This is in essence a "white list" of acceptable types.

* Today,restricted to images,audio,video and certain text types.

*/

public static final String[] ACCEPTABLE_SHARE_INBOUND_TYPES = new String[] {

/* ... some types such as images and music ... */

};

这限制了BluetoothOppObexServerSession.java中可接受的文件类型

// Reject policy: anything outside the "white list" plus unspecified

// MIME Types.

if (!pre_reject

&& (mimeType == null || (!Constants.mimeTypeMatches(mimeType,Constants.ACCEPTABLE_SHARE_INBOUND_TYPES)))) {

if (D) Log.w(TAG,"mimeType is null or in unacceptable list,reject the transfer");

pre_reject = true;

obexResponse = ResponseCodes.OBEX_HTTP_UNSUPPORTED_TYPE;

是什么让我们关注这种情况下的MIME类型?据我所知,我们可能希望阻止可执行文件(即* .apk,* .so),因为这些文件可能会损害我们的设备.如果阻止某些特定类型是我们在此设置列表的原因,为什么我们会在此补丁之前使用白名单而不是黑名单?当我们通过其他非蓝牙协议(如HTTP)传输文件时是否存在类似的限制?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值