summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/bluetooth/Utils.java4
-rwxr-xr-xsrc/com/android/bluetooth/map/BluetoothMapService.java5
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppHandoverReceiver.java2
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppManager.java35
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java18
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java13
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppReceiver.java7
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppService.java13
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppTransfer.java62
-rw-r--r--src/com/android/bluetooth/pbap/BluetoothPbapService.java4
10 files changed, 98 insertions, 65 deletions
diff --git a/src/com/android/bluetooth/Utils.java b/src/com/android/bluetooth/Utils.java
index e87a6d9e3..6a467f9c3 100644
--- a/src/com/android/bluetooth/Utils.java
+++ b/src/com/android/bluetooth/Utils.java
@@ -204,19 +204,15 @@ final public class Utils {
int callingUser = UserHandle.getCallingUserId();
int callingUid = Binder.getCallingUid();
long ident = Binder.clearCallingIdentity();
- Log.d(TAG,"callingUid =" + callingUid);
try {
// With calling identity cleared the current user is the foreground user.
int foregroundUser = ActivityManager.getCurrentUser();
ok = (foregroundUser == callingUser);
- Log.e(TAG, "foregroundUser =" + foregroundUser);
- Log.e(TAG, "callingUser =" + callingUser);
if (!ok) {
// Always allow SystemUI/System access.
int systemUiUid = ActivityThread.getPackageManager().getPackageUid(
"com.android.systemui", UserHandle.USER_OWNER);
- Log.d(TAG," systemUiUid :" + systemUiUid);
ok = (systemUiUid == callingUid) || (Process.SYSTEM_UID == callingUid);
}
} catch (Exception ex) {
diff --git a/src/com/android/bluetooth/map/BluetoothMapService.java b/src/com/android/bluetooth/map/BluetoothMapService.java
index 5d0b23aa2..003687658 100755
--- a/src/com/android/bluetooth/map/BluetoothMapService.java
+++ b/src/com/android/bluetooth/map/BluetoothMapService.java
@@ -594,17 +594,12 @@ public class BluetoothMapService extends ProfileService {
if(!VERBOSE)
VERBOSE = Log.isLoggable(LOG_TAG, Log.VERBOSE);
- if (!Utils.checkCaller()) {
- Log.w(TAG, "start received for non-active user, ignoring");
- return false;
- }
//Start MapProfile if not already done.
if (isMapStarted()) {
Log.w(TAG, "start received for already started, ignoring");
return false;
}
-
if (VERBOSE) Log.v(TAG, "verbose logging is enabled");
HandlerThread thread = new HandlerThread("BluetoothMapHandler");
thread.start();
diff --git a/src/com/android/bluetooth/opp/BluetoothOppHandoverReceiver.java b/src/com/android/bluetooth/opp/BluetoothOppHandoverReceiver.java
index 8eb073906..aa2af081d 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppHandoverReceiver.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppHandoverReceiver.java
@@ -38,7 +38,7 @@ public class BluetoothOppHandoverReceiver extends BroadcastReceiver {
if (action.equals(Constants.ACTION_HANDOVER_SEND) ||
action.equals(Constants.ACTION_HANDOVER_SEND_MULTIPLE)) {
- if (V) Log.v(TAG, "Transfer initiated from HANDOVER");
+
BluetoothDevice device =
(BluetoothDevice)intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (device == null) {
diff --git a/src/com/android/bluetooth/opp/BluetoothOppManager.java b/src/com/android/bluetooth/opp/BluetoothOppManager.java
index 7d259e15f..8805818e5 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppManager.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppManager.java
@@ -119,8 +119,6 @@ public class BluetoothOppManager {
// The time for which the whitelist entries remain valid.
private static final int WHITELIST_DURATION_MS = 15000;
- public boolean isOPPServiceUp = false;
-
/**
* Get singleton instance.
*/
@@ -429,28 +427,17 @@ public class BluetoothOppManager {
@Override
public void run() {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
- while (true) {
- if (mRemoteDevice == null) {
- Log.e(TAG, "Target bt device is null!");
- return;
- }
-
- if (V) Log.v(TAG, "OPPServiceUP = " + isOPPServiceUp);
- if (isOPPServiceUp) {
- if (mIsMultiple) {
- insertMultipleShare();
- } else {
- insertSingleShare();
- }
-
- synchronized (BluetoothOppManager.this) {
- mInsertShareThreadNum--;
- }
- return;
- } else if (!isEnabled()) {
- Log.v(TAG, "BT is OFF");
- return;
- }
+ if (mRemoteDevice == null) {
+ Log.e(TAG, "Target bt device is null!");
+ return;
+ }
+ if (mIsMultiple) {
+ insertMultipleShare();
+ } else {
+ insertSingleShare();
+ }
+ synchronized (BluetoothOppManager.this) {
+ mInsertShareThreadNum--;
}
}
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
index e2ecfc5b8..63de591b5 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
@@ -128,11 +128,13 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
private static final int sSleepTime = 1000;
private Uri contentUri;
private Context mContext1;
+ private volatile boolean interrupted = false;
public ContentResolverUpdateThread(Context context, Uri cntUri) {
super("BtOpp ContentResolverUpdateThread");
mContext1 = context;
contentUri = cntUri;
+ interrupted = false;
}
@@ -143,19 +145,33 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
ContentValues updateValues;
if (V) Log.v(TAG, "Is ContentResolverUpdateThread Interrupted :" + isInterrupted());
/* Check if the Operation is interrupted before entering into loop */
- while (!isInterrupted()) {
+ while (!interrupted) {
updateValues = new ContentValues();
updateValues.put(BluetoothShare.CURRENT_BYTES, position);
mContext1.getContentResolver().update(contentUri, updateValues,
null, null);
+
+ /* Check if the Operation is interrupted before entering sleep */
+ if (interrupted) {
+ if (V) Log.v(TAG, "ContentResolverUpdateThread was interrupted before sleep !, exiting");
+ return;
+ }
+
try {
Thread.sleep(sSleepTime);
} catch (InterruptedException e1) {
if (V) Log.v(TAG, "ContentResolverUpdateThread was interrupted (1), exiting");
+ interrupted = true;
return;
}
}
}
+
+ @Override
+ public void interrupt() {
+ interrupted = true;
+ super.interrupt();
+ }
}
private class ClientThread extends Thread {
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java
index 0056450ab..4a90e04ba 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java
@@ -173,11 +173,13 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen
private static final int sSleepTime = 1000;
private Uri contentUri;
private Context mContext1;
+ private volatile boolean interrupted = false;
public ContentResolverUpdateThread(Context context, Uri cntUri) {
super("BtOpp Server ContentResolverUpdateThread");
mContext1 = context;
contentUri = cntUri;
+ interrupted = false;
}
@Override
@@ -188,14 +190,14 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen
if (V) Log.v(TAG, "Is ContentResolverUpdateThread Interrupted :" + isInterrupted());
/* Check if the Operation is interrupted before entering into loop */
- while ( !isInterrupted() ) {
+ while (!interrupted) {
updateValues = new ContentValues();
updateValues.put(BluetoothShare.CURRENT_BYTES, position);
mContext1.getContentResolver().update(contentUri, updateValues,
null, null);
/* Check if the Operation is interrupted before entering sleep */
- if (isInterrupted()) {
+ if (interrupted) {
if (V) Log.v(TAG, "ContentResolverUpdateThread was interrupted before sleep !,"+
" exiting");
return ;
@@ -205,10 +207,17 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen
} catch (InterruptedException e1) {
if (V) Log.v(TAG, "Server ContentResolverUpdateThread was interrupted (1),"+
" exiting");
+ interrupted = true;
return ;
}
}
}
+
+ @Override
+ public void interrupt() {
+ interrupted = true;
+ super.interrupt();
+ }
}
/*
* Called when a ABORT request is received.
diff --git a/src/com/android/bluetooth/opp/BluetoothOppReceiver.java b/src/com/android/bluetooth/opp/BluetoothOppReceiver.java
index ff56d29b8..b4626c0be 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppReceiver.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppReceiver.java
@@ -48,7 +48,6 @@ import android.database.Cursor;
import android.net.Uri;
import android.util.Log;
import android.widget.Toast;
-import com.android.bluetooth.Utils;
/**
* Receives and handles: system broadcasts; Intents from other applications;
@@ -64,12 +63,6 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
String action = intent.getAction();
if (D) Log.d(TAG, "Action :" + action);
- /* Ignore if Broadcast action is not transfer complete and Invalid user */
- if (!Utils.checkCaller() && !action.equals(BluetoothShare.TRANSFER_COMPLETED_ACTION)) {
- Log.w(TAG, action + " received for non-active user, ignoring!!");
- return;
- }
- if (V) Log.v(TAG, action + " Intent received for active user");
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
if (BluetoothAdapter.STATE_ON == intent.getIntExtra(
diff --git a/src/com/android/bluetooth/opp/BluetoothOppService.java b/src/com/android/bluetooth/opp/BluetoothOppService.java
index c7c867051..c70d0fe17 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppService.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppService.java
@@ -148,8 +148,6 @@ public class BluetoothOppService extends Service {
*/
private BluetoothOppObexServerSession mServerSession;
- BluetoothOppManager mOppManager = null;
-
@Override
public IBinder onBind(Intent arg0) {
throw new UnsupportedOperationException("Cannot bind to Bluetooth OPP Service");
@@ -170,11 +168,12 @@ public class BluetoothOppService extends Service {
mNotifier.updateNotification();
final ContentResolver contentResolver = getContentResolver();
- synchronized (BluetoothOppService.this) {
- trimDatabase(contentResolver);
- }
+ new Thread("trimDatabase") {
+ public void run() {
+ trimDatabase(contentResolver);
+ }
+ }.start();
- mOppManager = BluetoothOppManager.getInstance(this);
IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
registerReceiver(mBluetoothReceiver, filter);
@@ -184,7 +183,6 @@ public class BluetoothOppService extends Service {
} else {
startListener();
}
- mOppManager.isOPPServiceUp = true;
}
if (V) BluetoothOppPreference.getInstance(this).dump();
updateFromProvider();
@@ -396,7 +394,6 @@ public class BluetoothOppService extends Service {
public void onDestroy() {
if (V) Log.v(TAG, "onDestroy");
super.onDestroy();
- mOppManager.isOPPServiceUp = false;
getContentResolver().unregisterContentObserver(mObserver);
unregisterReceiver(mBluetoothReceiver);
if(mSocketListener != null) {
diff --git a/src/com/android/bluetooth/opp/BluetoothOppTransfer.java b/src/com/android/bluetooth/opp/BluetoothOppTransfer.java
index e1b720c5a..c4960d4f1 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppTransfer.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppTransfer.java
@@ -567,10 +567,17 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
mConnectThread = new SocketConnectThread("localhost", Constants.TCP_DEBUG_PORT, 0);
mConnectThread.start();
} else {
- OolConnManager.setSdpInitiatedAddress(mBatch.mDestination);
- mBatch.mDestination.sdpSearch(BluetoothUuid.ObexObjectPush);
- mConnectThread = new SocketConnectThread(mBatch.mDestination,false);
- mConnectThread.start();
+ OolConnManager.setSdpInitiatedAddress(mBatch.mDestination);
+ if (!mBatch.mDestination.sdpSearch(BluetoothUuid.ObexObjectPush)) {
+ /* SDP failed, start rfcomm connect directly */
+ mConnectThread = new SocketConnectThread(mBatch.mDestination, false, false);
+ /* update bd address as sdp could not be started */
+ OolConnManager.setSdpInitiatedAddress(null);
+ } else {
+ /* SDP sucessfully started, start l2cap connect after sdp completes */
+ mConnectThread = new SocketConnectThread(mBatch.mDestination, false, true);
+ }
+ mConnectThread.start();
}
}
@@ -593,6 +600,8 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
private boolean mRetry = false;
+ private boolean mSdpInitiated = false;
+
/* create a TCP socket */
public SocketConnectThread(String host, int port, int dummy) {
super("Socket Connect Thread");
@@ -600,9 +609,10 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
this.channel = port;
this.device = null;
isConnected = false;
+ mSdpInitiated = false;
}
- /* create a Rfcomm Socket */
+ /* create a Rfcomm/L2CAP Socket */
public SocketConnectThread(BluetoothDevice device, int channel, boolean
retry) {
super("Socket Connect Thread");
@@ -611,17 +621,30 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
this.channel = channel;
isConnected = false;
mRetry = retry;
+ mSdpInitiated = false;
}
- /* create a Rfcomm Socket */
- public SocketConnectThread(BluetoothDevice device, boolean
- retry) {
+ /* create a Rfcomm/L2CAP Socket */
+ public SocketConnectThread(BluetoothDevice device, boolean retry) {
+ super("Socket Connect Thread");
+ this.device = device;
+ this.host = null;
+ this.channel = -1;
+ isConnected = false;
+ mRetry = retry;
+ mSdpInitiated = false;
+ }
+
+ /* create a Rfcomm/L2CAP Socket */
+ public SocketConnectThread(BluetoothDevice device, boolean retry,
+ boolean sdpInitiated) {
super("Socket Connect Thread");
this.device = device;
this.host = null;
this.channel = -1;
isConnected = false;
mRetry = retry;
+ mSdpInitiated = sdpInitiated;
}
public void interrupt() {
@@ -745,11 +768,32 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
return ;
}
+ Log.d(TAG, "sdp initiated = " + mSdpInitiated);
+
+ // check if sdp initiated successfully for l2cap or not. If not connect
+ // directly to rfcomm
+ if (!mSdpInitiated) {
+ /* sdp failed for some reason, connect on rfcomm */
+ Log.d(TAG, "sdp not initiated, connecting on rfcomm");
+ connectRfcommSocket();
+ return;
+ }
+
+ /* Reset the flag */
+ mSdpInitiated = false;
+
/* Use BluetoothSocket to connect */
l2cChannel = 0;
try {
l2cChannel = OolConnManager.getL2cPSM(device);
- btSocket = device.createInsecureL2capSocket(l2cChannel);
+ if (l2cChannel > 0) {
+ Log.d(TAG, "Connecting to l2cap psm = " + l2cChannel);
+ btSocket = device.createInsecureL2capSocket(l2cChannel);
+ } else {
+ Log.d(TAG, "L2cap psm not found, connecting on rfcomm");
+ connectRfcommSocket();
+ return;
+ }
} catch (IOException e1) {
Log.e(TAG, "L2cap socket create error",e1);
connectRfcommSocket();
diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapService.java b/src/com/android/bluetooth/pbap/BluetoothPbapService.java
index dcfc5c209..6cfd71339 100644
--- a/src/com/android/bluetooth/pbap/BluetoothPbapService.java
+++ b/src/com/android/bluetooth/pbap/BluetoothPbapService.java
@@ -200,10 +200,6 @@ public class BluetoothPbapService extends Service {
mInterrupted = false;
mAdapter = BluetoothAdapter.getDefaultAdapter();
- if (!Utils.checkCaller()) {
- Log.w(TAG, "onCreate received for non-active user, ignoring");
- return;
- }
if (!mHasStarted) {
mHasStarted = true;