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

Commit e38028ce authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4473011 from 4dd2262c to pi-release

Change-Id: I5bfa5cde22cfb2e57b9b1dda70d3e2efad699c32
parents f1f387ad 4dd2262c
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.Message;
import android.os.ParcelUuid;
import android.os.RemoteException;
import android.os.UserManager;
import android.telephony.TelephonyManager;
import android.text.format.DateUtils;
import android.util.Log;

@@ -676,6 +677,24 @@ public class BluetoothMapObexServer extends ServerRequestHandler {
            // Decode the messageBody
            message = BluetoothMapbMessage.parse(bMsgStream, appParams.getCharset());
            message.setVersionString(messageVersion);
            if (D) {
                Log.d(TAG, "pushMessage: charset" + appParams.getCharset() + "folderId: "
                                + folderElement.getFolderId() + "Name: " + folderName + "TYPE: "
                                + message.getType());
            }
            if (message.getType().equals(TYPE.SMS_GSM) || message.getType().equals(TYPE.SMS_CDMA)) {
                // Convert messages to the default network type.
                TelephonyManager tm =
                        (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
                if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
                    message.setType(TYPE.SMS_GSM);
                } else if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
                    message.setType(TYPE.SMS_CDMA);
                }
                if (D) {
                    Log.d(TAG, "Updated message type: " + message.getType());
                }
            }
            // Send message
            if (mObserver == null || message == null) {
                // Should not happen except at shutdown.
+14 −8
Original line number Diff line number Diff line
@@ -266,12 +266,14 @@ public class BluetoothOppManager {
        synchronized (BluetoothOppManager.this) {
            mMultipleFlag = false;
            mMimeTypeOfSendingFile = mimeType;
            mUriOfSendingFile = uriString;
            mIsHandoverInitiated = isHandover;
            Uri uri = Uri.parse(uriString);
            BluetoothOppUtility.putSendFileInfo(uri,
            BluetoothOppSendFileInfo sendFileInfo =
                    BluetoothOppSendFileInfo.generateFileInfo(mContext, uri, mimeType,
                            fromExternal));
                    fromExternal);
            uri = BluetoothOppUtility.generateUri(uri, sendFileInfo);
            BluetoothOppUtility.putSendFileInfo(uri, sendFileInfo);
            mUriOfSendingFile = uri.toString();
            storeApplicationData();
        }
    }
@@ -281,12 +283,15 @@ public class BluetoothOppManager {
        synchronized (BluetoothOppManager.this) {
            mMultipleFlag = true;
            mMimeTypeOfSendingFiles = mimeType;
            mUrisOfSendingFiles = uris;
            mUrisOfSendingFiles = new ArrayList<Uri>();
            mIsHandoverInitiated = isHandover;
            for (Uri uri : uris) {
                BluetoothOppUtility.putSendFileInfo(uri,
                BluetoothOppSendFileInfo sendFileInfo =
                        BluetoothOppSendFileInfo.generateFileInfo(mContext, uri, mimeType,
                                fromExternal));
                        fromExternal);
                uri = BluetoothOppUtility.generateUri(uri, sendFileInfo);
                mUrisOfSendingFiles.add(uri);
                BluetoothOppUtility.putSendFileInfo(uri, sendFileInfo);
            }
            storeApplicationData();
        }
@@ -452,7 +457,10 @@ public class BluetoothOppManager {
            Long ts = System.currentTimeMillis();
            for (int i = 0; i < count; i++) {
                Uri fileUri = mUris.get(i);
                ContentValues values = new ContentValues();
                values.put(BluetoothShare.URI, fileUri.toString());
                ContentResolver contentResolver = mContext.getContentResolver();
                fileUri = BluetoothOppUtility.originalUri(fileUri);
                String contentType = contentResolver.getType(fileUri);
                if (V) {
                    Log.v(TAG, "Got mimetype: " + contentType + "  Got uri: " + fileUri);
@@ -461,8 +469,6 @@ public class BluetoothOppManager {
                    contentType = mTypeOfMultipleFiles;
                }

                ContentValues values = new ContentValues();
                values.put(BluetoothShare.URI, fileUri.toString());
                values.put(BluetoothShare.MIMETYPE, contentType);
                values.put(BluetoothShare.DESTINATION, mRemoteDevice.getAddress());
                values.put(BluetoothShare.TIMESTAMP, ts);
+8 −0
Original line number Diff line number Diff line
@@ -593,4 +593,12 @@ class BluetoothOppNotification {
        }
        cursor.close();
    }

    void cancelNotifications() {
        if (V) {
            Log.v(TAG, "cancelNotifications ");
        }
        mHandler.removeCallbacksAndMessages(null);
        mNotificationMgr.cancelAll();
    }
}
+38 −34
Original line number Diff line number Diff line
@@ -144,6 +144,22 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti

    private int mOppSdpHandle = -1;

    private static final String INVISIBLE =
            BluetoothShare.VISIBILITY + "=" + BluetoothShare.VISIBILITY_HIDDEN;

    private static final String WHERE_INBOUND_SUCCESS =
            BluetoothShare.DIRECTION + "=" + BluetoothShare.DIRECTION_INBOUND + " AND "
                    + BluetoothShare.STATUS + "=" + BluetoothShare.STATUS_SUCCESS + " AND "
                    + INVISIBLE;

    private static final String WHERE_CONFIRM_PENDING_INBOUND = BluetoothShare.DIRECTION + "="
            + BluetoothShare.DIRECTION_INBOUND + " AND " + BluetoothShare.USER_CONFIRMATION + "="
            + BluetoothShare.USER_CONFIRMATION_PENDING;

    private static final String WHERE_INVISIBLE_UNCONFIRMED = "(" + BluetoothShare.STATUS + ">="
            + BluetoothShare.STATUS_SUCCESS + " AND " + INVISIBLE + ") OR ("
            + WHERE_CONFIRM_PENDING_INBOUND + ")";

    /*
     * TODO No support for queue incoming from multiple devices.
     * Make an array list of server session to support receiving queue from
@@ -163,13 +179,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
@@ -189,7 +199,6 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
        if (V) {
            BluetoothOppPreference.getInstance(this).dump();
        }
        updateFromProvider();
    }

    @Override
@@ -197,6 +206,11 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
        if (V) {
            Log.v(TAG, "start()");
        }
        mObserver = new BluetoothShareContentObserver();
        getContentResolver().registerContentObserver(BluetoothShare.CONTENT_URI, true, mObserver);
        mNotifier = new BluetoothOppNotification(this);
        mNotifier.mNotificationMgr.cancelAll();
        mNotifier.updateNotification();
        updateFromProvider();
        return true;
    }
@@ -248,6 +262,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                        mTransfer.onBatchCanceled();
                        mTransfer = null;
                    }
                    unregisterReceivers();
                    synchronized (BluetoothOppService.this) {
                        if (mUpdateThread != null) {
                            try {
@@ -259,6 +274,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                            mUpdateThread = null;
                        }
                    }
                    mNotifier.cancelNotifications();
                    break;
                case START_LISTENER:
                    if (mAdapter.isEnabled()) {
@@ -387,8 +403,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 +416,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 " + e.toString());
        }
    }

    /* suppose we auto accept an incoming OPUSH connection */
    private void createServerSession(ObexTransport transport) {
        mServerSession = new BluetoothOppObexServerSession(this, transport, mServerSocket);
@@ -1031,35 +1057,13 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                && info.mConfirm != BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED;
    }

    private static final String INVISIBLE =
            BluetoothShare.VISIBILITY + "=" + BluetoothShare.VISIBILITY_HIDDEN;
    private static final String WHERE_INVISIBLE_COMPLETE_OUTBOUND =
            BluetoothShare.DIRECTION + "=" + BluetoothShare.DIRECTION_OUTBOUND + " AND "
                    + BluetoothShare.STATUS + ">=" + BluetoothShare.STATUS_SUCCESS + " AND "
                    + INVISIBLE;
    private static final String WHERE_INVISIBLE_COMPLETE_INBOUND_FAILED =
            BluetoothShare.DIRECTION + "=" + BluetoothShare.DIRECTION_INBOUND + " AND "
                    + BluetoothShare.STATUS + ">" + BluetoothShare.STATUS_SUCCESS + " AND "
                    + INVISIBLE;
    private static final String WHERE_INBOUND_SUCCESS =
            BluetoothShare.DIRECTION + "=" + BluetoothShare.DIRECTION_INBOUND + " AND "
                    + BluetoothShare.STATUS + "=" + BluetoothShare.STATUS_SUCCESS + " AND "
                    + INVISIBLE;

    // Run in a background thread at boot.
    private static void trimDatabase(ContentResolver contentResolver) {
        // remove the invisible/complete/outbound shares
        // remove the invisible/unconfirmed inbound shares
        int delNum = contentResolver.delete(BluetoothShare.CONTENT_URI,
                WHERE_INVISIBLE_COMPLETE_OUTBOUND, null);
        if (V) {
            Log.v(TAG, "Deleted complete outbound shares, number =  " + delNum);
        }

        // remove the invisible/finished/inbound/failed shares
        delNum = contentResolver.delete(BluetoothShare.CONTENT_URI,
                WHERE_INVISIBLE_COMPLETE_INBOUND_FAILED, null);
                WHERE_INVISIBLE_UNCONFIRMED, null);
        if (V) {
            Log.v(TAG, "Deleted complete inbound failed shares, number = " + delNum);
            Log.v(TAG, "Deleted shares, number = " + delNum);
        }

        // Only keep the inbound and successful shares for LiverFolder use
+7 −0
Original line number Diff line number Diff line
@@ -381,6 +381,13 @@ public class BluetoothOppTransferActivity extends AlertActivity
                            mTransInfo.mID);

                    // retry the failed transfer
                    Uri uri = BluetoothOppUtility.originalUri(Uri.parse(mTransInfo.mFileUri));
                    BluetoothOppSendFileInfo sendFileInfo =
                            BluetoothOppSendFileInfo.generateFileInfo(BluetoothOppTransferActivity
                            .this, uri, mTransInfo.mFileType, false);
                    uri = BluetoothOppUtility.generateUri(uri, sendFileInfo);
                    BluetoothOppUtility.putSendFileInfo(uri, sendFileInfo);
                    mTransInfo.mFileUri = uri.toString();
                    BluetoothOppUtility.retryTransfer(this, mTransInfo);

                    BluetoothDevice remoteDevice = mAdapter.getRemoteDevice(mTransInfo.mDestAddr);
Loading