自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
btsock_interface_t 結構體參考資料
#include <
bt_sock.h
>
|
size_t
|
size
|
|
bt_status_t
(*
|
listen
)(
btsock_type_t
type, const char *service_name, const uint8_t *service_uuid, int channel, int *sock_fd, int flags, int callingUid)
|
|
bt_status_t
(*
|
connect
)(const bt_bdaddr_t *bd_addr,
btsock_type_t
type, const uint8_t *uuid, int channel, int *sock_fd, int flags, int callingUid)
|
|
bt_status_t
(* connect)(const bt_bdaddr_t *bd_addr,
btsock_type_t
type, const uint8_t *uuid, int channel, int *sock_fd, int flags, int callingUid)
|
連線至遠端裝置的 RFCOMM UUID 管道,並傳回 Socket fd,以便在連線時讀取 btsock_connect_signal 和要接受的新 Socket fd。callingUid 是要求 Socket 的應用程式 UID。這項資訊可用於流量記錄。
定義位於檔案
bt_sock.h
的
71
行。
bt_status_t
(* listen)(
btsock_type_t
type, const char *service_name, const uint8_t *service_uuid, int channel, int *sock_fd, int flags, int callingUid)
|
監聽 RFCOMM UUID 或管道。它會傳回 Socket fd,可在遠端裝置連線時讀取 btsock_connect_signal。如果未提供 UUID 或管道,系統會分配管道,並建立服務記錄,提供在 bt_sdp 中 create_sdp_record(...) 的管道號碼。callingUid 是要求 Socket 的應用程式 UID。這項資訊可用於流量記錄。
定義位於檔案
bt_sock.h 的
62
行。
這個結構體的說明文件是由下列檔案產生:
-
hardware/libhardware/include/hardware/
bt_sock.h
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Android Hardware Abstraction Layer: btsock_interface_t Struct Reference\n\nbtsock_interface_t Struct Reference\n===================================\n\n[Data Fields](#pub-attribs) \nbtsock_interface_t Struct Reference \n\n`\n#include \u003c\n`[bt_sock.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h)`\n\u003e\n`\n\n|-------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Data Fields ----------- ||\n| size_t | [size](/reference/hal/structbtsock__interface__t#a854352f53b148adc24983a58a1866d66) |\n| ||\n| [bt_status_t](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bluetooth.h) (\\* | [listen](/reference/hal/structbtsock__interface__t#a9d38d485b8f8af482153e9fda49f1d87) )( [btsock_type_t](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h) type, const char \\*service_name, const uint8_t \\*service_uuid, int channel, int \\*sock_fd, int flags, int callingUid) |\n| ||\n| [bt_status_t](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bluetooth.h) (\\* | [connect](/reference/hal/structbtsock__interface__t#a3db005809916dd7c595f37b088c4a277) )(const bt_bdaddr_t \\*bd_addr, [btsock_type_t](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h) type, const uint8_t \\*uuid, int channel, int \\*sock_fd, int flags, int callingUid) |\n| ||\n\n\nDetailed Description\n--------------------\n\n\nDefinition at line\n[49](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h)\nof file\n[bt_sock.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h)\n.\n\nField Documentation\n-------------------\n\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [bt_status_t](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bluetooth.h) (\\* connect)(const bt_bdaddr_t \\*bd_addr, [btsock_type_t](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h) type, const uint8_t \\*uuid, int channel, int \\*sock_fd, int flags, int callingUid) |\n\n\nConnect to a RFCOMM UUID channel of remote device, It returns the socket fd from which the btsock_connect_signal and a new socket fd to be accepted can be read out when connected. The callingUid is the UID of the application which is requesting the socket. This is used for traffic accounting purposes.\n\n\nDefinition at line\n[71](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h)\nof file\n[bt_sock.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h)\n.\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [bt_status_t](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bluetooth.h) (\\* listen)( [btsock_type_t](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h) type, const char \\*service_name, const uint8_t \\*service_uuid, int channel, int \\*sock_fd, int flags, int callingUid) |\n\n\nListen to a RFCOMM UUID or channel. It returns the socket fd from which btsock_connect_signal can be read out when a remote device connected. If neither a UUID nor a channel is provided, a channel will be allocated and a service record can be created providing the channel number to create_sdp_record(...) in bt_sdp. The callingUid is the UID of the application which is requesting the socket. This is used for traffic accounting purposes.\n\n\nDefinition at line\n[62](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h)\nof file\n[bt_sock.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h)\n.\n\n|-------------|\n| size_t size |\n\n\nset to size of this struct\n\n\nDefinition at line\n[51](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h)\nof file\n[bt_sock.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h)\n.\n\n*** ** * ** ***\n\nThe documentation for this struct was generated from the following file:\n\n- hardware/libhardware/include/hardware/ [bt_sock.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/bt_sock.h)"]]