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

Commit 96d5a89f authored by Colin Cross's avatar Colin Cross
Browse files

Fix kotlin nullable errors in Bluetooth

Fix kotlin nullable errors that were exposed by setting the retention
of android.annotation.NonNull and android.annotation.Nullable to
class retention.

Bug: 294110802
Test: m PandoraServer
Change-Id: I69fb2cd63b04b70e23c1005ac88f22b460345754
parent efde2785
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ class AndroidInternal(val context: Context) : AndroidImplBase(), Closeable {

    private val bluetoothManager = context.getSystemService(BluetoothManager::class.java)!!
    private val bluetoothAdapter = bluetoothManager.adapter
    private var telephonyManager = context.getSystemService(TelephonyManager::class.java)
    private var telephonyManager = context.getSystemService(TelephonyManager::class.java)!!
    private val DEFAULT_MESSAGE_LEN = 130
    private var device: UiDevice =
        UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
+4 −2
Original line number Diff line number Diff line
@@ -614,8 +614,10 @@ class Host(
                        override fun onScanResult(callbackType: Int, result: ScanResult) {
                            val bluetoothDevice = result.device
                            val scanRecord = result.scanRecord
                            checkNotNull(scanRecord)
                            val scanData = scanRecord.getAdvertisingDataMap()
                            val serviceData = scanRecord?.serviceData!!
                            val serviceData = scanRecord.serviceData
                            checkNotNull(serviceData)

                            var dataTypesBuilder =
                                DataTypes.newBuilder().setTxPowerLevel(scanRecord.getTxPowerLevel())
@@ -732,7 +734,7 @@ class Host(

                            // Flags DataTypes CSSv10 1.3 Flags
                            val mode: DiscoverabilityMode =
                                when (result.scanRecord.advertiseFlags and 0b11) {
                                when (scanRecord.advertiseFlags and 0b11) {
                                    0b01 -> DiscoverabilityMode.DISCOVERABLE_LIMITED
                                    0b10 -> DiscoverabilityMode.DISCOVERABLE_GENERAL
                                    else -> DiscoverabilityMode.NOT_DISCOVERABLE
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ class Pan(private val context: Context) : PANImplBase(), Closeable {
        }

    init {
        mTetheringManager = context.getSystemService(TetheringManager::class.java)
        mTetheringManager = context.getSystemService(TetheringManager::class.java)!!
    }

    override fun close() {
+2 −0
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ class Pbap(val context: Context) : PBAPImplBase(), Closeable {
                .getContentResolver()
                .query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null)

        if (cursor == null) return

        if (cursor.getCount() >= CONTACT_LIST_SIZE) return // return if contacts are present

        for (item in cursor.getCount() + 1..CONTACT_LIST_SIZE) {