Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Remove the rewind for when the car disconnects

Barnabasba667996894b
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index 2c448bfc..22588e8a 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -5079,11 +5079,6 @@
"keepScreenOnPlayerSubtitle": "The screen stays on while the player is open",
"keepScreenOnCarMode": "Keep the screen on in car mode",
"keepScreenOnCarModeSubtitle": "The screen stays on while car mode is open",
- "carDisconnectRewind": "Rewind when the car disconnects",
- "carDisconnectRewindOff": "Off",
- "carDisconnectRewindValue": "{seconds} seconds",
- "@carDisconnectRewindValue": { "placeholders": { "seconds": { "type": "int" } } },
- "carDisconnectRewindInfo": "When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.",
"cardButtonFill": "Button background",
"cardButtonFillSubtitle": "How the buttons on the player card are filled",
"cardButtonFillClear": "Clear",
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index 06f6a056..0366594a 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -15651,30 +15651,6 @@ abstract class AppLocalizations {
/// **'The screen stays on while car mode is open'**
String get keepScreenOnCarModeSubtitle;
- /// No description provided for @carDisconnectRewind.
- ///
- /// In en, this message translates to:
- /// **'Rewind when the car disconnects'**
- String get carDisconnectRewind;
-
- /// No description provided for @carDisconnectRewindOff.
- ///
- /// In en, this message translates to:
- /// **'Off'**
- String get carDisconnectRewindOff;
-
- /// No description provided for @carDisconnectRewindValue.
- ///
- /// In en, this message translates to:
- /// **'{seconds} seconds'**
- String carDisconnectRewindValue(int seconds);
-
- /// No description provided for @carDisconnectRewindInfo.
- ///
- /// In en, this message translates to:
- /// **'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.'**
- String get carDisconnectRewindInfo;
-
/// No description provided for @cardButtonFill.
///
/// In en, this message translates to:
diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart
index df074604..5f00d057 100644
--- a/lib/l10n/app_localizations_de.dart
+++ b/lib/l10n/app_localizations_de.dart
@@ -9205,21 +9205,6 @@ class AppLocalizationsDe extends AppLocalizations {
String get keepScreenOnCarModeSubtitle =>
'The screen stays on while car mode is open';
- @override
- String get carDisconnectRewind => 'Rewind when the car disconnects';
-
- @override
- String get carDisconnectRewindOff => 'Off';
-
- @override
- String carDisconnectRewindValue(int seconds) {
- return '$seconds seconds';
- }
-
- @override
- String get carDisconnectRewindInfo =>
- 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';
-
@override
String get cardButtonFill => 'Button background';
diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dart
index 06f7e36f..7c349884 100644
--- a/lib/l10n/app_localizations_el.dart
+++ b/lib/l10n/app_localizations_el.dart
@@ -9084,21 +9084,6 @@ class AppLocalizationsEl extends AppLocalizations {
String get keepScreenOnCarModeSubtitle =>
'The screen stays on while car mode is open';
- @override
- String get carDisconnectRewind => 'Rewind when the car disconnects';
-
- @override
- String get carDisconnectRewindOff => 'Off';
-
- @override
- String carDisconnectRewindValue(int seconds) {
- return '$seconds seconds';
- }
-
- @override
- String get carDisconnectRewindInfo =>
- 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';
-
@override
String get cardButtonFill => 'Button background';
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index 9fc9cde6..ccf9acb0 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -9084,21 +9084,6 @@ class AppLocalizationsEn extends AppLocalizations {
String get keepScreenOnCarModeSubtitle =>
'The screen stays on while car mode is open';
- @override
- String get carDisconnectRewind => 'Rewind when the car disconnects';
-
- @override
- String get carDisconnectRewindOff => 'Off';
-
- @override
- String carDisconnectRewindValue(int seconds) {
- return '$seconds seconds';
- }
-
- @override
- String get carDisconnectRewindInfo =>
- 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';
-
@override
String get cardButtonFill => 'Button background';
diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart
index b6bcfb73..599a58fc 100644
--- a/lib/l10n/app_localizations_es.dart
+++ b/lib/l10n/app_localizations_es.dart
@@ -9086,21 +9086,6 @@ class AppLocalizationsEs extends AppLocalizations {
String get keepScreenOnCarModeSubtitle =>
'The screen stays on while car mode is open';
- @override
- String get carDisconnectRewind => 'Rewind when the car disconnects';
-
- @override
- String get carDisconnectRewindOff => 'Off';
-
- @override
- String carDisconnectRewindValue(int seconds) {
- return '$seconds seconds';
- }
-
- @override
- String get carDisconnectRewindInfo =>
- 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';
-
@override
String get cardButtonFill => 'Button background';
diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart
index 03120f20..0c3ae71c 100644
--- a/lib/l10n/app_localizations_fr.dart
+++ b/lib/l10n/app_localizations_fr.dart
@@ -9137,21 +9137,6 @@ class AppLocalizationsFr extends AppLocalizations {
String get keepScreenOnCarModeSubtitle =>
'The screen stays on while car mode is open';
- @override
- String get carDisconnectRewind => 'Rewind when the car disconnects';
-
- @override
- String get carDisconnectRewindOff => 'Off';
-
- @override
- String carDisconnectRewindValue(int seconds) {
- return '$seconds seconds';
- }
-
- @override
- String get carDisconnectRewindInfo =>
- 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';
-
@override
String get cardButtonFill => 'Button background';
diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart
index 337db24d..ec0b6974 100644
--- a/lib/l10n/app_localizations_it.dart
+++ b/lib/l10n/app_localizations_it.dart
@@ -9084,21 +9084,6 @@ class AppLocalizationsIt extends AppLocalizations {
String get keepScreenOnCarModeSubtitle =>
'The screen stays on while car mode is open';
- @override
- String get carDisconnectRewind => 'Rewind when the car disconnects';
-
- @override
- String get carDisconnectRewindOff => 'Off';
-
- @override
- String carDisconnectRewindValue(int seconds) {
- return '$seconds seconds';
- }
-
- @override
- String get carDisconnectRewindInfo =>
- 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';
-
@override
String get cardButtonFill => 'Button background';
diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart
index a6c45b29..605e03a4 100644
--- a/lib/l10n/app_localizations_ja.dart
+++ b/lib/l10n/app_localizations_ja.dart
@@ -9084,21 +9084,6 @@ class AppLocalizationsJa extends AppLocalizations {
String get keepScreenOnCarModeSubtitle =>
'The screen stays on while car mode is open';
- @override
- String get carDisconnectRewind => 'Rewind when the car disconnects';
-
- @override
- String get carDisconnectRewindOff => 'Off';
-
- @override
- String carDisconnectRewindValue(int seconds) {
- return '$seconds seconds';
- }
-
- @override
- String get carDisconnectRewindInfo =>
- 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';
-
@override
String get cardButtonFill => 'Button background';
diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dart
index fd291286..fff06c4b 100644
--- a/lib/l10n/app_localizations_no.dart
+++ b/lib/l10n/app_localizations_no.dart
@@ -9084,21 +9084,6 @@ class AppLocalizationsNo extends AppLocalizations {
String get keepScreenOnCarModeSubtitle =>
'The screen stays on while car mode is open';
- @override
- String get carDisconnectRewind => 'Rewind when the car disconnects';
-
- @override
- String get carDisconnectRewindOff => 'Off';
-
- @override
- String carDisconnectRewindValue(int seconds) {
- return '$seconds seconds';
- }
-
- @override
- String get carDisconnectRewindInfo =>
- 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';
-
@override
String get cardButtonFill => 'Button background';
diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart
index a22b097f..70921bb3 100644
--- a/lib/l10n/app_localizations_pt.dart
+++ b/lib/l10n/app_localizations_pt.dart
@@ -9084,21 +9084,6 @@ class AppLocalizationsPt extends AppLocalizations {
String get keepScreenOnCarModeSubtitle =>
'The screen stays on while car mode is open';
- @override
- String get carDisconnectRewind => 'Rewind when the car disconnects';
-
- @override
- String get carDisconnectRewindOff => 'Off';
-
- @override
- String carDisconnectRewindValue(int seconds) {
- return '$seconds seconds';
- }
-
- @override
- String get carDisconnectRewindInfo =>
- 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';
-
@override
String get cardButtonFill => 'Button background';
diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dart
index b6959e1e..e9021345 100644
--- a/lib/l10n/app_localizations_ro.dart
+++ b/lib/l10n/app_localizations_ro.dart
@@ -9084,21 +9084,6 @@ class AppLocalizationsRo extends AppLocalizations {
String get keepScreenOnCarModeSubtitle =>
'The screen stays on while car mode is open';
- @override
- String get carDisconnectRewind => 'Rewind when the car disconnects';
-
- @override
- String get carDisconnectRewindOff => 'Off';
-
- @override
- String carDisconnectRewindValue(int seconds) {
- return '$seconds seconds';
- }
-
- @override
- String get carDisconnectRewindInfo =>
- 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';
-
@override
String get cardButtonFill => 'Button background';
diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart
index 0138400d..36d4f22f 100644
--- a/lib/l10n/app_localizations_ru.dart
+++ b/lib/l10n/app_localizations_ru.dart
@@ -9089,21 +9089,6 @@ class AppLocalizationsRu extends AppLocalizations {
String get keepScreenOnCarModeSubtitle =>
'The screen stays on while car mode is open';
- @override
- String get carDisconnectRewind => 'Rewind when the car disconnects';
-
- @override
- String get carDisconnectRewindOff => 'Off';
-
- @override
- String carDisconnectRewindValue(int seconds) {
- return '$seconds seconds';
- }
-
- @override
- String get carDisconnectRewindInfo =>
- 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';
-
@override
String get cardButtonFill => 'Button background';
diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart
index 3ebc098e..f2118c40 100644
--- a/lib/l10n/app_localizations_zh.dart
+++ b/lib/l10n/app_localizations_zh.dart
@@ -8992,21 +8992,6 @@ class AppLocalizationsZh extends AppLocalizations {
String get keepScreenOnCarModeSubtitle =>
'The screen stays on while car mode is open';
- @override
- String get carDisconnectRewind => 'Rewind when the car disconnects';
-
- @override
- String get carDisconnectRewindOff => 'Off';
-
- @override
- String carDisconnectRewindValue(int seconds) {
- return '$seconds seconds';
- }
-
- @override
- String get carDisconnectRewindInfo =>
- 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';
-
@override
String get cardButtonFill => 'Button background';
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 245a5f0f..ac6fc81b 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -98,7 +98,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
bool _autoplayOnCarConnect = false;
bool _keepScreenOnPlayer = false;
bool _keepScreenOnCarMode = false;
- int _carDisconnectRewind = 0;
String _carBookSort = 'title';
bool _carBookSortReverse = false;
String _carPodcastSort = 'title';
@@ -1088,7 +1087,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
final autoplayOnCarConnect = await PlayerSettings.getAutoplayOnCarConnect();
final keepScreenOnPlayer = await PlayerSettings.getKeepScreenOnInPlayer();
final keepScreenOnCarMode = await PlayerSettings.getKeepScreenOnInCarMode();
- final carDisconnectRewind = await PlayerSettings.getCarDisconnectRewindSeconds();
final carBookSort = await PlayerSettings.getCarBookSort();
final carBookSortReverse = await PlayerSettings.getCarBookSortReverse();
final carPodcastSort = await PlayerSettings.getCarPodcastSort();
@@ -1115,7 +1113,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
_autoplayOnCarConnect = autoplayOnCarConnect;
_keepScreenOnPlayer = keepScreenOnPlayer;
_keepScreenOnCarMode = keepScreenOnCarMode;
- _carDisconnectRewind = carDisconnectRewind;
_carBookSort = carBookSort;
_carBookSortReverse = carBookSortReverse;
_carPodcastSort = carPodcastSort;
@@ -3175,37 +3172,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
} : null,
),
const Divider(height: 1, indent: 16, endIndent: 16),
- Padding(
- padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
- child: Row(
- children: [
- Expanded(
- child: Row(children: [
- Flexible(child: Text(l.carDisconnectRewind, style: tt.bodyMedium)),
- _infoIcon(l.carDisconnectRewind, l.carDisconnectRewindInfo),
- ]),
- ),
- Text(
- _carDisconnectRewind == 0
- ? l.carDisconnectRewindOff
- : l.carDisconnectRewindValue(_carDisconnectRewind),
- style: tt.bodyMedium?.copyWith(
- fontWeight: FontWeight.w700, color: cs.primary)),
- ],
- ),
- ),
- Slider(
- value: _carDisconnectRewind.toDouble(),
- min: 0,
- max: 30,
- divisions: 30,
- onChanged: _loaded ? (v) {
- setState(() => _carDisconnectRewind = v.round());
- } : null,
- onChangeEnd: (v) =>
- PlayerSettings.setCarDisconnectRewindSeconds(v.round()),
- ),
- const Divider(height: 1, indent: 16, endIndent: 16),
_carSortPicker(
tt,
l.carBookOrder,
diff --git a/lib/screens/settings_search_index.dart b/lib/screens/settings_search_index.dart
index 761ba278..41fd53ec 100644
--- a/lib/screens/settings_search_index.dart
+++ b/lib/screens/settings_search_index.dart
@@ -81,7 +81,6 @@ List<SettingSearchEntry> settingsSearchEntries(BuildContext context) {
Platform.isIOS ? l.carConnectAutoplayIos : l.carConnectAutoplay,
[l.carConnectAutoplayOnSubtitle, l.carConnectAutoplayOffSubtitle]),
SettingSearchEntry('Car', Platform.isIOS ? l.sectionCarIos : l.sectionCar, l.keepScreenOnCarMode, [l.keepScreenOnCarModeSubtitle]),
- SettingSearchEntry('Car', Platform.isIOS ? l.sectionCarIos : l.sectionCar, l.carDisconnectRewind, [l.carDisconnectRewindInfo]),
SettingSearchEntry('Car', Platform.isIOS ? l.sectionCarIos : l.sectionCar, l.carBookOrder, [l.title, l.author, l.dateAdded]),
SettingSearchEntry('Car', Platform.isIOS ? l.sectionCarIos : l.sectionCar, l.carBookOrderReverse, [l.carBookOrderReverseSubtitle]),
SettingSearchEntry('Car', Platform.isIOS ? l.sectionCarIos : l.sectionCar, l.carPodcastOrder, [l.title, l.dateAdded]),
diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dart
index ac2f3977..b43300bb 100644
--- a/lib/services/audio_player_service.dart
+++ b/lib/services/audio_player_service.dart
@@ -114,9 +114,7 @@ class AudioPlayerHandler extends BaseAudioHandler with SeekHandler {
'keyCode=${snap['lastKeyCode']} keyAgeMs=${snap['lastKeyAgeMs']} '
'lastPlayCaller=${snap['lastPlayCaller']} playAgeMs=${snap['lastPlayCallerAgeMs']} '
'lastPauseCaller=${snap['lastPauseCaller']} pauseAgeMs=${snap['lastPauseCallerAgeMs']} '
- 'carClientAgeMs=${snap['carClientAgeMs']} '
- 'carState=${snap['carConnectionState']} carGoneAgeMs=${snap['carGoneAgeMs']} '
- 'keyPkg=${snap['lastKeyPkg']}',
+ 'carClientAgeMs=${snap['carClientAgeMs']} keyPkg=${snap['lastKeyPkg']}',
);
}
@@ -3112,7 +3110,6 @@ class AudioPlayerService extends ChangeNotifier {
debugPrint(
'[AudioSession] Permanent focus loss - not resuming on its own',
);
- unawaited(service._rewindIfCarJustLeft());
}
// The notification reads the player directly, but the home
// widget, cards and watch only refresh on notify - without this
@@ -7364,7 +7361,6 @@ class AudioPlayerService extends ChangeNotifier {
_stuckCheckTimer = null;
}
await _player?.pause();
- unawaited(_rewindIfCarJustLeft());
_logEvent(PlaybackEventType.pause);
_onPlaybackStateChangedCallback?.call(false);
@@ -7480,62 +7476,6 @@ class AudioPlayerService extends ChangeNotifier {
notifyListeners();
}
- /// CarPlay reported the car gone. iOS pauses on the lost route on its own,
- /// so a pause in the last moments counts the same as still playing.
- Future<void> onCarDisconnected() async {
- final lastPause = _lastPauseTime;
- final pausedByRoute = !isPlaying &&
- _noisyPause &&
- lastPause != null &&
- DateTime.now().difference(lastPause) < const Duration(seconds: 20);
- if (!isPlaying && !pausedByRoute) return;
- if (isPlaying) await pause();
- await rewindForCarDisconnect();
- }
-
- DateTime? _lastCarRewindAt;
-
- /// Android: a pause that may be the system's late reaction to the car going
- /// away. The service stamps the moment Android Auto's projection ended; if
- /// that was just before this pause, or turns up within a few seconds after
- /// it, the stretch in between played to nobody.
- Future<void> _rewindIfCarJustLeft() async {
- if (!Platform.isAndroid) return;
- if (await PlayerSettings.getCarDisconnectRewindSeconds() <= 0) return;
- final last = _lastCarRewindAt;
- if (last != null && DateTime.now().difference(last) < const Duration(minutes: 1)) {
- return;
- }
- for (var attempt = 0; attempt < 3; attempt++) {
- final snap = await AudioPlayerHandler._absorbDiagSnapshot();
- final gone = snap?['carGoneAgeMs'];
- debugPrint('[CarRewind] check ${attempt + 1}: carState=${snap?['carConnectionState']} '
- 'carGoneAgeMs=$gone playing=$isPlaying');
- if (gone is int && gone >= 0 && gone < 30000) {
- _lastCarRewindAt = DateTime.now();
- await rewindForCarDisconnect();
- return;
- }
- if (isPlaying) return;
- await Future.delayed(const Duration(seconds: 4));
- }
- }
-
- /// Takes back the stretch that played after the car disconnected, in real
- /// seconds, so the setting matches a stopwatch at any playback speed.
- Future<void> rewindForCarDisconnect() async {
- final seconds = await PlayerSettings.getCarDisconnectRewindSeconds();
- if (seconds <= 0 || _player == null || !hasBook) return;
- var target = position - Duration(milliseconds: (seconds * 1000 * speed).round());
- if (target < Duration.zero) target = Duration.zero;
- debugPrint('[CarRewind] car disconnected while playing - rewinding ${seconds}s');
- await seekTo(
- target,
- logAs: PlaybackEventType.autoRewind,
- logDetail: '${seconds}s (car disconnected)',
- );
- }
-
/// Rewind triggered by the sleep timer firing. Same mechanics as a manual
/// seek-back, but logged as an auto-rewind so the playback history reads
/// "Auto-rewound 15m (sleep timer)" instead of a raw seek (GH #232).
diff --git a/lib/services/backup_service.dart b/lib/services/backup_service.dart
index 7c7a95ff..149146c0 100644
--- a/lib/services/backup_service.dart
+++ b/lib/services/backup_service.dart
@@ -32,7 +32,6 @@ class BackupService {
'speedAdjustedTime': await PlayerSettings.getSpeedAdjustedTime(),
'keepScreenOnPlayer': await PlayerSettings.getKeepScreenOnInPlayer(),
'keepScreenOnCarMode': await PlayerSettings.getKeepScreenOnInCarMode(),
- 'carDisconnectRewind': await PlayerSettings.getCarDisconnectRewindSeconds(),
'forwardSkip': await PlayerSettings.getForwardSkip(),
'backSkip': await PlayerSettings.getBackSkip(),
'longSkipButtons': await PlayerSettings.getLongSkipButtons(),
@@ -542,7 +541,6 @@ class BackupService {
if (s['speedAdjustedTime'] != null) PlayerSettings.setSpeedAdjustedTime(s['speedAdjustedTime'] as bool);
if (s['keepScreenOnPlayer'] != null) PlayerSettings.setKeepScreenOnInPlayer(s['keepScreenOnPlayer'] as bool);
if (s['keepScreenOnCarMode'] != null) PlayerSettings.setKeepScreenOnInCarMode(s['keepScreenOnCarMode'] as bool);
- if (s['carDisconnectRewind'] != null) PlayerSettings.setCarDisconnectRewindSeconds(s['carDisconnectRewind'] as int);
if (s['forwardSkip'] != null) PlayerSettings.setForwardSkip(s['forwardSkip'] as int);
if (s['backSkip'] != null) PlayerSettings.setBackSkip(s['backSkip'] as int);
if (s['shakeMode'] != null) PlayerSettings.setShakeMode(s['shakeMode'] as String);
diff --git a/lib/services/carplay_service.dart b/lib/services/carplay_service.dart
index fe0093b5..1d863874 100644
--- a/lib/services/carplay_service.dart
+++ b/lib/services/carplay_service.dart
@@ -88,7 +88,6 @@ class CarPlayService {
void _onConnectionChange(ConnectionStatusTypes status) {
debugPrint('[CarPlay] Connection status: $status');
if (status == ConnectionStatusTypes.disconnected) {
- if (_connected) unawaited(AudioPlayerService().onCarDisconnected());
_connected = false;
_rootTemplate = null;
_lastRootBuilt = null;
diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dart
index 2b927363..58a346d4 100644
--- a/lib/services/player_settings.dart
+++ b/lib/services/player_settings.dart
@@ -854,9 +854,6 @@ class PlayerSettings {
static Future<void> setKeepScreenOnInPlayer(bool value) =>
_set('keepScreenOnPlayer', value, notify: true);
static Future<bool> getKeepScreenOnInCarMode() => _get('keepScreenOnCarMode', false);
- static Future<int> getCarDisconnectRewindSeconds() => _get('carDisconnectRewind', 0);
- static Future<void> setCarDisconnectRewindSeconds(int seconds) =>
- _set('carDisconnectRewind', seconds, notify: true);
static Future<void> setKeepScreenOnInCarMode(bool value) =>
_set('keepScreenOnCarMode', value, notify: true);
diff --git a/packages/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioService.java b/packages/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioService.java
index 428ab40b..7c0ffaaf 100644
--- a/packages/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioService.java
+++ b/packages/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioService.java
@@ -7,8 +7,6 @@ import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.database.ContentObserver;
-import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.AudioManager;
@@ -131,54 +129,6 @@ public class AudioService extends MediaBrowserServiceCompat {
if (isCarPackage(pkg)) lastCarClientAt = SystemClock.elapsedRealtime();
}
- // Android Auto's connection, from the car app connection provider:
- // 2 = projection (Android Auto), 1 = the car's own Android, 0 = no car.
- // The moment projection ends is stamped so Dart can tell the system's
- // late pause after the engine went off from an ordinary pause.
- private static final Uri CAR_CONNECTION_URI = Uri.parse("content://androidx.car.app.connection");
- private static volatile int carConnectionState = 0;
- private static volatile long carGoneAt = 0;
- private ContentObserver carConnectionObserver;
-
- private void readCarConnectionState() {
- int state = 0;
- try (Cursor c = getContentResolver().query(CAR_CONNECTION_URI,
- new String[]{"CarConnectionState"}, null, null, null)) {
- if (c != null && c.moveToFirst()) {
- int col = c.getColumnIndex("CarConnectionState");
- if (col >= 0) state = c.getInt(col);
- }
- } catch (Exception e) {
- // No Android Auto on this phone.
- }
- if (carConnectionState == 2 && state != 2) carGoneAt = SystemClock.elapsedRealtime();
- carConnectionState = state;
- }
-
- private void watchCarConnection() {
- try {
- carConnectionObserver = new ContentObserver(new Handler(Looper.getMainLooper())) {
- @Override
- public void onChange(boolean selfChange) {
- readCarConnectionState();
- }
- };
- getContentResolver().registerContentObserver(CAR_CONNECTION_URI, false, carConnectionObserver);
- } catch (Exception e) {
- carConnectionObserver = null;
- }
- readCarConnectionState();
- }
-
- private void stopWatchingCarConnection() {
- if (carConnectionObserver == null) return;
- try {
- getContentResolver().unregisterContentObserver(carConnectionObserver);
- } catch (Exception ignored) {
- }
- carConnectionObserver = null;
- }
-
public static Map<String, Object> getDiagnosticSnapshot() {
final long now = SystemClock.elapsedRealtime();
final Map<String, Object> snapshot = new HashMap<>();
@@ -189,8 +139,6 @@ public class AudioService extends MediaBrowserServiceCompat {
snapshot.put("lastPauseCaller", "mediaSession");
snapshot.put("lastPauseCallerAgeMs", lastPauseAt == 0 ? -1 : now - lastPauseAt);
snapshot.put("carClientAgeMs", lastCarClientAt == 0 ? -1 : now - lastCarClientAt);
- snapshot.put("carConnectionState", carConnectionState);
- snapshot.put("carGoneAgeMs", carGoneAt == 0 ? -1 : now - carGoneAt);
snapshot.put("lastKeyPkg", lastMediaKeyPkg);
return snapshot;
}
@@ -430,7 +378,6 @@ public class AudioService extends MediaBrowserServiceCompat {
playing = false;
processingState = AudioProcessingState.idle;
mediaSession = new MediaSessionCompat(this, "media-session");
- watchCarConnection();
configure(new AudioServiceConfig(getApplicationContext()));
@@ -487,7 +434,6 @@ public class AudioService extends MediaBrowserServiceCompat {
@Override
public void onDestroy() {
super.onDestroy();
- stopWatchingCarConnection();
if (listener != null) {
listener.onDestroy();
listener = null;