summaryrefslogtreecommitdiffstats
path: root/pxp-monitor
diff options
context:
space:
mode:
authorNitin Arora <niarora@codeaurora.org>2014-04-04 16:02:32 -0700
committerNitin Arora <niarora@codeaurora.org>2014-04-04 16:02:32 -0700
commit9e39eea500d1b74e51bd8f35bb79ef35d23982bb (patch)
tree54ce4d36d65a5a0f9e7ca482e98dc963a3a34821 /pxp-monitor
parent5254d40bb2b36cd42a10f4ad3c63ba5923b4e1dc (diff)
downloadandroid_packages_apps_BluetoothExt-9e39eea500d1b74e51bd8f35bb79ef35d23982bb.tar.gz
android_packages_apps_BluetoothExt-9e39eea500d1b74e51bd8f35bb79ef35d23982bb.tar.bz2
android_packages_apps_BluetoothExt-9e39eea500d1b74e51bd8f35bb79ef35d23982bb.zip
Bluetooth: Enable bluetooth before binding the pxp proxy service
This change delays the binding of the pxp proxy service and confirms that bluetooth is enabled before doing that. This prevents the bluetooth crash at device reboot if pxp app tries to enable bluetooth. Change-Id: Iac63863a43afc1015219b6ad96959fe561acf228 CRs-Fixed: 641293
Diffstat (limited to 'pxp-monitor')
-rw-r--r--pxp-monitor/src/org/codeaurora/bluetooth/pxpmonitor/MainActivity.java33
1 files changed, 22 insertions, 11 deletions
diff --git a/pxp-monitor/src/org/codeaurora/bluetooth/pxpmonitor/MainActivity.java b/pxp-monitor/src/org/codeaurora/bluetooth/pxpmonitor/MainActivity.java
index 63813a1..0e2b239 100644
--- a/pxp-monitor/src/org/codeaurora/bluetooth/pxpmonitor/MainActivity.java
+++ b/pxp-monitor/src/org/codeaurora/bluetooth/pxpmonitor/MainActivity.java
@@ -83,27 +83,29 @@ public class MainActivity extends Activity implements ConnectToDeviceDialogListe
Toast.makeText(this, "BLE not supported", Toast.LENGTH_SHORT).show();
finish();
}
-
- final BluetoothManager bluetoothManager =
- (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
- mBluetoothAdapter = bluetoothManager.getAdapter();
-
- Log.d(TAG, "On create: new intent BluetoothService");
- Intent gattServiceIntent = new Intent(this, PxpServiceProxy.class);
-
- if (bindService(gattServiceIntent, mConnection, BIND_AUTO_CREATE) == false) {
- Log.e(TAG, "Unable to bind");
- }
}
@Override
protected void onResume() {
super.onResume();
+ final BluetoothManager bluetoothManager =
+ (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
+ mBluetoothAdapter = bluetoothManager.getAdapter();
+
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
+ else
+ {
+ Log.d(TAG, "On create: new intent BluetoothService");
+ Intent gattServiceIntent = new Intent(this, PxpServiceProxy.class);
+
+ if (bindService(gattServiceIntent, mConnection, BIND_AUTO_CREATE) == false) {
+ Log.e(TAG, "Unable to bind");
+ }
+ }
}
@Override
@@ -113,6 +115,15 @@ public class MainActivity extends Activity implements ConnectToDeviceDialogListe
finish();
return;
}
+ else if(requestCode == REQUEST_ENABLE_BT && resultCode == Activity.RESULT_OK)
+ {
+ Intent gattServiceIntent = new Intent(this, PxpServiceProxy.class);
+ Log.d(TAG, "On create: new intent BluetoothService");
+
+ if (bindService(gattServiceIntent, mConnection, BIND_AUTO_CREATE) == false) {
+ Log.e(TAG, "Unable to bind");
+ }
+ }
}
@Override