summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bttestapp/src/org/codeaurora/bluetooth/bttestapp/PbapTestActivity.java78
-rw-r--r--src/org/codeaurora/bluetooth/a4wp/A4wpService.java17
-rw-r--r--src/org/codeaurora/bluetooth/sap/BluetoothSapService.java9
3 files changed, 70 insertions, 34 deletions
diff --git a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/PbapTestActivity.java b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/PbapTestActivity.java
index e0208df..bf51c28 100644
--- a/bttestapp/src/org/codeaurora/bluetooth/bttestapp/PbapTestActivity.java
+++ b/bttestapp/src/org/codeaurora/bluetooth/bttestapp/PbapTestActivity.java
@@ -183,7 +183,9 @@ public class PbapTestActivity extends MonkeyActivity implements IBluetoothConnec
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
BluetoothPbapCard pbacpCard = (BluetoothPbapCard) parent.getAdapter().getItem(position);
- mProfileService.getPbapClient().pullVcardEntry(pbacpCard.handle);
+ if ((mProfileService != null) && (mProfileService.getPbapClient() != null)) {
+ mProfileService.getPbapClient().pullVcardEntry(pbacpCard.handle);
+ }
}
};
@@ -432,9 +434,13 @@ public class PbapTestActivity extends MonkeyActivity implements IBluetoothConnec
* Going to call abort if any pending request is ongoing,
* checks for the same are handled internally
*/
- mProfileService.getPbapClient().abort();
- super.onPause();
- Logger.v(TAG, "onPause()");
+ if ((mProfileService != null) && (mProfileService.getPbapClient() != null)) {
+ mProfileService.getPbapClient().abort();
+ super.onPause();
+ Logger.v(TAG, "onPause()");
+ } else {
+ Logger.e(TAG, "Not able to ABORT");
+ }
}
@Override
@@ -449,10 +455,12 @@ public class PbapTestActivity extends MonkeyActivity implements IBluetoothConnec
return false;
}
- if (mProfileService.getPbapClient().getState() != BluetoothPbapClient.ConnectionState.DISCONNECTED) {
- menu.findItem(R.id.menu_pbap_disconnect).setVisible(true);
- } else {
- menu.findItem(R.id.menu_pbap_connect).setVisible(true);
+ if (mProfileService.getPbapClient() != null) {
+ if (mProfileService.getPbapClient().getState() != BluetoothPbapClient.ConnectionState.DISCONNECTED) {
+ menu.findItem(R.id.menu_pbap_disconnect).setVisible(true);
+ } else {
+ menu.findItem(R.id.menu_pbap_connect).setVisible(true);
+ }
}
return true;
@@ -462,10 +470,12 @@ public class PbapTestActivity extends MonkeyActivity implements IBluetoothConnec
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_pbap_connect:
- mProfileService.getPbapClient().connect();
+ if ((mProfileService != null) && (mProfileService.getPbapClient() != null))
+ mProfileService.getPbapClient().connect();
break;
case R.id.menu_pbap_disconnect:
- mProfileService.getPbapClient().disconnect();
+ if ((mProfileService != null) && (mProfileService.getPbapClient() != null))
+ mProfileService.getPbapClient().disconnect();
break;
default:
Logger.w(TAG, "Unknown item selected.");
@@ -753,12 +763,13 @@ public class PbapTestActivity extends MonkeyActivity implements IBluetoothConnec
mEditTextDownloadOffsetValue.setText(String.valueOf(mDownloadValueOffset));
try {
- if (mProfileService.getPbapClient().pullPhoneBook(
- mDownloadSpinner.getSelectedItem().toString(), mDownloadValueFilter,
- mDownloadValueCardType, mDownloadValueMaxCount, mDownloadValueOffset)) {
- startProgressBarDownload();
+ if ((mProfileService != null) && (mProfileService.getPbapClient() != null)) {
+ if (mProfileService.getPbapClient().pullPhoneBook(
+ mDownloadSpinner.getSelectedItem().toString(), mDownloadValueFilter,
+ mDownloadValueCardType, mDownloadValueMaxCount, mDownloadValueOffset))
+ startProgressBarDownload();
} else {
- Toast.makeText(this, "PullPhoneBook FAILED", Toast.LENGTH_LONG).show();
+ Toast.makeText(this, "PullPhoneBook FAILED", Toast.LENGTH_LONG).show();
}
} catch (IllegalArgumentException e) {
Toast.makeText(this,
@@ -808,15 +819,16 @@ public class PbapTestActivity extends MonkeyActivity implements IBluetoothConnec
mEditTextBrowseOffsetValue.setText(String.valueOf(mBrowseValueOffset));
try {
- boolean started;
-
- if (searchValue != "" && !searchValue.isEmpty()) {
- started = mProfileService.getPbapClient().pullVcardListing(null, order,
+ boolean started = false;
+ if ((mProfileService != null) && (mProfileService.getPbapClient() != null)) {
+ if (searchValue != "" && !searchValue.isEmpty()) {
+ started = mProfileService.getPbapClient().pullVcardListing(null, order,
mBrowseValueSearchAttr, searchValue, mBrowseValueMaxCount,
mBrowseValueOffset);
- } else {
- started = mProfileService.getPbapClient().pullVcardListing(null, order,
+ } else {
+ started = mProfileService.getPbapClient().pullVcardListing(null, order,
mBrowseValueMaxCount, mBrowseValueOffset);
+ }
}
if (started) {
@@ -928,12 +940,16 @@ public class PbapTestActivity extends MonkeyActivity implements IBluetoothConnec
}
public void onClick_download_getsize(View v) {
- mProfileService.getPbapClient().pullPhoneBookSize(
+ if ((mProfileService != null) && (mProfileService.getPbapClient() != null)) {
+ mProfileService.getPbapClient().pullPhoneBookSize(
mDownloadSpinner.getSelectedItem().toString());
+ }
}
public void onClick_browse_getsize(View v) {
- mProfileService.getPbapClient().pullVcardListingSize("");
+ if ((mProfileService != null) && (mProfileService.getPbapClient() != null)) {
+ mProfileService.getPbapClient().pullVcardListingSize("");
+ }
}
public void onClickVcardFilterAttributes(View v) {
@@ -969,8 +985,10 @@ public class PbapTestActivity extends MonkeyActivity implements IBluetoothConnec
mEditTextHandleValue.setText(mVcardHandleValue);
}
- mProfileService.getPbapClient().pullVcardEntry(mVcardHandleValue, mVcardValueFilter,
+ if ((mProfileService != null) && (mProfileService.getPbapClient() != null)) {
+ mProfileService.getPbapClient().pullVcardEntry(mVcardHandleValue, mVcardValueFilter,
mVcardValueCardType);
+ }
}
private void setPhonebook(String dst) {
@@ -978,11 +996,15 @@ public class PbapTestActivity extends MonkeyActivity implements IBluetoothConnec
mSetPathQueue = new ArrayDeque<String>(Arrays.asList(dst.split("/")));
- mProfileService.getPbapClient().setPhoneBookFolderRoot();
+ if ((mProfileService != null) && (mProfileService.getPbapClient() != null)) {
+ mProfileService.getPbapClient().setPhoneBookFolderRoot();
+ }
}
private void setPhonebookFolder(String folder) {
- mProfileService.getPbapClient().setPhoneBookFolderDown(folder);
+ if ((mProfileService != null) && (mProfileService.getPbapClient() != null)) {
+ mProfileService.getPbapClient().setPhoneBookFolderDown(folder);
+ }
}
public void onClick_abort(View v) {
@@ -990,6 +1012,8 @@ public class PbapTestActivity extends MonkeyActivity implements IBluetoothConnec
* Going to call abort if any pending request is ongoing,
* checks for the same are handled internally
*/
- mProfileService.getPbapClient().abort();
+ if ((mProfileService != null) && (mProfileService.getPbapClient() != null)) {
+ mProfileService.getPbapClient().abort();
+ }
}
}
diff --git a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java
index 9e88249..7e9b7bb 100644
--- a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java
+++ b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java
@@ -107,6 +107,9 @@ 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;
+
//PRU Write param length for validation
private static final byte A4WP_PTU_STATIC_LENGTH = 0x11;
private static final byte A4WP_PRU_CTRL_LENGTH = 0x05;
@@ -439,9 +442,12 @@ public class A4wpService extends Service
mWipowerManager.startCharging();
mWipowerManager.enableAlertNotification(false);
mWipowerManager.enableDataNotification(true);
+ stopAdvertising();
isConnected = true;
} else {
Log.v(LOGTAG, "do Disable PruOutPut");
+ mWipowerManager.stopCharging();
+ mWipowerManager.enableDataNotification(false);
return status;
}
@@ -576,7 +582,6 @@ public class A4wpService extends Service
mState = newState;
if (mState == BluetoothProfile.STATE_DISCONNECTED && isConnected == true) {
Log.v(LOGTAG, "onConnectionStateChange:DISCONNECTED " + device + "charge complete " + mChargeComplete);
- stopAdvertising();
isConnected = false;
if (mDevice != null && mWipowerManager != null) {
mWipowerManager.enableDataNotification(false);
@@ -588,7 +593,7 @@ public class A4wpService extends Service
}
mDevice = null;
}
- } else {
+ } else if (mState == BluetoothProfile.STATE_CONNECTED) {
Log.v(LOGTAG, "onConnectionStateChange:CONNECTED");
mDevice = device;
}
@@ -634,6 +639,7 @@ public class A4wpService extends Service
else if(id == A4WP_PRU_STATIC_UUID)
{
value = mPruStaticParam.getValue();
+ mBluetoothGattServer.connect(mDevice, false);
}
else if (id == A4WP_PRU_DYNAMIC_UUID) {
if (mPruDynamicParam == null) {
@@ -704,7 +710,8 @@ public class A4wpService extends Service
mAdvertiseSettings = new AdvertiseSettings.Builder()
.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_POWER)
.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_ULTRA_LOW)
- .setConnectable(true).build();
+ .setConnectable(true)
+ .setTimeout(WIPOWER_ADV_TIMEOUT).build();
Log.d(LOGTAG, " Calling mAdvertiser.startAdvertising");
if(mAdvertiser != null)
@@ -716,7 +723,9 @@ public class A4wpService extends Service
private void stopAdvertising()
{
/* to be completed */
- mAdvertiser.stopAdvertising(mAdvertiseCallback);
+ if (mAdvertiseCallback != null && mAdvertiser != null) {
+ mAdvertiser.stopAdvertising(mAdvertiseCallback);
+ }
}
private boolean startServer() {
diff --git a/src/org/codeaurora/bluetooth/sap/BluetoothSapService.java b/src/org/codeaurora/bluetooth/sap/BluetoothSapService.java
index 4cb378d..70697b3 100644
--- a/src/org/codeaurora/bluetooth/sap/BluetoothSapService.java
+++ b/src/org/codeaurora/bluetooth/sap/BluetoothSapService.java
@@ -542,7 +542,8 @@ public class BluetoothSapService extends Service {
}
if (removeTimeoutMsg) {
- mSapHandler.removeMessages(MESSAGE_SAP_USER_TIMEOUT);
+ if (mSapHandler != null)
+ mSapHandler.removeMessages(MESSAGE_SAP_USER_TIMEOUT);
}
}
@@ -1226,7 +1227,8 @@ public class BluetoothSapService extends Service {
IpcMsgBuffer.putShort(SAP_IPC_MSG_OFF_MSG_LEN,SAP_IPC_CTRL_MSG_SIZE);
IpcMsgBuffer.put(SAP_IPC_MSG_OFF_MSG, SAP_CRTL_MSG_DISCONNECT_REQ);
try {
- mSapdOutputStream.write(IpcMsgBuffer.array(), 0, WriteLen);
+ if (mSapdOutputStream != null)
+ mSapdOutputStream.write(IpcMsgBuffer.array(), 0, WriteLen);
} catch (IOException ex) {
if (VERBOSE) Log.v(TAG, "mSapdOutputStream wrtie exception: " + ex.toString());
}
@@ -1254,7 +1256,8 @@ public class BluetoothSapService extends Service {
IpcMsgBuffer.putShort(SAP_IPC_MSG_OFF_MSG_LEN,SAP_IPC_CTRL_MSG_SIZE);
IpcMsgBuffer.put(SAP_IPC_MSG_OFF_MSG, SAP_CRTL_MSG_DISCONNECT_REQ_IMM);
try {
- mSapdOutputStream.write(IpcMsgBuffer.array(), 0, WriteLen);
+ if (mSapdOutputStream != null)
+ mSapdOutputStream.write(IpcMsgBuffer.array(), 0, WriteLen);
} catch (IOException ex) {
if (VERBOSE) Log.v(TAG, "mSapdOutputStream wrtie exception: " + ex.toString());
}