summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorSravan Kumar V <sravankumar@codeaurora.org>2016-07-19 17:28:46 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2016-09-15 06:09:10 -0700
commit96a55efb0edac3c2af523f938b338dd16d4f8ac4 (patch)
tree8428b6f808f92e5db8f27dae0489e0266e6d29ee /src/com/android
parentee8eae967a8db87eb6b505c2a28bfa89fda656f4 (diff)
downloadandroid_packages_apps_Bluetooth-96a55efb0edac3c2af523f938b338dd16d4f8ac4.tar.gz
android_packages_apps_Bluetooth-96a55efb0edac3c2af523f938b338dd16d4f8ac4.tar.bz2
android_packages_apps_Bluetooth-96a55efb0edac3c2af523f938b338dd16d4f8ac4.zip
Bluetooth: Disable NON-AOSP BT DATA Features
Disable NON-AOSP bluetooth data related features from resource configuration values If disable_non_aosp_bt_features is set as true in config.xml following NON-AOSP features would be disabled OPP-1.2 MAP-EMAIL PBAP-1.2 PBAP-SIM disable_non_aosp_bt_features is set to false by default. It can be configured as per need. Change-Id: I4c5924bd7c94407342c6da83869eaa8da905605d CRs-Fixed: 1064006
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/bluetooth/btservice/Config.java2
-rw-r--r--src/com/android/bluetooth/map/BluetoothMapAppObserver.java12
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppService.java16
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppTransfer.java6
-rw-r--r--src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java40
-rw-r--r--src/com/android/bluetooth/pbap/BluetoothPbapService.java27
-rw-r--r--src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java6
7 files changed, 82 insertions, 27 deletions
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/opp/BluetoothOppService.java b/src/com/android/bluetooth/opp/BluetoothOppService.java
index 611d8b226..4051b4226 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_ALL);
+ } else {
+ mOppSdpHandle = SdpManager.getDefaultManager().createOppOpsRecord(
+ "OBEX Object Push",mSocketListener.getRfcommChannel(),
+ mL2cSocketListener.getL2capPsm(), 0x0102,SdpManager.OPP_FORMAT_ALL);
+ }
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) {