fix: code review fixes — SharedPreferences docs, Log.e, dead notify code
This commit is contained in:
parent
36a20899be
commit
0833327cea
4 changed files with 9 additions and 16 deletions
|
|
@ -6,7 +6,6 @@ import android.annotation.SuppressLint
|
|||
import android.bluetooth.BluetoothAdapter
|
||||
import android.bluetooth.BluetoothGatt
|
||||
import android.bluetooth.BluetoothGattCharacteristic
|
||||
import android.bluetooth.BluetoothGattDescriptor
|
||||
import android.bluetooth.BluetoothProfile
|
||||
import android.bluetooth.le.ScanCallback
|
||||
import android.bluetooth.le.ScanFilter
|
||||
|
|
@ -34,7 +33,7 @@ class BleRelayManager(
|
|||
private val SERVICE_UUID: UUID = UUID.fromString("4fafc201-1fb5-459e-8fcc-c5c9c331914b")
|
||||
private val CHARACTERISTIC_UUID: UUID = UUID.fromString("beb5483e-36e1-4688-b7f5-ea07361f26d8")
|
||||
private val UUID_CHAR_UUID: UUID = UUID.fromString("beb5483e-36e1-4688-b7f5-ea07361f26d9")
|
||||
private val CCCD_UUID: UUID = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb")
|
||||
|
||||
private const val SCAN_TIMEOUT_MS = 30000L
|
||||
private const val RECONNECT_DELAY_MS = 2000L
|
||||
private const val MAX_SCAN_RETRIES = 3
|
||||
|
|
@ -251,12 +250,6 @@ class BleRelayManager(
|
|||
val storedUuid = deviceUuid
|
||||
if (storedUuid != null && value.contentEquals(storedUuid)) {
|
||||
Log.d(TAG, "UUID verified, setting up relay")
|
||||
relayCharacteristic?.let { rc ->
|
||||
gatt.setCharacteristicNotification(rc, true)
|
||||
val descriptor = rc.getDescriptor(CCCD_UUID)
|
||||
descriptor.value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE
|
||||
gatt.writeDescriptor(descriptor)
|
||||
}
|
||||
handler.post { callbacks.onStatusChanged(BleStatus.Connected) }
|
||||
} else {
|
||||
Log.w(TAG, "UUID mismatch -- disconnecting")
|
||||
|
|
|
|||
|
|
@ -376,6 +376,7 @@ class SettingsActivity : AppCompatActivity() {
|
|||
cleanupAction()
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Flash inner error", e)
|
||||
progressDialog?.dismiss()
|
||||
progressDialog = null
|
||||
Toast.makeText(this@SettingsActivity, getString(R.string.flash_failed, e.message), Toast.LENGTH_LONG).show()
|
||||
|
|
|
|||
Loading…
Reference in a new issue