summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/bluetooth/a2dp/A2dpSinkStateMachine.java2
-rwxr-xr-xsrc/com/android/bluetooth/btservice/AdapterService.java2
-rw-r--r--src/com/android/bluetooth/btservice/BondStateMachine.java10
-rw-r--r--src/com/android/bluetooth/btservice/RemoteDevices.java2
-rw-r--r--src/com/android/bluetooth/hdp/HealthService.java36
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java6
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java9
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppProvider.java10
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java2
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java2
-rw-r--r--src/com/android/bluetooth/opp/BluetoothShare.java7
11 files changed, 68 insertions, 20 deletions
diff --git a/src/com/android/bluetooth/a2dp/A2dpSinkStateMachine.java b/src/com/android/bluetooth/a2dp/A2dpSinkStateMachine.java
index 2f1f3d9cc..13c4ade46 100644
--- a/src/com/android/bluetooth/a2dp/A2dpSinkStateMachine.java
+++ b/src/com/android/bluetooth/a2dp/A2dpSinkStateMachine.java
@@ -619,7 +619,7 @@ final class A2dpSinkStateMachine extends StateMachine {
mPlayingDevice = null;
broadcastAudioState(device, BluetoothA2dpSink.STATE_NOT_PLAYING,
BluetoothA2dpSink.STATE_PLAYING);
- if ((mAudioFocusAcquired == AUDIO_FOCUS_LOSS_TRANSIENT) ||
+ if ((mAudioFocusAcquired == AUDIO_FOCUS_LOSS_TRANSIENT) &&
(state == AUDIO_STATE_REMOTE_SUSPEND)) {
log(" Dont't Loose audiofocus in case of suspend ");
break;
diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java
index 8a303fc0e..524d16a74 100755
--- a/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/src/com/android/bluetooth/btservice/AdapterService.java
@@ -1595,9 +1595,9 @@ public class AdapterService extends Service {
void setProfileAutoConnectionPriority (BluetoothDevice device, int profileId){
if (profileId == BluetoothProfile.HEADSET) {
HeadsetService hsService = HeadsetService.getHeadsetService();
- List<BluetoothDevice> deviceList = hsService.getConnectedDevices();
if ((hsService != null) &&
(BluetoothProfile.PRIORITY_AUTO_CONNECT != hsService.getPriority(device))){
+ List<BluetoothDevice> deviceList = hsService.getConnectedDevices();
adjustOtherHeadsetPriorities(hsService, deviceList);
hsService.setPriority(device,BluetoothProfile.PRIORITY_AUTO_CONNECT);
}
diff --git a/src/com/android/bluetooth/btservice/BondStateMachine.java b/src/com/android/bluetooth/btservice/BondStateMachine.java
index 3b82b18b2..68590e7b6 100644
--- a/src/com/android/bluetooth/btservice/BondStateMachine.java
+++ b/src/com/android/bluetooth/btservice/BondStateMachine.java
@@ -229,11 +229,21 @@ final class BondStateMachine extends StateMachine {
case SSP_REQUEST:
int passkey = msg.arg1;
int variant = msg.arg2;
+ if(devProp == null)
+ {
+ Log.e(TAG,"Received msg from an unknown device");
+ return false;
+ }
sendDisplayPinIntent(devProp.getAddress(), passkey, variant);
break;
case PIN_REQUEST:
BluetoothClass btClass = dev.getBluetoothClass();
int btDeviceClass = btClass.getDeviceClass();
+ if(devProp == null)
+ {
+ Log.e(TAG,"Received msg from an unknown device");
+ return false;
+ }
if (btDeviceClass == BluetoothClass.Device.PERIPHERAL_KEYBOARD ||
btDeviceClass == BluetoothClass.Device.PERIPHERAL_KEYBOARD_POINTING) {
// Its a keyboard. Follow the HID spec recommendation of creating the
diff --git a/src/com/android/bluetooth/btservice/RemoteDevices.java b/src/com/android/bluetooth/btservice/RemoteDevices.java
index b6c94890e..7ec817054 100644
--- a/src/com/android/bluetooth/btservice/RemoteDevices.java
+++ b/src/com/android/bluetooth/btservice/RemoteDevices.java
@@ -351,7 +351,7 @@ final class RemoteDevices {
device = getDeviceProperties(bdDevice);
}
- for (int j = 0; j < types.length; j++) {
+ for (int j = 0; j < types.length && device != null; j++) {
type = types[j];
val = values[j];
if(val.length <= 0)
diff --git a/src/com/android/bluetooth/hdp/HealthService.java b/src/com/android/bluetooth/hdp/HealthService.java
index 21846c677..01e3f4121 100644
--- a/src/com/android/bluetooth/hdp/HealthService.java
+++ b/src/com/android/bluetooth/hdp/HealthService.java
@@ -189,7 +189,12 @@ public class HealthService extends ProfileService {
{
BluetoothHealthAppConfiguration appConfig =
(BluetoothHealthAppConfiguration) msg.obj;
- int appId = (mApps.get(appConfig)).mAppId;
+ AppInfo appInfo = mApps.get(appConfig);
+ if (appInfo == null) {
+ Log.e(TAG, "No AppInfo found for AppConfig: " + appConfig);
+ break;
+ }
+ int appId = appInfo.mAppId;
if (!unregisterHealthAppNative(appId)) {
Log.e(TAG, "Failed to unregister application: id: " + appId);
callStatusCallback(appConfig,
@@ -201,7 +206,12 @@ public class HealthService extends ProfileService {
{
HealthChannel chan = (HealthChannel) msg.obj;
byte[] devAddr = Utils.getByteAddress(chan.mDevice);
- int appId = (mApps.get(chan.mConfig)).mAppId;
+ AppInfo appInfo = mApps.get(chan.mConfig);
+ if (appInfo == null) {
+ Log.e(TAG, "No AppInfo found for AppConfig: " + chan.mConfig);
+ break;
+ }
+ int appId = appInfo.mAppId;
chan.mChannelId = connectChannelNative(devAddr, appId);
if (chan.mChannelId == -1) {
callHealthChannelCallback(chan.mConfig, chan.mDevice,
@@ -241,6 +251,10 @@ public class HealthService extends ProfileService {
regStatus == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS) {
//unlink to death once app is unregistered
AppInfo appInfo = mApps.get(appConfig);
+ if (appInfo == null){
+ Log.e(TAG, "No AppInfo found for AppConfig " + appConfig);
+ break;
+ }
appInfo.cleanup();
mApps.remove(appConfig);
}
@@ -254,7 +268,7 @@ public class HealthService extends ProfileService {
findAppConfigByAppId(channelStateEvent.mAppId);
int newState;
newState = convertHalChannelState(channelStateEvent.mState);
- if (newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED &&
+ if (newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED ||
appConfig == null) {
Log.e(TAG,"Disconnected for non existing app");
break;
@@ -512,9 +526,15 @@ public class HealthService extends ProfileService {
private void callStatusCallback(BluetoothHealthAppConfiguration config, int status) {
if (VDBG) log ("Health Device Application: " + config + " State Change: status:" + status);
- IBluetoothHealthCallback callback = (mApps.get(config)).mCallback;
+ AppInfo appInfo = mApps.get(config);
+ if (appInfo == null) {
+ Log.e(TAG, " No AppInfo found for AppConfig " + config);
+ return;
+ }
+ IBluetoothHealthCallback callback = appInfo.mCallback;
if (callback == null) {
Log.e(TAG, "Callback object null");
+ return;
}
try {
@@ -604,8 +624,12 @@ public class HealthService extends ProfileService {
Log.e(TAG, "Exception while duping: " + e);
}
}
-
- IBluetoothHealthCallback callback = (mApps.get(config)).mCallback;
+ AppInfo appInfo = mApps.get(config);
+ if (appInfo == null) {
+ Log.e(TAG, "No AppInfo found for AppConfig " + config);
+ return;
+ }
+ IBluetoothHealthCallback callback = appInfo.mCallback;
if (callback == null) {
Log.e(TAG, "No callback found for config: " + config);
return;
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
index 6ec315ed9..159bb097e 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
@@ -667,8 +667,10 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
} else if (!mInterrupted && position == fileInfo.mLength) {
long endTime = System.currentTimeMillis();
Log.i(TAG, "SendFile finished sending file " + fileInfo.mFileName
- + " length " + fileInfo.mLength
- + "Bytes in " + (endTime - beginTime) + "ms" );
+ + " length " + fileInfo.mLength + " Bytes. Approx. throughput is "
+ + BluetoothShare.throughputInKbps(fileInfo.mLength,
+ (endTime - beginTime))
+ + " Kbps");
status = BluetoothShare.STATUS_SUCCESS;
outputStream.close();
} else {
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java
index a12782818..c7876409e 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java
@@ -384,9 +384,7 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen
values.put(BluetoothShare.FILENAME_HINT, name);
- if (length != null) {
- values.put(BluetoothShare.TOTAL_BYTES, length.intValue());
- }
+ values.put(BluetoothShare.TOTAL_BYTES, length);
values.put(BluetoothShare.MIMETYPE, mimeType);
@@ -664,8 +662,9 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen
if (position == fileInfo.mLength) {
long endTime = System.currentTimeMillis();
Log.i(TAG, "Receiving file completed for " + fileInfo.mFileName
- + " length " + fileInfo.mLength
- + " Bytes in " + (endTime - beginTime) + "ms" );
+ + " length " + fileInfo.mLength + " Bytes. Approx. throughput is "
+ + BluetoothShare.throughputInKbps(fileInfo.mLength, (endTime - beginTime))
+ + " Kbps");
status = BluetoothShare.STATUS_SUCCESS;
} else {
Log.i(TAG, "Reading file failed at " + position + " of " + fileInfo.mLength);
diff --git a/src/com/android/bluetooth/opp/BluetoothOppProvider.java b/src/com/android/bluetooth/opp/BluetoothOppProvider.java
index 132b950df..a3f3ef30f 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppProvider.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppProvider.java
@@ -228,6 +228,13 @@ public final class BluetoothOppProvider extends ContentProvider {
}
}
+ private static final void copyLong(String key, ContentValues from, ContentValues to) {
+ Long i = from.getAsLong(key);
+ if (i != null) {
+ to.put(key, i);
+ }
+ }
+
@Override
public Uri insert(Uri uri, ContentValues values) {
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
@@ -245,8 +252,7 @@ public final class BluetoothOppProvider extends ContentProvider {
copyString(BluetoothShare.DESTINATION, values, filteredValues);
copyInteger(BluetoothShare.VISIBILITY, values, filteredValues);
- copyInteger(BluetoothShare.TOTAL_BYTES, values, filteredValues);
-
+ copyLong(BluetoothShare.TOTAL_BYTES, values, filteredValues);
if (values.getAsInteger(BluetoothShare.VISIBILITY) == null) {
filteredValues.put(BluetoothShare.VISIBILITY, BluetoothShare.VISIBILITY_VISIBLE);
}
diff --git a/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java b/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java
index 4bd9c21fd..327261add 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java
@@ -113,7 +113,7 @@ public class BluetoothOppReceiveFileInfo {
try {
if (metadataCursor.moveToFirst()) {
hint = metadataCursor.getString(0);
- length = metadataCursor.getInt(1);
+ length = metadataCursor.getLong(1);
mimeType = metadataCursor.getString(2);
}
} finally {
diff --git a/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java b/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java
index f060a04e6..3901e7a31 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java
@@ -127,7 +127,7 @@ public class BluetoothOppSendFileInfo {
try {
if (metadataCursor.moveToFirst()) {
fileName = metadataCursor.getString(0);
- length = metadataCursor.getInt(1);
+ length = metadataCursor.getLong(1);
if (D) Log.d(TAG, "fileName = " + fileName + " length = " + length);
}
} finally {
diff --git a/src/com/android/bluetooth/opp/BluetoothShare.java b/src/com/android/bluetooth/opp/BluetoothShare.java
index ffec3c084..3242e7e34 100644
--- a/src/com/android/bluetooth/opp/BluetoothShare.java
+++ b/src/com/android/bluetooth/opp/BluetoothShare.java
@@ -426,4 +426,11 @@ public final class BluetoothShare implements BaseColumns {
*/
public static final int UI_UPDATE_INTERVAL = 1000;
+ /**
+ * Returns the throughput of the file transfer
+ */
+ public static float throughputInKbps(long fileSize, long timeDuration) {
+ float throughput = (float)(fileSize * 8 * 1000) / (timeDuration * 1024);
+ return throughput;
+ }
}