OSDN Git Service

DO NOT MERGE - cherry pick a Bluetooth property fix from master
authorMatthew Xie <mattx@google.com>
Tue, 17 Apr 2012 18:39:02 +0000 (11:39 -0700)
committerJason Simmons <jsimmons@google.com>
Thu, 14 Jun 2012 18:44:06 +0000 (11:44 -0700)
Check nullpointer of discoverableTimeout in initBluetoothAfterTurningOn.

When we fail to get the property, print out warning message, turn
Discoverable off.
Bug 6302990

Change-Id: Ie21aa2a89050c74d99d9ee521a95ffa822114757

core/java/android/server/BluetoothService.java

index dce31db..444567d 100755 (executable)
@@ -611,6 +611,11 @@ public class BluetoothService extends IBluetooth.Stub {
     /*package*/ void initBluetoothAfterTurningOn() {
         String discoverable = getProperty("Discoverable", false);
         String timeout = getProperty("DiscoverableTimeout", false);
+        if (timeout == null) {
+            Log.w(TAG, "Null DiscoverableTimeout property");
+            // assign a number, anything not 0
+            timeout = "1";
+        }
         if (discoverable.equals("true") && Integer.valueOf(timeout) != 0) {
             setAdapterPropertyBooleanNative("Discoverable", 0);
         }