fix(auto): guard shipped resources, walk favourite groups when skipping
History review requested by the owner: when and why did the Android Auto UI stop working. ANSWER: 31 July, commit2540556, "give the equalizer actions distinct, state-aware icons".9eff760(31-07) androidIcon: 'drawable/ic_stat_pluriwave' -> in the APK2540556(31-07) androidIcon: 'drawable/ic_auto_eq_on' -> NEVER in it That commit swapped a drawable that shipped for two that the stale CI resource cache never included. From that moment getResourceId returned 0, PlaybackStateCompat.CustomAction.Builder threw, and the throw aborted AudioService.setState before the session was published -- so every Android Auto symptom chased since is one line of that commit. The bitter part is that2540556was itself a fix for a report about two identical icons. Three changes. 1. CI guard. The build now unzips the release APK and fails if a drawable resolved by NAME at runtime is missing. Resolution by name cannot fail at compile time -- it fails in the car, silently, with id 0. This class of bug shipped undetected for a week; it cannot ship again. 2. Skipping stations now walks the favourites GROUP first, as requested: group -> all favourites -> my stations -> catalogue. Two deliberate exclusions, both tested: `sinAsignarId` is the ABSENCE of a group, not a group, so those walk all favourites; and a one-member group falls through too, or both buttons would be dead ends. The group is read from the FAVOURITE record, never from the playing station -- that one is rebuilt by emisoraDesdeMediaItem, which carries no group id and would always report "unfiled". 3. Diagnostics on the station skip. It was reported as doing nothing for radio, and every early return in that method is silent: an empty list and a single-entry list look identical from outside. The log now names which one fired, so the next capture answers it instead of another hypothesis. Tests: 1161 -> 1165.
This commit is contained in:
@@ -936,15 +936,26 @@ Future<void> reproducirPorMediaId(
|
||||
await reproducir(item);
|
||||
}
|
||||
|
||||
/// Which list previous/next should walk for [actual]: the NARROWEST list the
|
||||
/// station actually belongs to, favourites first, then my stations, then the
|
||||
/// full catalogue.
|
||||
/// Which list previous/next should walk for [actual]: the NARROWEST context
|
||||
/// the station belongs to.
|
||||
///
|
||||
/// Narrowest-first is the point. "Next station" while playing a favourite
|
||||
/// should land on the next favourite, not on entry 4,318 of a 50,000-station
|
||||
/// catalogue that happens to sit beside it alphabetically. Falling through to
|
||||
/// [todas] only when the station is in neither curated list keeps the button
|
||||
/// working for a station reached by search.
|
||||
/// Tightest first:
|
||||
/// 1. its FAVOURITES GROUP, when it is a favourite filed under a real group,
|
||||
/// 2. all favourites,
|
||||
/// 3. my stations,
|
||||
/// 4. the full catalogue.
|
||||
///
|
||||
/// The group tier is what the owner asked for: driving with a themed group,
|
||||
/// "next" should stay inside that group rather than wander across every
|
||||
/// favourite. And "next" from a favourite must never land on entry 4,318 of a
|
||||
/// 50,000-station catalogue that happens to sit beside it alphabetically.
|
||||
/// Falling through to [todas] only when the station is in neither curated
|
||||
/// list keeps the button alive for a station reached by search.
|
||||
///
|
||||
/// [GrupoFavoritos.sinAsignarId] is deliberately NOT treated as a group: it
|
||||
/// is the ABSENCE of one, so those stations walk all favourites instead of a
|
||||
/// bucket that only means "unfiled". A group with a single member also falls
|
||||
/// through to all favourites — otherwise both buttons would be dead ends.
|
||||
///
|
||||
/// Returns an empty list when [actual] is in none of them, which
|
||||
/// [emisoraVecina] turns into "do nothing".
|
||||
@@ -954,10 +965,28 @@ List<Emisora> listaParaSaltoEmisora({
|
||||
required List<Emisora> misEmisoras,
|
||||
required List<Emisora> todas,
|
||||
}) {
|
||||
bool contiene(List<Emisora> lista) => lista.any((e) => e.uuid == actual.uuid);
|
||||
if (contiene(favoritos)) return favoritos;
|
||||
if (contiene(misEmisoras)) return misEmisoras;
|
||||
if (contiene(todas)) return todas;
|
||||
Emisora? enLista(List<Emisora> lista) {
|
||||
for (final e in lista) {
|
||||
if (e.uuid == actual.uuid) return e;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// The FAVOURITE record is the authority on the group, never `actual`: the
|
||||
// playing station is rebuilt from a MediaItem by `emisoraDesdeMediaItem`,
|
||||
// which carries no group id and would always report "sin asignar".
|
||||
final favorita = enLista(favoritos);
|
||||
if (favorita != null) {
|
||||
final grupo = favorita.grupoFavoritosId;
|
||||
if (grupo != GrupoFavoritos.sinAsignarId) {
|
||||
final delGrupo =
|
||||
favoritos.where((e) => e.grupoFavoritosId == grupo).toList();
|
||||
if (delGrupo.length > 1) return delGrupo;
|
||||
}
|
||||
return favoritos;
|
||||
}
|
||||
if (enLista(misEmisoras) != null) return misEmisoras;
|
||||
if (enLista(todas) != null) return todas;
|
||||
return const [];
|
||||
}
|
||||
|
||||
|
||||
@@ -1544,6 +1544,15 @@ class PluriWaveAudioHandler extends BaseAudioHandler
|
||||
todas: await fuente.todas(),
|
||||
);
|
||||
final destino = emisoraVecina(actual, lista, haciaAtras: haciaAtras);
|
||||
// Reported: in the car these buttons did nothing for radio. Every early
|
||||
// return here is silent, so the log has to say WHICH one fired --
|
||||
// an empty list (the station matched none of the three) and a station
|
||||
// that is in a list of one are indistinguishable from outside.
|
||||
debugPrint(
|
||||
'[PluriWave][ServicioAudio] salto emisora atras=$haciaAtras '
|
||||
'actual=${actual.nombre} uuid=${actual.uuid} '
|
||||
'lista=${lista.length} destino=${destino?.nombre ?? "NINGUNO"}',
|
||||
);
|
||||
if (destino == null) return;
|
||||
await playMediaItem(mediaItemParaEmisora(destino, l10n: _textos));
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user