summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPradeep Panigrahi <pradeepp@codeaurora.org>2013-09-16 12:09:13 +0530
committerPradeep Panigrahi <pradeepp@codeaurora.org>2013-09-16 14:09:59 +0530
commitef1d58ef0a1612067d4bc351b2d99011df30ff91 (patch)
treeb02eb77677d43a88677ada10587d097fe8015fd2
parent0a77b74786b8e73f7ff51e5d0cbe909a38267667 (diff)
downloadandroid_packages_apps_BluetoothExt-ef1d58ef0a1612067d4bc351b2d99011df30ff91.tar.gz
android_packages_apps_BluetoothExt-ef1d58ef0a1612067d4bc351b2d99011df30ff91.tar.bz2
android_packages_apps_BluetoothExt-ef1d58ef0a1612067d4bc351b2d99011df30ff91.zip
Bluetooth: Use Trust feature in SAP/FTP/MAP applications
Add change in SAP/FTP/MAP application to use bluetoth framework api to set/get remote device trust value. This marks remote devices as trusted devices and stores it in NVRAM for subsequent connections. Change-Id: I6060698b6aa9c4f7dd6ae19b7b6a6b089b895239 CRs-fixed: 523135
-rw-r--r--src/org/codeaurora/bluetooth/ftp/BluetoothFtpService.java26
-rwxr-xr-xsrc/org/codeaurora/bluetooth/map/BluetoothMasService.java27
-rw-r--r--src/org/codeaurora/bluetooth/sap/BluetoothSapService.java27
3 files changed, 18 insertions, 62 deletions
diff --git a/src/org/codeaurora/bluetooth/ftp/BluetoothFtpService.java b/src/org/codeaurora/bluetooth/ftp/BluetoothFtpService.java
index ceec144..2cb8a14 100644
--- a/src/org/codeaurora/bluetooth/ftp/BluetoothFtpService.java
+++ b/src/org/codeaurora/bluetooth/ftp/BluetoothFtpService.java
@@ -216,7 +216,6 @@ public class BluetoothFtpService extends Service {
private BluetoothSocket mConnSocket = null;
- private static HashSet<BluetoothDevice> trustDevices = new HashSet<BluetoothDevice>();
private BluetoothDevice mRemoteDevice = null;
private static String sRemoteDeviceName = null;
@@ -313,8 +312,10 @@ public class BluetoothFtpService extends Service {
isWaitingAuthorization = false;
if (intent.getBooleanExtra(BluetoothFtpService.EXTRA_ALWAYS_ALLOWED, false)) {
- trustDevices.add(mRemoteDevice);
- Log.v(TAG, "setTrust() D: " + mRemoteDevice.getName()+ "ADDED: " + trustDevices.contains(mRemoteDevice));
+ if(mRemoteDevice != null) {
+ mRemoteDevice.setTrust(true);
+ Log.v(TAG, "setTrust() TRUE " + mRemoteDevice.getName());
+ }
}
try {
if (mConnSocket != null) {
@@ -350,21 +351,6 @@ public class BluetoothFtpService extends Service {
removeTimeoutMsg = false;
}
}
- } else if ( BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
-
- if (intent.hasExtra(BluetoothDevice.EXTRA_DEVICE)) {
- BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
- if(device != null)
- Log.d(TAG,"device: "+ device.getName());
- if(mRemoteDevice != null)
- Log.d(TAG," Remtedevie: "+mRemoteDevice.getName());
- if (device != null && trustDevices.contains(device) &&
- intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE) == BluetoothDevice.BOND_NONE) {
- Log.d(TAG,"BOND_STATE_CHANGED RFRSH trustDevices"+ device.getName());
- trustDevices.remove(device);
- }
- }
-
} else {
removeTimeoutMsg = false;
}
@@ -644,8 +630,8 @@ public class BluetoothFtpService extends Service {
mSessionStatusHandler.sendMessage(mSessionStatusHandler
.obtainMessage(MSG_INTERNAL_OBEX_RFCOMM_SESSION_UP));
boolean trust = false;
- if (trustDevices != null)
- trust = trustDevices.contains(mRemoteDevice);
+ if (mRemoteDevice != null)
+ trust = mRemoteDevice.getTrustState();
if (VERBOSE) Log.v(RTAG, "GetTrustState() = " + trust);
diff --git a/src/org/codeaurora/bluetooth/map/BluetoothMasService.java b/src/org/codeaurora/bluetooth/map/BluetoothMasService.java
index cbdbdba..a9434ef 100755
--- a/src/org/codeaurora/bluetooth/map/BluetoothMasService.java
+++ b/src/org/codeaurora/bluetooth/map/BluetoothMasService.java
@@ -182,7 +182,6 @@ public class BluetoothMasService extends Service {
BluetoothMns mnsClient;
private static BluetoothDevice mRemoteDevice = null;
- private static HashSet<BluetoothDevice> trustDevices = new HashSet<BluetoothDevice>();
private boolean mHasStarted = false;
private int mStartId = -1;
@@ -389,8 +388,10 @@ public class BluetoothMasService extends Service {
return;
}
if (intent.getBooleanExtra(BluetoothMasService.EXTRA_ALWAYS_ALLOWED, false) == true) {
- trustDevices.add(mRemoteDevice);
- Log.v(TAG, "setTrust() TRUE " + mRemoteDevice.getName());
+ if(mRemoteDevice != null) {
+ mRemoteDevice.setTrust(true);
+ Log.v(TAG, "setTrust() TRUE " + mRemoteDevice.getName());
+ }
}
Log.v(TAG, "parseIntent 2: mIsEmailEnabled: " + mIsEmailEnabled);
if(mIsEmailEnabled) {
@@ -405,22 +406,6 @@ public class BluetoothMasService extends Service {
notifyAuthKeyInput(sessionkey);
} else if (AUTH_CANCELLED_ACTION.equals(action)) {
notifyAuthCancelled();
- } else if ( BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
-
- if (intent.hasExtra(BluetoothDevice.EXTRA_DEVICE)) {
- BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
- if(device != null)
- Log.d(TAG,"device: "+ device.getName());
- if(mRemoteDevice != null)
- Log.d(TAG," Remtedevie: "+mRemoteDevice.getName());
- if (device != null && trustDevices.contains(device) &&
- intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE) == BluetoothDevice.BOND_NONE) {
- Log.d(TAG,"BOND_STATE_CHANGED REFRESH trustDevices"+ device.getName());
- trustDevices.remove(device);
- }
- }
-
- removeTimeoutMsg = false;
} else {
removeTimeoutMsg = false;
}
@@ -957,8 +942,8 @@ public class BluetoothMasService extends Service {
continue;
}
boolean trust = false;
- if (trustDevices != null)
- trust = trustDevices.contains(mRemoteDevice);
+ if (mRemoteDevice != null)
+ trust = mRemoteDevice.getTrustState();
if (VERBOSE) Log.v(TAG, "GetTrustState() = " + trust);
if (mIsRequestBeingNotified) {
if (VERBOSE) Log.v(TAG, "Request notification is still on going.");
diff --git a/src/org/codeaurora/bluetooth/sap/BluetoothSapService.java b/src/org/codeaurora/bluetooth/sap/BluetoothSapService.java
index f95fa39..aef74ec 100644
--- a/src/org/codeaurora/bluetooth/sap/BluetoothSapService.java
+++ b/src/org/codeaurora/bluetooth/sap/BluetoothSapService.java
@@ -270,8 +270,6 @@ public class BluetoothSapService extends Service {
private HashMap<BluetoothDevice, BluetoothSapDevice> mSapDevices;
- private static HashSet<BluetoothDevice> trustDevices = new HashSet<BluetoothDevice>();
-
private IBinder mSapBinder;
private BluetoothAdapter mAdapter;
@@ -484,8 +482,10 @@ public class BluetoothSapService extends Service {
}
if (intent.getBooleanExtra(BluetoothSapService.SAP_EXTRA_ALWAYS_ALLOWED, false) == true) {
- trustDevices.add(mRemoteDevice);
- Log.v(TAG, "setTrust() TRUE " + mRemoteDevice.getName());
+ if(mRemoteDevice != null) {
+ mRemoteDevice.setTrust(true);
+ Log.v(TAG, "setTrust() TRUE " + mRemoteDevice.getName());
+ }
}
/* start the uplink thread */
startUplinkThread();
@@ -495,21 +495,6 @@ public class BluetoothSapService extends Service {
sendErrorConnResp();
closeRfcommSocket();
startRfcommListenerThread();
- } else if ( BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
-
- if (intent.hasExtra(BluetoothDevice.EXTRA_DEVICE)) {
- BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
- if(device != null)
- Log.d(TAG,"device: "+ device.getName());
- if(mRemoteDevice != null)
- Log.d(TAG," Remtedevie: "+mRemoteDevice.getName());
- if (device != null && trustDevices.contains(device) &&
- intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE) == BluetoothDevice.BOND_NONE) {
- Log.d(TAG,"BOND_STATE_CHANGED REFRESH trustDevices"+ device.getName());
- trustDevices.remove(device);
- }
- }
-
} else {
removeTimeoutMsg = false;
}
@@ -835,8 +820,8 @@ public class BluetoothSapService extends Service {
break;
}
boolean trust = false;
- if (trustDevices != null)
- trust = trustDevices.contains(mRemoteDevice);
+ if (mRemoteDevice != null)
+ trust = mRemoteDevice.getTrustState();
if (VERBOSE) Log.v(TAG, "GetTrustState() = " + trust);
if (trust) {