Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14cde36c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "OPP: Clear all BT Notification while switching off BT"

parents 929ae14a f8b345fb
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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);
@@ -593,4 +592,10 @@ class BluetoothOppNotification {
        }
        cursor.close();
    }

    void cancelNotifications() {
        if (V) Log.v(TAG, "cancelNotifications ");
        mHandler.removeCallbacksAndMessages(null);
        mNotificationMgr.cancelAll();
    }
}
+28 −8
Original line number Diff line number Diff line
@@ -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
@@ -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;
    }
@@ -248,6 +248,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                        mTransfer.onBatchCanceled();
                        mTransfer = null;
                    }
                    unregisterReceivers();
                    synchronized (BluetoothOppService.this) {
                        if (mUpdateThread != null) {
                            try {
@@ -259,6 +260,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                            mUpdateThread = null;
                        }
                    }
                    mNotifier.cancelNotifications();
                    break;
                case START_LISTENER:
                    if (mAdapter.isEnabled()) {
@@ -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();
@@ -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);
@@ -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[]{