Loading android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java +6 −1 Original line number Diff line number Diff line Loading @@ -545,7 +545,6 @@ class BluetoothOppNotification { if (cursor == null) { return; } for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { BluetoothOppTransferInfo info = new BluetoothOppTransferInfo(); BluetoothOppUtility.fillRecord(mContext, cursor, info); Loading Loading @@ -593,4 +592,10 @@ class BluetoothOppNotification { } cursor.close(); } void cancelNotifications() { if (V) Log.v(TAG, "cancelNotifications "); mHandler.removeCallbacksAndMessages(null); mNotificationMgr.cancelAll(); } } android/app/src/com/android/bluetooth/opp/BluetoothOppService.java +28 −8 Original line number Diff line number Diff line Loading @@ -163,13 +163,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti } mShares = Lists.newArrayList(); mBatchs = Lists.newArrayList(); mObserver = new BluetoothShareContentObserver(); getContentResolver().registerContentObserver(BluetoothShare.CONTENT_URI, true, mObserver); mBatchId = 1; mNotifier = new BluetoothOppNotification(this); mNotifier.mNotificationMgr.cancelAll(); mNotifier.updateNotification(); final ContentResolver contentResolver = getContentResolver(); new Thread("trimDatabase") { @Override Loading Loading @@ -197,6 +191,12 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti if (V) { Log.v(TAG, "start()"); } /* Register observer during BT on */ mObserver = new BluetoothShareContentObserver(); getContentResolver().registerContentObserver(BluetoothShare.CONTENT_URI, true, mObserver); mNotifier = new BluetoothOppNotification(this); mNotifier.mNotificationMgr.cancelAll(); mNotifier.updateNotification(); updateFromProvider(); return true; } Loading Loading @@ -248,6 +248,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti mTransfer.onBatchCanceled(); mTransfer = null; } unregisterReceivers(); synchronized (BluetoothOppService.this) { if (mUpdateThread != null) { try { Loading @@ -259,6 +260,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti mUpdateThread = null; } } mNotifier.cancelNotifications(); break; case START_LISTENER: if (mAdapter.isEnabled()) { Loading Loading @@ -387,8 +389,6 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti if (V) { Log.v(TAG, "onDestroy"); } getContentResolver().unregisterContentObserver(mObserver); unregisterReceiver(mBluetoothReceiver); stopListeners(); if (mBatchs != null) { mBatchs.clear(); Loading @@ -402,6 +402,18 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti return true; } private void unregisterReceivers() { try { if (mObserver != null) { getContentResolver().unregisterContentObserver(mObserver); mObserver = null; } unregisterReceiver(mBluetoothReceiver); } catch (IllegalArgumentException e) { Log.w(TAG, "unregisterReceivers already " + e.toString()); } } /* suppose we auto accept an incoming OPUSH connection */ private void createServerSession(ObexTransport transport) { mServerSession = new BluetoothOppObexServerSession(this, transport, mServerSocket); Loading Loading @@ -1062,6 +1074,14 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti Log.v(TAG, "Deleted complete inbound failed shares, number = " + delNum); } // remove unconfirmed inbound shares. final String whereConfirmationPendingInbound = BluetoothShare.DIRECTION + "=" + BluetoothShare.DIRECTION_INBOUND + " AND " + BluetoothShare.USER_CONFIRMATION + "=" + BluetoothShare.USER_CONFIRMATION_PENDING; delNum = contentResolver.delete( BluetoothShare.CONTENT_URI, whereConfirmationPendingInbound, 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 Cursor cursor = contentResolver.query(BluetoothShare.CONTENT_URI, new String[]{ Loading Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java +6 −1 Original line number Diff line number Diff line Loading @@ -545,7 +545,6 @@ class BluetoothOppNotification { if (cursor == null) { return; } for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { BluetoothOppTransferInfo info = new BluetoothOppTransferInfo(); BluetoothOppUtility.fillRecord(mContext, cursor, info); Loading Loading @@ -593,4 +592,10 @@ class BluetoothOppNotification { } cursor.close(); } void cancelNotifications() { if (V) Log.v(TAG, "cancelNotifications "); mHandler.removeCallbacksAndMessages(null); mNotificationMgr.cancelAll(); } }
android/app/src/com/android/bluetooth/opp/BluetoothOppService.java +28 −8 Original line number Diff line number Diff line Loading @@ -163,13 +163,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti } mShares = Lists.newArrayList(); mBatchs = Lists.newArrayList(); mObserver = new BluetoothShareContentObserver(); getContentResolver().registerContentObserver(BluetoothShare.CONTENT_URI, true, mObserver); mBatchId = 1; mNotifier = new BluetoothOppNotification(this); mNotifier.mNotificationMgr.cancelAll(); mNotifier.updateNotification(); final ContentResolver contentResolver = getContentResolver(); new Thread("trimDatabase") { @Override Loading Loading @@ -197,6 +191,12 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti if (V) { Log.v(TAG, "start()"); } /* Register observer during BT on */ mObserver = new BluetoothShareContentObserver(); getContentResolver().registerContentObserver(BluetoothShare.CONTENT_URI, true, mObserver); mNotifier = new BluetoothOppNotification(this); mNotifier.mNotificationMgr.cancelAll(); mNotifier.updateNotification(); updateFromProvider(); return true; } Loading Loading @@ -248,6 +248,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti mTransfer.onBatchCanceled(); mTransfer = null; } unregisterReceivers(); synchronized (BluetoothOppService.this) { if (mUpdateThread != null) { try { Loading @@ -259,6 +260,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti mUpdateThread = null; } } mNotifier.cancelNotifications(); break; case START_LISTENER: if (mAdapter.isEnabled()) { Loading Loading @@ -387,8 +389,6 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti if (V) { Log.v(TAG, "onDestroy"); } getContentResolver().unregisterContentObserver(mObserver); unregisterReceiver(mBluetoothReceiver); stopListeners(); if (mBatchs != null) { mBatchs.clear(); Loading @@ -402,6 +402,18 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti return true; } private void unregisterReceivers() { try { if (mObserver != null) { getContentResolver().unregisterContentObserver(mObserver); mObserver = null; } unregisterReceiver(mBluetoothReceiver); } catch (IllegalArgumentException e) { Log.w(TAG, "unregisterReceivers already " + e.toString()); } } /* suppose we auto accept an incoming OPUSH connection */ private void createServerSession(ObexTransport transport) { mServerSession = new BluetoothOppObexServerSession(this, transport, mServerSocket); Loading Loading @@ -1062,6 +1074,14 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti Log.v(TAG, "Deleted complete inbound failed shares, number = " + delNum); } // remove unconfirmed inbound shares. final String whereConfirmationPendingInbound = BluetoothShare.DIRECTION + "=" + BluetoothShare.DIRECTION_INBOUND + " AND " + BluetoothShare.USER_CONFIRMATION + "=" + BluetoothShare.USER_CONFIRMATION_PENDING; delNum = contentResolver.delete( BluetoothShare.CONTENT_URI, whereConfirmationPendingInbound, 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 Cursor cursor = contentResolver.query(BluetoothShare.CONTENT_URI, new String[]{ Loading