summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2015-04-04 14:41:52 -0400
committerSteve Kondik <steve@cyngn.com>2015-04-04 14:41:52 -0400
commit785152b1aaef67e1ac913457c1e3c2d534bff20a (patch)
tree9d022bcd58e9d96c9b00a4463cfae852584109e3
parentd9238c1d172789e62265620fbb1bd3a74d833019 (diff)
parentf55ccbae89122bfa5d5c28f6a288d20861c7f2b0 (diff)
downloadandroid_packages_apps_Bluetooth-785152b1aaef67e1ac913457c1e3c2d534bff20a.tar.gz
android_packages_apps_Bluetooth-785152b1aaef67e1ac913457c1e3c2d534bff20a.tar.bz2
android_packages_apps_Bluetooth-785152b1aaef67e1ac913457c1e3c2d534bff20a.zip
Merge branch 'LA.BF64.1.2.1_rb2.6' of git://codeaurora.org/platform/packages/apps/Bluetooth into cm-12.1
-rw-r--r--src/com/android/bluetooth/avrcp/Avrcp.java2
-rw-r--r--src/com/android/bluetooth/btservice/AdapterState.java1
-rw-r--r--src/com/android/bluetooth/gatt/GattService.java20
-rwxr-xr-x[-rw-r--r--]src/com/android/bluetooth/map/BluetoothMapbMessage.java1
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppManager.java2
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppNotification.java21
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java14
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppService.java16
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppTransfer.java7
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppTransport.java15
10 files changed, 81 insertions, 18 deletions
diff --git a/src/com/android/bluetooth/avrcp/Avrcp.java b/src/com/android/bluetooth/avrcp/Avrcp.java
index 4917e711b..cdf26f92b 100644
--- a/src/com/android/bluetooth/avrcp/Avrcp.java
+++ b/src/com/android/bluetooth/avrcp/Avrcp.java
@@ -2971,7 +2971,7 @@ public final class Avrcp {
while (rccIterator.hasNext()) {
final MediaPlayerInfo di = rccIterator.next();
if (di.GetPlayerFocus()) {
- if (!di.IsRemoteAddressable()) {
+ if (!di.IsRemoteAddressable() || mCurrentPath.equals(PATH_INVALID)) {
getFolderItemsRspNative((byte)INTERNAL_ERROR, numItems, itemType,
uid, type, playable, displayName, numAtt, attValues, attIds);
Log.e(TAG, "GetFolderItems fails: addressed player is not browsable");
diff --git a/src/com/android/bluetooth/btservice/AdapterState.java b/src/com/android/bluetooth/btservice/AdapterState.java
index 419300ac3..3469068c4 100644
--- a/src/com/android/bluetooth/btservice/AdapterState.java
+++ b/src/com/android/bluetooth/btservice/AdapterState.java
@@ -333,6 +333,7 @@ final class AdapterState extends StateMachine {
adapterService.ssrcleanupNative(false);
mPendingCommandState.setTurningOn(false);
transitionTo(mOffState);
+ adapterService.stopProfileServices();
notifyAdapterStateChange(BluetoothAdapter.STATE_OFF);
break;
case STOP_TIMEOUT:
diff --git a/src/com/android/bluetooth/gatt/GattService.java b/src/com/android/bluetooth/gatt/GattService.java
index 3aa5b8067..307a87887 100644
--- a/src/com/android/bluetooth/gatt/GattService.java
+++ b/src/com/android/bluetooth/gatt/GattService.java
@@ -208,16 +208,28 @@ public class GattService extends ProfileService {
mServiceDeclarations.clear();
mActiveServiceDeclarations.clear();
mReliableQueue.clear();
- if (mAdvertiseManager != null) mAdvertiseManager.cleanup();
- if (mScanManager != null) mScanManager.cleanup();
+ if (mAdvertiseManager != null) {
+ mAdvertiseManager.cleanup();
+ mAdvertiseManager = null;
+ }
+ if (mScanManager != null) {
+ mScanManager.cleanup();
+ mScanManager = null;
+ }
return true;
}
protected boolean cleanup() {
if (DBG) Log.d(TAG, "cleanup()");
cleanupNative();
- if (mAdvertiseManager != null) mAdvertiseManager.cleanup();
- if (mScanManager != null) mScanManager.cleanup();
+ if (mAdvertiseManager != null) {
+ mAdvertiseManager.cleanup();
+ mAdvertiseManager = null;
+ }
+ if (mScanManager != null) {
+ mScanManager.cleanup();
+ mScanManager = null;
+ }
return true;
}
diff --git a/src/com/android/bluetooth/map/BluetoothMapbMessage.java b/src/com/android/bluetooth/map/BluetoothMapbMessage.java
index 21d96f13d..7d4d586c4 100644..100755
--- a/src/com/android/bluetooth/map/BluetoothMapbMessage.java
+++ b/src/com/android/bluetooth/map/BluetoothMapbMessage.java
@@ -225,6 +225,7 @@ public abstract class BluetoothMapbMessage {
// Empty phone number - ignore
}
else if(line.startsWith("EMAIL:")){
+ line = line.replace("&lt;", "<").replace("&gt;", ">");
parts = line.split("[^\\\\]:"); // Split on "un-escaped" :
if(parts.length == 2) {
String[] subParts = parts[1].split("[^\\\\];");
diff --git a/src/com/android/bluetooth/opp/BluetoothOppManager.java b/src/com/android/bluetooth/opp/BluetoothOppManager.java
index 44ea6a93f..29c4500f9 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppManager.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppManager.java
@@ -109,7 +109,7 @@ public class BluetoothOppManager {
public boolean mMultipleFlag;
- private int mfileNumInBatch;
+ private int mfileNumInBatch = 1;
private int mInsertShareThreadNum = 0;
diff --git a/src/com/android/bluetooth/opp/BluetoothOppNotification.java b/src/com/android/bluetooth/opp/BluetoothOppNotification.java
index 161cd576f..adfeeb68a 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppNotification.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppNotification.java
@@ -109,10 +109,11 @@ class BluetoothOppNotification {
private static final int NOTIFICATION_ID_INBOUND = -1000006;
+ private boolean mPendingUpdate = true;
private boolean mOutboundUpdateCompleteNotification = true;
private boolean mInboundUpdateCompleteNotification = true;
- private int confirmation = 0;
+ private int mConfirmation = 0;
private int mInboundActiveNotificationId = 0;
private int mOutboundActiveNotificationId = 0;
private int mRunning = 0;
@@ -158,7 +159,9 @@ class BluetoothOppNotification {
* Update the notification ui.
*/
public void updateNotification() {
+ if (V) Log.v(TAG, "Updating the notification");
synchronized (BluetoothOppNotification.this) {
+ mPendingUpdate = true;
if (mUpdateNotificationThread == null) {
if (V) Log.v(TAG, "new notify thread!!!");
mUpdateNotificationThread = new NotificationUpdateThread();
@@ -203,6 +206,7 @@ class BluetoothOppNotification {
throw new IllegalStateException(
"multiple UpdateThreads in BluetoothOppNotification");
}
+ mPendingUpdate = false;
}
updateActiveNotification();
@@ -210,7 +214,7 @@ class BluetoothOppNotification {
updateIncomingFileConfirmNotification();
try {
- if ((confirmation == BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED)
+ if ((mConfirmation == BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED)
|| mPowerManager.isScreenOn()) {
Thread.sleep(BluetoothShare.UI_UPDATE_INTERVAL);
}
@@ -219,9 +223,12 @@ class BluetoothOppNotification {
return;
}
- if (V) Log.v(TAG, "Running = " + mRunning);
- } while ((mRunning > 0) && (mPowerManager.isScreenOn()
- || (confirmation == BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED)));
+ if (V) {
+ Log.v(TAG, "Running = " + mRunning + " Pending notification is "
+ + mPendingUpdate);
+ }
+ } while ((mPendingUpdate || (mRunning > 0)) && (mPowerManager.isScreenOn()
+ || (mConfirmation == BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED)));
synchronized (BluetoothOppNotification.this) {
mUpdateNotificationThread = null;
@@ -314,7 +321,7 @@ class BluetoothOppNotification {
int id = cursor.getInt(idIndex);
long total = cursor.getLong(totalBytesIndex);
long current = cursor.getLong(currentBytesIndex);
- confirmation = cursor.getInt(confirmIndex);
+ mConfirmation = cursor.getInt(confirmIndex);
String destination = cursor.getString(destinationIndex);
String fileName = cursor.getString(dataIndex);
@@ -347,7 +354,7 @@ class BluetoothOppNotification {
item.totalCurrent = current;
item.totalTotal = total;
item.handoverInitiated =
- confirmation == BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED;
+ mConfirmation == BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED;
item.destination = destination;
mNotifications.put(batchID, item);
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
index 6684b1fd7..0b480e70b 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
@@ -587,6 +587,20 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
}
readLength = a.read(buffer, 0, outputBufferSize);
+
+ while (true) {
+ int congStatus = ((BluetoothOppTransport)mTransport1).getSockCongStatus();
+ if ((congStatus == 0) || (congStatus == -1)) {
+ break;
+ }
+ try {
+ Thread.sleep(5);
+ } catch (InterruptedException slpe) {
+ Log.v(TAG, "Interrupted while checking the socket congestion evt");
+ break;
+ }
+ }
+
int writtenLength = 0;
while (writtenLength != readLength) {
//SET MTU SIZE BEFORE WRITE
diff --git a/src/com/android/bluetooth/opp/BluetoothOppService.java b/src/com/android/bluetooth/opp/BluetoothOppService.java
index 7318c793b..2cec3b1c4 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppService.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppService.java
@@ -96,6 +96,8 @@ public class BluetoothOppService extends Service {
/** Class to handle Notification Manager updates */
private BluetoothOppNotification mNotifier;
+ private boolean mPendingUpdate = true;
+
private UpdateThread mUpdateThread;
private ArrayList<BluetoothOppShareInfo> mShares;
@@ -448,7 +450,9 @@ public class BluetoothOppService extends Service {
};
private void updateFromProvider() {
+ if (V) Log.v(TAG, "Updating the provider");
synchronized (BluetoothOppService.this) {
+ mPendingUpdate = true;
if ((mUpdateThread == null) && (mAdapter != null)
&& mAdapter.isEnabled()) {
if (V) Log.v(TAG, "Starting a new thread");
@@ -477,6 +481,7 @@ public class BluetoothOppService extends Service {
}
if (V) Log.v(TAG, "keepUpdateThread is " + keepService + " sListenStarted is "
+ mListenStarted);
+ mPendingUpdate = false;
}
Cursor cursor;
try {
@@ -627,15 +632,16 @@ public class BluetoothOppService extends Service {
}
try {
- if (((mServerSession != null) || (mTransfer != null))
- && mPowerManager.isScreenOn()) {
+ if (mPowerManager.isScreenOn()) {
Thread.sleep(BluetoothShare.UI_UPDATE_INTERVAL);
}
} catch (InterruptedException e) {
if (V) Log.v(TAG, "OppService Thread sleep is interrupted (1), exiting");
return;
}
- } while (mPowerManager.isScreenOn() && ((mServerSession != null) || (mTransfer != null)));
+
+ if(V) Log.v(TAG, "PendingUpdate is " + mPendingUpdate);
+ } while (mPendingUpdate);
synchronized (BluetoothOppService.this) {
mUpdateThread = null;
@@ -834,7 +840,9 @@ public class BluetoothOppService extends Service {
info.mVisibility = newVisibility;
if (info.mConfirm == BluetoothShare.USER_CONFIRMATION_PENDING
- && newConfirm != BluetoothShare.USER_CONFIRMATION_PENDING) {
+ && (newConfirm == BluetoothShare.USER_CONFIRMATION_CONFIRMED ||
+ newConfirm == BluetoothShare.USER_CONFIRMATION_AUTO_CONFIRMED ||
+ newConfirm == BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED)) {
confirmUpdated = true;
}
info.mConfirm = newConfirm;
diff --git a/src/com/android/bluetooth/opp/BluetoothOppTransfer.java b/src/com/android/bluetooth/opp/BluetoothOppTransfer.java
index 917bf53ee..9c639c72f 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppTransfer.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppTransfer.java
@@ -475,6 +475,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
private void startObexSession() {
mBatch.mStatus = Constants.BATCH_STATUS_RUNNING;
+ BluetoothOppManager mOppManager = BluetoothOppManager.getInstance(mContext);
mCurrentShare = mBatch.getPendingShare();
if (mCurrentShare == null) {
@@ -507,7 +508,11 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
}
if (mSession != null) {
- mSession.start(mSessionHandler, mBatch.getNumShares());
+ /* Read the number of files are sharing from OPP Manager instead of getting
+ * the number of files from Batch before OBEX session start.
+ */
+ if (V) Log.v(TAG, "Sharing files = " + mOppManager.getBatchSize());
+ mSession.start(mSessionHandler, mOppManager.getBatchSize());
processCurrentShare();
}
diff --git a/src/com/android/bluetooth/opp/BluetoothOppTransport.java b/src/com/android/bluetooth/opp/BluetoothOppTransport.java
index 25c66fc7e..0615c1899 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppTransport.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppTransport.java
@@ -99,6 +99,21 @@ public class BluetoothOppTransport implements ObexTransport {
return status;
}
+ /**
+ * Returns the Congestion status of the Socket
+ */
+ public int getSockCongStatus() {
+ ByteBuffer bb = ByteBuffer.allocate(4);
+ bb.order(ByteOrder.LITTLE_ENDIAN);
+ int status;
+ try {
+ status = mSocket.getSocketOpt(5, bb.array());
+ } catch (IOException ex) {
+ return -1;
+ }
+ return bb.getInt();
+ }
+
public void connect() throws IOException {
}