am e8d27539: am ccf9ef60: Merge "Reduce android.bluetooth package debug messages" into jb-mr1-dev

* commit 'e8d275392d5c47117880dcc1588d3646323348e7':
  Reduce android.bluetooth package debug messages
This commit is contained in:
Matthew Xie
2012-10-10 12:17:50 -07:00
committed by Android Git Automerger
8 changed files with 80 additions and 69 deletions

View File

@@ -45,6 +45,7 @@ import java.util.List;
public final class BluetoothA2dp implements BluetoothProfile { public final class BluetoothA2dp implements BluetoothProfile {
private static final String TAG = "BluetoothA2dp"; private static final String TAG = "BluetoothA2dp";
private static final boolean DBG = true; private static final boolean DBG = true;
private static final boolean VDBG = false;
/** /**
* Intent used to broadcast the change in connection state of the A2DP * Intent used to broadcast the change in connection state of the A2DP
@@ -113,7 +114,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
public void onBluetoothStateChange(boolean up) { public void onBluetoothStateChange(boolean up) {
if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up); if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up);
if (!up) { if (!up) {
if (DBG) Log.d(TAG,"Unbinding service..."); if (VDBG) Log.d(TAG,"Unbinding service...");
synchronized (mConnection) { synchronized (mConnection) {
try { try {
mService = null; mService = null;
@@ -126,7 +127,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
synchronized (mConnection) { synchronized (mConnection) {
try { try {
if (mService == null) { if (mService == null) {
if (DBG) Log.d(TAG,"Binding service..."); if (VDBG) Log.d(TAG,"Binding service...");
if (!mContext.bindService(new Intent(IBluetoothA2dp.class.getName()), mConnection, 0)) { if (!mContext.bindService(new Intent(IBluetoothA2dp.class.getName()), mConnection, 0)) {
Log.e(TAG, "Could not bind to Bluetooth A2DP Service"); Log.e(TAG, "Could not bind to Bluetooth A2DP Service");
} }
@@ -269,7 +270,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
* {@inheritDoc} * {@inheritDoc}
*/ */
public List<BluetoothDevice> getConnectedDevices() { public List<BluetoothDevice> getConnectedDevices() {
if (DBG) log("getConnectedDevices()"); if (VDBG) log("getConnectedDevices()");
if (mService != null && isEnabled()) { if (mService != null && isEnabled()) {
try { try {
return mService.getConnectedDevices(); return mService.getConnectedDevices();
@@ -286,7 +287,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
* {@inheritDoc} * {@inheritDoc}
*/ */
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
if (DBG) log("getDevicesMatchingStates()"); if (VDBG) log("getDevicesMatchingStates()");
if (mService != null && isEnabled()) { if (mService != null && isEnabled()) {
try { try {
return mService.getDevicesMatchingConnectionStates(states); return mService.getDevicesMatchingConnectionStates(states);
@@ -303,7 +304,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
* {@inheritDoc} * {@inheritDoc}
*/ */
public int getConnectionState(BluetoothDevice device) { public int getConnectionState(BluetoothDevice device) {
if (DBG) log("getState(" + device + ")"); if (VDBG) log("getState(" + device + ")");
if (mService != null && isEnabled() if (mService != null && isEnabled()
&& isValidDevice(device)) { && isValidDevice(device)) {
try { try {
@@ -365,7 +366,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
* @hide * @hide
*/ */
public int getPriority(BluetoothDevice device) { public int getPriority(BluetoothDevice device) {
if (DBG) log("getPriority(" + device + ")"); if (VDBG) log("getPriority(" + device + ")");
if (mService != null && isEnabled() if (mService != null && isEnabled()
&& isValidDevice(device)) { && isValidDevice(device)) {
try { try {

View File

@@ -46,6 +46,7 @@ import java.util.List;
public final class BluetoothHeadset implements BluetoothProfile { public final class BluetoothHeadset implements BluetoothProfile {
private static final String TAG = "BluetoothHeadset"; private static final String TAG = "BluetoothHeadset";
private static final boolean DBG = true; private static final boolean DBG = true;
private static final boolean VDBG = false;
/** /**
* Intent used to broadcast the change in connection state of the Headset * Intent used to broadcast the change in connection state of the Headset
@@ -226,7 +227,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
public void onBluetoothStateChange(boolean up) { public void onBluetoothStateChange(boolean up) {
if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up); if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up);
if (!up) { if (!up) {
if (DBG) Log.d(TAG,"Unbinding service..."); if (VDBG) Log.d(TAG,"Unbinding service...");
synchronized (mConnection) { synchronized (mConnection) {
try { try {
mService = null; mService = null;
@@ -239,7 +240,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
synchronized (mConnection) { synchronized (mConnection) {
try { try {
if (mService == null) { if (mService == null) {
if (DBG) Log.d(TAG,"Binding service..."); if (VDBG) Log.d(TAG,"Binding service...");
if (!mContext.bindService(new Intent(IBluetoothHeadset.class.getName()), mConnection, 0)) { if (!mContext.bindService(new Intent(IBluetoothHeadset.class.getName()), mConnection, 0)) {
Log.e(TAG, "Could not bind to Bluetooth Headset Service"); Log.e(TAG, "Could not bind to Bluetooth Headset Service");
} }
@@ -281,7 +282,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* are ok. * are ok.
*/ */
/*package*/ void close() { /*package*/ void close() {
if (DBG) log("close()"); if (VDBG) log("close()");
IBluetoothManager mgr = mAdapter.getBluetoothManager(); IBluetoothManager mgr = mAdapter.getBluetoothManager();
if (mgr != null) { if (mgr != null) {
@@ -387,7 +388,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* {@inheritDoc} * {@inheritDoc}
*/ */
public List<BluetoothDevice> getConnectedDevices() { public List<BluetoothDevice> getConnectedDevices() {
if (DBG) log("getConnectedDevices()"); if (VDBG) log("getConnectedDevices()");
if (mService != null && isEnabled()) { if (mService != null && isEnabled()) {
try { try {
return mService.getConnectedDevices(); return mService.getConnectedDevices();
@@ -404,7 +405,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* {@inheritDoc} * {@inheritDoc}
*/ */
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
if (DBG) log("getDevicesMatchingStates()"); if (VDBG) log("getDevicesMatchingStates()");
if (mService != null && isEnabled()) { if (mService != null && isEnabled()) {
try { try {
return mService.getDevicesMatchingConnectionStates(states); return mService.getDevicesMatchingConnectionStates(states);
@@ -421,7 +422,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* {@inheritDoc} * {@inheritDoc}
*/ */
public int getConnectionState(BluetoothDevice device) { public int getConnectionState(BluetoothDevice device) {
if (DBG) log("getConnectionState(" + device + ")"); if (VDBG) log("getConnectionState(" + device + ")");
if (mService != null && isEnabled() && if (mService != null && isEnabled() &&
isValidDevice(device)) { isValidDevice(device)) {
try { try {
@@ -483,7 +484,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* @hide * @hide
*/ */
public int getPriority(BluetoothDevice device) { public int getPriority(BluetoothDevice device) {
if (DBG) log("getPriority(" + device + ")"); if (VDBG) log("getPriority(" + device + ")");
if (mService != null && isEnabled() && if (mService != null && isEnabled() &&
isValidDevice(device)) { isValidDevice(device)) {
try { try {
@@ -566,7 +567,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* false otherwise or on error * false otherwise or on error
*/ */
public boolean isAudioConnected(BluetoothDevice device) { public boolean isAudioConnected(BluetoothDevice device) {
if (DBG) log("isAudioConnected()"); if (VDBG) log("isAudioConnected()");
if (mService != null && isEnabled() && if (mService != null && isEnabled() &&
isValidDevice(device)) { isValidDevice(device)) {
try { try {
@@ -594,7 +595,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* @hide * @hide
*/ */
public int getBatteryUsageHint(BluetoothDevice device) { public int getBatteryUsageHint(BluetoothDevice device) {
if (DBG) log("getBatteryUsageHint()"); if (VDBG) log("getBatteryUsageHint()");
if (mService != null && isEnabled() && if (mService != null && isEnabled() &&
isValidDevice(device)) { isValidDevice(device)) {
try { try {
@@ -661,7 +662,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* @hide * @hide
*/ */
public int getAudioState(BluetoothDevice device) { public int getAudioState(BluetoothDevice device) {
if (DBG) log("getAudioState"); if (VDBG) log("getAudioState");
if (mService != null && !isDisabled()) { if (mService != null && !isDisabled()) {
try { try {
return mService.getAudioState(device); return mService.getAudioState(device);
@@ -683,7 +684,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* @hide * @hide
*/ */
public boolean isAudioOn() { public boolean isAudioOn() {
if (DBG) log("isAudioOn()"); if (VDBG) log("isAudioOn()");
if (mService != null && isEnabled()) { if (mService != null && isEnabled()) {
try { try {
return mService.isAudioOn(); return mService.isAudioOn();

View File

@@ -58,6 +58,7 @@ import java.util.List;
public final class BluetoothHealth implements BluetoothProfile { public final class BluetoothHealth implements BluetoothProfile {
private static final String TAG = "BluetoothHealth"; private static final String TAG = "BluetoothHealth";
private static final boolean DBG = true; private static final boolean DBG = true;
private static final boolean VDBG = false;
/** /**
* Health Profile Source Role - the health device. * Health Profile Source Role - the health device.
@@ -102,7 +103,7 @@ public final class BluetoothHealth implements BluetoothProfile {
public void onBluetoothStateChange(boolean up) { public void onBluetoothStateChange(boolean up) {
if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up); if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up);
if (!up) { if (!up) {
if (DBG) Log.d(TAG,"Unbinding service..."); if (VDBG) Log.d(TAG,"Unbinding service...");
synchronized (mConnection) { synchronized (mConnection) {
try { try {
mService = null; mService = null;
@@ -115,7 +116,7 @@ public final class BluetoothHealth implements BluetoothProfile {
synchronized (mConnection) { synchronized (mConnection) {
try { try {
if (mService == null) { if (mService == null) {
if (DBG) Log.d(TAG,"Binding service..."); if (VDBG) Log.d(TAG,"Binding service...");
if (!mContext.bindService(new Intent(IBluetoothHealth.class.getName()), mConnection, 0)) { if (!mContext.bindService(new Intent(IBluetoothHealth.class.getName()), mConnection, 0)) {
Log.e(TAG, "Could not bind to Bluetooth Health Service"); Log.e(TAG, "Could not bind to Bluetooth Health Service");
} }
@@ -148,7 +149,7 @@ public final class BluetoothHealth implements BluetoothProfile {
BluetoothHealthCallback callback) { BluetoothHealthCallback callback) {
if (!isEnabled() || name == null) return false; if (!isEnabled() || name == null) return false;
if (DBG) log("registerSinkApplication(" + name + ":" + dataType + ")"); if (VDBG) log("registerSinkApplication(" + name + ":" + dataType + ")");
return registerAppConfiguration(name, dataType, SINK_ROLE, return registerAppConfiguration(name, dataType, SINK_ROLE,
CHANNEL_TYPE_ANY, callback); CHANNEL_TYPE_ANY, callback);
} }
@@ -174,7 +175,7 @@ public final class BluetoothHealth implements BluetoothProfile {
boolean result = false; boolean result = false;
if (!isEnabled() || !checkAppParam(name, role, channelType, callback)) return result; if (!isEnabled() || !checkAppParam(name, role, channelType, callback)) return result;
if (DBG) log("registerApplication(" + name + ":" + dataType + ")"); if (VDBG) log("registerApplication(" + name + ":" + dataType + ")");
BluetoothHealthCallbackWrapper wrapper = new BluetoothHealthCallbackWrapper(callback); BluetoothHealthCallbackWrapper wrapper = new BluetoothHealthCallbackWrapper(callback);
BluetoothHealthAppConfiguration config = BluetoothHealthAppConfiguration config =
new BluetoothHealthAppConfiguration(name, dataType, role, channelType); new BluetoothHealthAppConfiguration(name, dataType, role, channelType);
@@ -488,7 +489,7 @@ public final class BluetoothHealth implements BluetoothProfile {
} }
/*package*/ void close() { /*package*/ void close() {
if (DBG) log("close()"); if (VDBG) log("close()");
IBluetoothManager mgr = mAdapter.getBluetoothManager(); IBluetoothManager mgr = mAdapter.getBluetoothManager();
if (mgr != null) { if (mgr != null) {
try { try {

View File

@@ -45,6 +45,7 @@ import java.util.List;
public final class BluetoothInputDevice implements BluetoothProfile { public final class BluetoothInputDevice implements BluetoothProfile {
private static final String TAG = "BluetoothInputDevice"; private static final String TAG = "BluetoothInputDevice";
private static final boolean DBG = true; private static final boolean DBG = true;
private static final boolean VDBG = false;
/** /**
* Intent used to broadcast the change in connection state of the Input * Intent used to broadcast the change in connection state of the Input
@@ -191,7 +192,7 @@ public final class BluetoothInputDevice implements BluetoothProfile {
public void onBluetoothStateChange(boolean up) { public void onBluetoothStateChange(boolean up) {
if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up); if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up);
if (!up) { if (!up) {
if (DBG) Log.d(TAG,"Unbinding service..."); if (VDBG) Log.d(TAG,"Unbinding service...");
synchronized (mConnection) { synchronized (mConnection) {
try { try {
mService = null; mService = null;
@@ -204,7 +205,7 @@ public final class BluetoothInputDevice implements BluetoothProfile {
synchronized (mConnection) { synchronized (mConnection) {
try { try {
if (mService == null) { if (mService == null) {
if (DBG) Log.d(TAG,"Binding service..."); if (VDBG) Log.d(TAG,"Binding service...");
if (!mContext.bindService(new Intent(IBluetoothInputDevice.class.getName()), mConnection, 0)) { if (!mContext.bindService(new Intent(IBluetoothInputDevice.class.getName()), mConnection, 0)) {
Log.e(TAG, "Could not bind to Bluetooth HID Service"); Log.e(TAG, "Could not bind to Bluetooth HID Service");
} }
@@ -243,7 +244,7 @@ public final class BluetoothInputDevice implements BluetoothProfile {
} }
/*package*/ void close() { /*package*/ void close() {
if (DBG) log("close()"); if (VDBG) log("close()");
IBluetoothManager mgr = mAdapter.getBluetoothManager(); IBluetoothManager mgr = mAdapter.getBluetoothManager();
if (mgr != null) { if (mgr != null) {
try { try {
@@ -344,7 +345,7 @@ public final class BluetoothInputDevice implements BluetoothProfile {
* {@inheritDoc} * {@inheritDoc}
*/ */
public List<BluetoothDevice> getConnectedDevices() { public List<BluetoothDevice> getConnectedDevices() {
if (DBG) log("getConnectedDevices()"); if (VDBG) log("getConnectedDevices()");
if (mService != null && isEnabled()) { if (mService != null && isEnabled()) {
try { try {
return mService.getConnectedDevices(); return mService.getConnectedDevices();
@@ -361,7 +362,7 @@ public final class BluetoothInputDevice implements BluetoothProfile {
* {@inheritDoc} * {@inheritDoc}
*/ */
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
if (DBG) log("getDevicesMatchingStates()"); if (VDBG) log("getDevicesMatchingStates()");
if (mService != null && isEnabled()) { if (mService != null && isEnabled()) {
try { try {
return mService.getDevicesMatchingConnectionStates(states); return mService.getDevicesMatchingConnectionStates(states);
@@ -378,7 +379,7 @@ public final class BluetoothInputDevice implements BluetoothProfile {
* {@inheritDoc} * {@inheritDoc}
*/ */
public int getConnectionState(BluetoothDevice device) { public int getConnectionState(BluetoothDevice device) {
if (DBG) log("getState(" + device + ")"); if (VDBG) log("getState(" + device + ")");
if (mService != null && isEnabled() && isValidDevice(device)) { if (mService != null && isEnabled() && isValidDevice(device)) {
try { try {
return mService.getConnectionState(device); return mService.getConnectionState(device);
@@ -438,7 +439,7 @@ public final class BluetoothInputDevice implements BluetoothProfile {
* @hide * @hide
*/ */
public int getPriority(BluetoothDevice device) { public int getPriority(BluetoothDevice device) {
if (DBG) log("getPriority(" + device + ")"); if (VDBG) log("getPriority(" + device + ")");
if (mService != null && isEnabled() && isValidDevice(device)) { if (mService != null && isEnabled() && isValidDevice(device)) {
try { try {
return mService.getPriority(device); return mService.getPriority(device);
@@ -519,7 +520,7 @@ public final class BluetoothInputDevice implements BluetoothProfile {
* @hide * @hide
*/ */
public boolean getProtocolMode(BluetoothDevice device) { public boolean getProtocolMode(BluetoothDevice device) {
if (DBG) log("getProtocolMode(" + device + ")"); if (VDBG) log("getProtocolMode(" + device + ")");
if (mService != null && isEnabled() && isValidDevice(device)) { if (mService != null && isEnabled() && isValidDevice(device)) {
try { try {
return mService.getProtocolMode(device); return mService.getProtocolMode(device);
@@ -570,7 +571,7 @@ public final class BluetoothInputDevice implements BluetoothProfile {
* @hide * @hide
*/ */
public boolean getReport(BluetoothDevice device, byte reportType, byte reportId, int bufferSize) { public boolean getReport(BluetoothDevice device, byte reportType, byte reportId, int bufferSize) {
if (DBG) log("getReport(" + device + "), reportType=" + reportType + " reportId=" + reportId + "bufferSize=" + bufferSize); if (VDBG) log("getReport(" + device + "), reportType=" + reportType + " reportId=" + reportId + "bufferSize=" + bufferSize);
if (mService != null && isEnabled() && isValidDevice(device)) { if (mService != null && isEnabled() && isValidDevice(device)) {
try { try {
return mService.getReport(device, reportType, reportId, bufferSize); return mService.getReport(device, reportType, reportId, bufferSize);

View File

@@ -44,6 +44,7 @@ import java.util.List;
public final class BluetoothPan implements BluetoothProfile { public final class BluetoothPan implements BluetoothProfile {
private static final String TAG = "BluetoothPan"; private static final String TAG = "BluetoothPan";
private static final boolean DBG = true; private static final boolean DBG = true;
private static final boolean VDBG = false;
/** /**
* Intent used to broadcast the change in connection state of the Pan * Intent used to broadcast the change in connection state of the Pan
@@ -145,7 +146,7 @@ public final class BluetoothPan implements BluetoothProfile {
} }
/*package*/ void close() { /*package*/ void close() {
if (DBG) log("close()"); if (VDBG) log("close()");
if (mConnection != null) { if (mConnection != null) {
mContext.unbindService(mConnection); mContext.unbindService(mConnection);
mConnection = null; mConnection = null;
@@ -175,7 +176,7 @@ public final class BluetoothPan implements BluetoothProfile {
} }
Log.d(TAG, "BluetoothPan(), bindService called"); Log.d(TAG, "BluetoothPan(), bindService called");
} else { } else {
if (DBG) Log.d(TAG,"Unbinding service..."); if (VDBG) Log.d(TAG,"Unbinding service...");
synchronized (mConnection) { synchronized (mConnection) {
try { try {
mPanService = null; mPanService = null;
@@ -266,7 +267,7 @@ public final class BluetoothPan implements BluetoothProfile {
* {@inheritDoc} * {@inheritDoc}
*/ */
public List<BluetoothDevice> getConnectedDevices() { public List<BluetoothDevice> getConnectedDevices() {
if (DBG) log("getConnectedDevices()"); if (VDBG) log("getConnectedDevices()");
if (mPanService != null && isEnabled()) { if (mPanService != null && isEnabled()) {
try { try {
return mPanService.getConnectedDevices(); return mPanService.getConnectedDevices();
@@ -283,7 +284,7 @@ public final class BluetoothPan implements BluetoothProfile {
* {@inheritDoc} * {@inheritDoc}
*/ */
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
if (DBG) log("getDevicesMatchingStates()"); if (VDBG) log("getDevicesMatchingStates()");
if (mPanService != null && isEnabled()) { if (mPanService != null && isEnabled()) {
try { try {
return mPanService.getDevicesMatchingConnectionStates(states); return mPanService.getDevicesMatchingConnectionStates(states);
@@ -300,7 +301,7 @@ public final class BluetoothPan implements BluetoothProfile {
* {@inheritDoc} * {@inheritDoc}
*/ */
public int getConnectionState(BluetoothDevice device) { public int getConnectionState(BluetoothDevice device) {
if (DBG) log("getState(" + device + ")"); if (VDBG) log("getState(" + device + ")");
if (mPanService != null && isEnabled() if (mPanService != null && isEnabled()
&& isValidDevice(device)) { && isValidDevice(device)) {
try { try {
@@ -324,7 +325,7 @@ public final class BluetoothPan implements BluetoothProfile {
} }
public boolean isTetheringOn() { public boolean isTetheringOn() {
if (DBG) log("isTetheringOn()"); if (VDBG) log("isTetheringOn()");
try { try {
return mPanService.isTetheringOn(); return mPanService.isTetheringOn();
} catch (RemoteException e) { } catch (RemoteException e) {

View File

@@ -51,7 +51,8 @@ import android.util.Log;
public class BluetoothPbap { public class BluetoothPbap {
private static final String TAG = "BluetoothPbap"; private static final String TAG = "BluetoothPbap";
private static final boolean DBG = false; private static final boolean DBG = true;
private static final boolean VDBG = false;
/** int extra for PBAP_STATE_CHANGED_ACTION */ /** int extra for PBAP_STATE_CHANGED_ACTION */
public static final String PBAP_STATE = public static final String PBAP_STATE =
@@ -114,7 +115,7 @@ public class BluetoothPbap {
public void onBluetoothStateChange(boolean up) { public void onBluetoothStateChange(boolean up) {
if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up); if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up);
if (!up) { if (!up) {
if (DBG) Log.d(TAG,"Unbinding service..."); if (VDBG) Log.d(TAG,"Unbinding service...");
synchronized (mConnection) { synchronized (mConnection) {
try { try {
mService = null; mService = null;
@@ -127,7 +128,7 @@ public class BluetoothPbap {
synchronized (mConnection) { synchronized (mConnection) {
try { try {
if (mService == null) { if (mService == null) {
if (DBG) Log.d(TAG,"Binding service..."); if (VDBG) Log.d(TAG,"Binding service...");
if (!mContext.bindService( if (!mContext.bindService(
new Intent(IBluetoothPbap.class.getName()), new Intent(IBluetoothPbap.class.getName()),
mConnection, 0)) { mConnection, 0)) {
@@ -206,7 +207,7 @@ public class BluetoothPbap {
* object is currently not connected to the Pbap service. * object is currently not connected to the Pbap service.
*/ */
public int getState() { public int getState() {
if (DBG) log("getState()"); if (VDBG) log("getState()");
if (mService != null) { if (mService != null) {
try { try {
return mService.getState(); return mService.getState();
@@ -225,7 +226,7 @@ public class BluetoothPbap {
* the Pbap service. * the Pbap service.
*/ */
public BluetoothDevice getClient() { public BluetoothDevice getClient() {
if (DBG) log("getClient()"); if (VDBG) log("getClient()");
if (mService != null) { if (mService != null) {
try { try {
return mService.getClient(); return mService.getClient();
@@ -243,7 +244,7 @@ public class BluetoothPbap {
* object is not currently connected to the Pbap service. * object is not currently connected to the Pbap service.
*/ */
public boolean isConnected(BluetoothDevice device) { public boolean isConnected(BluetoothDevice device) {
if (DBG) log("isConnected(" + device + ")"); if (VDBG) log("isConnected(" + device + ")");
if (mService != null) { if (mService != null) {
try { try {
return mService.isConnected(device); return mService.isConnected(device);

View File

@@ -72,6 +72,8 @@ import java.nio.ByteBuffer;
*/ */
public final class BluetoothSocket implements Closeable { public final class BluetoothSocket implements Closeable {
private static final String TAG = "BluetoothSocket"; private static final String TAG = "BluetoothSocket";
private static final boolean DBG = true;
private static final boolean VDBG = false;
/** @hide */ /** @hide */
public static final int MAX_RFCOMM_CHANNEL = 30; public static final int MAX_RFCOMM_CHANNEL = 30;
@@ -172,7 +174,7 @@ public final class BluetoothSocket implements Closeable {
BluetoothSocket as = new BluetoothSocket(this); BluetoothSocket as = new BluetoothSocket(this);
as.mSocketState = SocketState.CONNECTED; as.mSocketState = SocketState.CONNECTED;
FileDescriptor[] fds = mSocket.getAncillaryFileDescriptors(); FileDescriptor[] fds = mSocket.getAncillaryFileDescriptors();
Log.d(TAG, "socket fd passed by stack fds: " + fds); if (VDBG) Log.d(TAG, "socket fd passed by stack fds: " + fds);
if(fds == null || fds.length != 1) { if(fds == null || fds.length != 1) {
Log.e(TAG, "socket fd passed from stack failed, fds: " + fds); Log.e(TAG, "socket fd passed from stack failed, fds: " + fds);
throw new IOException("bt socket acept failed"); throw new IOException("bt socket acept failed");
@@ -291,7 +293,7 @@ public final class BluetoothSocket implements Closeable {
mUuid, mPort, getSecurityFlags()); mUuid, mPort, getSecurityFlags());
synchronized(this) synchronized(this)
{ {
Log.d(TAG, "connect(), SocketState: " + mSocketState + ", mPfd: " + mPfd); if (DBG) Log.d(TAG, "connect(), SocketState: " + mSocketState + ", mPfd: " + mPfd);
if (mSocketState == SocketState.CLOSED) throw new IOException("socket closed"); if (mSocketState == SocketState.CLOSED) throw new IOException("socket closed");
if (mPfd == null) throw new IOException("bt socket connect failed"); if (mPfd == null) throw new IOException("bt socket connect failed");
FileDescriptor fd = mPfd.getFileDescriptor(); FileDescriptor fd = mPfd.getFileDescriptor();
@@ -339,23 +341,24 @@ public final class BluetoothSocket implements Closeable {
// read out port number // read out port number
try { try {
synchronized(this) { synchronized(this) {
Log.d(TAG, "bindListen(), SocketState: " + mSocketState + ", mPfd: " + mPfd); if (VDBG) Log.d(TAG, "bindListen(), SocketState: " + mSocketState + ", mPfd: " +
mPfd);
if(mSocketState != SocketState.INIT) return EBADFD; if(mSocketState != SocketState.INIT) return EBADFD;
if(mPfd == null) return -1; if(mPfd == null) return -1;
FileDescriptor fd = mPfd.getFileDescriptor(); FileDescriptor fd = mPfd.getFileDescriptor();
Log.d(TAG, "bindListen(), new LocalSocket "); if (VDBG) Log.d(TAG, "bindListen(), new LocalSocket ");
mSocket = new LocalSocket(fd); mSocket = new LocalSocket(fd);
Log.d(TAG, "bindListen(), new LocalSocket.getInputStream() "); if (VDBG) Log.d(TAG, "bindListen(), new LocalSocket.getInputStream() ");
mSocketIS = mSocket.getInputStream(); mSocketIS = mSocket.getInputStream();
mSocketOS = mSocket.getOutputStream(); mSocketOS = mSocket.getOutputStream();
} }
Log.d(TAG, "bindListen(), readInt mSocketIS: " + mSocketIS); if (VDBG) Log.d(TAG, "bindListen(), readInt mSocketIS: " + mSocketIS);
int channel = readInt(mSocketIS); int channel = readInt(mSocketIS);
synchronized(this) { synchronized(this) {
if(mSocketState == SocketState.INIT) if(mSocketState == SocketState.INIT)
mSocketState = SocketState.LISTENING; mSocketState = SocketState.LISTENING;
} }
Log.d(TAG, "channel: " + channel); if (VDBG) Log.d(TAG, "channel: " + channel);
if (mPort == -1) { if (mPort == -1) {
mPort = channel; mPort = channel;
} // else ASSERT(mPort == channel) } // else ASSERT(mPort == channel)
@@ -385,26 +388,26 @@ public final class BluetoothSocket implements Closeable {
} }
/*package*/ int available() throws IOException { /*package*/ int available() throws IOException {
Log.d(TAG, "available: " + mSocketIS); if (VDBG) Log.d(TAG, "available: " + mSocketIS);
return mSocketIS.available(); return mSocketIS.available();
} }
/*package*/ int read(byte[] b, int offset, int length) throws IOException { /*package*/ int read(byte[] b, int offset, int length) throws IOException {
Log.d(TAG, "read in: " + mSocketIS + " len: " + length); if (VDBG) Log.d(TAG, "read in: " + mSocketIS + " len: " + length);
int ret = mSocketIS.read(b, offset, length); int ret = mSocketIS.read(b, offset, length);
if(ret < 0) if(ret < 0)
throw new IOException("bt socket closed, read return: " + ret); throw new IOException("bt socket closed, read return: " + ret);
Log.d(TAG, "read out: " + mSocketIS + " ret: " + ret); if (VDBG) Log.d(TAG, "read out: " + mSocketIS + " ret: " + ret);
return ret; return ret;
} }
/*package*/ int write(byte[] b, int offset, int length) throws IOException { /*package*/ int write(byte[] b, int offset, int length) throws IOException {
Log.d(TAG, "write: " + mSocketOS + " length: " + length); if (VDBG) Log.d(TAG, "write: " + mSocketOS + " length: " + length);
mSocketOS.write(b, offset, length); mSocketOS.write(b, offset, length);
// There is no good way to confirm since the entire process is asynchronous anyway // There is no good way to confirm since the entire process is asynchronous anyway
Log.d(TAG, "write out: " + mSocketOS + " length: " + length); if (VDBG) Log.d(TAG, "write out: " + mSocketOS + " length: " + length);
return length; return length;
} }
@@ -420,10 +423,10 @@ public final class BluetoothSocket implements Closeable {
if(mSocketState == SocketState.CLOSED) if(mSocketState == SocketState.CLOSED)
return; return;
mSocketState = SocketState.CLOSED; mSocketState = SocketState.CLOSED;
Log.d(TAG, "close() this: " + this + ", channel: " + mPort + ", mSocketIS: " + mSocketIS + if (VDBG) Log.d(TAG, "close() this: " + this + ", channel: " + mPort + ", mSocketIS: " + mSocketIS +
", mSocketOS: " + mSocketOS + "mSocket: " + mSocket); ", mSocketOS: " + mSocketOS + "mSocket: " + mSocket);
if(mSocket != null) { if(mSocket != null) {
Log.d(TAG, "Closing mSocket: " + mSocket); if (VDBG) Log.d(TAG, "Closing mSocket: " + mSocket);
mSocket.shutdownInput(); mSocket.shutdownInput();
mSocket.shutdownOutput(); mSocket.shutdownOutput();
mSocket.close(); mSocket.close();
@@ -449,7 +452,7 @@ public final class BluetoothSocket implements Closeable {
private String waitSocketSignal(InputStream is) throws IOException { private String waitSocketSignal(InputStream is) throws IOException {
byte [] sig = new byte[SOCK_SIGNAL_SIZE]; byte [] sig = new byte[SOCK_SIGNAL_SIZE];
int ret = readAll(is, sig); int ret = readAll(is, sig);
Log.d(TAG, "waitSocketSignal read 16 bytes signal ret: " + ret); if (VDBG) Log.d(TAG, "waitSocketSignal read 16 bytes signal ret: " + ret);
ByteBuffer bb = ByteBuffer.wrap(sig); ByteBuffer bb = ByteBuffer.wrap(sig);
bb.order(ByteOrder.nativeOrder()); bb.order(ByteOrder.nativeOrder());
int size = bb.getShort(); int size = bb.getShort();
@@ -458,7 +461,7 @@ public final class BluetoothSocket implements Closeable {
int channel = bb.getInt(); int channel = bb.getInt();
int status = bb.getInt(); int status = bb.getInt();
String RemoteAddr = convertAddr(addr); String RemoteAddr = convertAddr(addr);
Log.d(TAG, "waitSocketSignal: sig size: " + size + ", remote addr: " if (VDBG) Log.d(TAG, "waitSocketSignal: sig size: " + size + ", remote addr: "
+ RemoteAddr + ", channel: " + channel + ", status: " + status); + RemoteAddr + ", channel: " + channel + ", status: " + status);
if(status != 0) if(status != 0)
throw new IOException("Connection failure, status: " + status); throw new IOException("Connection failure, status: " + status);
@@ -481,7 +484,7 @@ public final class BluetoothSocket implements Closeable {
private int readInt(InputStream is) throws IOException { private int readInt(InputStream is) throws IOException {
byte[] ibytes = new byte[4]; byte[] ibytes = new byte[4];
int ret = readAll(is, ibytes); int ret = readAll(is, ibytes);
Log.d(TAG, "inputStream.read ret: " + ret); if (VDBG) Log.d(TAG, "inputStream.read ret: " + ret);
ByteBuffer bb = ByteBuffer.wrap(ibytes); ByteBuffer bb = ByteBuffer.wrap(ibytes);
bb.order(ByteOrder.nativeOrder()); bb.order(ByteOrder.nativeOrder());
return bb.getInt(); return bb.getInt();

View File

@@ -51,6 +51,8 @@ import java.util.concurrent.atomic.AtomicInteger;
public class BluetoothTetheringDataTracker implements NetworkStateTracker { public class BluetoothTetheringDataTracker implements NetworkStateTracker {
private static final String NETWORKTYPE = "BLUETOOTH_TETHER"; private static final String NETWORKTYPE = "BLUETOOTH_TETHER";
private static final String TAG = "BluetoothTethering"; private static final String TAG = "BluetoothTethering";
private static final boolean DBG = true;
private static final boolean VDBG = false;
private AtomicBoolean mTeardownRequested = new AtomicBoolean(false); private AtomicBoolean mTeardownRequested = new AtomicBoolean(false);
private AtomicBoolean mPrivateDnsRouteSet = new AtomicBoolean(false); private AtomicBoolean mPrivateDnsRouteSet = new AtomicBoolean(false);
@@ -99,10 +101,10 @@ public class BluetoothTetheringDataTracker implements NetworkStateTracker {
* Begin monitoring connectivity * Begin monitoring connectivity
*/ */
public void startMonitoring(Context context, Handler target) { public void startMonitoring(Context context, Handler target) {
Log.d(TAG, "startMonitoring: target: " + target); if (DBG) Log.d(TAG, "startMonitoring: target: " + target);
mContext = context; mContext = context;
mCsHandler = target; mCsHandler = target;
Log.d(TAG, "startMonitoring: mCsHandler: " + mCsHandler); if (VDBG) Log.d(TAG, "startMonitoring: mCsHandler: " + mCsHandler);
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null) { if (adapter != null) {
adapter.getProfileProxy(mContext, mProfileServiceListener, BluetoothProfile.PAN); adapter.getProfileProxy(mContext, mProfileServiceListener, BluetoothProfile.PAN);
@@ -310,31 +312,31 @@ public class BluetoothTetheringDataTracker implements NetworkStateTracker {
} }
public synchronized void startReverseTether(String iface) { public synchronized void startReverseTether(String iface) {
mIface = iface; mIface = iface;
Log.d(TAG, "startReverseTether mCsHandler: " + mCsHandler); if (DBG) Log.d(TAG, "startReverseTether mCsHandler: " + mCsHandler);
mDhcpThread = new Thread(new Runnable() { mDhcpThread = new Thread(new Runnable() {
public void run() { public void run() {
//TODO(): Add callbacks for failure and success case. //TODO(): Add callbacks for failure and success case.
//Currently this thread runs independently. //Currently this thread runs independently.
Log.d(TAG, "startReverseTether mCsHandler: " + mCsHandler); if (DBG) Log.d(TAG, "startReverseTether mCsHandler: " + mCsHandler);
String DhcpResultName = "dhcp." + mIface + ".result";; String DhcpResultName = "dhcp." + mIface + ".result";;
String result = ""; String result = "";
Log.d(TAG, "waiting for change of sys prop dhcp result: " + DhcpResultName); if (VDBG) Log.d(TAG, "waiting for change of sys prop dhcp result: " + DhcpResultName);
for(int i = 0; i < 30*5; i++) { for(int i = 0; i < 30*5; i++) {
try { Thread.sleep(200); } catch (InterruptedException ie) { return;} try { Thread.sleep(200); } catch (InterruptedException ie) { return;}
result = SystemProperties.get(DhcpResultName); result = SystemProperties.get(DhcpResultName);
Log.d(TAG, "read " + DhcpResultName + ": " + result); if (VDBG) Log.d(TAG, "read " + DhcpResultName + ": " + result);
if(result.equals("failed")) { if(result.equals("failed")) {
Log.e(TAG, "startReverseTether, failed to start dhcp service"); Log.e(TAG, "startReverseTether, failed to start dhcp service");
return; return;
} }
if(result.equals("ok")) { if(result.equals("ok")) {
Log.d(TAG, "startReverseTether, dhcp resut: " + result); if (VDBG) Log.d(TAG, "startReverseTether, dhcp resut: " + result);
if(readLinkProperty(mIface)) { if(readLinkProperty(mIface)) {
mNetworkInfo.setIsAvailable(true); mNetworkInfo.setIsAvailable(true);
mNetworkInfo.setDetailedState(DetailedState.CONNECTED, null, null); mNetworkInfo.setDetailedState(DetailedState.CONNECTED, null, null);
Log.d(TAG, "startReverseTether mCsHandler: " + mCsHandler); if (VDBG) Log.d(TAG, "startReverseTether mCsHandler: " + mCsHandler);
if(mCsHandler != null) { if(mCsHandler != null) {
Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo);
msg.sendToTarget(); msg.sendToTarget();
@@ -346,7 +348,7 @@ public class BluetoothTetheringDataTracker implements NetworkStateTracker {
return; return;
} }
} }
Log.d(TAG, "startReverseTether, dhcp failed, resut: " + result); Log.e(TAG, "startReverseTether, dhcp failed, resut: " + result);
} }
}); });
mDhcpThread.start(); mDhcpThread.start();