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

Commit 9054dacb authored by Jaikumar Ganesh's avatar Jaikumar Ganesh
Browse files

Check if BT is already enabled before starting activity.

If BT is off, and if the user sends a file, BT will be turned on
and the "Enabling dialog" wil be shown. But with the hot feature,
BT turns on very fast which leads to the intent being missed and the
enabling dialog not being dismissed.

Change-Id: I4f4a6f08e04922a61eb7138b76383a77f8d37da4
parent d97e647e
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -63,12 +63,22 @@ public class BluetoothOppBtEnablingActivity extends AlertActivity {

    private static final int BT_ENABLING_TIMEOUT_VALUE = 20000;

    private boolean mRegistered = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // If BT is already enabled jus return.
        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
        if (adapter.isEnabled()) {
            finish();
            return;
        }

        IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
        registerReceiver(mBluetoothReceiver, filter);
        mRegistered = true;

        // Set up the "dialog"
        final AlertController.AlertParams p = mAlertParams;
@@ -103,8 +113,10 @@ public class BluetoothOppBtEnablingActivity extends AlertActivity {
    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mRegistered) {
            unregisterReceiver(mBluetoothReceiver);
        }
    }

    private final Handler mTimeoutHandler = new Handler() {
        @Override