diff options
author | Steve Kondik <steve@cyngn.com> | 2014-12-18 16:40:38 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2014-12-18 16:40:38 -0800 |
commit | 6f9f3b691c9d60ef0c8f6f64f91e69ed46554777 (patch) | |
tree | c8bfa691667d183d74babf312fd664c2875d1e67 | |
parent | 3984f7b833cb22179837033ec3161ba6e2ec2133 (diff) | |
parent | 9a636716a32dbbdff18845dbe2353e34a5d85fc0 (diff) | |
download | android_packages_apps_BluetoothExt-6f9f3b691c9d60ef0c8f6f64f91e69ed46554777.tar.gz android_packages_apps_BluetoothExt-6f9f3b691c9d60ef0c8f6f64f91e69ed46554777.tar.bz2 android_packages_apps_BluetoothExt-6f9f3b691c9d60ef0c8f6f64f91e69ed46554777.zip |
Merge branch 'LA.BF.1.1_rb1.16' of git://codeaurora.org/quic/la/platform/vendor/qcom-opensource/bluetooth into cm-12.0
12 files changed, 264 insertions, 181 deletions
@@ -24,10 +24,13 @@ LOCAL_JAVA_LIBRARIES += telephony-common LOCAL_STATIC_JAVA_LIBRARIES := com.android.vcard -LOCAL_REQUIRED_MODULES := libbluetooth_jni bluetooth.default +LOCAL_REQUIRED_MODULES := bluetooth.default LOCAL_PROGUARD_ENABLED := disabled +LOCAL_MULTILIB:= 32 +LOCAL_JNI_SHARED_LIBRARIES:= libbluetooth_jni + include $(BUILD_PACKAGE) diff --git a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java index aaf1369..05e722b 100644 --- a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java +++ b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/HfpTestActivity.java @@ -389,8 +389,10 @@ public class HfpTestActivity extends MonkeyActivity implements IBluetoothConnect if (mBluetoothHeadsetClient != null) { mCalls.clear(); Integer id = 1; + int connState = mBluetoothHeadsetClient.getConnectionState(mDevice); // save all calls status - if (!mBluetoothHeadsetClient.getCurrentCalls(mDevice).isEmpty()) { + if (connState == BluetoothProfile.STATE_CONNECTED && + !mBluetoothHeadsetClient.getCurrentCalls(mDevice).isEmpty()) { for (BluetoothHeadsetClientCall call : mBluetoothHeadsetClient.getCurrentCalls(mDevice)) { mCalls.put(id, call); diff --git a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/MapTestActivity.java b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/MapTestActivity.java index 8be5164..a924fcb 100644 --- a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/MapTestActivity.java +++ b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/MapTestActivity.java @@ -207,11 +207,14 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList @Override public void onServiceConnected(ComponentName name, IBinder service) { mProfileService = ((ProfileService.LocalBinder) service).getService(); - - BluetoothMasInstance inst = mProfileService.getMapClient(mMasInstanceId) - .getInstanceData(); - MapTestActivity.this.getActionBar().setSubtitle(inst.getName()); - + if(mProfileService != null) { + BluetoothMasClient cli = mProfileService.getMapClient(mMasInstanceId); + if (cli != null) { + BluetoothMasInstance inst = cli.getInstanceData(); + if(inst != null) + MapTestActivity.this.getActionBar().setSubtitle(inst.getName()); + } + } mProfileService.setMapCallback(mMasInstanceId, new IMapServiceCallback() { @Override @@ -244,7 +247,10 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList public void onSetPath(String path) { if (mSetPathQueue != null && mSetPathQueue.size() > 0) { String next = mSetPathQueue.removeFirst(); - mProfileService.getMapClient(mMasInstanceId).setFolderDown(next); + if(mProfileService != null && + (mProfileService.getMapClient(mMasInstanceId)) != null ) { + mProfileService.getMapClient(mMasInstanceId).setFolderDown(next); + } } else { mTextViewCurrentFolder.setText(path); clearFolderList(); @@ -436,9 +442,10 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList } } - mTextViewCurrentFolder.setText(mProfileService.getMapClient(mMasInstanceId) + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ){ + mTextViewCurrentFolder.setText(mProfileService.getMapClient(mMasInstanceId) .getCurrentPath()); - + } updateUi(true); if (mStartingGetMessageHandle != null) { @@ -599,7 +606,7 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList boolean connected = false; - if (mProfileService != null) { + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ) { connected = (mProfileService.getMapClient(mMasInstanceId).getState() == BluetoothMasClient.ConnectionState.CONNECTED); } @@ -645,18 +652,24 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList } private void onClickConnect() { - mProfileService.getMapClient(mMasInstanceId).connect(); - goToState(Job.CONNECT); + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ){ + mProfileService.getMapClient(mMasInstanceId).connect(); + goToState(Job.CONNECT); + } } private void onClickDisconnect() { - mProfileService.getMapClient(mMasInstanceId).disconnect(); - goToState(Job.DISCONNECT); + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ){ + mProfileService.getMapClient(mMasInstanceId).disconnect(); + goToState(Job.DISCONNECT); + } } private void onClickUpdateInbox() { - mProfileService.getMapClient(mMasInstanceId).updateInbox(); - goToState(Job.UPDATE_INBOX); + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ){ + mProfileService.getMapClient(mMasInstanceId).updateInbox(); + goToState(Job.UPDATE_INBOX); + } } private VCardEntry createVcard(BluetoothMapBmessage.Type type, String val) { @@ -705,7 +718,9 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList bmsg.setEncoding(encView.getSelectedItem().toString()); } - bmsg.setFolder(mProfileService.getMapClient(mMasInstanceId).getCurrentPath()); + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ) { + bmsg.setFolder(mProfileService.getMapClient(mMasInstanceId).getCurrentPath()); + } for (String rcpt : mEditOriginators) { bmsg.addOriginator(createVcard(bmsg.getType(), rcpt)); @@ -717,7 +732,8 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList bmsg.setBodyContent(contentsView.getText().toString()); - mProfileService + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ) { + mProfileService .getMapClient(mMasInstanceId) .pushMessage( null, @@ -725,7 +741,8 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList charset == R.id.map_msg_push_charset_native ? BluetoothMasClient.CharsetType.NATIVE : BluetoothMasClient.CharsetType.UTF_8, transparent, retry); - goToState(Job.PUSH_MESSAGE); + goToState(Job.PUSH_MESSAGE); + } } @Override @@ -755,7 +772,8 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList } public void onClickDeleteMessage(View view) { - if (mPreviewMsgHandle != null) { + if(mPreviewMsgHandle != null && mProfileService != null && + (mProfileService.getMapClient(mMasInstanceId)) != null ) { mProfileService.getMapClient(mMasInstanceId).setMessageDeletedStatus(mPreviewMsgHandle, true); goToState(Job.DELETE_MESSAGE); @@ -767,25 +785,31 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList return; } - if (mMapBmessage.getStatus().equals(BluetoothMapBmessage.Status.READ)) { - mProfileService.getMapClient(mMasInstanceId).setMessageReadStatus(mPreviewMsgHandle, + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ) { + if (mMapBmessage.getStatus().equals(BluetoothMapBmessage.Status.READ)) { + mProfileService.getMapClient(mMasInstanceId).setMessageReadStatus(mPreviewMsgHandle, false); - goToState(Job.SET_STATUS_UNREAD); - } else { - mProfileService.getMapClient(mMasInstanceId).setMessageReadStatus(mPreviewMsgHandle, + goToState(Job.SET_STATUS_UNREAD); + } else { + mProfileService.getMapClient(mMasInstanceId).setMessageReadStatus(mPreviewMsgHandle, true); - goToState(Job.SET_STATUS_READ); + goToState(Job.SET_STATUS_READ); + } } } public void onClickSetPathRoot(View view) { - mProfileService.getMapClient(mMasInstanceId).setFolderRoot(); - goToState(Job.SET_PATH); + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ){ + mProfileService.getMapClient(mMasInstanceId).setFolderRoot(); + goToState(Job.SET_PATH); + } } public void onClickSetPathUp(View view) { - mProfileService.getMapClient(mMasInstanceId).setFolderUp(); - goToState(Job.SET_PATH); + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ){ + mProfileService.getMapClient(mMasInstanceId).setFolderUp(); + goToState(Job.SET_PATH); + } } public void onClickSetPathEnter(View view) { @@ -804,19 +828,23 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList int count = Integer.parseInt(mEditTextMaxListCountFolders.getText().toString()); int offset = Integer.parseInt(mEditTextListStartOffsetFolders.getText().toString()); - try { - mProfileService.getMapClient(mMasInstanceId).getFolderListing(count, offset); - goToState(Job.GET_FOLDER_LISTING); - } catch (IllegalArgumentException e) { - Toast.makeText(this, + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ){ + try { + mProfileService.getMapClient(mMasInstanceId).getFolderListing(count, offset); + goToState(Job.GET_FOLDER_LISTING); + } catch (IllegalArgumentException e) { + Toast.makeText(this, "GetFolderListing FAILED: illegal arguments (" + e.getMessage() + ")", Toast.LENGTH_LONG).show(); + } } } public void onClickGetFolderListingSize(View view) { - mProfileService.getMapClient(mMasInstanceId).getFolderListingSize(); - goToState(Job.GET_FOLDER_LISTING_SIZE); + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ){ + mProfileService.getMapClient(mMasInstanceId).getFolderListingSize(); + goToState(Job.GET_FOLDER_LISTING_SIZE); + } } public void onClickMessageParameters(View view) { @@ -1068,11 +1096,12 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList } try { - mProfileService.getMapClient(mMasInstanceId).getMessagesListing(folder, - mMessageListingParameters, - getLocalMessageFilter(), subjectLength, maxListCount, listStartOffset); - - goToState(Job.GET_MESSAGE_LISTING); + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ){ + mProfileService.getMapClient(mMasInstanceId).getMessagesListing(folder, + mMessageListingParameters, + getLocalMessageFilter(), subjectLength, maxListCount, listStartOffset); + goToState(Job.GET_MESSAGE_LISTING); + } updateListEmptyView(true); } catch (IllegalArgumentException e) { Toast.makeText(this, @@ -1095,8 +1124,10 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList } public void onClickGetMessageListingSize(View view) { - mProfileService.getMapClient(mMasInstanceId).getMessagesListingSize(); - goToState(Job.GET_MESSAGE_LISTING_SIZE); + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ){ + mProfileService.getMapClient(mMasInstanceId).getMessagesListingSize(); + goToState(Job.GET_MESSAGE_LISTING_SIZE); + } } class BluetoothMapMessageAdapter extends ArrayAdapter<BluetoothMapMessage> { @@ -1237,12 +1268,12 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList LinearLayout lay = (LinearLayout) findViewById(R.id.maptest_tab_list); mListTouchables = lay.getTouchables(); } - - for (View view : mListTouchables) { - view.setEnabled(mProfileService.getMapClient(mMasInstanceId).getState() == BluetoothMasClient.ConnectionState.CONNECTED + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ){ + for (View view : mListTouchables) { + view.setEnabled(mProfileService.getMapClient(mMasInstanceId).getState() == BluetoothMasClient.ConnectionState.CONNECTED && mCurrentJob == Job.IDLE); + } } - if (invalidateOptionsMenu) { invalidateOptionsMenu(); } @@ -1333,15 +1364,21 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList switch (item.getItemId()) { case 1: case 2: - mProfileService.getMapClient(mMasInstanceId).setMessageReadStatus(bmsg.getHandle(), - item.getItemId() == 1); - goToState(Job.SET_STATUS_READ); + if(mProfileService != null && + (mProfileService.getMapClient(mMasInstanceId)) != null ) { + mProfileService.getMapClient(mMasInstanceId) + .setMessageReadStatus(bmsg.getHandle(),item.getItemId() == 1); + goToState(Job.SET_STATUS_READ); + } break; case 3: case 4: - mProfileService.getMapClient(mMasInstanceId).setMessageDeletedStatus( + if(mProfileService != null && + (mProfileService.getMapClient(mMasInstanceId)) != null ) { + mProfileService.getMapClient(mMasInstanceId).setMessageDeletedStatus( bmsg.getHandle(), item.getItemId() == 3); - goToState(Job.DELETE_MESSAGE); + goToState(Job.DELETE_MESSAGE); + } break; case 5: getMessage(bmsg.getHandle(), CharsetType.NATIVE, false); @@ -1449,7 +1486,9 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList private void goToFolder(String dst) { mSetPathQueue = new ArrayDeque<String>(Arrays.asList(dst.split("/"))); - mProfileService.getMapClient(mMasInstanceId).setFolderRoot(); + if(mProfileService != null && (mProfileService.getMapClient(mMasInstanceId)) != null ){ + mProfileService.getMapClient(mMasInstanceId).setFolderRoot(); + } } private boolean getMessage(String handle, CharsetType charset, boolean attachments) { @@ -1458,6 +1497,9 @@ public class MapTestActivity extends MonkeyActivity implements GetTextDialogList } BluetoothMasClient cli = mProfileService.getMapClient(mMasInstanceId); + if (cli == null) { + return false; + } if (!cli.getMessage(handle, charset, attachments)) { return false; diff --git a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/ServicesFragment.java b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/ServicesFragment.java index f73e435..f7d3bae 100644..100755 --- a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/ServicesFragment.java +++ b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/ServicesFragment.java @@ -447,50 +447,55 @@ public class ServicesFragment extends ListFragment { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Service srv = mServices.get((Integer) buttonView.getTag()); - - switch (srv.mType) { - case HFP: - if (isChecked) { - mActivity.mProfileService.getHfpClient().connect(mActivity.mDevice); - buttonView.setEnabled(false); - } else { - mActivity.mProfileService.getHfpClient().disconnect(mActivity.mDevice); - buttonView.setEnabled(false); - } - break; - - case PBAP: - if (isChecked) { - mActivity.mProfileService.getPbapClient().connect(); - buttonView.setEnabled(false); - } else { - mActivity.mProfileService.getPbapClient().disconnect(); - buttonView.setEnabled(false); - } - break; - - case MAP: - BluetoothMasClient cli = mActivity.mProfileService - .getMapClient(srv.mMasInstance.getId()); - if (isChecked) { - if (buttonView.getId() == R.id.service_switch) { - cli.connect(); + if (mActivity.mProfileService != null) { + switch (srv.mType) { + case HFP: + if (isChecked) { + mActivity.mProfileService.getHfpClient().connect(mActivity.mDevice); + buttonView.setEnabled(false); } else { - cli.setNotificationRegistration(true); + mActivity.mProfileService.getHfpClient().disconnect(mActivity.mDevice); + buttonView.setEnabled(false); } - buttonView.setEnabled(false); - } else { - if (buttonView.getId() == R.id.service_switch) { - cli.disconnect(); + break; + + case PBAP: + if (isChecked) { + if (mActivity.mProfileService.getPbapClient()!= null) + mActivity.mProfileService.getPbapClient().connect(); + buttonView.setEnabled(false); } else { - cli.setNotificationRegistration(false); + if (mActivity.mProfileService.getPbapClient()!= null) + mActivity.mProfileService.getPbapClient().disconnect(); + buttonView.setEnabled(false); } - buttonView.setEnabled(false); - } - break; - case AVRCP: - // not to be handled - break; + break; + + case MAP: + BluetoothMasClient cli = mActivity.mProfileService + .getMapClient(srv.mMasInstance.getId()); + if(cli != null ) { + if (isChecked) { + if (buttonView.getId() == R.id.service_switch) { + cli.connect(); + } else { + cli.setNotificationRegistration(true); + } + buttonView.setEnabled(false); + } else { + if (buttonView.getId() == R.id.service_switch) { + cli.disconnect(); + } else { + cli.setNotificationRegistration(false); + } + buttonView.setEnabled(false); + } + } + break; + case AVRCP: + // not to be handled + break; + } } } } diff --git a/hiddtestapp/src/org/codeaurora/bluetooth/hiddtestapp/HidConsts.java b/hiddtestapp/src/org/codeaurora/bluetooth/hiddtestapp/HidConsts.java index a1b3368..6f616ec 100644 --- a/hiddtestapp/src/org/codeaurora/bluetooth/hiddtestapp/HidConsts.java +++ b/hiddtestapp/src/org/codeaurora/bluetooth/hiddtestapp/HidConsts.java @@ -43,7 +43,7 @@ public class HidConsts { (byte) 0xa1, (byte) 0x01, // COLLECTION (Application) (byte) 0x09, (byte) 0x01, // USAGE (Pointer) (byte) 0xa1, (byte) 0x00, // COLLECTION (Physical) - (byte) 0x85, (byte) 0x01, // REPORT_ID (1) + (byte) 0x85, (byte) 0x02, // REPORT_ID (2) (byte) 0x05, (byte) 0x09, // USAGE_PAGE (Button) (byte) 0x19, (byte) 0x01, // USAGE_MINIMUM (Button 1) (byte) 0x29, (byte) 0x03, // USAGE_MAXIMUM (Button 3) @@ -93,7 +93,7 @@ public class HidConsts { (byte) 0x05, (byte) 0x01, // USAGE_PAGE (Generic Desktop) (byte) 0x09, (byte) 0x06, // USAGE (Keyboard) (byte) 0xa1, (byte) 0x01, // COLLECTION (Application) - (byte) 0x85, (byte) 0x10, // REPORT_ID (16) + (byte) 0x85, (byte) 0x01, // REPORT_ID (1) (byte) 0x05, (byte) 0x07, // USAGE_PAGE (Keyboard) (byte) 0x19, (byte) 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) (byte) 0x29, (byte) 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI) @@ -121,7 +121,7 @@ public class HidConsts { (byte) 0x05, (byte) 0x07, // USAGE_PAGE (Keyboard) (byte) 0x95, (byte) 0x05, // REPORT_COUNT (5) (byte) 0x75, (byte) 0x01, // REPORT_SIZE (1) - (byte) 0x85, (byte) 0x10, // REPORT_ID (16) + (byte) 0x85, (byte) 0x01, // REPORT_ID (1) (byte) 0x05, (byte) 0x08, // USAGE_PAGE (LEDs) (byte) 0x19, (byte) 0x01, // USAGE_MINIMUM (Num Lock) (byte) 0x29, (byte) 0x05, // USAGE_MAXIMUM (Kana) @@ -141,11 +141,11 @@ public class HidConsts { }; /* @formatter:on */ - public final static byte MOUSE_REPORT_ID = 1; + public final static byte KEYBOARD_INPUT_REPORT_ID = 1; - public final static byte KEYBOARD_INPUT_REPORT_ID = 16; + public final static byte KEYBOARD_OUTPUT_REPORT_ID = 1; - public final static byte KEYBOARD_OUTPUT_REPORT_ID = 16; + public final static byte MOUSE_REPORT_ID = 2; public final static byte BOOT_KEYBOARD_REPORT_ID = 1; diff --git a/hiddtestapp/src/org/codeaurora/bluetooth/hiddtestapp/Keyboard.java b/hiddtestapp/src/org/codeaurora/bluetooth/hiddtestapp/Keyboard.java index f2e5967..5d58b71 100644 --- a/hiddtestapp/src/org/codeaurora/bluetooth/hiddtestapp/Keyboard.java +++ b/hiddtestapp/src/org/codeaurora/bluetooth/hiddtestapp/Keyboard.java @@ -133,7 +133,8 @@ public class Keyboard extends LinearLayout implements Key.KeyListener { VISIBLE : INVISIBLE); key.setKeyListener(this); - if (attrs != null & attrs.shiftLabel != null & attrs.shiftLabel.length() > 0) { + if (attrs != null && attrs.shiftLabel != null && + attrs.shiftLabel.length() > 0) { mKeysWithShiftLabel.add(key); } diff --git a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java index 240d487..4e6ceaa 100644 --- a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java +++ b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java @@ -107,8 +107,8 @@ public class A4wpService extends Service private static final int MSB_MASK = 0xFF00; private static final int LSB_MASK= 0x00FF; - //Timout value set to 30Sec which enures we advertise in lmited mode - private static final int WIPOWER_ADV_TIMEOUT= 0x7530; + //Timeout value set to 5Sec which enures we advertise in limited mode + private static final int WIPOWER_ADV_TIMEOUT = 5000; //PRU Write param length for validation private static final byte A4WP_PTU_STATIC_LENGTH = 0x11; @@ -437,15 +437,22 @@ public class A4wpService extends Service Log.v(LOGTAG, "processPruControl>"); PruControl control = new PruControl(value); control.print(); + + if (mWipowerManager == null) { + Log.e(LOGTAG, "mWipowerManager is null"); + return status; + } + if (control.getEnablePruOutput()) { Log.v(LOGTAG, "do Enable PruOutPut"); mWipowerManager.startCharging(); mWipowerManager.enableAlertNotification(false); mWipowerManager.enableDataNotification(true); - stopAdvertising(); - isConnected = true; } else { Log.v(LOGTAG, "do Disable PruOutPut"); + if (mChargeComplete == true) { + mWipowerManager.enablePowerApply(true, true, true); + } mWipowerManager.stopCharging(); mWipowerManager.enableDataNotification(false); return status; @@ -584,11 +591,10 @@ public class A4wpService extends Service Log.v(LOGTAG, "onConnectionStateChange:DISCONNECTED " + device + "charge complete " + mChargeComplete); isConnected = false; if (mDevice != null && mWipowerManager != null) { + stopAdvertising(); mWipowerManager.enableDataNotification(false); mWipowerManager.stopCharging(); - if (mChargeComplete == true) { - mWipowerManager.enablePowerApply(true, true, true); - } else { + if (mChargeComplete != true) { mWipowerManager.enablePowerApply(true, true, false); } mDevice = null; @@ -596,6 +602,9 @@ public class A4wpService extends Service } else if (mState == BluetoothProfile.STATE_CONNECTED) { Log.v(LOGTAG, "onConnectionStateChange:CONNECTED"); mDevice = device; + /* Initiate a dummy connection such that on stop advertisment + the advetisment instances are cleared properly */ + mBluetoothGattServer.connect(mDevice, false); } } @@ -639,7 +648,7 @@ public class A4wpService extends Service else if(id == A4WP_PRU_STATIC_UUID) { value = mPruStaticParam.getValue(); - mBluetoothGattServer.connect(mDevice, false); + isConnected = true; } else if (id == A4WP_PRU_DYNAMIC_UUID) { if (mPruDynamicParam == null) { @@ -776,9 +785,6 @@ public class A4wpService extends Service mBluetoothGattServer.addService(a4wpService); - //Log.d(LOGTAG, "calling StartAdvertising"); - //StartAdvertising(); - return true; } diff --git a/src/org/codeaurora/bluetooth/dun/BluetoothDunService.java b/src/org/codeaurora/bluetooth/dun/BluetoothDunService.java index 58bba02..92ec785 100644 --- a/src/org/codeaurora/bluetooth/dun/BluetoothDunService.java +++ b/src/org/codeaurora/bluetooth/dun/BluetoothDunService.java @@ -529,7 +529,7 @@ public class BluetoothDunService extends Service { removeTimeoutMsg = false; } - if (removeTimeoutMsg) { + if (removeTimeoutMsg && mDunHandler != null) { mDunHandler.removeMessages(MESSAGE_DUN_USER_TIMEOUT); } } @@ -1264,7 +1264,8 @@ public class BluetoothDunService extends Service { IpcMsgBuffer.putShort(DUN_IPC_MSG_OFF_MSG_LEN,DUN_IPC_CTRL_MSG_SIZE); IpcMsgBuffer.put(DUN_IPC_MSG_OFF_MSG, DUN_CRTL_MSG_DISCONNECT_REQ); try { - mDundOutputStream.write(IpcMsgBuffer.array(), 0, WriteLen); + if (mDundOutputStream != null) + mDundOutputStream.write(IpcMsgBuffer.array(), 0, WriteLen); } catch (IOException ex) { Log.w(TAG, "disconnect: Handled mDundOutputStream write exception: " + ex.toString()); } @@ -1293,7 +1294,8 @@ public class BluetoothDunService extends Service { IpcMsgBuffer.putShort(DUN_IPC_MSG_OFF_MSG_LEN,DUN_IPC_MDM_STATUS_MSG_SIZE); IpcMsgBuffer.put(DUN_IPC_MSG_OFF_MSG, status); try { - mDundOutputStream.write(IpcMsgBuffer.array(), 0, WriteLen); + if (mDundOutputStream != null) + mDundOutputStream.write(IpcMsgBuffer.array(), 0, WriteLen); } catch (IOException ex) { Log.e(TAG, "Handled mDundOutputStream write exception: " + ex.toString()); } diff --git a/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java b/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java index 78a7483..b602eec 100644 --- a/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java +++ b/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java @@ -767,7 +767,7 @@ public class BluetoothFtpObexServer extends ServerRequestHandler { * * Else call the routine to send the requested file names contents */ - if(type.equals(TYPE_LISTING)){ + if(type.equals(TYPE_LISTING)) { if(!validName || ( mCurrentPath!= null && ( mCurrentPath.equals(rootPrimaryStoragePath) || mCurrentPath.equals(rootSecondaryStoragePath)) ) ) { if (D) Log.d(TAG,"Not having a name "); @@ -790,7 +790,7 @@ public class BluetoothFtpObexServer extends ServerRequestHandler { } } else { if (D) Log.d(TAG,"Non Root Folder"); - if(type.equals(TYPE_LISTING)){ + if(type.equals(TYPE_LISTING) && mCurrentPath != null) { File currentfolder = new File(mCurrentPath); if (D) Log.d(TAG,"Current folder name = " + currentfolder.getName() + @@ -876,6 +876,10 @@ public class BluetoothFtpObexServer extends ServerRequestHandler { outputStream = op.openOutputStream(); } catch(IOException e) { Log.e(TAG,"SendFilecontents open stream "+ e.toString()); + if(outputStream != null ) { + closeStream(outputStream, op); + outputStream = null; + } return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR; } finally { if (fileInputStream != null && outputStream == null) { diff --git a/src/org/codeaurora/bluetooth/ftp/BluetoothFtpService.java b/src/org/codeaurora/bluetooth/ftp/BluetoothFtpService.java index 164aa4a..77737aa 100644 --- a/src/org/codeaurora/bluetooth/ftp/BluetoothFtpService.java +++ b/src/org/codeaurora/bluetooth/ftp/BluetoothFtpService.java @@ -83,7 +83,7 @@ public class BluetoothFtpService extends Service { //public static final boolean VERBOSE = false; public static final boolean DEBUG = true; - public static boolean VERBOSE; + public static boolean VERBOSE = true; private int mState; /** @@ -240,16 +240,16 @@ public class BluetoothFtpService extends Service { @Override public void onCreate() { super.onCreate(); - if (VERBOSE) Log.v(TAG, "Ftp Service onCreate"); + Log.v(TAG, "Ftp Service onCreate"); mAdapter = BluetoothAdapter.getDefaultAdapter(); if (!mHasStarted) { int state = mAdapter.getState(); - if (VERBOSE) Log.v(TAG, "FTP service not started Adapter STATE: "+state); + Log.v(TAG, "FTP service not started Adapter STATE: "+state); if (state == BluetoothAdapter.STATE_ON) { - if (VERBOSE) Log.v(TAG, "FTP service start listener"); + Log.v(TAG, "FTP service start listener"); mHasStarted = true; mSessionStatusHandler.sendMessage(mSessionStatusHandler .obtainMessage(MSG_INTERNAL_START_LISTENER)); @@ -259,7 +259,7 @@ public class BluetoothFtpService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { - if (VERBOSE) Log.v(TAG, "Ftp Service onStartCommand"); + Log.v(TAG, "Ftp Service onStartCommand"); int retCode = super.onStartCommand(intent, flags, startId); if (retCode == START_STICKY) { mStartId = startId; @@ -286,13 +286,13 @@ public class BluetoothFtpService extends Service { Log.e(TAG, "Unexpected error! action is null"); return; } - if (VERBOSE) Log.v(TAG, "PARSE INTENT action: " + action); + Log.v(TAG, "PARSE INTENT action: " + action); int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR); boolean removeTimeoutMsg = true; if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { removeTimeoutMsg = false; - Log.d(TAG, "ACTION_STATE_CHANGED: state: " + state + "mHasStarted: " + mHasStarted); + Log.d(TAG, "ACTION_STATE_CHANGED: state: " + state + " mHasStarted: " + mHasStarted); if ((state == BluetoothAdapter.STATE_TURNING_OFF) && (mAdapter != null)) { /** Terminate file copy operation if it is in progress */ FileUtils.interruptFileCopy = true; @@ -306,7 +306,7 @@ public class BluetoothFtpService extends Service { closeService(); } else if (state == BluetoothAdapter.STATE_ON && !mHasStarted ) { - if (VERBOSE) Log.v(TAG, "FTP service start listener"); + Log.v(TAG, "FTP service start listener"); mHasStarted = true; mSessionStatusHandler.sendMessage(mSessionStatusHandler .obtainMessage(MSG_INTERNAL_START_LISTENER)); @@ -314,28 +314,31 @@ public class BluetoothFtpService extends Service { } else if (action.equals(ACCESS_ALLOWED_ACTION)) { if (!isWaitingAuthorization) { // this reply is not for us + Log.v(TAG, "isWaitingAuthorization = " + isWaitingAuthorization); return; } isWaitingAuthorization = false; - if (intent.getBooleanExtra(BluetoothFtpService.EXTRA_ALWAYS_ALLOWED, false)) { - if(mRemoteDevice != null) { - mRemoteDevice.setTrust(true); - Log.v(TAG, "setTrust() TRUE " + mRemoteDevice.getName()); - } + if (intent.getBooleanExtra(BluetoothFtpService.EXTRA_ALWAYS_ALLOWED, false)) { + if(mRemoteDevice != null) { + mRemoteDevice.setTrust(true); + Log.v(TAG, "setTrust() TRUE " + mRemoteDevice.getName()); } - try { - if (mConnSocket != null) { - startObexServerSession(); - } else { - stopObexServerSession(); - } - } catch (IOException ex) { - Log.e(TAG, "Caught the error: " + ex.toString()); + } + try { + if (mConnSocket != null) { + startObexServerSession(); + } else { + stopObexServerSession(); } + } catch (IOException ex) { + Log.e(TAG, "Caught the error: " + ex.toString()); + } removeFtpNotification(NOTIFICATION_ID_ACCESS); } else if (action.equals(ACCESS_DISALLOWED_ACTION)) { + Log.v(TAG, "ACCESS_DISALLOWED_ACTION"); + isWaitingAuthorization = false; stopObexServerSession(); } else if (action.equals(AUTH_RESPONSE_ACTION)) { String sessionkey = intent.getStringExtra(EXTRA_SESSION_KEY); @@ -352,25 +355,24 @@ public class BluetoothFtpService extends Service { if (device != null && device.equals(mRemoteDevice)) { /** Terminate file copy operation if it is in progress */ FileUtils.interruptFileCopy = true; - if (mSessionStatusHandler != null) { - /* Let the user timeout handle this case as well */ - mSessionStatusHandler.sendMessage(mSessionStatusHandler - .obtainMessage(MSG_INTERNAL_USER_TIMEOUT)); - removeTimeoutMsg = false; - } + Intent intent1 = new Intent(USER_CONFIRM_TIMEOUT_ACTION); + sendBroadcast(intent1); + removeFtpNotification(NOTIFICATION_ID_ACCESS); + isWaitingAuthorization = false; + stopObexServerSession(); } } else { removeTimeoutMsg = false; } - if (removeTimeoutMsg) { + if (removeTimeoutMsg && mSessionStatusHandler != null) { mSessionStatusHandler.removeMessages(MSG_INTERNAL_USER_TIMEOUT); } } @Override public void onDestroy() { - if (VERBOSE) Log.v(TAG, "Ftp Service onDestroy"); + Log.v(TAG, "Ftp Service onDestroy"); super.onDestroy(); closeService(); @@ -378,13 +380,13 @@ public class BluetoothFtpService extends Service { @Override public IBinder onBind(Intent intent) { - if (VERBOSE) Log.v(TAG, "Ftp Service onBind"); + Log.v(TAG, "Ftp Service onBind"); return null; } private void startRfcommSocketListener() { VERBOSE = Log.isLoggable(BluetoothFtpService.LOG_TAG, Log.VERBOSE) ? true : false; - if (VERBOSE) Log.v(TAG, "Ftp Service startRfcommSocketListener"); + Log.v(TAG, "Ftp Service startRfcommSocketListener"); if (mRfcommServerSocket == null) { if (!initRfcommSocket()) { @@ -399,7 +401,7 @@ public class BluetoothFtpService extends Service { } } private final boolean initRfcommSocket() { - if (VERBOSE) Log.v(TAG, "Ftp Service initSocket"); + Log.v(TAG, "Ftp Service initSocket"); boolean initSocketOK = false; final int CREATE_RETRY_TIME = 10; @@ -418,7 +420,7 @@ public class BluetoothFtpService extends Service { if (!initSocketOK) { synchronized (this) { try { - if (VERBOSE) Log.v(TAG, "wait 300 ms"); + Log.v(TAG, "wait 300 ms"); Thread.sleep(300); } catch (InterruptedException e) { Log.e(TAG, "socketAcceptThread thread was interrupted (3)"); @@ -431,7 +433,7 @@ public class BluetoothFtpService extends Service { } if (initSocketOK && (mRfcommServerSocket != null) ) { - if (VERBOSE) Log.v(TAG, "Succeed to create listening socket on channel " + PORT_NUM); + Log.v(TAG, "Succeed to create listening socket on channel " + PORT_NUM); } else { Log.e(TAG, "Error to create listening socket after " + CREATE_RETRY_TIME + " try"); @@ -458,7 +460,7 @@ public class BluetoothFtpService extends Service { } } private final void closeService() { - if (VERBOSE) Log.v(TAG, "Ftp Service closeService"); + Log.v(TAG, "Ftp Service closeService"); try { closeRfcommSocket(true, false); @@ -489,12 +491,12 @@ public class BluetoothFtpService extends Service { mHasStarted = false; if (stopSelfResult(mStartId)) { - if (VERBOSE) Log.v(TAG, "successfully stopped ftp service"); + Log.v(TAG, "successfully stopped ftp service"); } } private final void startObexServerSession() throws IOException { - if (VERBOSE) Log.v(TAG, "Ftp Service startObexServerSession"); + Log.v(TAG, "Ftp Service startObexServerSession"); mFtpServer = new BluetoothFtpObexServer(mSessionStatusHandler, this); synchronized (this) { @@ -519,22 +521,32 @@ public class BluetoothFtpService extends Service { } mServerSession = new ServerSession(transport, mFtpServer, mAuth); - if (VERBOSE) { + { Log.v(TAG, "startObexServerSession() success!"); } } private void stopObexServerSession() { - if (VERBOSE) Log.v(TAG, "Ftp Service stopObexServerSession"); + Log.v(TAG, "Ftp Service stopObexServerSession"); if (mServerSession != null) { + Log.v(TAG, "stopObexServerSession, closing mServerSession"); mServerSession.close(); mServerSession = null; } - mRfcommAcceptThread = null; + if (mRfcommAcceptThread != null) { + try { + mRfcommAcceptThread.shutdown(); + mRfcommAcceptThread.join(); + mRfcommAcceptThread = null; + } catch (InterruptedException ex) { + Log.w(TAG, "mAcceptThread close error" + ex); + } + } try { + Log.v(TAG, "stopObexServerSession, closeRfcommSocket"); closeRfcommSocket(false, true); } catch (IOException e) { Log.e(TAG, "closeSocket error: " + e.toString()); @@ -542,6 +554,7 @@ public class BluetoothFtpService extends Service { // Last obex transaction is finished, we start to listen for incoming // connection again if (mAdapter.isEnabled()) { + Log.v(TAG, "stopObexServerSession, startRfcommSocketListener"); startRfcommSocketListener(); } } @@ -579,7 +592,7 @@ public class BluetoothFtpService extends Service { } private void notifyContentResolver(Uri uri) { - if (VERBOSE) Log.v(TAG,"FTP_MEDIA_SCANNED deleting uri "+uri); + Log.v(TAG,"FTP_MEDIA_SCANNED deleting uri "+uri); ContentProviderClient client = getContentResolver() .acquireContentProviderClient(MediaStore.AUTHORITY); if (client == null) { @@ -591,7 +604,7 @@ public class BluetoothFtpService extends Service { } catch(RemoteException e){ Log.e(TAG,e.toString()); } - if (VERBOSE) Log.v(TAG,"FTP_MEDIA_SCANNED deleted uri "+uri); + Log.v(TAG,"FTP_MEDIA_SCANNED deleted uri "+uri); } /** @@ -635,7 +648,7 @@ public class BluetoothFtpService extends Service { if (mRemoteDevice != null) trust = mRemoteDevice.getTrustState(); - if (VERBOSE) Log.v(RTAG, "GetTrustState() = " + trust); + Log.v(RTAG, "GetTrustState() = " + trust); if (trust) { try { @@ -657,8 +670,10 @@ public class BluetoothFtpService extends Service { stopped = true; // job done ,close this thread; } catch (IOException ex) { stopped = true; //IO exception, close the thread - if (VERBOSE) Log.v(RTAG, "Accept exception: " + ex.toString()); + Log.v(RTAG, "Accept exception: " + ex.toString()); } + Log.i(RTAG, "stopped = " + stopped + + " mRfcommServerSocket = " + mRfcommServerSocket); } } @@ -672,7 +687,7 @@ public class BluetoothFtpService extends Service { private final Handler mSessionStatusHandler = new Handler() { @Override public void handleMessage(Message msg) { - if (VERBOSE) Log.v(TAG, "Handler(): got msg=" + msg.what); + Log.v(TAG, "Handler(): got msg=" + msg.what); switch (msg.what) { case MSG_INTERNAL_START_LISTENER: @@ -709,28 +724,28 @@ public class BluetoothFtpService extends Service { case MSG_SESSION_DISCONNECTED: break; case MSG_FILE_RECEIVED: - if (VERBOSE) Log.v(TAG,"MSG_FILE_RECEIVED"); + Log.v(TAG,"MSG_FILE_RECEIVED"); Bundle arguments = (Bundle) msg.obj; notifyMediaScanner(arguments,FTP_MEDIA_ADD); break; case MSG_FILE_DELETED: - if (VERBOSE) Log.v(TAG,"MSG_FILE_DELETED"); + Log.v(TAG,"MSG_FILE_DELETED"); Bundle delarguments = (Bundle) msg.obj; notifyMediaScanner(delarguments,FTP_MEDIA_DELETE); break; case MSG_FILES_DELETED: - if (VERBOSE) Log.v(TAG,"MSG_FILES_DELETED"); + Log.v(TAG,"MSG_FILES_DELETED"); Bundle delfilesarguments = (Bundle) msg.obj; notifyMediaScanner(delfilesarguments,FTP_MEDIA_FILES_DELETE); break; case MSG_FILES_RECEIVED: - if (VERBOSE) Log.v(TAG,"MSG_FILES_RECEIVED"); + Log.v(TAG,"MSG_FILES_RECEIVED"); Bundle newfilearguments = (Bundle) msg.obj; notifyMediaScanner(newfilearguments,FTP_MEDIA_FILES_ADD); break; case FTP_MEDIA_SCANNED: - if (VERBOSE) Log.v(TAG,"FTP_MEDIA_SCANNED arg1 "+msg.arg1); + Log.v(TAG,"FTP_MEDIA_SCANNED arg1 "+msg.arg1); Uri uri = (Uri)msg.obj; /* If the media scan was for a * Deleted file Delete the entry @@ -741,7 +756,7 @@ public class BluetoothFtpService extends Service { } break; case MSG_INTERNAL_OBEX_RFCOMM_SESSION_UP: - if (VERBOSE) Log.v(TAG,"MSG_INTERNAL_OBEX_RFCOMM_SESSION_UP"); + Log.v(TAG,"MSG_INTERNAL_OBEX_RFCOMM_SESSION_UP"); /*Avoid RfcommServer socket close to avoid SDP *re-registration for every FTP connection request */ @@ -757,7 +772,7 @@ public class BluetoothFtpService extends Service { } }; private Notification createFtpConnectedNotification() { - if (VERBOSE) Log.v(TAG, "Creating FTP access CONNECTED"); + Log.v(TAG, "Creating FTP access CONNECTED"); Notification notification = new Notification(android.R.drawable.stat_sys_data_bluetooth, getString(R.string.ftp_notif_active_session), System.currentTimeMillis()); @@ -847,7 +862,7 @@ public class BluetoothFtpService extends Service { mContext = context; mCallback = handler; mOp = op; - if (VERBOSE) Log.v(TAG, "FTP MediaScannerConnection FtpMediaScannerNotifier mFilename =" + Log.v(TAG, "FTP MediaScannerConnection FtpMediaScannerNotifier mFilename =" + filename + " mMimetype = " + mimetype +"operation " + mOp); List<String> filenames = new ArrayList<String>(); List<String> types = new ArrayList<String>(); @@ -864,19 +879,19 @@ public class BluetoothFtpService extends Service { mContext = context; mCallback = handler; mOp = op; - if (VERBOSE) Log.v(TAG, "FtpMediaScannerNotifier scan for multiple files " + + Log.v(TAG, "FtpMediaScannerNotifier scan for multiple files " + filenames.length +" " +mimetypes.length ); MediaScannerConnection.scanFile(context,filenames,mimetypes, this); } public void onMediaScannerConnected() { - if (VERBOSE) Log.v(TAG, "FTP MediaScannerConnection onMediaScannerConnected"); + Log.v(TAG, "FTP MediaScannerConnection onMediaScannerConnected"); } public void onScanCompleted(String path, Uri uri) { try { - if (VERBOSE) { + { Log.v(TAG, "FTP MediaScannerConnection onScanCompleted"); Log.v(TAG, "FTP MediaScannerConnection path is " + path); Log.v(TAG, "FTP MediaScannerConnection Uri is " + uri); @@ -899,7 +914,7 @@ public class BluetoothFtpService extends Service { } catch (Exception ex) { Log.e(TAG, "FTP !!!MediaScannerConnection exception: " + ex); } finally { - if (VERBOSE) Log.v(TAG, "FTP MediaScannerConnection disconnect"); + Log.v(TAG, "FTP MediaScannerConnection disconnect"); } } }; diff --git a/src/org/codeaurora/bluetooth/ftp/FileUtils.java b/src/org/codeaurora/bluetooth/ftp/FileUtils.java index 03b5b31..fb598d2 100644 --- a/src/org/codeaurora/bluetooth/ftp/FileUtils.java +++ b/src/org/codeaurora/bluetooth/ftp/FileUtils.java @@ -159,9 +159,6 @@ public class FileUtils { } catch(FileNotFoundException e) { Log.e(TAG,"copyFile file not found "+ e.toString()); return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR; - } catch(IOException e) { - Log.e(TAG,"copyFile open stream failed "+ e.toString()); - return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR; } finally { if (null != reader && null == writer) { try { diff --git a/src/org/codeaurora/bluetooth/sap/BluetoothSapService.java b/src/org/codeaurora/bluetooth/sap/BluetoothSapService.java index 70697b3..cd90fad 100644 --- a/src/org/codeaurora/bluetooth/sap/BluetoothSapService.java +++ b/src/org/codeaurora/bluetooth/sap/BluetoothSapService.java @@ -1017,6 +1017,7 @@ public class BluetoothSapService extends Service { /* Read the SAP request from Rfcomm channel */ NumRead = mRfcommInputStream.read(IpcMsgBuffer.array(), SAP_IPC_MSG_OFF_MSG + TotalRead, SAP_MAX_MSG_LEN - TotalRead); + if (VERBOSE) Log.v(TAG, "NumRead from rfcomm = " + NumRead); if ( NumRead < 0) { break; } @@ -1134,7 +1135,7 @@ public class BluetoothSapService extends Service { if (VERBOSE) Log.v(TAG, "Reading the SAP responses from Sapd"); /* Read the SAP responses from SAP server */ NumRead = mSapdInputStream.read(IpcMsgBuffer.array(),0, SAP_MAX_IPC_MSG_LEN); - if (VERBOSE) Log.v(TAG, "NumRead" + NumRead); + if (VERBOSE) Log.v(TAG, "NumRead from sapd = " + NumRead); if ( NumRead < 0) { break; } @@ -1153,12 +1154,14 @@ public class BluetoothSapService extends Service { try { mRfcommOutputStream.write(IpcMsgBuffer.array(), ReadIndex + SAP_IPC_MSG_OFF_MSG, IpcMsgBuffer.getShort(ReadIndex + SAP_IPC_MSG_OFF_MSG_LEN)); + mRfcommOutputStream.flush(); } catch (IOException ex) { stopped = true; break; } if (VERBOSE) - Log.v(TAG, "DownlinkThread Msg written to Rfcomm"); + Log.v(TAG, "Length of DownlinkThread Msg written to Rfcomm" + + IpcMsgBuffer.getShort(ReadIndex + SAP_IPC_MSG_OFF_MSG_LEN)); } else if (IpcMsgBuffer.get(ReadIndex + SAP_IPC_MSG_OFF_MSG_TYPE) == SAP_IPC_MSG_CTRL_RESPONSE) { @@ -1290,7 +1293,10 @@ public class BluetoothSapService extends Service { IpcMsgBuffer.put(SAP_HEADER_SIZE + SAP_MSG_OFF_PARAM_VAL, CONN_ERR); try { - mRfcommOutputStream.write(IpcMsgBuffer.array(), 0, WriteLen); + if (mRfcommOutputStream != null) { + mRfcommOutputStream.write(IpcMsgBuffer.array(), 0, WriteLen); + mRfcommOutputStream.flush(); + } } catch (IOException ex) { if (VERBOSE) Log.v(TAG, "mRfcommOutputStream wrtie exception: " + ex.toString()); } |