FileDocCategorySizeDatePackage
BluetoothPbapObexSession.javaAPI DocAndroid 5.1 API6882Thu Mar 12 22:22:50 GMT 2015android.bluetooth.client.pbap

BluetoothPbapObexSession

public final class BluetoothPbapObexSession extends Object

Fields Summary
private static final String
TAG
private static final byte[]
PBAP_TARGET
static final int
OBEX_SESSION_CONNECTED
static final int
OBEX_SESSION_FAILED
static final int
OBEX_SESSION_DISCONNECTED
static final int
OBEX_SESSION_REQUEST_COMPLETED
static final int
OBEX_SESSION_REQUEST_FAILED
static final int
OBEX_SESSION_AUTHENTICATION_REQUEST
static final int
OBEX_SESSION_AUTHENTICATION_TIMEOUT
private android.os.Handler
mSessionHandler
private final javax.obex.ObexTransport
mTransport
private ObexClientThread
mObexClientThread
private BluetoothPbapObexAuthenticator
mAuth
Constructors Summary
public BluetoothPbapObexSession(javax.obex.ObexTransport transport)


       
        mTransport = transport;
    
Methods Summary
public voidabort()

        Log.d(TAG, "abort");

        if (mObexClientThread != null && mObexClientThread.mRequest != null) {
            /*
             * since abort may block until complete GET is processed inside OBEX
             * session, let's run it in separate thread so it won't block UI
             */
            (new Thread() {
                @Override
                public void run() {
                    mObexClientThread.mRequest.abort();
                }
            }).run();
        }
    
public booleanschedule(BluetoothPbapRequest request)

        Log.d(TAG, "schedule: " + request.getClass().getSimpleName());

        if (mObexClientThread == null) {
            Log.e(TAG, "OBEX session not started");
            return false;
        }

        return mObexClientThread.schedule(request);
    
public booleansetAuthReply(java.lang.String key)

        Log.d(TAG, "setAuthReply key=" + key);

        if (mAuth == null) {
            return false;
        }

        mAuth.setReply(key);

        return true;
    
public voidstart(android.os.Handler handler)

        Log.d(TAG, "start");
        mSessionHandler = handler;

        mAuth = new BluetoothPbapObexAuthenticator(mSessionHandler);

        mObexClientThread = new ObexClientThread();
        mObexClientThread.start();
    
public voidstop()

        Log.d(TAG, "stop");

        if (mObexClientThread != null) {
            try {
                mObexClientThread.interrupt();
                mObexClientThread.join();
                mObexClientThread = null;
            } catch (InterruptedException e) {
            }
        }