summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHemant Gupta <hemantg@codeaurora.org>2014-11-18 22:49:13 +0530
committerArne Coucheron <arco68@gmail.com>2015-01-22 00:50:31 +0100
commit02bf7ae9826a355db8614d1aad4f04bb5d6509ab (patch)
tree8c4be425da5b12c08e3abf7a141a9bc4747212b7
parent1e84e28b720178b2882b9f38a4bf832b4f260b1a (diff)
downloadandroid_packages_apps_Bluetooth-02bf7ae9826a355db8614d1aad4f04bb5d6509ab.tar.gz
android_packages_apps_Bluetooth-02bf7ae9826a355db8614d1aad4f04bb5d6509ab.tar.bz2
android_packages_apps_Bluetooth-02bf7ae9826a355db8614d1aad4f04bb5d6509ab.zip
PBAP: Add support for handling connection state
This patch adds support for updating connection state for pbap server on settings UI. A new flag is added to allow settings sub menu to show pbap preference only when remote device has intiaited pbap request and not for all devices for which user has started/accepted pairing request from remote device. Change-Id: I3ba777a6be4a6321a260739b9a87a8c6054a74d3 CRs-Fixed: 758697
-rwxr-xr-xsrc/com/android/bluetooth/btservice/AdapterService.java5
-rw-r--r--src/com/android/bluetooth/map/BluetoothMapService.java2
-rw-r--r--src/com/android/bluetooth/pbap/BluetoothPbapService.java16
3 files changed, 14 insertions, 9 deletions
diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java
index 524d16a74..44f2cf844 100755
--- a/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/src/com/android/bluetooth/btservice/AdapterService.java
@@ -1768,8 +1768,7 @@ public class AdapterService extends Service {
if (!pref.contains(device.getAddress())) {
return BluetoothDevice.ACCESS_UNKNOWN;
}
- return pref.getBoolean(device.getAddress(), false)
- ? BluetoothDevice.ACCESS_ALLOWED : BluetoothDevice.ACCESS_REJECTED;
+ return pref.getInt(device.getAddress(), BluetoothDevice.ACCESS_UNKNOWN);
}
boolean setPhonebookAccessPermission(BluetoothDevice device, int value) {
@@ -1781,7 +1780,7 @@ public class AdapterService extends Service {
if (value == BluetoothDevice.ACCESS_UNKNOWN) {
editor.remove(device.getAddress());
} else {
- editor.putBoolean(device.getAddress(), value == BluetoothDevice.ACCESS_ALLOWED);
+ editor.putInt(device.getAddress(), value);
}
return editor.commit();
}
diff --git a/src/com/android/bluetooth/map/BluetoothMapService.java b/src/com/android/bluetooth/map/BluetoothMapService.java
index 413cd51d1..7582766b1 100644
--- a/src/com/android/bluetooth/map/BluetoothMapService.java
+++ b/src/com/android/bluetooth/map/BluetoothMapService.java
@@ -1029,7 +1029,7 @@ public class BluetoothMapService extends ProfileService {
}
} else if (action.equals(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY)) {
int requestType = intent.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
- BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS);
+ BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS);
if (DEBUG) Log.d(TAG, "Received ACTION_CONNECTION_ACCESS_REPLY:" +
requestType + "isWaitingAuthorization:" + isWaitingAuthorization);
if ((!isWaitingAuthorization) ||
diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapService.java b/src/com/android/bluetooth/pbap/BluetoothPbapService.java
index f0f42337f..62787b4fe 100644
--- a/src/com/android/bluetooth/pbap/BluetoothPbapService.java
+++ b/src/com/android/bluetooth/pbap/BluetoothPbapService.java
@@ -178,6 +178,9 @@ public class BluetoothPbapService extends Service {
private int mStartId = -1;
+ // PBAP Client has sent pbap connection request
+ private final static int PBAP_CONNECT_RECEIVED = 3;
+
//private IBluetooth mBluetoothService;
private boolean mIsWaitingAuthorization = false;
@@ -295,9 +298,9 @@ public class BluetoothPbapService extends Service {
if (intent.getBooleanExtra(BluetoothDevice.EXTRA_ALWAYS_ALLOWED, false)) {
boolean result = mRemoteDevice.setPhonebookAccessPermission(
- BluetoothDevice.ACCESS_ALLOWED);
+ PBAP_CONNECT_RECEIVED);
if (VERBOSE) {
- Log.v(TAG, "setPhonebookAccessPermission(ACCESS_ALLOWED) result="
+ Log.v(TAG, "setPhonebookAccessPermission(PBAP_CONNECT_RECEIVED) result="
+ result);
}
}
@@ -614,12 +617,15 @@ public class BluetoothPbapService extends Service {
int permission = mRemoteDevice.getPhonebookAccessPermission();
if (VERBOSE) Log.v(TAG, "getPhonebookAccessPermission() = " + permission);
- if (permission == BluetoothDevice.ACCESS_ALLOWED) {
+ if (permission == BluetoothDevice.ACCESS_ALLOWED ||
+ permission == PBAP_CONNECT_RECEIVED) {
try {
if (VERBOSE) {
Log.v(TAG, "incoming connection accepted from: " + sRemoteDeviceName
+ " automatically as already allowed device");
}
+ // update permission access request
+ mRemoteDevice.setPhonebookAccessPermission(PBAP_CONNECT_RECEIVED);
startObexServerSession();
} catch (IOException ex) {
Log.e(TAG, "Caught exception starting obex server session"
@@ -756,8 +762,8 @@ public class BluetoothPbapService extends Service {
int prevState = mState;
mState = state;
Intent intent = new Intent(BluetoothPbap.PBAP_STATE_CHANGED_ACTION);
- intent.putExtra(BluetoothPbap.PBAP_PREVIOUS_STATE, prevState);
- intent.putExtra(BluetoothPbap.PBAP_STATE, mState);
+ intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, prevState);
+ intent.putExtra(BluetoothProfile.EXTRA_STATE, mState);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mRemoteDevice);
sendBroadcast(intent, BLUETOOTH_PERM);
AdapterService s = AdapterService.getAdapterService();