Methods Summary |
---|
public synchronized boolean | accept()Accept incoming SCO connections.
Does not block.
if (VDBG) log("accept() " + this);
if (mState != STATE_READY) {
if (DBG) log("Bad state");
return false;
}
if (acceptNative()) {
mState = STATE_ACCEPT;
return true;
} else {
mState = STATE_CLOSED;
return false;
}
|
private native boolean | acceptNative()
|
private void | acquireWakeLock()
if (!mWakeLock.isHeld()) {
mWakeLock.acquire();
if (VDBG) log("mWakeLock.acquire() " + this);
}
|
private static native void | classInitNative()
|
public synchronized void | close()
if (DBG) log(this + " SCO OBJECT close() mState = " + mState);
acquireWakeLock();
mState = STATE_CLOSED;
closeNative();
releaseWakeLock();
|
private native void | closeNative()
|
public synchronized boolean | connect(java.lang.String address)Connect this SCO socket to the given BT address.
Does not block.
if (VDBG) log("connect() " + this);
if (mState != STATE_READY) {
if (DBG) log("connect(): Bad state");
return false;
}
acquireWakeLock();
if (connectNative(address)) {
mState = STATE_CONNECTING;
return true;
} else {
mState = STATE_CLOSED;
releaseWakeLockNow();
return false;
}
|
private native boolean | connectNative(java.lang.String address)
|
private native void | destroyNative()
|
protected void | finalize()
try {
if (VDBG) log(this + " SCO OBJECT DTOR");
destroyNative();
releaseWakeLockNow();
} finally {
super.finalize();
}
|
public synchronized int | getState()
return mState;
|
private native void | initNative()
|
private void | log(java.lang.String msg)
Log.d(TAG, msg);
|
private synchronized void | onAccepted(int result)
if (VDBG) log("onAccepted() " + this);
if (mState != STATE_ACCEPT) {
if (DBG) log("Strange state " + this);
return;
}
if (result >= 0) {
mState = STATE_CONNECTED;
} else {
mState = STATE_CLOSED;
}
mHandler.obtainMessage(mAcceptedCode, mState, -1, this).sendToTarget();
|
private synchronized void | onClosed()
if (DBG) log("onClosed() " + this);
if (mState != STATE_CLOSED) {
mState = STATE_CLOSED;
mHandler.obtainMessage(mClosedCode, mState, -1, this).sendToTarget();
releaseWakeLock();
}
|
private synchronized void | onConnected(int result)
if (VDBG) log(this + " onConnected() mState = " + mState + " " + this);
if (mState != STATE_CONNECTING) {
if (DBG) log("Strange state, closing " + mState + " " + this);
return;
}
if (result >= 0) {
mState = STATE_CONNECTED;
} else {
mState = STATE_CLOSED;
}
mHandler.obtainMessage(mConnectedCode, mState, -1, this).sendToTarget();
releaseWakeLockNow();
|
private void | releaseWakeLock()
if (mWakeLock.isHeld()) {
// Keep apps processor awake for a further 2 seconds.
// This is a hack to resolve issue http://b/1616263 - in which
// we are left in a 80 mA power state when remotely terminating a
// call while connected to BT headset "HTC BH S100 " with A2DP and
// HFP profiles.
if (VDBG) log("mWakeLock.release() in 2 sec" + this);
mWakeLock.acquire(2000);
}
|
private void | releaseWakeLockNow()
if (mWakeLock.isHeld()) {
if (VDBG) log("mWakeLock.release() now" + this);
mWakeLock.release();
}
|