Loading src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java +12 −13 Original line number Diff line number Diff line Loading @@ -77,6 +77,8 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { private final int MIN_FILE_LEN_FOR_TPUT_MEASUREMENT = 500000; private long position; public BluetoothOppObexClientSession(Context context, ObexTransport transport) { if (transport == null) { throw new NullPointerException("transport is null"); Loading Loading @@ -123,29 +125,26 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { } private class ContentResolverUpdateThread extends Thread { private static final int sSleepTime = 500; private static final int sSleepTime = 1000; private Uri contentUri; private Context mContext1; private long position; public ContentResolverUpdateThread(Context context, Uri cntUri, long pos) { public ContentResolverUpdateThread(Context context, Uri cntUri) { super("BtOpp ContentResolverUpdateThread"); mContext1 = context; contentUri = cntUri; position = pos; } public void updateProgress (long pos) { position = pos; } @Override public void run() { ContentValues updateValues; Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); while (true) { if (V) Log.v(TAG, "Is ContentResolverUpdateThread Interrupted :" + isInterrupted()); /* Check if the Operation is interrupted before entering into loop */ while (!isInterrupted()) { updateValues = new ContentValues(); updateValues.put(BluetoothShare.CURRENT_BYTES, position); mContext1.getContentResolver().update(contentUri, updateValues, Loading Loading @@ -379,7 +378,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { private int sendFile(BluetoothOppSendFileInfo fileInfo) { boolean error = false; int responseCode = -1; long position = 0; position = 0; int status = BluetoothShare.STATUS_SUCCESS; Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + mInfo.mId); ContentValues updateValues; Loading Loading @@ -522,10 +521,9 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { if (uiUpdateThread == null) { uiUpdateThread = new ContentResolverUpdateThread (mContext1, contentUri, position); contentUri); if (V) Log.v(TAG, "Worker for Updation : Created"); uiUpdateThread.start ( ); } else { uiUpdateThread.updateProgress (position); } } } Loading @@ -533,6 +531,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { if (uiUpdateThread != null) { try { if (V) Log.v(TAG, "Worker for Updation : Destroying"); uiUpdateThread.interrupt (); uiUpdateThread.join (); uiUpdateThread = null; Loading src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java +27 −26 Original line number Diff line number Diff line Loading @@ -109,6 +109,8 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen boolean mTransferInProgress = false; private int position; public BluetoothOppObexServerSession(Context context, ObexTransport transport) { mContext = context; mTransport = transport; Loading Loading @@ -169,40 +171,40 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen private class ContentResolverUpdateThread extends Thread { private static final int sSleepTime = 500; private static final int sSleepTime = 1000; private Uri contentUri; private Context mContext1; private long position; public ContentResolverUpdateThread(Context context, Uri cntUri, long pos) { private volatile boolean interrupted = false; public ContentResolverUpdateThread(Context context, Uri cntUri) { super("BtOpp Server ContentResolverUpdateThread"); mContext1 = context; contentUri = cntUri; position = pos; } public void updateProgress (long pos) { position = pos; } @Override public void run() { ContentValues updateValues; Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); ContentValues updateValues; if (V) Log.v(TAG, "Is ContentResolverUpdateThread Interrupted :" + isInterrupted()); /* Check if the Operation is interrupted before entering into loop */ while ( !isInterrupted() ) { 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 (V) Log.v(TAG, "ContentResolverUpdateThread was interrupted before sleep !,"+ " exiting"); return ; } try { Thread.sleep(sSleepTime); } catch (InterruptedException e1) { if (V) Log.v(TAG, "Server ContentResolverUpdateThread was interrupted (1), exiting"); if (V) Log.v(TAG, "Server ContentResolverUpdateThread was interrupted (1),"+ " exiting"); return ; } } Loading Loading @@ -506,6 +508,7 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen BufferedOutputStream bos = null; ContentResolverUpdateThread uiUpdateThread = null; InputStream is = null; boolean error = false; try { Loading @@ -524,7 +527,7 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen mContext.getContentResolver().update(contentUri, updateValues, null, null); } long position = 0; position = 0; if (!error) { bos = new BufferedOutputStream(fileInfo.mOutputStream, 0x10000); } Loading Loading @@ -556,11 +559,9 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen } if (uiUpdateThread == null) { uiUpdateThread = new ContentResolverUpdateThread (mContext, contentUri, position); uiUpdateThread = new ContentResolverUpdateThread (mContext, contentUri); if (V) Log.v(TAG, "Worker for Updation : Created"); uiUpdateThread.start(); } else { uiUpdateThread.updateProgress (position); } } Loading Loading
src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java +12 −13 Original line number Diff line number Diff line Loading @@ -77,6 +77,8 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { private final int MIN_FILE_LEN_FOR_TPUT_MEASUREMENT = 500000; private long position; public BluetoothOppObexClientSession(Context context, ObexTransport transport) { if (transport == null) { throw new NullPointerException("transport is null"); Loading Loading @@ -123,29 +125,26 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { } private class ContentResolverUpdateThread extends Thread { private static final int sSleepTime = 500; private static final int sSleepTime = 1000; private Uri contentUri; private Context mContext1; private long position; public ContentResolverUpdateThread(Context context, Uri cntUri, long pos) { public ContentResolverUpdateThread(Context context, Uri cntUri) { super("BtOpp ContentResolverUpdateThread"); mContext1 = context; contentUri = cntUri; position = pos; } public void updateProgress (long pos) { position = pos; } @Override public void run() { ContentValues updateValues; Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); while (true) { if (V) Log.v(TAG, "Is ContentResolverUpdateThread Interrupted :" + isInterrupted()); /* Check if the Operation is interrupted before entering into loop */ while (!isInterrupted()) { updateValues = new ContentValues(); updateValues.put(BluetoothShare.CURRENT_BYTES, position); mContext1.getContentResolver().update(contentUri, updateValues, Loading Loading @@ -379,7 +378,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { private int sendFile(BluetoothOppSendFileInfo fileInfo) { boolean error = false; int responseCode = -1; long position = 0; position = 0; int status = BluetoothShare.STATUS_SUCCESS; Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + mInfo.mId); ContentValues updateValues; Loading Loading @@ -522,10 +521,9 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { if (uiUpdateThread == null) { uiUpdateThread = new ContentResolverUpdateThread (mContext1, contentUri, position); contentUri); if (V) Log.v(TAG, "Worker for Updation : Created"); uiUpdateThread.start ( ); } else { uiUpdateThread.updateProgress (position); } } } Loading @@ -533,6 +531,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { if (uiUpdateThread != null) { try { if (V) Log.v(TAG, "Worker for Updation : Destroying"); uiUpdateThread.interrupt (); uiUpdateThread.join (); uiUpdateThread = null; Loading
src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java +27 −26 Original line number Diff line number Diff line Loading @@ -109,6 +109,8 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen boolean mTransferInProgress = false; private int position; public BluetoothOppObexServerSession(Context context, ObexTransport transport) { mContext = context; mTransport = transport; Loading Loading @@ -169,40 +171,40 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen private class ContentResolverUpdateThread extends Thread { private static final int sSleepTime = 500; private static final int sSleepTime = 1000; private Uri contentUri; private Context mContext1; private long position; public ContentResolverUpdateThread(Context context, Uri cntUri, long pos) { private volatile boolean interrupted = false; public ContentResolverUpdateThread(Context context, Uri cntUri) { super("BtOpp Server ContentResolverUpdateThread"); mContext1 = context; contentUri = cntUri; position = pos; } public void updateProgress (long pos) { position = pos; } @Override public void run() { ContentValues updateValues; Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); ContentValues updateValues; if (V) Log.v(TAG, "Is ContentResolverUpdateThread Interrupted :" + isInterrupted()); /* Check if the Operation is interrupted before entering into loop */ while ( !isInterrupted() ) { 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 (V) Log.v(TAG, "ContentResolverUpdateThread was interrupted before sleep !,"+ " exiting"); return ; } try { Thread.sleep(sSleepTime); } catch (InterruptedException e1) { if (V) Log.v(TAG, "Server ContentResolverUpdateThread was interrupted (1), exiting"); if (V) Log.v(TAG, "Server ContentResolverUpdateThread was interrupted (1),"+ " exiting"); return ; } } Loading Loading @@ -506,6 +508,7 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen BufferedOutputStream bos = null; ContentResolverUpdateThread uiUpdateThread = null; InputStream is = null; boolean error = false; try { Loading @@ -524,7 +527,7 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen mContext.getContentResolver().update(contentUri, updateValues, null, null); } long position = 0; position = 0; if (!error) { bos = new BufferedOutputStream(fileInfo.mOutputStream, 0x10000); } Loading Loading @@ -556,11 +559,9 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen } if (uiUpdateThread == null) { uiUpdateThread = new ContentResolverUpdateThread (mContext, contentUri, position); uiUpdateThread = new ContentResolverUpdateThread (mContext, contentUri); if (V) Log.v(TAG, "Worker for Updation : Created"); uiUpdateThread.start(); } else { uiUpdateThread.updateProgress (position); } } Loading