Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01f3e1f3 authored by Wei Wang's avatar Wei Wang Committed by android-build-merger
Browse files

Merge "Shutdown: Continue shutdown with BLE only mode" into oc-dr1-dev

am: 043e60f5

Change-Id: I67d2a04e767198e2af7217e4e723025daf81d16e
parents be56a66a 043e60f5
Loading
Loading
Loading
Loading
+14 −9
Original line number Original line Diff line number Diff line
@@ -556,7 +556,7 @@ public final class ShutdownThread extends Thread {
        Thread t = new Thread() {
        Thread t = new Thread() {
            public void run() {
            public void run() {
                boolean nfcOff;
                boolean nfcOff;
                boolean bluetoothOff;
                boolean bluetoothReadyForShutdown;
                boolean radioOff;
                boolean radioOff;


                final INfcAdapter nfc =
                final INfcAdapter nfc =
@@ -580,15 +580,15 @@ public final class ShutdownThread extends Thread {
                }
                }


                try {
                try {
                    bluetoothOff = bluetooth == null ||
                    bluetoothReadyForShutdown = bluetooth == null ||
                            bluetooth.getState() == BluetoothAdapter.STATE_OFF;
                            bluetooth.getState() == BluetoothAdapter.STATE_OFF;
                    if (!bluetoothOff) {
                    if (!bluetoothReadyForShutdown) {
                        Log.w(TAG, "Disabling Bluetooth...");
                        Log.w(TAG, "Disabling Bluetooth...");
                        bluetooth.disable(mContext.getPackageName(), false);  // disable but don't persist new state
                        bluetooth.disable(mContext.getPackageName(), false);  // disable but don't persist new state
                    }
                    }
                } catch (RemoteException ex) {
                } catch (RemoteException ex) {
                    Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
                    Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
                    bluetoothOff = true;
                    bluetoothReadyForShutdown = true;
                }
                }


                try {
                try {
@@ -613,14 +613,19 @@ public final class ShutdownThread extends Thread {
                        sInstance.setRebootProgress(status, null);
                        sInstance.setRebootProgress(status, null);
                    }
                    }


                    if (!bluetoothOff) {
                    if (!bluetoothReadyForShutdown) {
                        try {
                        try {
                            bluetoothOff = bluetooth.getState() == BluetoothAdapter.STATE_OFF;
                          // BLE only mode can happen when BT is turned off
                          // We will continue shutting down in such case
                          bluetoothReadyForShutdown =
                                  bluetooth.getState() == BluetoothAdapter.STATE_OFF ||
                                  bluetooth.getState() == BluetoothAdapter.STATE_BLE_TURNING_OFF ||
                                  bluetooth.getState() == BluetoothAdapter.STATE_BLE_ON;
                        } catch (RemoteException ex) {
                        } catch (RemoteException ex) {
                            Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
                            Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
                            bluetoothOff = true;
                            bluetoothReadyForShutdown = true;
                        }
                        }
                        if (bluetoothOff) {
                        if (bluetoothReadyForShutdown) {
                            Log.i(TAG, "Bluetooth turned off.");
                            Log.i(TAG, "Bluetooth turned off.");
                        }
                        }
                    }
                    }
@@ -647,7 +652,7 @@ public final class ShutdownThread extends Thread {
                        }
                        }
                    }
                    }


                    if (radioOff && bluetoothOff && nfcOff) {
                    if (radioOff && bluetoothReadyForShutdown && nfcOff) {
                        Log.i(TAG, "NFC, Radio and Bluetooth shutdown complete.");
                        Log.i(TAG, "NFC, Radio and Bluetooth shutdown complete.");
                        done[0] = true;
                        done[0] = true;
                        break;
                        break;