playback: disable bluetooth autoplay
Temporarily disable and clean up the bluetooth autoplay system for now until I can get it working sensibly.
This commit is contained in:
@@ -71,18 +71,6 @@ class MainActivity : AppCompatActivity() {
|
||||
if (!startIntentAction(intent)) {
|
||||
playbackModel.startAction(InternalPlayer.Action.RestoreState)
|
||||
}
|
||||
|
||||
// Check bluetooth connect permissions if required for bt autoconnect feature
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
val settings = Settings(this)
|
||||
if (settings.bluetoothAutoplay) {
|
||||
ActivityCompat.requestPermissions(
|
||||
this,
|
||||
arrayOf<String>(android.Manifest.permission.BLUETOOTH_CONNECT),
|
||||
BLUETOOTH_PERMISSION_REQUEST_ID
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent?) {
|
||||
@@ -145,6 +133,5 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
companion object {
|
||||
private const val KEY_INTENT_USED = BuildConfig.APPLICATION_ID + ".key.FILE_INTENT_USED"
|
||||
private const val BLUETOOTH_PERMISSION_REQUEST_ID = 1337 * 42;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package org.oxycblt.auxio.playback.system
|
||||
|
||||
import android.bluetooth.BluetoothProfile
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import org.oxycblt.auxio.playback.state.InternalPlayer
|
||||
import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
||||
import org.oxycblt.auxio.settings.Settings
|
||||
|
||||
class BluetoothConnectReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action == android.bluetooth.BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED) {
|
||||
val newState = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, BluetoothProfile.STATE_DISCONNECTED)
|
||||
if (newState == BluetoothProfile.STATE_CONNECTED) {
|
||||
val settings = Settings(context)
|
||||
if (settings.bluetoothAutoplay) {
|
||||
// make sure required services are up and running
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
context.startForegroundService(Intent(context, PlaybackService::class.java))
|
||||
} else {
|
||||
context.startService(Intent(context, PlaybackService::class.java))
|
||||
}
|
||||
// start playback
|
||||
val playbackManager = PlaybackStateManager.getInstance()
|
||||
playbackManager.startAction(InternalPlayer.Action.RestoreState)
|
||||
playbackManager.changePlaying(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.oxycblt.auxio.playback.system
|
||||
|
||||
import android.bluetooth.BluetoothProfile
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
/**
|
||||
* A [BroadcastReceiver] that handles connections from bluetooth headsets, starting playback if
|
||||
* they occur.
|
||||
* @author seijikun, OxygenCobalt
|
||||
*/
|
||||
class BluetoothHeadsetReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action == android.bluetooth.BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED) {
|
||||
val newState = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, BluetoothProfile.STATE_DISCONNECTED)
|
||||
if (newState == BluetoothProfile.STATE_CONNECTED) {
|
||||
// TODO: Initialize the service (Permission workflow must be figured out)
|
||||
// Perhaps move this to the internal receivers?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,10 +230,6 @@ class Settings(private val context: Context, private val callback: Callback? = n
|
||||
val headsetAutoplay: Boolean
|
||||
get() = inner.getBoolean(context.getString(R.string.set_key_headset_autoplay), false)
|
||||
|
||||
/** Whether a connected bluetooth device should cause Auxio to spawn and start playback */
|
||||
val bluetoothAutoplay: Boolean
|
||||
get() = inner.getBoolean(context.getString(R.string.set_key_bluetooth_autoplay), false)
|
||||
|
||||
/** The current ReplayGain configuration */
|
||||
val replayGainMode: ReplayGainMode
|
||||
get() =
|
||||
|
||||
Reference in New Issue
Block a user