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

Commit af705d26 authored by Andrew Cheng's avatar Andrew Cheng
Browse files

Add BluetoothConnectionCallback to Companion App

Tag: #refactor
Fixes: 180729821
Test: atest BluetoothInstrumentationTests
Merged-In: Id24a4b3a3510781d9105763b1722f44583a7fd7c
Change-Id: I598428052191e4a23e4d7cd0b265c84a088431c7
parent b8e09882
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import android.annotation.CheckResult;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.companion.Association;
import android.companion.AssociationRequest;
import android.companion.CompanionDeviceManager;
@@ -665,6 +667,12 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
        }
    }

    void onDeviceConnected(String address) {
    }

    void onDeviceDisconnected(String address) {
    }

    private class ShellCmd extends ShellCommand {
        public static final String USAGE = "help\n"
                + "list USER_ID\n"
@@ -709,4 +717,17 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
        }
    }


    private class BluetoothDeviceConnectedListener
            extends BluetoothAdapter.BluetoothConnectionCallback {
        @Override
        public void onDeviceConnected(BluetoothDevice device) {
            CompanionDeviceManagerService.this.onDeviceConnected(device.getAddress());
        }

        @Override
        public void onDeviceDisconnected(BluetoothDevice device) {
            CompanionDeviceManagerService.this.onDeviceDisconnected(device.getAddress());
        }
    }
}