Android Bluetooth OPP的理解与使用之一
当前OPP Source Code基于Android O(8);
Andorid 中Bluetooth OPP的实现与其HFP、A2DP等Profile不一样,其没有Framework层实现,即
frameworks\base\core\java\android\bluetooth中并没有OPP的对外接口;
同时在Server 层中,packages\apps\Bluetooth\src\com\android\bluetooth\opp的命名也和HFP等Profile不一样:其Java file命名使用了Bluetoothxxx字样,这通常只出现在Framework等对外的接口中;
本文继续以问答形式展开:
问题点1: Android 手机的OPP 如何使用?
OPP的使用并不是先配对连接再操作,而是在Android手机中先选择需发送的文件,然后选择蓝牙发送,其会弹出已配对设备,选择后将直接发送,发送完成后将自动断开OPP连接;
以下截图是OPP手机操作文件发送:
问题点2:Android Bluetooth OPP Server 层相关OPP files的作用;
在packages\apps\Bluetooth\src\com\android\bluetooth\opp中相关OPP files比别的profile多很多,理清基本file作用,有助于对OPP的理解;
BluetoothOppBatch:This class stores information about a batch of OPP shares that should be transferred in one session;用于保存一个或一批OPP 发送或接收对象信息,其作为OPP的操作单元去理解;
BluetoothOppBtEnableActivity: 用于BluetoothOppLauncherActivity,若当前BT 没有打开时,BluetoothOppLauncherActivity将执行当前Activity弹出提示菜单用于User 点击确认(将执行mOppManager.enableBluetooth();)或取消打开BT(此时不做任何处理直接关闭当前dialog);
BluetoothOppBtEnablingActivity: 当前菜单将在BluetoothOppBtEnableActivity点击确认后弹出,其内部设置20S超时Message BT_ENABLING_TIMEOUT用于等待BT on成功或失败;
BluetoothOppBtErrorActivity: 这是一个错误提示菜单,用于基于实际情形进行错误信息提示;
BluetoothOppFileProvider:继承于FileProvider(但FileProvider本身是ContentProvider的子类),用于操作已经接收到的文件(注意:这里并不是操作接收的过程,而是对已经接收到的文件进行操作);
BluetoothOppHandoverReceiver: 用于接收特定4个Message
"android.btopp.intent.action.WHITELIST_DEVICE",
"android.btopp.intent.action.STOP_HANDOVER_TRANSFER",
"android.nfc.handover.intent.action.HANDOVER_SEND",
"android.nfc.handover.intent.action.HANDOVER_SEND_MULTIPLE"
其在Androidmanifest.xml中静态注册;
BluetoothOppIncomingFileConfirmActivity: 同于提示User,OPP 收到新的文件;
Note:注意其与方法updateIncomingFileConfirmNotification的区别及关联;
Android O实测:当收到新文件,在系统通知(updateIncomingFileConfirmNotification中发出的系统通知)中点击ACCEPT时,Log显示收到了“Constants.ACTION_ACCEPT” 但并没有显示收到“Receiver ACTION_INCOMING_FILE_CONFIRM”,
进而BluetoothOppIncomingFileConfirmActivity没有被触发,但不影响文件的接收;
BluetoothOppLauncherActivity:其他APP 需要调用BT 发送文件时的入口类,在BluetoothManagerService.java中被拉起;---具体详看后续问题点的描述;
BluetoothOppManager: 这是一个OPP 操作管理实现,提供类似其他profile的操作接口,如提供主动发送的方法startTransfer。
BluetoothOppNotification:用于通知正在发送、正在接收以及发送成功、失败时的消息告知;
BluetoothOppObexClientSession:实现接口BluetoothOppObexSession。实现了主动断开、连接、发送等;---但这里需要关注其状态结果(连接、断开等消息)在哪返回;
BluetoothOppObexServerSession: 实现接口BluetoothOppObexSession 和继承
ServerRequestHandler;其没有主动连接等实现,但有关于连接和断开的相关callback API;
其中“onPut”为接收data callback,可理解为OPP Server端数据开始暴露出来的callback;
BluetoothOppObexSession: 这是一个接口,本身并没有具体实现,
当前被BluetoothOppObexClientSession和BluetoothOppObexServerSession实作;
BluetoothOppPreference: 用于保存本地蓝牙名称和channel,其自身描述是:
This class cache Bluetooth device name and channel locally. Its a temp
solution which should be replaced by bluetooth_devices in SettingsProvider
Note:这里虽说是一个temp solution,但实际上在Android9、10、11还继续存在;
BluetoothOppProvider:继承于ContentProvider,用于实现类似数据库(但其并不直接描述为数据库操作,而是使用“表格”来描述,原因是:数据库形式只是其中一种使用方式)的相关操作;---具体详看后续问题点描述;
BluetoothOppReceiveFileInfo: 用于存储正在接收的单一文件信息;
BluetoothOppReceiver:继承于BroadcastReceiver,用于接收相关Message
虽然在Androidmanifest.xml静态注册时以下截图所示Message,但实际上在Source Code中,其监听多个Message,包括收到新文件的通知
Message “ACTION_INCOMING_FILE_CONFIRM”
BluetoothOppSendFileInfo: 与BluetoothOppReceiveFileInfo功能相反,其存储了正被发送的data信息,自自身描述是:This class stores information about a single sending file It will only be used for outbound share.
BluetoothOppService: OPP 的核心类;
BluetoothOppShareInfo: 自身描述:This class stores information about a single OBEX share, e.g. one object send/receive to a destination address. 存储单一对象的相关信息,不强调正在发送、接收等状态,Opp Client和Server 都能使用;
BluetoothOppTransfer: 自身描述:This class run an actual Opp transfer session (from connect target device to disconnect);这里包含发送和接口,并不是字面理解的发送;
BluetoothOppTransferActivity: 自身描述:Handle all transfer related dialogs;
BluetoothOppTransferAdapter: 自身描述:This class is used to represent the data for the transfer history list box. The only real work done by this class is to construct a custom view for the line items.其唯一被使用位置是在BluetoothOppTransferHistory中list出相关信息;
BluetoothOppTransferHistory:用于显示User已经完成发送或接收文件的相关弹窗;
BluetoothOppTransferInfo:自身描述:This is currently used by Application codes. This class stores information about a single OBEX transfer (operation)。实际Code没有data ,作为类似结构体使用;
BluetoothOppUtility:这个类干得事情有点杂,很难定性是专门发送,还是接收;
BluetoothShare: 类似Constants的功能,自身描述:Exposes constants used to interact with the Bluetooth Share manager's content provider.
Constants: OPP 的相关宏定义;
TestActivity: 这是OPP 自带的测试Activity;
Android Bluetooth OPP的理解与使用之一相关推荐
- Android Bluetooth OPP的理解与使用之八
问题点21: Android Bluetooth的OPPC主动发送完成后,自行断开的flow: OPP 传送,一般是OPPC 发送文件前主动连接,文件发送完成后,主动断开: 基于Android BT的 ...
- Android Bluetooth OPP
本篇博客,分析Android Bluetooth的Object Push Profile,分别是架构.代码流程,日志打印,HCI帧. 1. 蓝牙OPP架构 本章根据BLUETOOTH CORE SPE ...
- android 蓝牙 bluetooth OPP文件传输
蓝牙文件分享的流程,也就是蓝牙应用opp目录下的代码,作为蓝牙最基本的一个功能,这部分的代码在之前的版本中就已经有了,新旧版本代码对比很多类名都是一样的,这一部分新东西不多,写在这里帮助大家梳理下流程 ...
- Android Bluetooth 文件接收路径修改方法
修改文件: packages/apps/Bluetooth/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java 相关代码片段: ...
- Android 蓝牙 OPP文件传输-Obex协议连接-socket连接 从framework到协议栈btif层 --- 全网最详细(一)
同学,别退出呀,我可是全网最牛逼的 Android 蓝牙分析博主,我写了上百篇蓝牙文章,请点击下面了解本专栏,进入本博主主页看看再走呗,一定不会让你后悔的,记得一定要去看主页置顶文章哦. 一.概述 今 ...
- android ble peripheral,Android - BlueTooth BLE 之 Central 与 Peripheral 理解
一.前言 Andorid 5.0 之前是无法进行 外围设备开发的,在Android 5.0 API 21 android.bluetooth.le包下,新增加 Scaner相关类和 Advertise ...
- Android Bluetooth模块学习笔记
一.蓝牙基础知识 1.蓝牙( Bluetooth )是一种无线技术标准,可实现固定设备.移动设备和楼宇个人域网之间的短距离数据交换.蓝牙基于设备低成本的收发器芯片,传输距离近.低功耗. 2.微波频段: ...
- Android Bluetooth BLE相关开发资源汇总
Android开启蓝牙开关 转载自Android:Bluetooth 的打开和关闭 检查系统蓝牙是否开启 BluetoothManager bluetoothManager = (BluetoothM ...
- 【转】Android bluetooth介绍(三): 蓝牙扫描(scan)设备分析
原文网址:http://blog.csdn.net/xubin341719/article/details/38584469 关键词:蓝牙blueZ A2DP.SINK.sink_connect.s ...
- Android Bluetooth HID实现详解
Android Bluetooth HID实现详解 Android 关于蓝牙的部分使用的是BlueZ协议栈.但是直到目前2.3.3都没有扩展HID的profile,只是实现了最基本的Handset和d ...
最新文章
- OpenTSDB介绍
- [c/c++]可变参数加法
- 转:五大常用算法——贪心算法详解及经典例子
- TUXEDO中间件介绍及应用
- unity开发微信小游戏1
- Vue多个元素的过渡
- su必备插件_sketchup插件 su十大必备插件
- 蓝鸥iOS开发工程师职场提升路线图
- Firefox同步密钥丢失的解决办法
- 计算机网络(第7版) - 第七章 网络安全 - 习题
- JixiPix Romantic Photo for Mac(照片浪漫效果软件)
- iOS——内存监控(Memory)
- 微信直接用手机默认浏览器打开下载 IOS苹果跳转App Store(苹果商店)打开下载
- Oracle数据库错误码1502解决,SQL的1502错误处理
- 视频直播平台性能测试
- android绿豆通讯录xml,Android 数据库(SQLite)【简介、创建、使用(增删改查、事务、实战演练)、数据显示控件(ListView、Adapter、实战演练)】...
- 《怪诞行为学》读书笔记
- 导入Excel表格数据(一)
- 如何快速开发一个App手机应用
- 观察 | 热度稍纵即逝,预测市场半红不火,预测平台有潜力没能力