BluetoothPbapClientpublic class BluetoothPbapClient extends Object Public API to control Phone Book Profile (PCE role only).
This class defines methods that shall be used by application for the
retrieval of phone book objects from remote device.
How to connect to remote device which is acting in PSE role:
- Create a
BluetoothDevice object which corresponds to remote
device in PSE role;
- Create an instance of
BluetoothPbapClient class, passing
BluetothDevice object along with a Handler to it;
- Use {@link #setPhoneBookFolderRoot}, {@link #setPhoneBookFolderUp} and
{@link #setPhoneBookFolderDown} to navigate in virtual phone book folder
structure
- Use {@link #pullPhoneBookSize} or {@link #pullVcardListingSize} to
retrieve the size of selected phone book
- Use {@link #pullPhoneBook} to retrieve phone book entries
- Use {@link #pullVcardListing} to retrieve list of entries in the phone
book
- Use {@link #pullVcardEntry} to pull single entry from the phone book
Upon completion of each call above PCE will notify application if operation
completed successfully (along with results) or failed.
Therefore, application should handle following events in its message queue
handler:
EVENT_PULL_PHONE_BOOK_SIZE_DONE
EVENT_PULL_VCARD_LISTING_SIZE_DONE
EVENT_PULL_PHONE_BOOK_DONE
EVENT_PULL_VCARD_LISTING_DONE
EVENT_PULL_VCARD_ENTRY_DONE
EVENT_SET_PHONE_BOOK_DONE
and
EVENT_PULL_PHONE_BOOK_SIZE_ERROR
EVENT_PULL_VCARD_LISTING_SIZE_ERROR
EVENT_PULL_PHONE_BOOK_ERROR
EVENT_PULL_VCARD_LISTING_ERROR
EVENT_PULL_VCARD_ENTRY_ERROR
EVENT_SET_PHONE_BOOK_ERROR
connect and disconnect methods are introduced for
testing purposes. An application does not need to use them as the session
connection and disconnection happens automatically internally. |
Fields Summary |
---|
private static final String | TAG | public static final String | ICH_PATHPath to local incoming calls history object | public static final String | OCH_PATHPath to local outgoing calls history object | public static final String | MCH_PATHPath to local missed calls history object | public static final String | CCH_PATHPath to local combined calls history object | public static final String | PB_PATHPath to local main phone book object | public static final String | SIM_ICH_PATHPath to incoming calls history object stored on the phone's SIM card | public static final String | SIM_OCH_PATHPath to outgoing calls history object stored on the phone's SIM card | public static final String | SIM_MCH_PATHPath to missed calls history object stored on the phone's SIM card | public static final String | SIM_CCH_PATHPath to combined calls history object stored on the phone's SIM card | public static final String | SIM_PB_PATHPath to main phone book object stored on the phone's SIM card | public static final byte | ORDER_BY_DEFAULTIndicates to server that default sorting order shall be used for vCard
listing. | public static final byte | ORDER_BY_INDEXEDIndicates to server that indexed sorting order shall be used for vCard
listing. | public static final byte | ORDER_BY_ALPHABETICALIndicates to server that alphabetical sorting order shall be used for the
vCard listing. | public static final byte | ORDER_BY_PHONETICIndicates to server that phonetical (based on sound attribute) sorting
order shall be used for the vCard listing. | public static final byte | SEARCH_ATTR_NAMEIndicates to server that Name attribute of vCard shall be used to carry
out the search operation on | public static final byte | SEARCH_ATTR_NUMBERIndicates to server that Number attribute of vCard shall be used to carry
out the search operation on | public static final byte | SEARCH_ATTR_SOUNDIndicates to server that Sound attribute of vCard shall be used to carry
out the search operation | public static final byte | VCARD_TYPE_21VCard format version 2.1 | public static final byte | VCARD_TYPE_30VCard format version 3.0 | public static final long | VCARD_ATTR_VERSION | public static final long | VCARD_ATTR_FN | public static final long | VCARD_ATTR_N | public static final long | VCARD_ATTR_PHOTO | public static final long | VCARD_ATTR_BDAY | public static final long | VCARD_ATTR_ADDR | public static final long | VCARD_ATTR_LABEL | public static final long | VCARD_ATTR_TEL | public static final long | VCARD_ATTR_EMAIL | public static final long | VCARD_ATTR_MAILER | public static final long | VCARD_ATTR_TZ | public static final long | VCARD_ATTR_GEO | public static final long | VCARD_ATTR_TITLE | public static final long | VCARD_ATTR_ROLE | public static final long | VCARD_ATTR_LOGO | public static final long | VCARD_ATTR_AGENT | public static final long | VCARD_ATTR_ORG | public static final long | VCARD_ATTR_NOTE | public static final long | VCARD_ATTR_REV | public static final long | VCARD_ATTR_SOUND | public static final long | VCARD_ATTR_URL | public static final long | VCARD_ATTR_UID | public static final long | VCARD_ATTR_KEY | public static final long | VCARD_ATTR_NICKNAME | public static final long | VCARD_ATTR_CATEGORIES | public static final long | VCARD_ATTR_PROID | public static final long | VCARD_ATTR_CLASS | public static final long | VCARD_ATTR_SORT_STRING | public static final long | VCARD_ATTR_X_IRMC_CALL_DATETIME | public static final short | MAX_LIST_COUNTMaximal number of entries of the phone book that PCE can handle | public static final int | EVENT_SET_PHONE_BOOK_DONEEvent propagated upon completion of setPhoneBookFolderRoot ,
setPhoneBookFolderUp or setPhoneBookFolderDown
request.
This event indicates that request completed successfully. | public static final int | EVENT_PULL_PHONE_BOOK_DONEEvent propagated upon completion of pullPhoneBook request.
This event carry on results of the request.
The resulting message contains:
msg.arg1 |
newMissedCalls parameter (only in case of missed calls history object
request) |
msg.obj |
which is a list of VCardEntry objects |
| public static final int | EVENT_PULL_VCARD_LISTING_DONEEvent propagated upon completion of pullVcardListing
request.
This event carry on results of the request.
The resulting message contains:
msg.arg1 |
newMissedCalls parameter (only in case of missed calls history object
request) |
msg.obj |
which is a list of BluetoothPbapCard objects |
| public static final int | EVENT_PULL_VCARD_ENTRY_DONEEvent propagated upon completion of pullVcardEntry request.
This event carry on results of the request.
The resulting message contains:
msg.obj |
vCard as and object of type VCardEntry |
| public static final int | EVENT_PULL_PHONE_BOOK_SIZE_DONEEvent propagated upon completion of pullPhoneBookSize
request.
This event carry on results of the request.
The resulting message contains:
msg.arg1 |
size of the phone book |
| public static final int | EVENT_PULL_VCARD_LISTING_SIZE_DONEEvent propagated upon completion of pullVcardListingSize
request.
This event carry on results of the request.
The resulting message contains:
msg.arg1 |
size of the phone book listing |
| public static final int | EVENT_SET_PHONE_BOOK_ERROREvent propagated upon completion of setPhoneBookFolderRoot ,
setPhoneBookFolderUp or setPhoneBookFolderDown
request. This event indicates an error during operation. | public static final int | EVENT_PULL_PHONE_BOOK_ERROREvent propagated upon completion of pullPhoneBook request.
This event indicates an error during operation. | public static final int | EVENT_PULL_VCARD_LISTING_ERROREvent propagated upon completion of pullVcardListing
request. This event indicates an error during operation. | public static final int | EVENT_PULL_VCARD_ENTRY_ERROREvent propagated upon completion of pullVcardEntry request.
This event indicates an error during operation. | public static final int | EVENT_PULL_PHONE_BOOK_SIZE_ERROREvent propagated upon completion of pullPhoneBookSize
request. This event indicates an error during operation. | public static final int | EVENT_PULL_VCARD_LISTING_SIZE_ERROREvent propagated upon completion of pullVcardListingSize
request. This event indicates an error during operation. | public static final int | EVENT_SESSION_CONNECTEDEvent propagated when PCE has been connected to PSE | public static final int | EVENT_SESSION_DISCONNECTEDEvent propagated when PCE has been disconnected from PSE | public static final int | EVENT_SESSION_AUTH_REQUESTED | public static final int | EVENT_SESSION_AUTH_TIMEOUT | private final android.os.Handler | mClientHandler | private final BluetoothPbapSession | mSession | private ConnectionState | mConnectionState | private SessionHandler | mSessionHandler |
Constructors Summary |
---|
public BluetoothPbapClient(android.bluetooth.BluetoothDevice device, android.os.Handler handler)Constructs PCE object
if (device == null) {
throw new NullPointerException("BluetothDevice is null");
}
mClientHandler = handler;
mSessionHandler = new SessionHandler(this);
mSession = new BluetoothPbapSession(device, mSessionHandler);
|
Methods Summary |
---|
public void | abort()Aborts current request, if any
mSession.abort();
| public void | connect()Starts a pbap session. This method set up rfcomm session, obex
session and waits for requests to be transfered to PSE.
mSession.start();
| public void | disconnect()Stops all the active transactions and disconnects from the server.
mSession.stop();
| public void | finalize()
if (mSession != null) {
mSession.stop();
}
| public android.bluetooth.client.pbap.BluetoothPbapClient$ConnectionState | getState()
return mConnectionState;
| public boolean | pullPhoneBook(java.lang.String pbName)Pulls complete phone book. This method pulls phone book which entries are
of VCARD_TYPE_21 type and each single vCard contains minimal
required set of fields and the number of entries in response is not
limited.
return pullPhoneBook(pbName, 0, VCARD_TYPE_21, 0, 0);
| public boolean | pullPhoneBook(java.lang.String pbName, long filter, byte format)Pulls complete phone book. This method pulls all entries from the phone
book.
return pullPhoneBook(pbName, filter, format, 0, 0);
| public boolean | pullPhoneBook(java.lang.String pbName, int maxListCount, int listStartOffset)Pulls complete phone book. This method pulls entries from the phone book
limited to the number of maxListCount starting from the
position of listStartOffset .
The resulting list contains vCard objects in version
VCARD_TYPE_21 which in turns contain minimal required set of
vCard fields.
return pullPhoneBook(pbName, 0, VCARD_TYPE_21, maxListCount, listStartOffset);
| public boolean | pullPhoneBook(java.lang.String pbName, long filter, byte format, int maxListCount, int listStartOffset)Pulls complete phone book.
BluetoothPbapRequest req = new BluetoothPbapRequestPullPhoneBook(pbName, filter, format,
maxListCount, listStartOffset);
return mSession.makeRequest(req);
| public boolean | pullPhoneBookSize(java.lang.String pbName)Requests for the number of entries in the phone book.
BluetoothPbapRequestPullPhoneBookSize req = new BluetoothPbapRequestPullPhoneBookSize(
pbName);
return mSession.makeRequest(req);
| public boolean | pullVcardEntry(java.lang.String handle)Pulls single vCard object
return pullVcardEntry(handle, (byte) 0, VCARD_TYPE_21);
| public boolean | pullVcardEntry(java.lang.String handle, long filter, byte format)Pulls single vCard object
BluetoothPbapRequest req = new BluetoothPbapRequestPullVcardEntry(handle, filter, format);
return mSession.makeRequest(req);
| public boolean | pullVcardListing(java.lang.String folder)Pulls list of entries in the phone book.
This method pulls the list of entries in the folder .
return pullVcardListing(folder, ORDER_BY_DEFAULT, SEARCH_ATTR_NAME, null, 0, 0);
| public boolean | pullVcardListing(java.lang.String folder, byte order)Pulls list of entries in the folder .
return pullVcardListing(folder, order, SEARCH_ATTR_NAME, null, 0, 0);
| public boolean | pullVcardListing(java.lang.String folder, byte searchAttr, java.lang.String searchVal)Pulls list of entries in the folder . Only entries where
searchAttr attribute of vCard matches searchVal
will be listed.
return pullVcardListing(folder, ORDER_BY_DEFAULT, searchAttr, searchVal, 0, 0);
| public boolean | pullVcardListing(java.lang.String folder, byte order, int maxListCount, int listStartOffset)Pulls list of entries in the folder .
return pullVcardListing(folder, order, SEARCH_ATTR_NAME, null, maxListCount,
listStartOffset);
| public boolean | pullVcardListing(java.lang.String folder, int maxListCount, int listStartOffset)Pulls list of entries in the folder .
return pullVcardListing(folder, ORDER_BY_DEFAULT, SEARCH_ATTR_NAME, null, maxListCount,
listStartOffset);
| public boolean | pullVcardListing(java.lang.String folder, byte order, byte searchAttr, java.lang.String searchVal, int maxListCount, int listStartOffset)Pulls list of entries in the folder .
BluetoothPbapRequest req = new BluetoothPbapRequestPullVcardListing(folder, order,
searchAttr, searchVal, maxListCount, listStartOffset);
return mSession.makeRequest(req);
| public boolean | pullVcardListingSize(java.lang.String folder)Requests for the number of entries in the phone book listing.
BluetoothPbapRequestPullVcardListingSize req = new BluetoothPbapRequestPullVcardListingSize(
folder);
return mSession.makeRequest(req);
| private void | sendToClient(int eventId)
sendToClient(eventId, 0, null);
| private void | sendToClient(int eventId, int param)
sendToClient(eventId, param, null);
| private void | sendToClient(int eventId, java.lang.Object param)
sendToClient(eventId, 0, param);
| private void | sendToClient(int eventId, int param1, java.lang.Object param2)
mClientHandler.obtainMessage(eventId, param1, 0, param2).sendToTarget();
| public boolean | setAuthResponse(java.lang.String key)
Log.d(TAG, " setAuthResponse key=" + key);
return mSession.setAuthResponse(key);
| public boolean | setPhoneBookFolderDown(java.lang.String folder)Sets current folder to selected sub-folder
BluetoothPbapRequest req = new BluetoothPbapRequestSetPath(folder);
return mSession.makeRequest(req);
| public boolean | setPhoneBookFolderRoot()Sets current folder to root
BluetoothPbapRequest req = new BluetoothPbapRequestSetPath(false);
return mSession.makeRequest(req);
| public boolean | setPhoneBookFolderUp()Sets current folder to parent
BluetoothPbapRequest req = new BluetoothPbapRequestSetPath(true);
return mSession.makeRequest(req);
|
|