Fields Summary |
---|
private static final String | TAG |
private static final int | SOCKET_CONNECTED |
private static final int | SOCKET_ERROR |
public static final int | EVENT_CONNECTCallback message sent when connection state changes
arg1 is set to {@link #STATUS_OK} when connection is
established successfully and {@link #STATUS_FAILED} when connection
either failed or was disconnected (depends on request from application) |
public static final int | EVENT_UPDATE_INBOXCallback message sent when MSE accepted update inbox request |
public static final int | EVENT_SET_PATHCallback message sent when path is changed
obj is set to path currently set on MSE |
public static final int | EVENT_GET_FOLDER_LISTINGCallback message sent when folder listing is received
obj contains ArrayList of sub-folder names |
public static final int | EVENT_GET_FOLDER_LISTING_SIZECallback message sent when folder listing size is received
obj contains number of items in folder listing |
public static final int | EVENT_GET_MESSAGES_LISTINGCallback message sent when messages listing is received
obj contains ArrayList of {@link BluetoothMapBmessage} |
public static final int | EVENT_GET_MESSAGECallback message sent when message is received
obj contains {@link BluetoothMapBmessage} |
public static final int | EVENT_SET_MESSAGE_STATUSCallback message sent when message status is changed |
public static final int | EVENT_PUSH_MESSAGECallback message sent when message is pushed to MSE
obj contains handle of message as allocated by MSE |
public static final int | EVENT_SET_NOTIFICATION_REGISTRATIONCallback message sent when notification status is changed
obj contains 1 if notifications are enabled and
0 otherwise |
public static final int | EVENT_EVENT_REPORTCallback message sent when event report is received from MSE to MNS
obj contains {@link BluetoothMapEventReport} |
public static final int | EVENT_GET_MESSAGES_LISTING_SIZECallback message sent when messages listing size is received
obj contains number of items in messages listing |
public static final int | STATUS_OKStatus for callback message when request is successful |
public static final int | STATUS_FAILEDStatus for callback message when request is not successful |
public static final int | PARAMETER_DEFAULTConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_SUBJECTConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_DATETIMEConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_SENDER_NAMEConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_SENDER_ADDRESSINGConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_RECIPIENT_NAMEConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_RECIPIENT_ADDRESSINGConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_TYPEConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_SIZEConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_RECEPTION_STATUSConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_TEXTConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_ATTACHMENT_SIZEConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_PRIORITYConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_READConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_SENTConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_PROTECTEDConstant corresponding to ParameterMask application
parameter value in MAP specification |
public static final int | PARAMETER_REPLYTO_ADDRESSINGConstant corresponding to ParameterMask application
parameter value in MAP specification |
private final android.bluetooth.BluetoothDevice | mDevicedevice associated with client |
private final android.bluetooth.BluetoothMasInstance | mMasMAS instance associated with client |
private final android.os.Handler | mCallbackcallback handler to application |
private ConnectionState | mConnectionState |
private boolean | mNotificationEnabled |
private SocketConnectThread | mConnectThread |
private javax.obex.ObexTransport | mObexTransport |
private BluetoothMasObexClientSession | mObexSession |
private SessionHandler | mSessionHandler |
private BluetoothMnsService | mMnsService |
private ArrayDeque | mPath |
Methods Summary |
---|
public void | connect()Connects to MAS instance
Upon completion callback handler will receive {@link #EVENT_CONNECT}
if (mSessionHandler == null) {
mSessionHandler = new SessionHandler(this);
}
if (mConnectThread == null && mObexSession == null) {
mConnectionState = ConnectionState.CONNECTING;
mConnectThread = new SocketConnectThread();
mConnectThread.start();
}
|
private boolean | disableNotifications()
Log.v(TAG, "enableNotifications()");
if (mMnsService != null) {
mMnsService.unregisterCallback(mMas.getId());
}
mMnsService = null;
BluetoothMasRequest request = new BluetoothMasRequestSetNotificationRegistration(false);
return mObexSession.makeRequest(request);
|
public void | disconnect()Disconnects from MAS instance
Upon completion callback handler will receive {@link #EVENT_CONNECT}
if (mConnectThread == null && mObexSession == null) {
return;
}
mConnectionState = ConnectionState.DISCONNECTING;
if (mConnectThread != null) {
mConnectThread.interrupt();
}
if (mObexSession != null) {
mObexSession.stop();
}
|
private boolean | enableNotifications()
Log.v(TAG, "enableNotifications()");
if (mMnsService == null) {
mMnsService = new BluetoothMnsService();
}
mMnsService.registerCallback(mMas.getId(), mSessionHandler);
BluetoothMasRequest request = new BluetoothMasRequestSetNotificationRegistration(true);
return mObexSession.makeRequest(request);
|
public void | finalize()
disconnect();
|
public java.lang.String | getCurrentPath()Gets current path in folder hierarchy
if (mPath.size() == 0) {
return "";
}
Iterator<String> iter = mPath.iterator();
StringBuilder sb = new StringBuilder(iter.next());
while (iter.hasNext()) {
sb.append("/").append(iter.next());
}
return sb.toString();
|
public boolean | getFolderListing()Gets list of sub-folders in current folder
Upon completion callback handler will receive
{@link #EVENT_GET_FOLDER_LISTING}
return getFolderListing((short) 0, (short) 0);
|
public boolean | getFolderListing(int maxListCount, int listStartOffset)Gets list of sub-folders in current folder
Upon completion callback handler will receive
{@link #EVENT_GET_FOLDER_LISTING}
if (mObexSession == null) {
return false;
}
BluetoothMasRequest request = new BluetoothMasRequestGetFolderListing(maxListCount,
listStartOffset);
return mObexSession.makeRequest(request);
|
public boolean | getFolderListingSize()Gets number of sub-folders in current folder
Upon completion callback handler will receive
{@link #EVENT_GET_FOLDER_LISTING_SIZE}
if (mObexSession == null) {
return false;
}
BluetoothMasRequest request = new BluetoothMasRequestGetFolderListingSize();
return mObexSession.makeRequest(request);
|
public android.bluetooth.BluetoothMasInstance | getInstanceData()Retrieves MAS instance data associated with client
return mMas;
|
public boolean | getMessage(java.lang.String handle, android.bluetooth.client.map.BluetoothMasClient$CharsetType charset, boolean attachment)Retrieves message from MSE
Upon completion callback handler will receive {@link #EVENT_GET_MESSAGE}
if (mObexSession == null) {
return false;
}
try {
/* just to validate */
new BigInteger(handle, 16);
} catch (NumberFormatException e) {
return false;
}
BluetoothMasRequest request = new BluetoothMasRequestGetMessage(handle, charset,
attachment);
return mObexSession.makeRequest(request);
|
public boolean | getMessagesListing(java.lang.String folder, int parameters)Gets list of messages in specified sub-folder
Upon completion callback handler will receive
{@link #EVENT_GET_MESSAGES_LISTING}
return getMessagesListing(folder, parameters, null, (byte) 0, 0, 0);
|
public boolean | getMessagesListing(java.lang.String folder, int parameters, android.bluetooth.client.map.BluetoothMasClient$MessagesFilter filter, int subjectLength)Gets list of messages in specified sub-folder
Upon completion callback handler will receive
{@link #EVENT_GET_MESSAGES_LISTING}
return getMessagesListing(folder, parameters, filter, subjectLength, 0, 0);
|
public boolean | getMessagesListing(java.lang.String folder, int parameters, android.bluetooth.client.map.BluetoothMasClient$MessagesFilter filter, int subjectLength, int maxListCount, int listStartOffset)Gets list of messages in specified sub-folder
Upon completion callback handler will receive
{@link #EVENT_GET_MESSAGES_LISTING}
if (mObexSession == null) {
return false;
}
BluetoothMasRequest request = new BluetoothMasRequestGetMessagesListing(folder,
parameters, filter, subjectLength, maxListCount, listStartOffset);
return mObexSession.makeRequest(request);
|
public boolean | getMessagesListingSize()Gets number of messages in current folder
Upon completion callback handler will receive
{@link #EVENT_GET_MESSAGES_LISTING_SIZE}
if (mObexSession == null) {
return false;
}
BluetoothMasRequest request = new BluetoothMasRequestGetMessagesListingSize();
return mObexSession.makeRequest(request);
|
public boolean | getNotificationRegistration()Gets current state of notifications for MAS instance
return mNotificationEnabled;
|
public android.bluetooth.client.map.BluetoothMasClient$ConnectionState | getState()Gets current connection state
return mConnectionState;
|
public boolean | pushMessage(java.lang.String folder, BluetoothMapBmessage bmsg, android.bluetooth.client.map.BluetoothMasClient$CharsetType charset)Pushes new message to MSE
Upon completion callback handler will receive {@link #EVENT_PUSH_MESSAGE}
return pushMessage(folder, bmsg, charset, false, false);
|
public boolean | pushMessage(java.lang.String folder, BluetoothMapBmessage bmsg, android.bluetooth.client.map.BluetoothMasClient$CharsetType charset, boolean transparent, boolean retry)Pushes new message to MSE
Upon completion callback handler will receive {@link #EVENT_PUSH_MESSAGE}
if (mObexSession == null) {
return false;
}
String bmsgString = BluetoothMapBmessageBuilder.createBmessage(bmsg);
BluetoothMasRequest request =
new BluetoothMasRequestPushMessage(folder, bmsgString, charset, transparent, retry);
return mObexSession.makeRequest(request);
|
private void | sendToClient(int event, boolean success)
sendToClient(event, success, null);
|
private void | sendToClient(int event, boolean success, int param)
sendToClient(event, success, Integer.valueOf(param));
|
private void | sendToClient(int event, boolean success, java.lang.Object param)
if (success) {
mCallback.obtainMessage(event, STATUS_OK, mMas.getId(), param).sendToTarget();
} else {
mCallback.obtainMessage(event, STATUS_FAILED, mMas.getId(), null).sendToTarget();
}
|
public boolean | setFolderDown(java.lang.String name)Goes down to specified sub-folder in folder hierarchy
Upon completion callback handler will receive {@link #EVENT_SET_PATH}
if (mObexSession == null) {
return false;
}
if (name == null || name.isEmpty() || name.contains("/")) {
return false;
}
BluetoothMasRequest request = new BluetoothMasRequestSetPath(name);
return mObexSession.makeRequest(request);
|
public boolean | setFolderRoot()Goes back to root of folder hierarchy
Upon completion callback handler will receive {@link #EVENT_SET_PATH}
if (mObexSession == null) {
return false;
}
BluetoothMasRequest request = new BluetoothMasRequestSetPath(true);
return mObexSession.makeRequest(request);
|
public boolean | setFolderUp()Goes back to parent folder in folder hierarchy
Upon completion callback handler will receive {@link #EVENT_SET_PATH}
if (mObexSession == null) {
return false;
}
BluetoothMasRequest request = new BluetoothMasRequestSetPath(false);
return mObexSession.makeRequest(request);
|
public boolean | setMessageDeletedStatus(java.lang.String handle, boolean deleted)Sets deleted status of message on MSE
Upon completion callback handler will receive
{@link #EVENT_SET_MESSAGE_STATUS}
if (mObexSession == null) {
return false;
}
try {
/* just to validate */
new BigInteger(handle, 16);
} catch (NumberFormatException e) {
return false;
}
BluetoothMasRequest request = new BluetoothMasRequestSetMessageStatus(handle,
StatusIndicator.DELETED, deleted);
return mObexSession.makeRequest(request);
|
public boolean | setMessageReadStatus(java.lang.String handle, boolean read)Sets read status of message on MSE
Upon completion callback handler will receive
{@link #EVENT_SET_MESSAGE_STATUS}
if (mObexSession == null) {
return false;
}
try {
/* just to validate */
new BigInteger(handle, 16);
} catch (NumberFormatException e) {
return false;
}
BluetoothMasRequest request = new BluetoothMasRequestSetMessageStatus(handle,
StatusIndicator.READ, read);
return mObexSession.makeRequest(request);
|
public boolean | setNotificationRegistration(boolean status)Sets state of notifications for MAS instance
Once notifications are enabled, callback handler will receive
{@link #EVENT_EVENT_REPORT} when new notification is received
Upon completion callback handler will receive
{@link #EVENT_SET_NOTIFICATION_REGISTRATION}
if (mObexSession == null) {
return false;
}
if (status) {
return enableNotifications();
} else {
return disableNotifications();
}
|
public boolean | updateInbox()Requests MSE to initiate ubdate of inbox
Upon completion callback handler will receive {@link #EVENT_UPDATE_INBOX}
if (mObexSession == null) {
return false;
}
BluetoothMasRequest request = new BluetoothMasRequestUpdateInbox();
return mObexSession.makeRequest(request);
|