diff options
author | Steve Kondik <steve@cyngn.com> | 2016-10-17 21:55:54 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-10-17 21:55:54 -0700 |
commit | e93c758d9ebd245e7c5143635be755e494a23262 (patch) | |
tree | 49de13c3bca3e17db4b35c0f073cbf12ea9f1e5a | |
parent | 73f1cecb3c726e3dc1bc49bb348ca0c5472d7548 (diff) | |
parent | 0611b4c33703d8e8b1c772f56bd689031e73ccb9 (diff) | |
download | android_packages_apps_Bluetooth-cm-14.0.tar.gz android_packages_apps_Bluetooth-cm-14.0.tar.bz2 android_packages_apps_Bluetooth-cm-14.0.zip |
Merge tag 'LA.UM.5.5.r1-00900-8x96.0' of git://codeaurora.org/platform/packages/apps/Bluetooth into cm-14.0cm-14.0
"LA.UM.5.5.r1-00900-8x96.0"
15 files changed, 177 insertions, 49 deletions
diff --git a/res/values/config.xml b/res/values/config.xml index c7635bb44..dcbe20837 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -55,4 +55,8 @@ <!-- For enabling the hfp client connection service --> <bool name="hfp_client_connection_service_enabled">false</bool> + + <!-- For disabling non AOSP bluetooth features --> + <bool name="disable_non_aosp_bt_features">false</bool> + </resources> diff --git a/src/com/android/bluetooth/a2dp/A2dpStateMachine.java b/src/com/android/bluetooth/a2dp/A2dpStateMachine.java index 86a006129..8016b348c 100644 --- a/src/com/android/bluetooth/a2dp/A2dpStateMachine.java +++ b/src/com/android/bluetooth/a2dp/A2dpStateMachine.java @@ -217,7 +217,14 @@ final class A2dpStateMachine extends StateMachine { public void cleanup() { log("Enter cleanup()"); + int deviceSize = mConnectedDevicesList.size(); + log("cleanup: mConnectedDevicesList size is " + deviceSize); cleanupNative(); + for (int i = 0; i < deviceSize; i++) { + mCurrentDevice = mConnectedDevicesList.get(i); + broadcastConnectionState(mCurrentDevice, BluetoothProfile.STATE_DISCONNECTED, + BluetoothProfile.STATE_CONNECTED); + } log("Exit cleanup()"); } diff --git a/src/com/android/bluetooth/btservice/Config.java b/src/com/android/bluetooth/btservice/Config.java index 66d96d08c..3254feb01 100644 --- a/src/com/android/bluetooth/btservice/Config.java +++ b/src/com/android/bluetooth/btservice/Config.java @@ -27,7 +27,7 @@ import android.content.res.Resources; import android.os.SystemProperties; import android.provider.Settings; import android.util.Log; -import android.os.SystemProperties; + import com.android.bluetooth.R; import com.android.bluetooth.a2dp.A2dpService; diff --git a/src/com/android/bluetooth/map/BluetoothMapAppObserver.java b/src/com/android/bluetooth/map/BluetoothMapAppObserver.java index c526dc3a9..a1b78ddf6 100644 --- a/src/com/android/bluetooth/map/BluetoothMapAppObserver.java +++ b/src/com/android/bluetooth/map/BluetoothMapAppObserver.java @@ -14,6 +14,7 @@ */ package com.android.bluetooth.map; +import com.android.bluetooth.R; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -53,7 +54,7 @@ public class BluetoothMapAppObserver{ private Context mContext; private BroadcastReceiver mReceiver; private PackageManager mPackageManager = null; - BluetoothMapAccountEmailLoader mLoader; + BluetoothMapAccountLoader mLoader; BluetoothMapService mMapService = null; private boolean mRegisteredReceiver = false; @@ -61,7 +62,14 @@ public class BluetoothMapAppObserver{ mContext = context; mMapService = mapService; mResolver = context.getContentResolver(); - mLoader = new BluetoothMapAccountEmailLoader(mContext); + boolean isDisabledNonAosp = context.getResources().getBoolean + (R.bool.disable_non_aosp_bt_features); + if (D) Log.d(TAG, "isDisabledNonAosp :" + isDisabledNonAosp); + if (isDisabledNonAosp) { + mLoader = new BluetoothMapAccountLoader(mContext); + } else { + mLoader = new BluetoothMapAccountEmailLoader(mContext); + } mFullList = mLoader.parsePackages(false); /* Get the current list of apps */ createReceiver(); initObservers(); diff --git a/src/com/android/bluetooth/map/BluetoothMapContentEmail.java b/src/com/android/bluetooth/map/BluetoothMapContentEmail.java index 8e5204ec0..495b73807 100644..100755 --- a/src/com/android/bluetooth/map/BluetoothMapContentEmail.java +++ b/src/com/android/bluetooth/map/BluetoothMapContentEmail.java @@ -121,6 +121,7 @@ public class BluetoothMapContentEmail extends BluetoothMapContent { /* The MasInstance reference is used to update persistent (over a connection) version counters*/ private final BluetoothMapMasInstance mMasInstance; private String mMessageVersion = BluetoothMapUtils.MAP_V10_STR; + private final boolean EMAIL_ATTACHMENT_IMPLEMENTED = false; private int mRemoteFeatureMask = BluetoothMapUtils.MAP_FEATURE_DEFAULT_BITMASK; private int mMsgListingVersion = BluetoothMapUtils.MAP_MESSAGE_LISTING_FORMAT_V10; @@ -1719,7 +1720,7 @@ public class BluetoothMapContentEmail extends BluetoothMapContent { message.setEmailBody(emailBody); //Parts Long partId = c.getLong(c.getColumnIndex(BaseColumns._ID)); - String contentType = "Content-Type: text/plain; charset=\"UTF-8\""; + String contentType = " text/plain; charset=\"UTF-8\""; String name = null;//c.getString(c.getColumnIndex("displayName")); String text = null; @@ -1820,7 +1821,7 @@ public class BluetoothMapContentEmail extends BluetoothMapContent { // Set message type: message.setType(TYPE.EMAIL); message.setVersionString(mMessageVersion); - message.setContentType("Content-Type: text/plain; charset=\"UTF-8\""); + message.setContentType(" text/plain; charset=\"UTF-8\""); message.setDate(c.getLong(c.getColumnIndex(BluetoothMapEmailContract .ExtEmailMessageColumns.TIMESTAMP))); message.setSubject(c.getString(c.getColumnIndex(BluetoothMapContract @@ -1868,10 +1869,12 @@ public class BluetoothMapContentEmail extends BluetoothMapContent { if(c != null) c.close(); } // Find out if we get attachments - //TODO: Attachment Support needs fetch from Attachment content Uri + /* TODO: Attachment yet to be supported: Needs fetch from Attachment content Uri. + Hence, mark attachment support false always for now. // String attStr = (appParams.getAttachment() == 0) ? // "/" + BluetoothMapContract.FILE_MSG_NO_ATTACHMENTS : ""; - message.setIncludeAttachments(appParams.getAttachment() == 0 ? false : true); + */ + message.setIncludeAttachments(EMAIL_ATTACHMENT_IMPLEMENTED); // The parts extractEmailParts(id, message); diff --git a/src/com/android/bluetooth/map/BluetoothMapbMessageExtEmail.java b/src/com/android/bluetooth/map/BluetoothMapbMessageExtEmail.java index 6f2230383..19f9eb186 100644..100755 --- a/src/com/android/bluetooth/map/BluetoothMapbMessageExtEmail.java +++ b/src/com/android/bluetooth/map/BluetoothMapbMessageExtEmail.java @@ -198,6 +198,61 @@ public class BluetoothMapbMessageExtEmail extends BluetoothMapbMessageMime { Log.v(TAG, "fetch body Email NULL:"); } + public void encodeEmailHeaders(StringBuilder sb) throws UnsupportedEncodingException { + /* TODO: From RFC-4356 - about the RFC-(2)822 headers: + * "Current Internet Message format requires that only 7-bit US-ASCII + * characters be present in headers. Non-7-bit characters in an address + * domain must be encoded with [IDN]. If there are any non-7-bit + * characters in the local part of an address, the message MUST be + * rejected. Non-7-bit characters elsewhere in a header MUST be encoded + * according to [Hdr-Enc]." + * We need to add the address encoding in encodeHeaderAddresses, but it is not + * straight forward, as it is unclear how to do this. */ + if (getDate() != INVALID_VALUE) + sb.append("Date: ").append(getDateString()).append("\r\n"); + /* According to RFC-2822 headers must use US-ASCII, where the MAP specification states + * UTF-8 should be used for the entire <bmessage-body-content>. We let the MAP specification + * take precedence above the RFC-2822. + */ + if (getSubject() != null) + sb.append("Subject: ").append(getSubject()).append("\r\n"); + if (getFrom() == null) + sb.append("From: \r\n"); + if (getFrom() != null) + encodeHeaderAddresses(sb, "From: ", getFrom()); // This includes folding if needed. + if (getSender() != null) + encodeHeaderAddresses(sb, "Sender: ", getSender()); // This includes folding if needed. + /* For MMS one recipient(to, cc or bcc) must exists, if none: 'To: undisclosed- + * recipients:;' could be used. + */ + if (getTo() == null && getCc() == null && getBcc() == null) + sb.append("To: undisclosed-recipients:;\r\n"); + if (getTo() != null) + encodeHeaderAddresses(sb, "To: ", getTo()); // This includes folding if needed. + if (getCc() != null) + encodeHeaderAddresses(sb, "Cc: ", getCc()); // This includes folding if needed. + if (getBcc() != null) + encodeHeaderAddresses(sb, "Bcc: ", getBcc()); // This includes folding if needed. + if (getReplyTo() != null) // This includes folding if needed. + encodeHeaderAddresses(sb, "Reply-To: ", getReplyTo()); + if (getIncludeAttachments() == true) { + if (getMessageId() != null) + sb.append("Message-Id: ").append(getMessageId()).append("\r\n"); + if (getContentType() != null) + sb.append("Content-Type: ").append(getContentType()) + .append("; boundary=").append(getBoundary()).append("\r\n"); + } else { + // Attachment fetaure not supported . Append below MIME Headers. + sb.append("Mime-Version: 1.0").append("\r\n"); + sb.append( + "Content-Type: multipart/mixed; boundary=\""+ getBoundary() + "\"") + .append("\r\n"); + sb.append("Content-Transfer-Encoding: 8bit").append("\r\n"); + } + // If no headers exists, we still need two CRLF, hence keep it out of the if above. + sb.append("\r\n"); + } + public byte[] encodeEmail() throws UnsupportedEncodingException { if (V) Log.v(TAG, "Inside encodeEmail "); @@ -205,18 +260,9 @@ public class BluetoothMapbMessageExtEmail extends BluetoothMapbMessageMime { StringBuilder sb = new StringBuilder (); int count = 0; String emailBody; - Random randomGenerator = new Random(); - int randomInt = randomGenerator.nextInt(1000); - String boundary = "MessageBoundary."+randomInt; - encodeHeaders(sb); - sb.append("Mime-Version: 1.0").append("\r\n"); - sb.append( - "Content-Type: multipart/mixed; boundary=\""+boundary+"\"") - .append("\r\n"); - sb.append("Content-Transfer-Encoding: 8bit").append("\r\n") - .append("\r\n"); + encodeEmailHeaders(sb); sb.append("MIME Message").append("\r\n"); - sb.append("--"+boundary).append("\r\n"); + sb.append("--" + getBoundary()).append("\r\n"); Log.v(TAG, "after encode header sb is "+ sb.toString()); if (parts != null) { if (getIncludeAttachments() == false) { @@ -224,7 +270,7 @@ public class BluetoothMapbMessageExtEmail extends BluetoothMapbMessageMime { /* We call encode on all parts, to include a tag, * where an attachment is missing. */ part.encodePlainText(sb); - sb.append("--"+boundary+"--").append("\r\n"); + sb.append("--" + getBoundary() + "--").append("\r\n"); } } else { for (MimePart part : parts) { diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java index 308df6f78..4517ec8ef 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java +++ b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java @@ -101,7 +101,7 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen boolean mTransferInProgress = false; - private int position; + private long position; public BluetoothOppObexServerSession(Context context, ObexTransport transport) { mContext = context; diff --git a/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java b/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java index f8622620a..2a9cadb8b 100755..100644 --- a/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java +++ b/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java @@ -231,8 +231,9 @@ public class BluetoothOppSendFileInfo { private static long getStreamSize(FileInputStream is) throws IOException { long length = 0; byte unused[] = new byte[4096]; - while (is.available() > 0) { - length += is.read(unused, 0, 4096); + int bytesRead = -1; + while ((bytesRead = is.read(unused, 0, 4096)) != -1) { + length += bytesRead; } return length; } diff --git a/src/com/android/bluetooth/opp/BluetoothOppService.java b/src/com/android/bluetooth/opp/BluetoothOppService.java index 611d8b226..8c10ab7e9 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppService.java +++ b/src/com/android/bluetooth/opp/BluetoothOppService.java @@ -32,6 +32,7 @@ package com.android.bluetooth.opp; +import com.android.bluetooth.R; import com.google.android.collect.Lists; import javax.obex.ObexTransport; @@ -381,9 +382,18 @@ public class BluetoothOppService extends Service { if ( ( mSocketListener.openRfcommSocket() != null) && ( mL2cSocketListener.openL2capSocket() != null) && SdpManager.getDefaultManager() != null) { - mOppSdpHandle = SdpManager.getDefaultManager() - .createOppOpsRecord("OBEX Object Push", mSocketListener.getRfcommChannel(), - mL2cSocketListener.getL2capPsm(), 0x0102, SdpManager.OPP_FORMAT_ALL); + boolean isDisabledNonAosp = getResources().getBoolean + (R.bool.disable_non_aosp_bt_features); + if (D) Log.d(TAG, "isDisabledNonAosp :" + isDisabledNonAosp); + if (isDisabledNonAosp) { + mOppSdpHandle = SdpManager.getDefaultManager().createOppOpsRecord + ("OBEX Object Push",mSocketListener.getRfcommChannel(), + -1, 0x0101, SdpManager.OPP_FORMAT); + } else { + mOppSdpHandle = SdpManager.getDefaultManager().createOppOpsRecord( + "OBEX Object Push",mSocketListener.getRfcommChannel(), + mL2cSocketListener.getL2capPsm(), 0x0102,SdpManager.OPP_FORMAT); + } mSocketListener.start(mHandler); mL2cSocketListener.start(mHandler); } else { diff --git a/src/com/android/bluetooth/opp/BluetoothOppTransfer.java b/src/com/android/bluetooth/opp/BluetoothOppTransfer.java index 4dcbb09c3..d74cbd67b 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppTransfer.java +++ b/src/com/android/bluetooth/opp/BluetoothOppTransfer.java @@ -32,6 +32,7 @@ package com.android.bluetooth.opp; +import com.android.bluetooth.R; import javax.obex.ObexTransport; import com.android.bluetooth.BluetoothObexTransport; @@ -565,7 +566,10 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch mConnectThread.start(); } else { OolConnManager.setSdpInitiatedAddress(mBatch.mDestination); - if (!mBatch.mDestination.sdpSearch(BluetoothUuid.ObexObjectPush)) { + boolean isDisabledNonAosp = mContext.getResources().getBoolean + (R.bool.disable_non_aosp_bt_features); + if (D) Log.d(TAG, "isDisabledNonAosp :" + isDisabledNonAosp); + if (isDisabledNonAosp || !mBatch.mDestination.sdpSearch(BluetoothUuid.ObexObjectPush)) { /* SDP failed, start rfcomm connect directly */ mConnectThread = new SocketConnectThread(mBatch.mDestination, false, false); /* update bd address as sdp could not be started */ diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java b/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java index 8462291bd..0a78e67ec 100644 --- a/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java +++ b/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java @@ -32,6 +32,7 @@ package com.android.bluetooth.pbap; +import com.android.bluetooth.R; import android.content.Context; import android.content.ContentResolver; import android.database.Cursor; @@ -181,6 +182,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { public static boolean sIsAborted = false; + private boolean isDisabledNonAosp = false; + private long mDatabaseIdentifierLow = INVALID_VALUE_PARAMETER; private long mDatabaseIdentifierHigh = INVALID_VALUE_PARAMETER; AppParamValue connAppParamValue; @@ -205,13 +208,17 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { mContext = context; mService = service; mVcardManager = new BluetoothPbapVcardManager(mContext); + isDisabledNonAosp = mContext.getResources().getBoolean(R.bool.disable_non_aosp_bt_features); + if (D) Log.d(TAG, "isDisabledNonAosp :" + isDisabledNonAosp); + } @Override public int onConnect(final HeaderSet request, HeaderSet reply) { if (V) logHeader(request); notifyUpdateWakeLock(); - resetFolderVersionCounters(); + if (!isDisabledNonAosp) + resetFolderVersionCounters(); try { byte[] uuid = (byte[])request.getHeader(HeaderSet.TARGET); if (uuid == null) { @@ -396,6 +403,12 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { validName = false; } + if (isDisabledNonAosp && ((mCurrentPath.contains("SIM") || + (validName && name.contains("SIM"))))) { + if (D) Log.d(TAG, "SIM support disabled "); + return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE; + } + if (!validName || (validName && type.equals(TYPE_VCARD))) { if (D) Log.d(TAG, "Guess what carkit actually want from current path (" + mCurrentPath + ")"); @@ -494,7 +507,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } // down load phone book request else if (type.equals(TYPE_PB)) { - if (mVcardSelector) + if (!isDisabledNonAosp && mVcardSelector) return pullSelectedPhonebook(appParam, appParamValue, reply, op, name); else return pullPhonebook(appParam, appParamValue, reply, op, name); @@ -509,11 +522,9 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { ByteBuffer pvc = ByteBuffer.allocate(16); pvc.putLong(primaryVcMsb); - Log.d(TAG,"BluetoothPbapService.primaryVersionCounter is "+ - BluetoothPbapService.primaryVersionCounter); - - updatePBSecondaryFolderVersion( + Log.d(TAG,"BluetoothPbapService.primaryVersionCounter is " + BluetoothPbapService.primaryVersionCounter); + updatePBSecondaryFolderVersion(BluetoothPbapService.primaryVersionCounter); pvc.putLong(BluetoothPbapService.primaryVersionCounter); return pvc.array(); } @@ -833,10 +844,10 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { ArrayList<String> nameList = null; ArrayList<String> selectedNameList = new ArrayList<String>(); //check if current request is for SIM - if(SIM) { + if (SIM) { nameList = mVcardManager.getSIMPhonebookNameList(mOrderBy); - }else{ - if (mVcardSelector) + } else { + if (!isDisabledNonAosp && mVcardSelector) nameList = mVcardManager.getSelectedPhonebookNameList(mOrderBy, vcard21, needSendBody, size, vCardSelector, vCardSelectorOperator); else @@ -1021,7 +1032,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { reply.setHeader(HeaderSet.APPLICATION_PARAMETER, ap.getAPPparam()); } - if (mNeedSendPhonebookVersionCounters){ + if (!isDisabledNonAosp && mNeedSendPhonebookVersionCounters) { mNeedSendPhonebookVersionCounters = false; ap.addAPPHeader(ApplicationParameter.TRIPLET_TAGID.PRIMARYVERSIONCOUNTER_TAGID, ApplicationParameter.TRIPLET_LENGTH.PRIMARYVERSIONCOUNTER_LENGTH, @@ -1094,7 +1105,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } } - if (checkPbapFeatureSupport(DatabaseIdentifierBit)) { + if (!isDisabledNonAosp && checkPbapFeatureSupport(DatabaseIdentifierBit)) { ap.addAPPHeader(ApplicationParameter.TRIPLET_TAGID.DATABASEIDENTIFIER_TAGID, ApplicationParameter.TRIPLET_LENGTH.DATABASEIDENTIFIER_LENGTH, getDatabaseIdentifier()); @@ -1107,7 +1118,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } } - if (mNeedSendPhonebookVersionCounters){ + if (!isDisabledNonAosp && mNeedSendPhonebookVersionCounters) { mNeedSendPhonebookVersionCounters = false; ap.addAPPHeader(ApplicationParameter.TRIPLET_TAGID.PRIMARYVERSIONCOUNTER_TAGID, ApplicationParameter.TRIPLET_LENGTH.PRIMARYVERSIONCOUNTER_LENGTH, @@ -1271,8 +1282,9 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { // For others (ich/och/cch/mch), 0.vcf is meaningless, and must // begin from 1.vcf if (intIndex >= 1) { - return mVcardManager.composeAndSendCallLogVcards(appParamValue.needTag, op, intIndex, - intIndex, vcard21, appParamValue.ignorefilter, appParamValue.propertySelector); + return mVcardManager.composeAndSendCallLogVcards(appParamValue.needTag, op, + intIndex, intIndex, vcard21, appParamValue.ignorefilter, + appParamValue.propertySelector); } } return ResponseCodes.OBEX_HTTP_OK; diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapService.java b/src/com/android/bluetooth/pbap/BluetoothPbapService.java index acbf823dd..8c8d677fe 100644 --- a/src/com/android/bluetooth/pbap/BluetoothPbapService.java +++ b/src/com/android/bluetooth/pbap/BluetoothPbapService.java @@ -166,6 +166,12 @@ public class BluetoothPbapService extends Service implements IObexConnectionHand private static final int NOTIFICATION_ID_AUTH = -1000002; + private static final int SDP_PBAP_AOSP_SERVER_VERSION = 0x0101; + + private static final int SDP_PBAP_AOSP_SUPPORTED_REPOSITORIES = 0x0001; + + private static final int SDP_PBAP_AOSP_SUPPORTED_FEATURES = 0x0003; + private PowerManager.WakeLock mWakeLock = null; private BluetoothAdapter mAdapter; @@ -484,14 +490,25 @@ public class BluetoothPbapService extends Service implements IObexConnectionHand mSdpHandle = -1; } if (SdpManager.getDefaultManager() != null) { - mSdpHandle = SdpManager.getDefaultManager().createPbapPseRecord( - "OBEX Phonebook Access Server", mServerSockets.getRfcommChannel(), - mServerSockets.getL2capPsm(), SDP_PBAP_SERVER_VERSION, + boolean isDisabledNonAosp = getResources().getBoolean + (R.bool.disable_non_aosp_bt_features); + if (DEBUG) Log.d(TAG, "isDisabledNonAosp :" + isDisabledNonAosp); + if (isDisabledNonAosp) { + mSdpHandle = SdpManager.getDefaultManager().createPbapPseRecord + ("OBEX Phonebook Access Server",mServerSockets.getRfcommChannel(), + -1, SDP_PBAP_AOSP_SERVER_VERSION, SDP_PBAP_AOSP_SUPPORTED_REPOSITORIES, + SDP_PBAP_AOSP_SUPPORTED_FEATURES); + } else { + mSdpHandle = SdpManager.getDefaultManager().createPbapPseRecord + ("OBEX Phonebook Access Server",mServerSockets.getRfcommChannel(), + mServerSockets.getL2capPsm(), SDP_PBAP_SERVER_VERSION, SDP_PBAP_SUPPORTED_REPOSITORIES, SDP_PBAP_SUPPORTED_FEATURES); + // Here we might have changed crucial data, hence reset DB + // identifier + updateDbIdentifier(); + } } - // Here we might have changed crucial data, hence reset DB identifier - updateDbIdentifier(); if(DEBUG) Log.d(TAG, "Creating new SDP record for PBAP server with handle: " + mSdpHandle); } } diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java b/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java index 9c9e3feb5..721a886d5 100644 --- a/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java +++ b/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java @@ -80,6 +80,8 @@ public class BluetoothPbapVcardManager { private ContentResolver mResolver; + private boolean isDisabledNonAosp = false; + private Context mContext; static final String[] PHONES_PROJECTION = new String[] { @@ -128,6 +130,7 @@ public class BluetoothPbapVcardManager { public BluetoothPbapVcardManager(final Context context) { mContext = context; + isDisabledNonAosp = mContext.getResources().getBoolean(R.bool.disable_non_aosp_bt_features); mResolver = mContext.getContentResolver(); LAST_FETCHED_TIME_STAMP = System.currentTimeMillis(); } @@ -759,7 +762,7 @@ public class BluetoothPbapVcardManager { } } - if (vcardselect) + if (!isDisabledNonAosp && vcardselect) return composeContactsAndSendSelectedVCards(op, contactIdCursor, vcardType21, ownerVCard, needSendBody, pbSize, ignorefilter, filter, vcardselector, vcardselectorop); @@ -767,6 +770,7 @@ public class BluetoothPbapVcardManager { return composeContactsAndSendVCards(op, contactIdCursor, vcardType21, ownerVCard, ignorefilter, filter); } + public final int composeAndSendSIMPhonebookVcards(Operation op, final int startPoint, final int endPoint, final boolean vcardType21, String ownerVCard) { if (startPoint < 1 || startPoint > endPoint) { diff --git a/src/com/android/bluetooth/sap/SapService.java b/src/com/android/bluetooth/sap/SapService.java index d6fab3232..02927d897 100755..100644 --- a/src/com/android/bluetooth/sap/SapService.java +++ b/src/com/android/bluetooth/sap/SapService.java @@ -417,8 +417,12 @@ public class SapService extends ProfileService { + sRemoteDeviceName); } else { - // Assuming reject is the stored state - continue to accept new connection. - continue; + // Close RFCOMM socket for current connection and start + // listening again for new connections. + Log.w(TAG, "Can't connect with " + sRemoteDeviceName + + " as access is rejected"); + if (mSessionStatusHandler != null) + mSessionStatusHandler.sendEmptyMessage(MSG_SERVERSESSION_CLOSE); } stopped = true; // job done ,close this thread; } catch (IOException ex) { @@ -793,7 +797,8 @@ public class SapService extends ProfileService { BluetoothDevice.ACCESS_ALLOWED); if (VERBOSE) { Log.v(TAG, "setSimAccessPermission(ACCESS_ALLOWED) result=" + result); - } } + } + } try { if (mConnSocket != null) { // start obex server and rfcomm connection diff --git a/src/com/android/bluetooth/sdp/SdpManager.java b/src/com/android/bluetooth/sdp/SdpManager.java index 365c1c3e6..86823a027 100644 --- a/src/com/android/bluetooth/sdp/SdpManager.java +++ b/src/com/android/bluetooth/sdp/SdpManager.java @@ -70,6 +70,13 @@ public class SdpManager { OPP_FORMAT_VMESSAGE, OPP_FORMAT_ANY_TYPE_OF_OBJ}; + public static final byte[] OPP_FORMAT= { + OPP_FORMAT_VCARD21, + OPP_FORMAT_VCARD30, + OPP_FORMAT_ICAL20, + OPP_FORMAT_ANY_TYPE_OF_OBJ}; + + /* Variables to keep track of ongoing and queued search requests. * mTrackerLock must be held, when using/changing sSdpSearchTracker * and mSearchInProgress. */ |