Methods Summary |
---|
private synchronized void | acquireWakeLock()
if (!mWakeLock.isHeld()) {
mWakeLock.acquire();
}
|
private static native void | classInitNative()
|
private native void | cleanupNativeDataNative()
|
public boolean | connect(android.os.Handler handler)
if (mEventThread == null) {
if (!connectNative()) return false;
mEventThreadHandler = handler;
}
return true;
|
public boolean | connectAsync()
return connectAsyncNative();
|
private native boolean | connectAsyncNative()
|
private native boolean | connectNative()
|
public void | disconnect()
if (mEventThread != null) {
stopEventThread();
}
disconnectNative();
|
private native void | disconnectNative()
|
protected void | finalize() // held while processing an AT command
classInitNative();
try {
cleanupNativeDataNative();
releaseWakeLock();
} finally {
super.finalize();
}
|
public java.lang.String | getAddress()
return mAddress;
|
public AtParser | getAtParser()
return mAtParser;
|
public long | getConnectTimestamp()
return mConnectTimestamp;
|
public int | getDirection()
return mDirection;
|
private native int | getLastReadStatusNative()
|
public java.lang.String | getName()
return mBluetooth.getRemoteName(mAddress);
|
public int | getRemainingAsyncConnectWaitingTimeMs()
return mTimeoutRemainingMs;
|
protected void | handleInput(java.lang.String input)
acquireWakeLock();
long timestamp;
if (DBG) timestamp = System.currentTimeMillis();
AtCommandResult result = mAtParser.process(input);
if (DBG) Log.d(TAG, "Processing " + input + " took " +
(System.currentTimeMillis() - timestamp) + " ms");
if (result.getResultCode() == AtCommandResult.ERROR) {
Log.i(TAG, "Error pocessing <" + input + ">");
}
sendURC(result.toString());
releaseWakeLock();
|
protected void | initializeAtParser()Register AT commands that are common to all Headset / Handsets. This
function is called by the HeadsetBase constructor.
mAtParser = new AtParser();
//TODO(): Get rid of this as there are no parsers registered. But because of dependencies,
//it needs to be done as part of refactoring HeadsetBase and BluetoothHandsfree
|
private native void | initializeNativeDataNative(int socketFd)
|
public boolean | isConnected()
return mEventThread != null;
|
private void | log(java.lang.String msg)
Log.d(TAG, msg);
|
private native java.lang.String | readNative(int timeout_ms)
|
private synchronized void | releaseWakeLock()
if (mWakeLock.isHeld()) {
mWakeLock.release();
}
|
public synchronized boolean | sendURC(java.lang.String urc)
if (urc.length() > 0) {
boolean ret = sendURCNative(urc);
return ret;
}
return true;
|
private native boolean | sendURCNative(java.lang.String urc)
|
public void | startEventThread()
mEventThread =
new Thread("HeadsetBase Event Thread") {
public void run() {
int last_read_error;
while (!mEventThreadInterrupted) {
String input = readNative(500);
if (input != null) {
handleInput(input);
}
else {
last_read_error = getLastReadStatusNative();
if (last_read_error != 0) {
Log.i(TAG, "headset read error " + last_read_error);
if (mEventThreadHandler != null) {
mEventThreadHandler.obtainMessage(RFCOMM_DISCONNECTED)
.sendToTarget();
}
disconnectNative();
break;
}
}
}
}
};
mEventThreadInterrupted = false;
mEventThread.start();
|
private void | stopEventThread()
mEventThreadInterrupted = true;
mEventThread.interrupt();
try {
mEventThread.join();
} catch (java.lang.InterruptedException e) {
// FIXME: handle this,
}
mEventThread = null;
|
public int | waitForAsyncConnect(int timeout_ms, android.os.Handler handler)
int res = waitForAsyncConnectNative(timeout_ms);
if (res > 0) {
mEventThreadHandler = handler;
}
return res;
|
private native int | waitForAsyncConnectNative(int timeout_ms)
|