Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth-assisted Push to Talk (PTT) via Element Call #6464

Draft
wants to merge 50 commits into
base: develop
Choose a base branch
from

Conversation

onurays
Copy link
Contributor

@onurays onurays commented Jul 5, 2022

This is a proof-of-concept implementation of hardware-supported Push-to-Talk (PTT) using Element Call in a widget.

  • Experimental proof-of-concept (PoC); not fit for general use
  • Replaces native 1on1 calls (temporary shortcut)
  • Only works with specific Bluetooth PTT buttons
ptt_bottomsheet.mp4

@github-actions
Copy link

github-actions bot commented Jul 5, 2022

Ktlint Results

👎Failed
vector 🔸 features/widgets/ptt/BluetoothLowEnergyService.kt:19:1: Imports must be ordered in lexicographic order without any empty lines in-between with "java", "javax", "kotlin" and aliases in the end (import-ordering)

@sonarcloud
Copy link

sonarcloud bot commented Jul 5, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@@ -128,14 +146,6 @@ class WidgetFragment @Inject constructor(
}
}

override fun onPause() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we possibly want to keep this for non-Element-Call widgets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, it is in my to-do list. Nice catch though, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
val notification = notificationUtils.buildBluetoothLowEnergyNotification()
startForeground(Random.nextInt(), notification)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to kill the service when the WidgetFragment is destroyed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also disconnect from the bluetooth device which it looks like we might not be doing currently

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


override fun onScanResult(device: BluetoothDevice) {
Timber.d("### WidgetFragment. New BLE device found: " + device.name + " - " + device.address)
if (device.name == null || bluetoothDevices.map { it.address }.contains(device.address)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of logic and even this method should not be in the fragment if we want to merge this into the develop at one point.

bluetoothManager
?.adapter
?.bondedDevices
?.firstOrNull { it.name == "PTT-Z" }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should improve the UX with extra screens to get rid of the hardcoded device name.

override fun onServicesDiscovered(gatt: BluetoothGatt, status: Int) {
gatt.services.forEach { service ->
service.characteristics.forEach { characteristic ->
if (characteristic.uuid.equals(UUID.fromString("0000ffe1-0000-1000-8000-00805f9b34fb"))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should improve the UX with extra screens to get rid of the hardcoded uuid.

service.characteristics.forEach { characteristic ->
if (characteristic.uuid.equals(UUID.fromString("0000ffe1-0000-1000-8000-00805f9b34fb"))) {
gatt.setCharacteristicNotification(characteristic, true)
val descriptor = characteristic.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should improve the UX with extra screens to get rid of the hardcoded uuid.

Johennes and others added 3 commits July 7, 2022 08:46
@sonarcloud
Copy link

sonarcloud bot commented Nov 4, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 12 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Johennes Johennes changed the title Push to Talk Gatt Client Implementation Bluetooth-assisted Push to Talk (PTT) via Element Call Nov 8, 2022
@bmarty
Copy link
Member

bmarty commented Jan 10, 2023

@onurays what is the status of the PR?

@Johennes
Copy link
Contributor

@onurays what is the status of the PR?

@bmarty We don't plan on merging this in the near future but would like to be able to have the ability to build APKs off of the branch for customer demos. So unless the PR creates any issues, it'd be very helpful if we could keep it alive.

Start Element Call widget in its own task

So that closing the app does not end a PTT call
@@ -17,8 +17,13 @@
package im.vector.app.features.widgets

import android.app.Activity
import android.bluetooth.BluetoothDevice

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 🚫 Unused import

import im.vector.app.databinding.FragmentRoomWidgetBinding
import im.vector.app.features.settings.VectorPreferences
import im.vector.app.features.webview.WebEventListener
import im.vector.app.features.widgets.ptt.BluetoothLowEnergyDevice
import im.vector.app.features.widgets.ptt.BluetoothLowEnergyDeviceScanner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 🚫 Unused import

@@ -46,17 +50,21 @@ import org.matrix.android.sdk.flow.flow
import org.matrix.android.sdk.flow.mapOptional
import org.matrix.android.sdk.flow.unwrap
import timber.log.Timber
import javax.inject.Inject

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 🚫 Unused import

@sonarcloud
Copy link

sonarcloud bot commented Jan 25, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 12 Code Smells

2.1% 2.1% Coverage
0.0% 0.0% Duplication

@CLAassistant
Copy link

CLAassistant commented Sep 25, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 4 committers have signed the CLA.

✅ Johennes
❌ Onuray Sahin
❌ jonnyandrew
❌ onurays


Onuray Sahin seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants