summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHemant Gupta <hemantg@codeaurora.org>2014-07-30 14:09:32 +0530
committerLinux Build Service Account <lnxbuild@localhost>2014-11-04 08:26:03 -0700
commitfdf073a106e79dc12596a216b8549a130987a8be (patch)
tree22a3b5e409897f654afe36feaaa1cf764b28954f
parent004757417790e8ca7d2679e370c4727a6c135c9a (diff)
downloadandroid_packages_apps_Bluetooth-fdf073a106e79dc12596a216b8549a130987a8be.tar.gz
android_packages_apps_Bluetooth-fdf073a106e79dc12596a216b8549a130987a8be.tar.bz2
android_packages_apps_Bluetooth-fdf073a106e79dc12596a216b8549a130987a8be.zip
OPP: Delete interrupted outbound content resolver entry
Deleting interrupted outbound content resolver entry when BT is turned ON. Otherwise, during ongoing transfer if files are queued and device rebooted. After booting up share entry will be picked up from content resolver and display will show the toast message about transfer failure. CRs-Fixed: 703674 Change-Id: I26857c1b9cb57011c677468391b4f996e8bdf445
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppService.java103
1 files changed, 14 insertions, 89 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppService.java b/src/com/android/bluetooth/opp/BluetoothOppService.java
index 84c50dc1c..3fde44b93 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppService.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppService.java
@@ -414,7 +414,6 @@ public class BluetoothOppService extends Service {
case BluetoothAdapter.STATE_TURNING_OFF:
if (V) Log.v(TAG, "Receiver DISABLED_ACTION ");
mNotifier.btOffNotification();
- removePendingTransfer();
//FIX: Don't block main thread
/*
mSocketListener.stop();
@@ -862,94 +861,6 @@ public class BluetoothOppService extends Service {
}
}
- private void removePendingTransfer() {
- if (V) Log.v(TAG, "Remove pending share");
- Cursor cursor = null;
- try {
- cursor = getContentResolver().query(BluetoothShare.CONTENT_URI, null, null,
- null, BluetoothShare._ID);
- } catch (SQLiteException e) {
- if (cursor != null){
- cursor.close();
- }
- cursor = null;
- Log.e(TAG, "UpdateThread: " + e);
- } catch (CursorWindowAllocationException e) {
- cursor = null;
- Log.e(TAG, "UpdateThread: " + e);
- }
-
- if (cursor == null) {
- return;
- }
-
- cursor.moveToFirst();
- int arrayPos = 0;
- boolean isAfterLast = cursor.isAfterLast();
-
- while (!isAfterLast || arrayPos < mShares.size()) {
- String uriString = cursor.getString(cursor.getColumnIndexOrThrow(BluetoothShare.URI));
- Uri uri;
- if (uriString != null) {
- uri = Uri.parse(uriString);
- Log.d(TAG, "removeShare parsed URI: " + uri);
- } else {
- uri = null;
- Log.e(TAG, "removeShare found null URI at cursor!");
- }
- BluetoothOppShareInfo info = new BluetoothOppShareInfo(
- cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare._ID)),
- uri,
- cursor.getString(cursor.getColumnIndexOrThrow(BluetoothShare.FILENAME_HINT)),
- cursor.getString(cursor.getColumnIndexOrThrow(BluetoothShare._DATA)),
- cursor.getString(cursor.getColumnIndexOrThrow(BluetoothShare.MIMETYPE)),
- cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.DIRECTION)),
- cursor.getString(cursor.getColumnIndexOrThrow(BluetoothShare.DESTINATION)),
- cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.VISIBILITY)),
- cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.USER_CONFIRMATION)),
- cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.STATUS)),
- cursor.getLong(cursor.getColumnIndexOrThrow(BluetoothShare.TOTAL_BYTES)),
- cursor.getLong(cursor.getColumnIndexOrThrow(BluetoothShare.CURRENT_BYTES)),
- cursor.getLong(cursor.getColumnIndexOrThrow(BluetoothShare.TIMESTAMP)),
- cursor.getInt(cursor.getColumnIndexOrThrow(Constants.MEDIA_SCANNED)) != Constants.MEDIA_SCANNED_NOT_SCANNED);
-
- if (V) {
- Log.v(TAG, "Service remove entry");
- Log.v(TAG, "ID : " + info.mId);
- // Log.v(TAG, "URI : " + ((info.mUri != null) ? "yes" : "no"));
- Log.v(TAG, "URI : " + info.mUri);
- Log.v(TAG, "HINT : " + info.mHint);
- Log.v(TAG, "FILENAME: " + info.mFilename);
- Log.v(TAG, "MIMETYPE: " + info.mMimetype);
- Log.v(TAG, "DIRECTION: " + info.mDirection);
- Log.v(TAG, "DESTINAT: " + info.mDestination);
- Log.v(TAG, "VISIBILI: " + info.mVisibility);
- Log.v(TAG, "CONFIRM : " + info.mConfirm);
- Log.v(TAG, "STATUS : " + info.mStatus);
- Log.v(TAG, "TOTAL : " + info.mTotalBytes);
- Log.v(TAG, "CURRENT : " + info.mCurrentBytes);
- Log.v(TAG, "TIMESTAMP : " + info.mTimestamp);
- Log.v(TAG, "SCANNED : " + info.mMediaScanned);
- }
-
- if (info.isReadyToStart()) {
- if (info.mDirection == BluetoothShare.DIRECTION_OUTBOUND) {
- BluetoothOppSendFileInfo sendFileInfo = BluetoothOppUtility.getSendFileInfo(
- info.mUri);
- Constants.updateShareStatus(this, info.mId, BluetoothShare.STATUS_BAD_REQUEST);
- BluetoothOppUtility.closeSendFileInfo(info.mUri);
- }
- }
-
- ++arrayPos;
- cursor.moveToNext();
- isAfterLast = cursor.isAfterLast();
- }
- cursor.close();
- if (V) Log.v(TAG, "Freeing cursor: " + cursor);
- cursor = null;
- }
-
/**
* Removes the local copy of the info about a share.
*/
@@ -1119,6 +1030,20 @@ public class BluetoothOppService extends Service {
WHERE_INVISIBLE_COMPLETE_INBOUND_FAILED, null);
if (V) Log.v(TAG, "Deleted complete inbound failed shares, number = " + delNum);
+ // remove outbound share interrupted by battery removal
+ final String WHERE_OUTBOUND_INTERRUPTED_ON_POWER_OFF = BluetoothShare.DIRECTION + "="
+ + BluetoothShare.DIRECTION_OUTBOUND + " AND " + BluetoothShare.STATUS + "="
+ + BluetoothShare.STATUS_PENDING + " OR " + BluetoothShare.STATUS + "="
+ + BluetoothShare.STATUS_RUNNING;
+
+ try {
+ delNum = contentResolver.delete(BluetoothShare.CONTENT_URI,
+ WHERE_OUTBOUND_INTERRUPTED_ON_POWER_OFF, null);
+ if (V) Log.v(TAG, "Delete interrupted outbound share, number = " + delNum);
+ } catch (SQLiteException e) {
+ Log.e(TAG, "trimDatabase: could not deleted interrupted outbound failed shares: " + e);
+ }
+
final String WHERE_INBOUND_INTERRUPTED_ON_POWER_OFF = BluetoothShare.DIRECTION + "="
+ BluetoothShare.DIRECTION_INBOUND + " AND " + BluetoothShare.STATUS + "="
+ BluetoothShare.STATUS_RUNNING;