您的位置:首页 > 科技 > 能源 > 武汉天元千川渔具有限公司_西安关键词seo公司_如何做网络推广运营_百度快速收录入口

武汉天元千川渔具有限公司_西安关键词seo公司_如何做网络推广运营_百度快速收录入口

2024/12/24 20:30:04 来源:https://blog.csdn.net/qq_42137577/article/details/144659378  浏览:    关键词:武汉天元千川渔具有限公司_西安关键词seo公司_如何做网络推广运营_百度快速收录入口
武汉天元千川渔具有限公司_西安关键词seo公司_如何做网络推广运营_百度快速收录入口

问题

APK UI上的转圈启、停是根据什么广播来的,安卓原生实际的扫描时间如何控制


分析

扫描开始广播

BluetoothAdapter.ACTION_DISCOVERY_STARTED = "android.bluetooth.adapter.action.DISCOVERY_STARTED";

扫描完成广播

BluetoothAdapter.ACTION_DISCOVERY_FINISHED = "android.bluetooth.adapter.action.DISCOVERY_FINISHED";

如下路径发出广播
packages\apps\Bluetooth\src\com\android\bluetooth\btservice\AdapterProperties.java

    void discoveryStateChangeCallback(int state) {infoLog("Callback:discoveryStateChangeCallback with state:" + state);synchronized (mObject) {Intent intent;if (state == AbstractionLayer.BT_DISCOVERY_STOPPED) {mDiscovering = false;mService.clearDiscoveringPackages();mDiscoveryEndMs = System.currentTimeMillis();intent = new Intent(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);mService.sendBroadcast(intent, AdapterService.BLUETOOTH_PERM);} else if (state == AbstractionLayer.BT_DISCOVERY_STARTED) {mDiscovering = true;mDiscoveryEndMs = System.currentTimeMillis() + DEFAULT_DISCOVERY_TIMEOUT_MS;intent = new Intent(BluetoothAdapter.ACTION_DISCOVERY_STARTED);mService.sendBroadcast(intent, AdapterService.BLUETOOTH_PERM);}}}

协议栈中实际扫描时间控制

system\bt\btif\src\btif_dm.cc

/********************************************************************************* Function         btif_dm_start_discovery** Description      Start device discovery/inquiry** Returns          bt_status_t*******************************************************************************/
bt_status_t btif_dm_start_discovery(void) {tBTA_DM_INQ inq_params;tBTA_SERVICE_MASK services = 0;BTIF_TRACE_EVENT("%s", __func__);/* Cleanup anything remaining on index 0 */do_in_main_thread(FROM_HERE,base::Bind(&BTM_BleAdvFilterParamSetup, BTM_BLE_SCAN_COND_DELETE, 0,nullptr, base::Bind(&bte_scan_filt_param_cfg_evt, 0)));auto adv_filt_param = std::make_unique<btgatt_filt_param_setup_t>();/* Add an allow-all filter on index 0*/adv_filt_param->dely_mode = IMMEDIATE_DELY_MODE;adv_filt_param->feat_seln = ALLOW_ALL_FILTER;adv_filt_param->filt_logic_type = BTA_DM_BLE_PF_FILT_LOGIC_OR;adv_filt_param->list_logic_type = BTA_DM_BLE_PF_LIST_LOGIC_OR;adv_filt_param->rssi_low_thres = LOWEST_RSSI_VALUE;adv_filt_param->rssi_high_thres = LOWEST_RSSI_VALUE;do_in_main_thread(FROM_HERE, base::Bind(&BTM_BleAdvFilterParamSetup, BTM_BLE_SCAN_COND_ADD,0, base::Passed(&adv_filt_param),base::Bind(&bte_scan_filt_param_cfg_evt, 0)));/* TODO: Do we need to handle multiple inquiries at the same time? *//* Set inquiry params and call API */inq_params.mode = BTA_DM_GENERAL_INQUIRY | BTA_BLE_GENERAL_INQUIRY;inq_params.duration = BTIF_DM_DEFAULT_INQ_MAX_DURATION;inq_params.max_resps = BTIF_DM_DEFAULT_INQ_MAX_RESULTS;inq_params.report_dup = true;inq_params.filter_type = BTA_DM_INQ_CLR;/* TODO: Filter device by BDA needs to be implemented here *//* Will be enabled to true once inquiry busy level has been received */btif_dm_inquiry_in_progress = false;/* find nearby devices */BTA_DmSearch(&inq_params, services, bte_search_devices_evt);return BT_STATUS_SUCCESS;
}

其中 BTIF_DM_DEFAULT_INQ_MAX_DURATION可以控制实际扫描时长,unit--1.28s

Note:packages\apps\Bluetooth\src\com\android\bluetooth\btservice\AdapterProperties.java中的private static final long DEFAULT_DISCOVERY_TIMEOUT_MS = 12800;并不能改变实际扫描时长

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com