OSDN Git Service

Updated the AdapterState class to handle persisted Bluetooth setting after AIRPLANE...
authorSyed Ibrahim M <syedibra@broadcom.com>
Wed, 4 Apr 2012 06:51:13 +0000 (23:51 -0700)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Tue, 17 Jul 2012 04:55:08 +0000 (21:55 -0700)
Change-Id: I5e1ca111b72ff49498e87149c32769997e545c54

src/com/android/bluetooth/btservice/AdapterService.java
src/com/android/bluetooth/btservice/AdapterState.java

index fd2dca2..6fd859e 100755 (executable)
@@ -471,7 +471,7 @@ public class AdapterService extends Application {
         Binder.restoreCallingIdentity(origCallerIdentityToken);
     }
 
-    private boolean getBluetoothPersistedSetting() {
+    boolean getBluetoothPersistedSetting() {
         ContentResolver contentResolver = mContext.getContentResolver();
         return (Settings.Secure.getInt(contentResolver,
                                        Settings.Secure.BLUETOOTH_ON, 0) > 0);
index 5314509..11bdbfe 100644 (file)
@@ -81,9 +81,26 @@ final class AdapterState extends StateMachine {
                        transitionTo(mPendingCommandState);
                    }
                    break;
+               case AIRPLANE_MODE_OFF:
+               {
+                   if(mAdapterService.getBluetoothPersistedSetting()) {
+                        Log.i(TAG, "OffState : Turning BT on after Airplane"+
+                            " Mode OFF state");
+                        sendIntent(BluetoothAdapter.STATE_TURNING_ON);
+                        ret = mAdapterService.enableNative();
+                        if (!ret) {
+                            Log.e(TAG, "Error while turning Bluetooth On");
+                            sendIntent(BluetoothAdapter.STATE_OFF);
+                        } else {
+                            sendMessageDelayed(ENABLE_TIMEOUT,
+                                ENABLE_TIMEOUT_DELAY);
+                            transitionTo(mPendingCommandState);
+                        }
+                   }
+                   break;
+               }
                case USER_TURN_OFF:
                case AIRPLANE_MODE_ON:
-               case AIRPLANE_MODE_OFF:
                    //ignore
                    break;
                default: