diff options
author | Juffin Alex Varghese <jalex@codeaurora.org> | 2014-12-05 15:34:05 +0530 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2015-01-22 00:50:14 +0100 |
commit | 1e84e28b720178b2882b9f38a4bf832b4f260b1a (patch) | |
tree | 6bfb206f89daf55fabb72389a929755cfbbc4515 | |
parent | dda47fc26f4830eb5aa603be2f894ad0e4ccb46a (diff) | |
download | android_packages_apps_Bluetooth-1e84e28b720178b2882b9f38a4bf832b4f260b1a.tar.gz android_packages_apps_Bluetooth-1e84e28b720178b2882b9f38a4bf832b4f260b1a.tar.bz2 android_packages_apps_Bluetooth-1e84e28b720178b2882b9f38a4bf832b4f260b1a.zip |
Bluetooth-OPP: Update interrupted outbound/inbound shares status after BT turned ON
Updated interrupted outbound or inbound unconfirmed shares status to
UNKNOWN_ERROR if outbound transfer is interrupted by hardware error,
BT turned off etc.
CRs-Fixed: 768298
Change-Id: I0b12add43812fab86cb83e3b2b8e63683f8603c5
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppService.java | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppService.java b/src/com/android/bluetooth/opp/BluetoothOppService.java index 760f70c51..c6fb79ad2 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppService.java +++ b/src/com/android/bluetooth/opp/BluetoothOppService.java @@ -161,7 +161,6 @@ public class BluetoothOppService extends Service { mBatchId = 1; mNotifier = new BluetoothOppNotification(this); mNotifier.mNotificationMgr.cancelAll(); - mNotifier.updateNotification(); final ContentResolver contentResolver = getContentResolver(); new Thread("trimDatabase") { @@ -1069,18 +1068,54 @@ 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 + ContentValues updateValues; + // Update interrupted outbound share status 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); + Cursor cursorToUpdate = contentResolver.query(BluetoothShare.CONTENT_URI, null, + WHERE_OUTBOUND_INTERRUPTED_ON_POWER_OFF, null, null); + if (cursorToUpdate != null) { + for (cursorToUpdate.moveToFirst(); !cursorToUpdate.isAfterLast(); + cursorToUpdate.moveToNext()) { + updateValues = new ContentValues(); + updateValues.put(BluetoothShare.STATUS, BluetoothShare.STATUS_UNKNOWN_ERROR); + int mId = cursorToUpdate.getInt(cursorToUpdate.getColumnIndexOrThrow( + BluetoothShare._ID)); + Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + mId); + contentResolver.update(contentUri, updateValues, null, null); + } + if (V) Log.v(TAG, "Update interrupted outbound share status, number = " + + cursorToUpdate.getCount()); + cursorToUpdate.close(); + cursorToUpdate = null; + } + + // Update unconfirmed interrupted inbound shares status + final String WHERE_CONFIRMATION_PENDING_INBOUND = BluetoothShare.DIRECTION + "=" + + BluetoothShare.DIRECTION_INBOUND + " AND " + BluetoothShare.USER_CONFIRMATION + + "=" + BluetoothShare.USER_CONFIRMATION_PENDING; + + cursorToUpdate = contentResolver.query(BluetoothShare.CONTENT_URI, null, + WHERE_CONFIRMATION_PENDING_INBOUND, null, null); + + if (cursorToUpdate != null) { + if (cursorToUpdate.moveToFirst()) { + updateValues = new ContentValues(); + updateValues.put(BluetoothShare.USER_CONFIRMATION, + BluetoothShare.USER_CONFIRMATION_DENIED); + updateValues.put(BluetoothShare.STATUS, BluetoothShare.STATUS_UNKNOWN_ERROR); + int mId = cursorToUpdate.getInt(cursorToUpdate.getColumnIndexOrThrow( + BluetoothShare._ID)); + Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + mId); + contentResolver.update(contentUri, updateValues, null, null); + } + if (V) Log.v(TAG, "Update interrupted inbound share status, number = " + + cursorToUpdate.getCount()); + cursorToUpdate.close(); + cursorToUpdate = null; } final String WHERE_INBOUND_INTERRUPTED_ON_POWER_OFF = BluetoothShare.DIRECTION + "=" @@ -1107,14 +1142,6 @@ public class BluetoothOppService extends Service { cursorToFile = null; } - // on boot : remove unconfirmed inbound shares. - final String WHERE_CONFIRMATION_PENDING_INBOUND = BluetoothShare.DIRECTION + "=" - + BluetoothShare.DIRECTION_INBOUND + " AND " + BluetoothShare.USER_CONFIRMATION - + "=" + BluetoothShare.USER_CONFIRMATION_PENDING; - delNum = contentResolver.delete(BluetoothShare.CONTENT_URI, - WHERE_CONFIRMATION_PENDING_INBOUND, null); - if (V) Log.v(TAG, "Deleted unconfirmed incoming shares, number = " + delNum); - // Only keep the inbound and successful shares for LiverFolder use // Keep the latest 1000 to easy db query final String WHERE_INBOUND_SUCCESS = BluetoothShare.DIRECTION + "=" |