react-native-audio-browser 0.2.0-next.53 → 0.2.0-next.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -19
- package/android/src/cast/java/com/audiobrowser/cast/CastSupport.kt +8 -10
- package/android/src/main/java/com/audiobrowser/AudioBrowser.kt +96 -243
- package/android/src/main/java/com/audiobrowser/AudioBrowserLifecycleModule.kt +8 -12
- package/android/src/main/java/com/audiobrowser/AudioBrowserPackage.kt +1 -3
- package/android/src/main/java/com/audiobrowser/Callbacks.kt +1 -10
- package/android/src/main/java/com/audiobrowser/ForegroundStart.kt +13 -18
- package/android/src/main/java/com/audiobrowser/HeadlessTaskService.kt +3 -7
- package/android/src/main/java/com/audiobrowser/RemoteOutputs.kt +8 -10
- package/android/src/main/java/com/audiobrowser/Service.kt +20 -61
- package/android/src/main/java/com/audiobrowser/ServiceBinding.kt +9 -17
- package/android/src/main/java/com/audiobrowser/browser/ArtworkResolutionRegistry.kt +10 -9
- package/android/src/main/java/com/audiobrowser/browser/BrowseArtworkRegistry.kt +11 -8
- package/android/src/main/java/com/audiobrowser/browser/BrowserManager.kt +117 -448
- package/android/src/main/java/com/audiobrowser/browser/BrowserUrlResolution.kt +21 -60
- package/android/src/main/java/com/audiobrowser/browser/InertStyleDiagnostic.kt +20 -80
- package/android/src/main/java/com/audiobrowser/browser/JsonArtwork.kt +6 -10
- package/android/src/main/java/com/audiobrowser/browser/JsonModels.kt +7 -24
- package/android/src/main/java/com/audiobrowser/browser/RouteMatch.kt +2 -4
- package/android/src/main/java/com/audiobrowser/browser/SectionScope.kt +13 -31
- package/android/src/main/java/com/audiobrowser/browser/SimpleRouter.kt +12 -40
- package/android/src/main/java/com/audiobrowser/browser/StyleResolver.kt +15 -26
- package/android/src/main/java/com/audiobrowser/browser/TrackLoadHandler.kt +5 -15
- package/android/src/main/java/com/audiobrowser/extension/EnumExtensions.kt +1 -0
- package/android/src/main/java/com/audiobrowser/extension/NumberExt.kt +2 -0
- package/android/src/main/java/com/audiobrowser/extension/ResolvedTrackExt.kt +4 -8
- package/android/src/main/java/com/audiobrowser/extension/TappedTrack.kt +4 -6
- package/android/src/main/java/com/audiobrowser/extension/TrackIdentity.kt +3 -7
- package/android/src/main/java/com/audiobrowser/http/HttpClient.kt +13 -22
- package/android/src/main/java/com/audiobrowser/http/RequestConfigBuilder.kt +17 -38
- package/android/src/main/java/com/audiobrowser/model/IcyTitle.kt +5 -6
- package/android/src/main/java/com/audiobrowser/model/PlaybackMetadata.kt +4 -9
- package/android/src/main/java/com/audiobrowser/model/PlayerSetupOptions.kt +18 -29
- package/android/src/main/java/com/audiobrowser/model/PlayerUpdateOptions.kt +6 -16
- package/android/src/main/java/com/audiobrowser/player/AutomaticBufferManager.kt +15 -45
- package/android/src/main/java/com/audiobrowser/player/CapabilityControls.kt +23 -59
- package/android/src/main/java/com/audiobrowser/player/CrossOriginHeaderStripper.kt +14 -26
- package/android/src/main/java/com/audiobrowser/player/DynamicLoadControl.kt +15 -43
- package/android/src/main/java/com/audiobrowser/player/EnginePlayback.kt +4 -4
- package/android/src/main/java/com/audiobrowser/player/EqualizerController.kt +15 -21
- package/android/src/main/java/com/audiobrowser/player/InterceptingPlayer.kt +14 -31
- package/android/src/main/java/com/audiobrowser/player/LocalEngine.kt +8 -8
- package/android/src/main/java/com/audiobrowser/player/MediaFactory.kt +16 -27
- package/android/src/main/java/com/audiobrowser/player/MediaSessionCallback.kt +119 -237
- package/android/src/main/java/com/audiobrowser/player/MediaSessionCommandManager.kt +48 -145
- package/android/src/main/java/com/audiobrowser/player/NowPlayingUpdater.kt +39 -100
- package/android/src/main/java/com/audiobrowser/player/PlaybackErrorClassifier.kt +16 -26
- package/android/src/main/java/com/audiobrowser/player/PlaybackStateMachine.kt +22 -28
- package/android/src/main/java/com/audiobrowser/player/PlaybackStateStore.kt +28 -64
- package/android/src/main/java/com/audiobrowser/player/PlaybackTimer.kt +8 -4
- package/android/src/main/java/com/audiobrowser/player/Player.kt +117 -405
- package/android/src/main/java/com/audiobrowser/player/PlayerCapabilitiesExt.kt +1 -1
- package/android/src/main/java/com/audiobrowser/player/PlayerEngineFactory.kt +11 -19
- package/android/src/main/java/com/audiobrowser/player/PlayerListener.kt +30 -96
- package/android/src/main/java/com/audiobrowser/player/RetryLoadErrorHandlingPolicy.kt +39 -95
- package/android/src/main/java/com/audiobrowser/player/ShuffleOrderLedBy.kt +7 -13
- package/android/src/main/java/com/audiobrowser/player/SleepTimer.kt +13 -30
- package/android/src/main/java/com/audiobrowser/player/SleepTimerManager.kt +7 -11
- package/android/src/main/java/com/audiobrowser/player/StuckRecoveryPolicy.kt +9 -22
- package/android/src/main/java/com/audiobrowser/player/TransformingDataSource.kt +22 -54
- package/android/src/main/java/com/audiobrowser/player/VolumeFader.kt +8 -15
- package/android/src/main/java/com/audiobrowser/remote/RemoteItem.kt +9 -8
- package/android/src/main/java/com/audiobrowser/remote/RemoteOutputsController.kt +13 -10
- package/android/src/main/java/com/audiobrowser/remote/RemotePlayback.kt +8 -8
- package/android/src/main/java/com/audiobrowser/remote/RemoteQueue.kt +12 -5
- package/android/src/main/java/com/audiobrowser/remote/RemoteSwitchingPlayer.kt +28 -48
- package/android/src/main/java/com/audiobrowser/sonos/DeviceDescriptionParser.kt +11 -19
- package/android/src/main/java/com/audiobrowser/sonos/DidlLite.kt +2 -2
- package/android/src/main/java/com/audiobrowser/sonos/SoapClient.kt +6 -6
- package/android/src/main/java/com/audiobrowser/sonos/SoapEnvelopes.kt +8 -9
- package/android/src/main/java/com/audiobrowser/sonos/SoapResponseParser.kt +11 -18
- package/android/src/main/java/com/audiobrowser/sonos/SonosDiscoverer.kt +10 -10
- package/android/src/main/java/com/audiobrowser/sonos/SonosOutputs.kt +10 -10
- package/android/src/main/java/com/audiobrowser/sonos/SonosPlayer.kt +21 -33
- package/android/src/main/java/com/audiobrowser/sonos/SonosRemote.kt +4 -6
- package/android/src/main/java/com/audiobrowser/sonos/SonosRouteProviderService.kt +9 -10
- package/android/src/main/java/com/audiobrowser/sonos/SonosStreamUri.kt +7 -7
- package/android/src/main/java/com/audiobrowser/sonos/SonosTransport.kt +5 -4
- package/android/src/main/java/com/audiobrowser/sonos/SsdpDiscovery.kt +8 -3
- package/android/src/main/java/com/audiobrowser/sonos/SsdpMessages.kt +4 -6
- package/android/src/main/java/com/audiobrowser/sonos/ZoneGroupState.kt +13 -11
- package/android/src/main/java/com/audiobrowser/tls/AiaCertChaser.kt +34 -71
- package/android/src/main/java/com/audiobrowser/tls/AiaChasingExtendedTrustManager.kt +20 -37
- package/android/src/main/java/com/audiobrowser/tls/AiaChasingTrustManager.kt +18 -27
- package/android/src/main/java/com/audiobrowser/tls/AiaTls.kt +14 -29
- package/android/src/main/java/com/audiobrowser/tls/CachingCertificateFetcher.kt +68 -133
- package/android/src/main/java/com/audiobrowser/util/ArtworkContentProvider.kt +10 -22
- package/android/src/main/java/com/audiobrowser/util/ArtworkRoutes.kt +6 -6
- package/android/src/main/java/com/audiobrowser/util/ArtworkUris.kt +4 -3
- package/android/src/main/java/com/audiobrowser/util/ArtworkVariant.kt +2 -13
- package/android/src/main/java/com/audiobrowser/util/Automotive.kt +2 -4
- package/android/src/main/java/com/audiobrowser/util/BatteryOptimizationHelper.kt +3 -9
- package/android/src/main/java/com/audiobrowser/util/BatteryWarningStore.kt +4 -14
- package/android/src/main/java/com/audiobrowser/util/BrowserPathHelper.kt +21 -85
- package/android/src/main/java/com/audiobrowser/util/CoilArtworkLoader.kt +7 -7
- package/android/src/main/java/com/audiobrowser/util/CoilArtworkLoaderHolder.kt +5 -8
- package/android/src/main/java/com/audiobrowser/util/CoilBitmapLoader.kt +8 -24
- package/android/src/main/java/com/audiobrowser/util/EqualizerManager.kt +7 -39
- package/android/src/main/java/com/audiobrowser/util/MediaExtrasBuilder.kt +10 -14
- package/android/src/main/java/com/audiobrowser/util/MetadataAdapter.kt +5 -9
- package/android/src/main/java/com/audiobrowser/util/NetworkConnectivityMonitor.kt +5 -9
- package/android/src/main/java/com/audiobrowser/util/OutputMonitor.kt +21 -50
- package/android/src/main/java/com/audiobrowser/util/OutputSwitcher.kt +7 -20
- package/android/src/main/java/com/audiobrowser/util/PlayingStateFactory.kt +3 -5
- package/android/src/main/java/com/audiobrowser/util/RatingFavorites.kt +4 -5
- package/android/src/main/java/com/audiobrowser/util/StyleWire.kt +5 -5
- package/android/src/main/java/com/audiobrowser/util/SvgArtworkRenderer.kt +5 -9
- package/android/src/main/java/com/audiobrowser/util/SystemVolumeMonitor.kt +6 -9
- package/android/src/main/java/com/audiobrowser/util/TrackFactory.kt +25 -47
- package/android/src/nocast/java/com/audiobrowser/cast/CastSupport.kt +0 -2
- package/android/src/test/java/com/audiobrowser/ForegroundStartTest.kt +1 -2
- package/android/src/test/java/com/audiobrowser/LegacyRatingTest.kt +3 -3
- package/android/src/test/java/com/audiobrowser/ServiceBindingTest.kt +0 -13
- package/android/src/test/java/com/audiobrowser/ServiceTaskRemovedTest.kt +2 -3
- package/android/src/test/java/com/audiobrowser/TestFixtures.kt +5 -14
- package/android/src/test/java/com/audiobrowser/browser/BrowseArtworkRegistryTest.kt +1 -1
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerBuildApiRequestTest.kt +2 -8
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerFavoritesTest.kt +2 -12
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerLayerResolutionTest.kt +5 -28
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerTest.kt +11 -43
- package/android/src/test/java/com/audiobrowser/browser/BrowserUrlResolutionTest.kt +4 -13
- package/android/src/test/java/com/audiobrowser/browser/InertStyleDiagnosticTest.kt +2 -11
- package/android/src/test/java/com/audiobrowser/browser/JsonArtworkTest.kt +0 -2
- package/android/src/test/java/com/audiobrowser/browser/JsonStyleTest.kt +3 -8
- package/android/src/test/java/com/audiobrowser/browser/SectionScopeTest.kt +2 -14
- package/android/src/test/java/com/audiobrowser/browser/SimpleRouterTest.kt +1 -5
- package/android/src/test/java/com/audiobrowser/browser/StyleResolverTest.kt +2 -13
- package/android/src/test/java/com/audiobrowser/extension/TappedTrackTest.kt +1 -7
- package/android/src/test/java/com/audiobrowser/extension/TrackIdentityTest.kt +0 -5
- package/android/src/test/java/com/audiobrowser/http/RequestConfigBuilderTest.kt +8 -16
- package/android/src/test/java/com/audiobrowser/model/IcyTitleTest.kt +1 -1
- package/android/src/test/java/com/audiobrowser/player/BrowseTilesTest.kt +12 -29
- package/android/src/test/java/com/audiobrowser/player/CapabilityControlsTest.kt +3 -12
- package/android/src/test/java/com/audiobrowser/player/CrossOriginHeaderStripperTest.kt +0 -7
- package/android/src/test/java/com/audiobrowser/player/DynamicLoadControlTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/player/EqualizerControllerTest.kt +0 -9
- package/android/src/test/java/com/audiobrowser/player/LiveSeekCommandTest.kt +1 -2
- package/android/src/test/java/com/audiobrowser/player/MediaSessionSlotMappingTest.kt +0 -9
- package/android/src/test/java/com/audiobrowser/player/NowPlayingUpdaterTest.kt +15 -22
- package/android/src/test/java/com/audiobrowser/player/PlaybackErrorClassifierTest.kt +1 -24
- package/android/src/test/java/com/audiobrowser/player/PlaybackStateMachineTest.kt +0 -20
- package/android/src/test/java/com/audiobrowser/player/PlaybackStateStoreTrackJsonTest.kt +1 -6
- package/android/src/test/java/com/audiobrowser/player/PlaybackTimerTest.kt +2 -4
- package/android/src/test/java/com/audiobrowser/player/PlayerCastTest.kt +2 -2
- package/android/src/test/java/com/audiobrowser/player/PlayerEngineFactoryTest.kt +0 -3
- package/android/src/test/java/com/audiobrowser/player/PlayerInvalidTrackTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/player/PlayerSetupTest.kt +3 -2
- package/android/src/test/java/com/audiobrowser/player/PlayerSonosTest.kt +5 -1
- package/android/src/test/java/com/audiobrowser/player/PlayerSuppressionTest.kt +5 -7
- package/android/src/test/java/com/audiobrowser/player/RetryLoadErrorHandlingPolicyTest.kt +4 -35
- package/android/src/test/java/com/audiobrowser/player/SessionErrorMaskTest.kt +0 -5
- package/android/src/test/java/com/audiobrowser/player/ShuffleOrderLedByTest.kt +1 -8
- package/android/src/test/java/com/audiobrowser/player/StandardSkipTest.kt +4 -6
- package/android/src/test/java/com/audiobrowser/player/StuckRecoveryPolicyTest.kt +11 -11
- package/android/src/test/java/com/audiobrowser/player/TransformingDataSourceTest.kt +2 -23
- package/android/src/test/java/com/audiobrowser/remote/FakeRemote.kt +9 -10
- package/android/src/test/java/com/audiobrowser/remote/RemoteSwitchingPlayerTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/sonos/DeviceDescriptionParserTest.kt +1 -3
- package/android/src/test/java/com/audiobrowser/sonos/DidlLiteTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/sonos/SoapClientTest.kt +0 -3
- package/android/src/test/java/com/audiobrowser/sonos/SoapEnvelopesTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/sonos/SoapResponseParserTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/sonos/SonosDiscovererTest.kt +2 -0
- package/android/src/test/java/com/audiobrowser/sonos/SonosPlayerTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/sonos/SonosRemoteTest.kt +1 -1
- package/android/src/test/java/com/audiobrowser/sonos/SonosRoutesTest.kt +2 -0
- package/android/src/test/java/com/audiobrowser/sonos/SonosTransportTest.kt +2 -6
- package/android/src/test/java/com/audiobrowser/sonos/SsdpMessagesTest.kt +0 -2
- package/android/src/test/java/com/audiobrowser/tls/AiaCertChaserTest.kt +13 -37
- package/android/src/test/java/com/audiobrowser/tls/AiaChasingTrustManagerTest.kt +10 -24
- package/android/src/test/java/com/audiobrowser/tls/CachingCertificateFetcherCallSiteTest.kt +15 -39
- package/android/src/test/java/com/audiobrowser/tls/CachingCertificateFetcherTest.kt +4 -10
- package/android/src/test/java/com/audiobrowser/util/ArtworkContentProviderTest.kt +2 -11
- package/android/src/test/java/com/audiobrowser/util/ArtworkUrisTest.kt +0 -1
- package/android/src/test/java/com/audiobrowser/util/BrowserPathHelperTest.kt +0 -4
- package/android/src/test/java/com/audiobrowser/util/CoilArtworkLoaderHolderTest.kt +1 -1
- package/android/src/test/java/com/audiobrowser/util/CoilArtworkLoaderTest.kt +0 -5
- package/android/src/test/java/com/audiobrowser/util/FakeImageLoader.kt +2 -2
- package/android/src/test/java/com/audiobrowser/util/MediaExtrasBuilderTest.kt +4 -12
- package/android/src/test/java/com/audiobrowser/util/OutputMonitorTest.kt +1 -1
- package/android/src/test/java/com/audiobrowser/util/PlayingStateFactoryTest.kt +0 -4
- package/android/src/test/java/com/audiobrowser/util/TrackFactoryBrowseTest.kt +1 -1
- package/android/src/test/java/com/audiobrowser/util/TrackFactoryMediaIdTest.kt +4 -6
- package/android/src/testCast/java/com/audiobrowser/cast/CastEndsTest.kt +1 -1
- package/android/src/testCast/java/com/audiobrowser/cast/SendingMediaItemConverterTest.kt +1 -0
- package/ios/AVPlayerEngine.swift +13 -21
- package/ios/AVPlayerEngineCallbacks.swift +2 -4
- package/ios/Browser/BrowseGate.swift +7 -8
- package/ios/Browser/BrowserConfig.swift +19 -34
- package/ios/Browser/BrowserError.swift +0 -1
- package/ios/Browser/BrowserManager.swift +29 -75
- package/ios/Browser/BrowserPathHelper.swift +13 -93
- package/ios/Browser/FavoriteSet.swift +7 -10
- package/ios/Browser/InertStyleDiagnostic.swift +17 -82
- package/ios/Browser/JsonModels.swift +11 -51
- package/ios/Browser/NavigationErrorState.swift +3 -2
- package/ios/Browser/PageResolver.swift +13 -23
- package/ios/Browser/RequestLayer.swift +16 -20
- package/ios/Browser/RequestPipeline.swift +33 -43
- package/ios/Browser/SearchDrillIn.swift +7 -13
- package/ios/Browser/SectionScope.swift +14 -26
- package/ios/Browser/SimpleRouter.swift +8 -15
- package/ios/Browser/StyleResolver.swift +12 -29
- package/ios/Browser/TabBarEntries.swift +6 -11
- package/ios/Browser/TrackIdTemplate.swift +6 -14
- package/ios/CarPlay/CPInterfaceController+Safe.swift +19 -28
- package/ios/CarPlay/CarPlayArtworkResolver.swift +5 -9
- package/ios/CarPlay/CarPlayController.swift +4 -4
- package/ios/CarPlay/CarPlayImageLoader.swift +11 -26
- package/ios/CarPlay/CarPlayListItemFactory.swift +30 -80
- package/ios/CarPlay/CarPlayNowPlayingManager.swift +19 -54
- package/ios/CarPlay/CarPlaySession+Navigator.swift +10 -10
- package/ios/CarPlay/CarPlaySession+PageLoader.swift +6 -5
- package/ios/CarPlay/CarPlaySession+Refresher.swift +2 -2
- package/ios/CarPlay/CarPlaySession+TabBar.swift +19 -26
- package/ios/CarPlay/CarPlaySession.swift +13 -17
- package/ios/CarPlay/CarPlayTemplates.swift +6 -7
- package/ios/CarPlay/IntentHandlers.swift +3 -5
- package/ios/CarPlay/MediaIntentCriteria.swift +15 -29
- package/ios/CarPlay/MediaIntentHandler.swift +4 -7
- package/ios/CarPlay/MediaIntentPlayback.swift +9 -8
- package/ios/CarPlay/NowPlayingButtonRules.swift +3 -4
- package/ios/CarPlay/SectionPresentation.swift +18 -28
- package/ios/CarPlay/TopTemplateReplacer.swift +8 -9
- package/ios/Extension/Capability+RemoteCommand.swift +3 -3
- package/ios/Extension/ChapterMetadata+AVFoundation.swift +2 -5
- package/ios/Extension/CxxVectorConformances.swift +4 -16
- package/ios/Extension/NavigationError+Conversion.swift +4 -7
- package/ios/Extension/PlayerCapabilities+Favorite.swift +0 -1
- package/ios/Extension/RequestConfig+Copying.swift +2 -6
- package/ios/Extension/ResolvedTrack+Copying.swift +2 -8
- package/ios/Extension/SearchParams+Query.swift +4 -4
- package/ios/Extension/Section+Copying.swift +3 -6
- package/ios/Extension/String+IcyCharset.swift +5 -5
- package/ios/Extension/TimedMetadata+AVFoundation.swift +6 -12
- package/ios/Extension/Track+AVPlayer.swift +1 -2
- package/ios/Extension/Track+Copying.swift +2 -8
- package/ios/Extension/Track+Identity.swift +4 -9
- package/ios/Extension/TrackMetadata+AVFoundation.swift +10 -13
- package/ios/Extension/UIApplication+ActiveScene.swift +6 -14
- package/ios/Extension/Variant+Artwork.swift +8 -22
- package/ios/Http/HttpClient.swift +3 -3
- package/ios/HybridAudioBrowser+Browser.swift +10 -16
- package/ios/HybridAudioBrowser+Options.swift +6 -9
- package/ios/HybridAudioBrowser+Player.swift +8 -16
- package/ios/HybridAudioBrowser+PlayerCallbacks.swift +4 -5
- package/ios/HybridAudioBrowser+Stubs.swift +5 -7
- package/ios/HybridAudioBrowser.swift +54 -79
- package/ios/Model/NitroTypeStubs.swift +15 -22
- package/ios/Model/PlayerUpdateOptions.swift +6 -21
- package/ios/Model/RemoteCommand.swift +2 -2
- package/ios/Model/TrackPlayerError.swift +9 -22
- package/ios/NowPlayingInfo/NowPlayingInfoController.swift +21 -40
- package/ios/NowPlayingInfo/SilentAudioPrimer.swift +10 -16
- package/ios/Observer/ItemObserver.swift +7 -5
- package/ios/Observer/PlayerObserver.swift +5 -5
- package/ios/PlaybackEvent.swift +2 -2
- package/ios/Player/AirPlayStallJudgement.swift +7 -9
- package/ios/Player/AudioSessionController.swift +14 -15
- package/ios/Player/DeferredSeek.swift +2 -2
- package/ios/Player/EndOfTrackJudgement.swift +6 -13
- package/ios/Player/ErrorStatus.swift +8 -7
- package/ios/Player/MediaLoader.swift +20 -24
- package/ios/Player/NowPlayingLines.swift +1 -4
- package/ios/Player/NowPlayingUpdater.swift +35 -61
- package/ios/Player/PersistedPlaybackState.swift +1 -2
- package/ios/Player/PlaybackFailure.swift +20 -24
- package/ios/Player/PlaybackPersistence.swift +5 -6
- package/ios/Player/PlaybackStateMachine.swift +8 -11
- package/ios/Player/PlaybackTimer.swift +8 -11
- package/ios/Player/Player.swift +6 -13
- package/ios/Player/PlayerEngine.swift +20 -20
- package/ios/Player/PlayerStatusTypes.swift +1 -2
- package/ios/Player/QueueManager.swift +23 -67
- package/ios/Player/RetryLoop.swift +39 -50
- package/ios/Player/ShuffleOrder.swift +17 -57
- package/ios/Player/SleepTimerManager.swift +13 -28
- package/ios/Player/VolumeFader.swift +16 -16
- package/ios/RemoteCommand/RemoteCommandCallbacks.swift +6 -16
- package/ios/RemoteCommand/RemoteCommandController.swift +8 -10
- package/ios/Tests/AirPlayStallJudgementTests.swift +4 -4
- package/ios/Tests/BrowserPathHelperTests.swift +3 -6
- package/ios/Tests/DeferredSeekTests.swift +1 -3
- package/ios/Tests/EmitterTests.swift +0 -1
- package/ios/Tests/EndOfTrackJudgementTests.swift +1 -6
- package/ios/Tests/FavoriteSetTests.swift +1 -0
- package/ios/Tests/GenerationMemoTests.swift +2 -2
- package/ios/Tests/InertStyleDiagnosticTests.swift +4 -10
- package/ios/Tests/JsonModelsTests.swift +5 -12
- package/ios/Tests/LRUCacheTests.swift +1 -5
- package/ios/Tests/MediaIntentCriteriaTests.swift +2 -7
- package/ios/Tests/MediaLoaderTests.swift +3 -12
- package/ios/Tests/ObserverTests.swift +3 -3
- package/ios/Tests/PlaybackErrorTests.swift +7 -9
- package/ios/Tests/PlaybackFailureTests.swift +9 -17
- package/ios/Tests/PlaybackPersistenceTests.swift +1 -0
- package/ios/Tests/PlaybackStateMachineTests.swift +1 -16
- package/ios/Tests/PlaybackTimerTests.swift +2 -3
- package/ios/Tests/PlayerPolicyTests.swift +10 -26
- package/ios/Tests/PlayerTests.swift +53 -88
- package/ios/Tests/PlayingStateTests.swift +0 -1
- package/ios/Tests/QueueManagerTests.swift +30 -80
- package/ios/Tests/RemoteCommandControllerTests.swift +5 -13
- package/ios/Tests/ResolvedTrackCopyingTests.swift +0 -2
- package/ios/Tests/RetryLoopTests.swift +12 -35
- package/ios/Tests/SearchDrillInTests.swift +4 -5
- package/ios/Tests/SectionPresentationTests.swift +3 -16
- package/ios/Tests/SectionScopeTests.swift +3 -6
- package/ios/Tests/SimpleRouterTests.swift +1 -5
- package/ios/Tests/SleepTimerManagerTests.swift +8 -11
- package/ios/Tests/StyleResolverTests.swift +4 -13
- package/ios/Tests/Support/ManualSleepTimerScheduler.swift +3 -8
- package/ios/Tests/Support/TestTypes.swift +5 -15
- package/ios/Tests/TabBarEntriesTests.swift +0 -2
- package/ios/Tests/TimedMetadataAVFoundationTests.swift +2 -3
- package/ios/Tests/TopTemplateReplacerTests.swift +1 -1
- package/ios/Tests/TrackIdTemplateTests.swift +2 -6
- package/ios/Tests/TrackMetadataAVFoundationTests.swift +1 -4
- package/ios/Tests/TrackSelectorTests.swift +3 -15
- package/ios/TrackSelector.swift +13 -25
- package/ios/Util/ArtworkFreshness.swift +6 -6
- package/ios/Util/ArtworkImageFetcher.swift +19 -20
- package/ios/Util/ConcurrentMap.swift +2 -2
- package/ios/Util/Emitter.swift +8 -13
- package/ios/Util/NetworkMonitor.swift +4 -6
- package/ios/Util/OutputPicker.swift +1 -1
- package/ios/Util/ReadyValue.swift +3 -2
- package/ios/Util/SFSymbolRenderer.swift +17 -30
- package/ios/Util/SVGProcessor.swift +5 -9
- package/lib/commonjs/CLAUDE.md +7 -2
- package/lib/commonjs/features/battery.js +16 -12
- package/lib/commonjs/features/battery.js.map +1 -1
- package/lib/commonjs/features/browser-config.js +1 -1
- package/lib/commonjs/features/browser.js +74 -24
- package/lib/commonjs/features/browser.js.map +1 -1
- package/lib/commonjs/features/carConnection.js +3 -4
- package/lib/commonjs/features/carConnection.js.map +1 -1
- package/lib/commonjs/features/equalizer.js +9 -5
- package/lib/commonjs/features/equalizer.js.map +1 -1
- package/lib/commonjs/features/errors.js +35 -21
- package/lib/commonjs/features/errors.js.map +1 -1
- package/lib/commonjs/features/favorites.js +15 -13
- package/lib/commonjs/features/favorites.js.map +1 -1
- package/lib/commonjs/features/gate.js +12 -6
- package/lib/commonjs/features/gate.js.map +1 -1
- package/lib/commonjs/features/metadata.js +16 -14
- package/lib/commonjs/features/metadata.js.map +1 -1
- package/lib/commonjs/features/network.js +5 -1
- package/lib/commonjs/features/network.js.map +1 -1
- package/lib/commonjs/features/nowPlaying.js +28 -14
- package/lib/commonjs/features/nowPlaying.js.map +1 -1
- package/lib/commonjs/features/output.js +8 -4
- package/lib/commonjs/features/output.js.map +1 -1
- package/lib/commonjs/features/playback/controls.js +10 -5
- package/lib/commonjs/features/playback/controls.js.map +1 -1
- package/lib/commonjs/features/playback/playWhenReady.js +6 -5
- package/lib/commonjs/features/playback/playWhenReady.js.map +1 -1
- package/lib/commonjs/features/playback/playing.js +5 -3
- package/lib/commonjs/features/playback/playing.js.map +1 -1
- package/lib/commonjs/features/playback/progress.js +11 -5
- package/lib/commonjs/features/playback/progress.js.map +1 -1
- package/lib/commonjs/features/playback/state.js +3 -3
- package/lib/commonjs/features/playback/state.js.map +1 -1
- package/lib/commonjs/features/playback/trackPlaybackTime.js +6 -1
- package/lib/commonjs/features/playback/trackPlaybackTime.js.map +1 -1
- package/lib/commonjs/features/playback/volume.js +6 -5
- package/lib/commonjs/features/playback/volume.js.map +1 -1
- package/lib/commonjs/features/player/options.js +20 -10
- package/lib/commonjs/features/player/options.js.map +1 -1
- package/lib/commonjs/features/player/setup.js +34 -38
- package/lib/commonjs/features/player/setup.js.map +1 -1
- package/lib/commonjs/features/queue/activeTrack.js +0 -1
- package/lib/commonjs/features/queue/activeTrack.js.map +1 -1
- package/lib/commonjs/features/queue/queue.js +48 -20
- package/lib/commonjs/features/queue/queue.js.map +1 -1
- package/lib/commonjs/features/queue/repeatMode.js +2 -1
- package/lib/commonjs/features/queue/repeatMode.js.map +1 -1
- package/lib/commonjs/features/queue/shuffle.js +0 -1
- package/lib/commonjs/features/queue/shuffle.js.map +1 -1
- package/lib/commonjs/features/remoteControls.js +59 -35
- package/lib/commonjs/features/remoteControls.js.map +1 -1
- package/lib/commonjs/features/sleepTimer.js +15 -6
- package/lib/commonjs/features/sleepTimer.js.map +1 -1
- package/lib/commonjs/utils/LazyNativeEmitter.js +6 -9
- package/lib/commonjs/utils/LazyNativeEmitter.js.map +1 -1
- package/lib/commonjs/utils/NativeUpdatedValue.js +13 -12
- package/lib/commonjs/utils/NativeUpdatedValue.js.map +1 -1
- package/lib/commonjs/utils/getTrackIdentity.js +6 -4
- package/lib/commonjs/utils/getTrackIdentity.js.map +1 -1
- package/lib/commonjs/utils/useDebug.js +16 -3
- package/lib/commonjs/utils/useDebug.js.map +1 -1
- package/lib/commonjs/web/NativeAudioBrowser.js +2 -4
- package/lib/commonjs/web/NativeAudioBrowser.js.map +1 -1
- package/lib/commonjs/web/browser/parseSearchResponse.js +3 -4
- package/lib/commonjs/web/browser/parseSearchResponse.js.map +1 -1
- package/lib/commonjs/web/browser/sections.js +1 -1
- package/lib/commonjs/web/util/BrowserPathHelper.js +1 -3
- package/lib/commonjs/web/util/BrowserPathHelper.js.map +1 -1
- package/lib/module/CLAUDE.md +7 -2
- package/lib/module/features/battery.js +16 -12
- package/lib/module/features/battery.js.map +1 -1
- package/lib/module/features/browser-config.js +1 -1
- package/lib/module/features/browser.js +74 -24
- package/lib/module/features/browser.js.map +1 -1
- package/lib/module/features/carConnection.js +3 -4
- package/lib/module/features/carConnection.js.map +1 -1
- package/lib/module/features/equalizer.js +9 -5
- package/lib/module/features/equalizer.js.map +1 -1
- package/lib/module/features/errors.js +35 -21
- package/lib/module/features/errors.js.map +1 -1
- package/lib/module/features/favorites.js +15 -13
- package/lib/module/features/favorites.js.map +1 -1
- package/lib/module/features/gate.js +12 -6
- package/lib/module/features/gate.js.map +1 -1
- package/lib/module/features/metadata.js +16 -14
- package/lib/module/features/metadata.js.map +1 -1
- package/lib/module/features/network.js +5 -1
- package/lib/module/features/network.js.map +1 -1
- package/lib/module/features/nowPlaying.js +28 -14
- package/lib/module/features/nowPlaying.js.map +1 -1
- package/lib/module/features/output.js +8 -4
- package/lib/module/features/output.js.map +1 -1
- package/lib/module/features/playback/controls.js +10 -5
- package/lib/module/features/playback/controls.js.map +1 -1
- package/lib/module/features/playback/playWhenReady.js +6 -5
- package/lib/module/features/playback/playWhenReady.js.map +1 -1
- package/lib/module/features/playback/playing.js +5 -3
- package/lib/module/features/playback/playing.js.map +1 -1
- package/lib/module/features/playback/progress.js +11 -5
- package/lib/module/features/playback/progress.js.map +1 -1
- package/lib/module/features/playback/state.js +3 -3
- package/lib/module/features/playback/state.js.map +1 -1
- package/lib/module/features/playback/trackPlaybackTime.js +6 -1
- package/lib/module/features/playback/trackPlaybackTime.js.map +1 -1
- package/lib/module/features/playback/volume.js +6 -5
- package/lib/module/features/playback/volume.js.map +1 -1
- package/lib/module/features/player/options.js +20 -10
- package/lib/module/features/player/options.js.map +1 -1
- package/lib/module/features/player/setup.js +34 -38
- package/lib/module/features/player/setup.js.map +1 -1
- package/lib/module/features/queue/activeTrack.js +0 -1
- package/lib/module/features/queue/activeTrack.js.map +1 -1
- package/lib/module/features/queue/queue.js +48 -20
- package/lib/module/features/queue/queue.js.map +1 -1
- package/lib/module/features/queue/repeatMode.js +2 -1
- package/lib/module/features/queue/repeatMode.js.map +1 -1
- package/lib/module/features/queue/shuffle.js +0 -1
- package/lib/module/features/queue/shuffle.js.map +1 -1
- package/lib/module/features/remoteControls.js +59 -35
- package/lib/module/features/remoteControls.js.map +1 -1
- package/lib/module/features/sleepTimer.js +15 -6
- package/lib/module/features/sleepTimer.js.map +1 -1
- package/lib/module/utils/LazyNativeEmitter.js +6 -9
- package/lib/module/utils/LazyNativeEmitter.js.map +1 -1
- package/lib/module/utils/NativeUpdatedValue.js +13 -12
- package/lib/module/utils/NativeUpdatedValue.js.map +1 -1
- package/lib/module/utils/getTrackIdentity.js +6 -4
- package/lib/module/utils/getTrackIdentity.js.map +1 -1
- package/lib/module/utils/useDebug.js +16 -3
- package/lib/module/utils/useDebug.js.map +1 -1
- package/lib/module/web/NativeAudioBrowser.js +2 -4
- package/lib/module/web/NativeAudioBrowser.js.map +1 -1
- package/lib/module/web/browser/parseSearchResponse.js +3 -4
- package/lib/module/web/browser/parseSearchResponse.js.map +1 -1
- package/lib/module/web/browser/sections.js +1 -1
- package/lib/module/web/util/BrowserPathHelper.js +1 -3
- package/lib/module/web/util/BrowserPathHelper.js.map +1 -1
- package/lib/typescript/src/features/battery.d.ts +17 -12
- package/lib/typescript/src/features/battery.d.ts.map +1 -1
- package/lib/typescript/src/features/browser.d.ts +64 -24
- package/lib/typescript/src/features/browser.d.ts.map +1 -1
- package/lib/typescript/src/features/carConnection.d.ts +3 -4
- package/lib/typescript/src/features/carConnection.d.ts.map +1 -1
- package/lib/typescript/src/features/equalizer.d.ts +9 -5
- package/lib/typescript/src/features/equalizer.d.ts.map +1 -1
- package/lib/typescript/src/features/errors.d.ts +37 -22
- package/lib/typescript/src/features/errors.d.ts.map +1 -1
- package/lib/typescript/src/features/favorites.d.ts +15 -13
- package/lib/typescript/src/features/favorites.d.ts.map +1 -1
- package/lib/typescript/src/features/gate.d.ts +14 -8
- package/lib/typescript/src/features/gate.d.ts.map +1 -1
- package/lib/typescript/src/features/metadata.d.ts +37 -17
- package/lib/typescript/src/features/metadata.d.ts.map +1 -1
- package/lib/typescript/src/features/network.d.ts +5 -1
- package/lib/typescript/src/features/network.d.ts.map +1 -1
- package/lib/typescript/src/features/nowPlaying.d.ts +28 -14
- package/lib/typescript/src/features/nowPlaying.d.ts.map +1 -1
- package/lib/typescript/src/features/output.d.ts +8 -4
- package/lib/typescript/src/features/output.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/controls.d.ts +10 -5
- package/lib/typescript/src/features/playback/controls.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/playWhenReady.d.ts +6 -5
- package/lib/typescript/src/features/playback/playWhenReady.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/playing.d.ts +16 -3
- package/lib/typescript/src/features/playback/playing.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/progress.d.ts +11 -5
- package/lib/typescript/src/features/playback/progress.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/state.d.ts +8 -3
- package/lib/typescript/src/features/playback/state.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/trackPlaybackTime.d.ts +9 -2
- package/lib/typescript/src/features/playback/trackPlaybackTime.d.ts.map +1 -1
- package/lib/typescript/src/features/playback/volume.d.ts +6 -5
- package/lib/typescript/src/features/playback/volume.d.ts.map +1 -1
- package/lib/typescript/src/features/player/options.d.ts +52 -37
- package/lib/typescript/src/features/player/options.d.ts.map +1 -1
- package/lib/typescript/src/features/player/setup.d.ts +65 -60
- package/lib/typescript/src/features/player/setup.d.ts.map +1 -1
- package/lib/typescript/src/features/queue/activeTrack.d.ts +0 -1
- package/lib/typescript/src/features/queue/activeTrack.d.ts.map +1 -1
- package/lib/typescript/src/features/queue/queue.d.ts +48 -20
- package/lib/typescript/src/features/queue/queue.d.ts.map +1 -1
- package/lib/typescript/src/features/queue/repeatMode.d.ts +1 -1
- package/lib/typescript/src/features/queue/repeatMode.d.ts.map +1 -1
- package/lib/typescript/src/features/queue/shuffle.d.ts +0 -1
- package/lib/typescript/src/features/queue/shuffle.d.ts.map +1 -1
- package/lib/typescript/src/features/remoteControls.d.ts +58 -25
- package/lib/typescript/src/features/remoteControls.d.ts.map +1 -1
- package/lib/typescript/src/features/sleepTimer.d.ts +15 -7
- package/lib/typescript/src/features/sleepTimer.d.ts.map +1 -1
- package/lib/typescript/src/types/browser-nodes.d.ts +54 -57
- package/lib/typescript/src/types/browser-nodes.d.ts.map +1 -1
- package/lib/typescript/src/types/browser.d.ts +181 -144
- package/lib/typescript/src/types/browser.d.ts.map +1 -1
- package/lib/typescript/src/utils/LazyNativeEmitter.d.ts +6 -9
- package/lib/typescript/src/utils/LazyNativeEmitter.d.ts.map +1 -1
- package/lib/typescript/src/utils/NativeUpdatedValue.d.ts +13 -12
- package/lib/typescript/src/utils/NativeUpdatedValue.d.ts.map +1 -1
- package/lib/typescript/src/utils/getTrackIdentity.d.ts +6 -4
- package/lib/typescript/src/utils/getTrackIdentity.d.ts.map +1 -1
- package/lib/typescript/src/utils/useDebug.d.ts +16 -3
- package/lib/typescript/src/utils/useDebug.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/CLAUDE.md +7 -2
- package/src/docs-floors.test.ts +71 -0
- package/src/features/battery.ts +17 -13
- package/src/features/browser-config.ts +1 -1
- package/src/features/browser.ts +65 -24
- package/src/features/carConnection.ts +3 -4
- package/src/features/equalizer.ts +9 -5
- package/src/features/errors.ts +37 -22
- package/src/features/favorites.ts +15 -13
- package/src/features/gate.ts +14 -8
- package/src/features/metadata.ts +37 -17
- package/src/features/network.ts +5 -1
- package/src/features/nowPlaying.ts +28 -14
- package/src/features/output.ts +8 -4
- package/src/features/playback/controls.ts +10 -5
- package/src/features/playback/playWhenReady.ts +6 -5
- package/src/features/playback/playing.ts +16 -3
- package/src/features/playback/progress.ts +11 -5
- package/src/features/playback/state.ts +8 -3
- package/src/features/playback/trackPlaybackTime.ts +9 -2
- package/src/features/playback/volume.ts +6 -5
- package/src/features/player/options.ts +54 -43
- package/src/features/player/setup.ts +67 -61
- package/src/features/queue/activeTrack.ts +0 -1
- package/src/features/queue/queue.ts +48 -20
- package/src/features/queue/repeatMode.ts +1 -1
- package/src/features/queue/shuffle.ts +0 -1
- package/src/features/remoteControls.ts +59 -35
- package/src/features/sleepTimer.ts +15 -7
- package/src/types/browser-nodes.ts +54 -57
- package/src/types/browser.ts +183 -146
- package/src/utils/LazyNativeEmitter.ts +6 -9
- package/src/utils/NativeUpdatedValue.ts +13 -12
- package/src/utils/getTrackIdentity.ts +6 -4
- package/src/utils/useDebug.ts +16 -3
- package/src/web/NativeAudioBrowser.ts +2 -4
- package/src/web/browser/parseSearchResponse.ts +3 -4
- package/src/web/browser/sections.ts +1 -1
- package/src/web/util/BrowserPathHelper.ts +1 -3
- package/website/guide/android-auto.md +25 -13
- package/website/guide/android-certificates.md +199 -120
- package/website/guide/artwork.md +93 -48
- package/website/guide/audio-output.md +86 -68
- package/website/guide/automotive.md +15 -10
- package/website/guide/basic-usage.md +5 -2
- package/website/guide/battery.md +50 -23
- package/website/guide/browser.md +155 -68
- package/website/guide/carplay.md +132 -49
- package/website/guide/configuration.md +85 -49
- package/website/guide/equalizer.md +36 -32
- package/website/guide/errors.md +106 -64
- package/website/guide/favorites.md +41 -31
- package/website/guide/gate.md +24 -10
- package/website/guide/getting-started.md +55 -2
- package/website/guide/hooks.md +53 -47
- package/website/guide/live-streams.md +80 -49
- package/website/guide/metadata.md +87 -53
- package/website/guide/migrating-from-track-player.md +94 -49
- package/website/guide/native-callback-fetch.md +46 -36
- package/website/guide/network.md +36 -20
- package/website/guide/now-playing.md +72 -44
- package/website/guide/playback.md +112 -35
- package/website/guide/queue.md +77 -43
- package/website/guide/remote-controls.md +87 -29
- package/website/guide/search.md +37 -22
- package/website/guide/sleep-timer.md +35 -14
- package/website/guide/track.md +59 -35
|
@@ -17,76 +17,52 @@ import kotlin.concurrent.thread
|
|
|
17
17
|
import timber.log.Timber
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Fetches and caches issuer certificates from AIA "CA Issuers" URLs
|
|
21
|
-
*
|
|
20
|
+
* Fetches and caches issuer certificates from AIA "CA Issuers" URLs, for [AiaChasingTrustManager]
|
|
21
|
+
* to fill in intermediates a server failed to send.
|
|
22
22
|
*
|
|
23
|
-
* Runs on the TLS handshake thread
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* - a response is capped at [MAX_RESPONSE_BYTES] and [MAX_RESPONSE_MILLIS],
|
|
30
|
-
* - at most [MAX_REDIRECTS] redirects are followed,
|
|
31
|
-
* - the cache holds at most [MAX_CACHE_ENTRIES], and only successful fetches, so a round trip
|
|
32
|
-
* happens at most once per intermediate while transient failures stay retryable,
|
|
33
|
-
* - the whole call — every connect, handshake, read and redirect hop — ends at the caller's
|
|
34
|
-
* `deadlineNanos`: each per-operation timeout is clipped to the time remaining, connect and read
|
|
35
|
-
* by their socket timeouts and the TLS handshake plus the exchange by a watchdog that closes the
|
|
36
|
-
* underlying transport, and once the deadline has passed nothing further is even started.
|
|
23
|
+
* Runs on the TLS handshake thread and never throws: a failed, oversized or slow fetch is an empty
|
|
24
|
+
* list. Every input is chosen by the server being validated (the AIA URL names host, port and path;
|
|
25
|
+
* that host picks the response), so the URL must pass [isSafeUrl], a response is capped at
|
|
26
|
+
* [MAX_RESPONSE_BYTES] and [MAX_RESPONSE_MILLIS], at most [MAX_REDIRECTS] redirects are followed,
|
|
27
|
+
* and every connect, handshake, read and redirect hop ends at the caller's deadline. Only
|
|
28
|
+
* successful fetches are cached, so failures stay retryable.
|
|
37
29
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* keeps the count down — a certificate can only make us resolve a few names, not a few hundred.
|
|
30
|
+
* DNS is the one step no deadline reaches: `InetSocketAddress` resolves synchronously with no
|
|
31
|
+
* timeout, so a lookup started just inside the deadline can overrun it. None is started past it,
|
|
32
|
+
* and [AiaCertChaser.MAX_URLS_PER_CERT] bounds how many names a certificate can make us resolve.
|
|
42
33
|
*
|
|
43
|
-
* Both schemes go over a raw [Socket]
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* [
|
|
51
|
-
*
|
|
52
|
-
* For `https` it is because `HttpURLConnection.getInputStream()` performs the connect, request and
|
|
53
|
-
* response *headers* before returning a stream, so a read cap applied to that stream bounds only
|
|
54
|
-
* the body: a server dripping header bytes just inside the per-read timeout would hold the
|
|
55
|
-
* handshake thread for as long as it liked. Reading the headers ourselves puts them inside the same
|
|
56
|
-
* budget as the body. It also keeps one redirect policy — the platform stack would otherwise follow
|
|
57
|
-
* its own, ignoring [MAX_REDIRECTS].
|
|
34
|
+
* Both schemes go over a raw [Socket], not `HttpURLConnection`:
|
|
35
|
+
* - `http`: CA Issuers URLs are plain `http` (the CA/Browser Forum Baseline Requirements mandate
|
|
36
|
+
* it), and Android blocks cleartext `HttpURLConnection` from API 28 targets. A raw socket is not
|
|
37
|
+
* subject to `NetworkSecurityPolicy`; the fetched certificate is still verified as the real
|
|
38
|
+
* issuer before it is trusted.
|
|
39
|
+
* - `https`: `HttpURLConnection` reads the response headers before handing back a stream, outside
|
|
40
|
+
* any read cap, so a server dripping header bytes could hold the handshake thread indefinitely.
|
|
41
|
+
* It would also follow its own redirect policy instead of [MAX_REDIRECTS].
|
|
58
42
|
*/
|
|
59
43
|
class CachingCertificateFetcher(
|
|
60
44
|
private val connectTimeoutMs: Int = 5_000,
|
|
61
45
|
private val readTimeoutMs: Int = 5_000,
|
|
62
46
|
private val nowNanos: () -> Long = System::nanoTime,
|
|
63
47
|
) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* from it, so an unbounded map would retain a megabyte per hostile handshake for the process
|
|
67
|
-
* lifetime. A real app needs a handful of intermediates.
|
|
68
|
-
*/
|
|
48
|
+
// LRU and bounded: a hostile server can name any URL and serve any parseable certificate, so an
|
|
49
|
+
// unbounded map would grow per hostile handshake for the life of the process.
|
|
69
50
|
private val cache =
|
|
70
51
|
object : LinkedHashMap<String, List<X509Certificate>>(16, 0.75f, true) {
|
|
71
52
|
override fun removeEldestEntry(eldest: Map.Entry<String, List<X509Certificate>>) =
|
|
72
53
|
size > MAX_CACHE_ENTRIES
|
|
73
54
|
}
|
|
74
55
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
* the process default — which, once this library's AIA factory is installed there, would recurse
|
|
78
|
-
* into AIA chasing during the fetch's own handshake.
|
|
79
|
-
*/
|
|
56
|
+
// System-default, not the process default: once this library's AIA factory is installed as the
|
|
57
|
+
// process default, an `https` fetch through it would recurse into AIA chasing.
|
|
80
58
|
private val plainSslSocketFactory: SSLSocketFactory by lazy {
|
|
81
59
|
SSLContext.getInstance("TLS").apply { init(null, null, null) }.socketFactory
|
|
82
60
|
}
|
|
83
61
|
|
|
84
62
|
/**
|
|
85
|
-
*
|
|
86
|
-
* on [nowNanos]'s
|
|
87
|
-
* one budget bounds
|
|
88
|
-
*
|
|
89
|
-
* A cache hit is answered even past the deadline — it costs no I/O.
|
|
63
|
+
* The certificates served at [url], or empty on any failure. Gives up by [deadlineNanos],
|
|
64
|
+
* absolute on [nowNanos]'s clock; [AiaCertChaser.completeChain] passes its whole-chase deadline
|
|
65
|
+
* so one budget bounds every fetch it makes. A cache hit is answered even past the deadline.
|
|
90
66
|
*/
|
|
91
67
|
fun fetch(
|
|
92
68
|
url: String,
|
|
@@ -101,7 +77,6 @@ class CachingCertificateFetcher(
|
|
|
101
77
|
return certs
|
|
102
78
|
}
|
|
103
79
|
|
|
104
|
-
/** Milliseconds until [deadlineNanos]; zero or negative once it has passed. */
|
|
105
80
|
private fun remainingMs(deadlineNanos: Long): Long = (deadlineNanos - nowNanos()) / 1_000_000
|
|
106
81
|
|
|
107
82
|
private fun download(
|
|
@@ -110,33 +85,29 @@ class CachingCertificateFetcher(
|
|
|
110
85
|
redirectsLeft: Int = MAX_REDIRECTS,
|
|
111
86
|
): ByteArray? =
|
|
112
87
|
try {
|
|
113
|
-
//
|
|
114
|
-
//
|
|
88
|
+
// Before anything starts, DNS included. Redirects recurse through here, so every hop
|
|
89
|
+
// re-checks the deadline and the URL.
|
|
115
90
|
require(remainingMs(deadlineNanos) > 0) { "AIA chase budget exhausted" }
|
|
116
91
|
require(isSafeUrl(url)) { "AIA URL contains characters that are not valid in a URL" }
|
|
117
92
|
val parsed = URL(url)
|
|
118
93
|
when (parsed.protocol) {
|
|
119
|
-
// restrict to http/https — file:, ftp: etc. are never valid CA-issuer sources
|
|
120
94
|
"http" -> fetchOverSocket(parsed, deadlineNanos, redirectsLeft, secure = false)
|
|
121
95
|
"https" -> fetchOverSocket(parsed, deadlineNanos, redirectsLeft, secure = true)
|
|
122
96
|
else -> null
|
|
123
97
|
}
|
|
124
98
|
} catch (e: Exception) {
|
|
125
|
-
// The URL is
|
|
126
|
-
// check, so it is escaped rather than handed to the log verbatim.
|
|
99
|
+
// The URL is server-chosen and may be the one that failed isSafeUrl.
|
|
127
100
|
Timber.w(e, "AIA CA-issuer fetch failed: %s", sanitizeForLog(url))
|
|
128
101
|
null
|
|
129
102
|
}
|
|
130
103
|
|
|
131
104
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* close [transport], whose close is immediate and fails every read layered above it.
|
|
105
|
+
* The socket to speak HTTP over, and the plain TCP [transport] beneath it (the same socket for
|
|
106
|
+
* `http`). Closing an `SSLSocket` writes `close_notify`, which can block against a peer that
|
|
107
|
+
* stopped reading, so whatever must unblock a stalled call closes [transport].
|
|
136
108
|
*/
|
|
137
109
|
private class Connection(val socket: Socket, val transport: Socket)
|
|
138
110
|
|
|
139
|
-
/** One HTTP/1.0 exchange over a socket, TLS-wrapped when [secure], then redirects. */
|
|
140
111
|
private fun fetchOverSocket(
|
|
141
112
|
url: URL,
|
|
142
113
|
deadlineNanos: Long,
|
|
@@ -145,7 +116,7 @@ class CachingCertificateFetcher(
|
|
|
145
116
|
): ByteArray? {
|
|
146
117
|
val host = url.host
|
|
147
118
|
val port = if (url.port != -1) url.port else if (secure) 443 else 80
|
|
148
|
-
val path = url.file.ifEmpty { "/" } //
|
|
119
|
+
val path = url.file.ifEmpty { "/" } // path + query
|
|
149
120
|
val connection = connect(host, port, secure, deadlineNanos)
|
|
150
121
|
val raw =
|
|
151
122
|
try {
|
|
@@ -155,9 +126,9 @@ class CachingCertificateFetcher(
|
|
|
155
126
|
) {
|
|
156
127
|
val socket = connection.socket
|
|
157
128
|
socket.soTimeout = timeoutMs(deadlineNanos, readTimeoutMs)
|
|
158
|
-
// HTTP/1.0
|
|
159
|
-
//
|
|
160
|
-
//
|
|
129
|
+
// HTTP/1.0 with `Connection: close`: the server closes after the body, so it is read to
|
|
130
|
+
// EOF without Content-Length. A non-default port belongs in Host, or a name-based
|
|
131
|
+
// virtual host answers for the wrong site.
|
|
161
132
|
val hostHeader = if (port == (if (secure) 443 else 80)) host else "$host:$port"
|
|
162
133
|
val request =
|
|
163
134
|
"GET $path HTTP/1.0\r\n" +
|
|
@@ -178,8 +149,7 @@ class CachingCertificateFetcher(
|
|
|
178
149
|
}
|
|
179
150
|
}
|
|
180
151
|
} finally {
|
|
181
|
-
// Transport first
|
|
182
|
-
// SSLSocket's close_notify attempt afterwards fails fast instead of stalling.
|
|
152
|
+
// Transport first, so the SSLSocket's close_notify then fails fast instead of blocking.
|
|
183
153
|
runCatching { connection.transport.close() }
|
|
184
154
|
runCatching { connection.socket.close() }
|
|
185
155
|
} ?: return null
|
|
@@ -187,35 +157,26 @@ class CachingCertificateFetcher(
|
|
|
187
157
|
return when {
|
|
188
158
|
response.status in 200..299 -> response.body
|
|
189
159
|
response.status in 300..399 && response.location != null && redirectsLeft > 0 ->
|
|
190
|
-
// Follow CA-issuer redirects (rare). `download` is the recursion point, so the target
|
|
191
|
-
// goes through the same URL check and the same deadline.
|
|
192
160
|
download(URL(url, response.location).toString(), deadlineNanos, redirectsLeft - 1)
|
|
193
161
|
else -> null
|
|
194
162
|
}
|
|
195
163
|
}
|
|
196
164
|
|
|
197
165
|
/**
|
|
198
|
-
* Connects to [host]:[port], wrapping in TLS when [secure]
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* The TLS socket verifies the hostname explicitly. A raw `SSLSocket` does not do it on its own,
|
|
202
|
-
* and `SSLParameters.setEndpointIdentificationAlgorithm` is API 24+, so the platform's default
|
|
203
|
-
* verifier is applied against the negotiated session instead — which works on every supported
|
|
204
|
-
* level and is the same check `HttpsURLConnection` would have made.
|
|
166
|
+
* Connects to [host]:[port], wrapping in TLS when [secure], with the connect and handshake
|
|
167
|
+
* clipped to [deadlineNanos]. The hostname is verified with the platform's default verifier: a
|
|
168
|
+
* raw `SSLSocket` does not verify it, and `setEndpointIdentificationAlgorithm` is API 24+.
|
|
205
169
|
*/
|
|
206
170
|
private fun connect(host: String, port: Int, secure: Boolean, deadlineNanos: Long): Connection {
|
|
207
171
|
val plain = Socket()
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
// every unreachable AIA host would otherwise leak one until finalization.
|
|
172
|
+
// Android's Socket.connect, unlike OpenJDK's, does not close itself on failure, so the catch
|
|
173
|
+
// below closes `plain` or every unreachable AIA host leaks a descriptor until finalization.
|
|
211
174
|
var wrapper: SSLSocket? = null
|
|
212
175
|
return try {
|
|
213
176
|
plain.connect(InetSocketAddress(host, port), timeoutMs(deadlineNanos, connectTimeoutMs))
|
|
214
177
|
if (!secure) return Connection(plain, plain)
|
|
215
|
-
//
|
|
216
|
-
//
|
|
217
|
-
// `plain`, the transport — closing the SSLSocket instead would write a close_notify that
|
|
218
|
-
// can block against the very peer that caused the stall.
|
|
178
|
+
// soTimeout is per-read, so a peer drip-feeding handshake bytes would outlast it; the
|
|
179
|
+
// watchdog closes the transport, not the SSLSocket (see Connection).
|
|
219
180
|
withWatchdog(
|
|
220
181
|
minOf(remainingMs(deadlineNanos), connectTimeoutMs + MAX_RESPONSE_MILLIS),
|
|
221
182
|
abort = { plain.close() },
|
|
@@ -231,32 +192,23 @@ class CachingCertificateFetcher(
|
|
|
231
192
|
}
|
|
232
193
|
} catch (e: Exception) {
|
|
233
194
|
runCatching { plain.close() }
|
|
234
|
-
//
|
|
235
|
-
// fails fast
|
|
195
|
+
// Frees the wrapper's buffers now instead of at GC; with the transport closed, its
|
|
196
|
+
// close_notify fails fast.
|
|
236
197
|
runCatching { wrapper?.close() }
|
|
237
198
|
throw e
|
|
238
199
|
}
|
|
239
200
|
}
|
|
240
201
|
|
|
241
|
-
|
|
242
|
-
* A per-operation socket timeout: [perOperationMs] clipped to the deadline, and never 0 ("no
|
|
243
|
-
* timeout" to a socket) — an already-expired deadline still gets a 1 ms timeout and fails at
|
|
244
|
-
* once.
|
|
245
|
-
*/
|
|
202
|
+
// Never 0, which a socket reads as "no timeout": a passed deadline gets 1 ms and fails at once.
|
|
246
203
|
private fun timeoutMs(deadlineNanos: Long, perOperationMs: Int): Int =
|
|
247
204
|
minOf(remainingMs(deadlineNanos), perOperationMs.toLong())
|
|
248
205
|
.coerceIn(1, Int.MAX_VALUE.toLong())
|
|
249
206
|
.toInt()
|
|
250
207
|
|
|
251
208
|
/**
|
|
252
|
-
* Runs [body]
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* The socket timeouts are per-operation and so cannot bound a peer that keeps every individual
|
|
257
|
-
* read just inside them; [abort] — closing the underlying transport — is what actually ends a
|
|
258
|
-
* stalled handshake or exchange: the blocked call throws, and a failed fetch is already handled
|
|
259
|
-
* as "no AIA".
|
|
209
|
+
* Runs [body], calling [abort] from another thread if it is still running after [budgetMs].
|
|
210
|
+
* Socket timeouts are per-operation, so this is what ends a peer that keeps every read just
|
|
211
|
+
* inside them: [abort] closes the transport and the blocked call throws.
|
|
260
212
|
*/
|
|
261
213
|
private inline fun <T> withWatchdog(
|
|
262
214
|
budgetMs: Long,
|
|
@@ -280,35 +232,29 @@ class CachingCertificateFetcher(
|
|
|
280
232
|
companion object {
|
|
281
233
|
private const val MAX_REDIRECTS = 5
|
|
282
234
|
|
|
283
|
-
/** Ceiling on how many fetched issuer certificates are retained. */
|
|
284
235
|
const val MAX_CACHE_ENTRIES = 32
|
|
285
236
|
|
|
286
|
-
/** Ceiling on
|
|
287
|
-
const val MAX_RESPONSE_BYTES = 1 shl 20
|
|
237
|
+
/** Ceiling on one AIA response, headers included. */
|
|
238
|
+
const val MAX_RESPONSE_BYTES = 1 shl 20
|
|
288
239
|
|
|
289
240
|
/** Ceiling on the wall-clock time spent reading one AIA response. */
|
|
290
241
|
const val MAX_RESPONSE_MILLIS = 10_000L
|
|
291
242
|
|
|
292
243
|
/**
|
|
293
|
-
* Whether [url] is free of characters
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
* control characters — `URL("http://host:6379/\r\nSET foo bar")` parses to that host and port
|
|
298
|
-
* with the CRLF intact in `file` — so without this check a certificate could inject request
|
|
299
|
-
* lines of its own, to any host and port the device can reach. Space is excluded too: it would
|
|
300
|
-
* split the request line's target from its HTTP version.
|
|
244
|
+
* Whether [url] is free of control characters, space and DEL. The path is written into a
|
|
245
|
+
* request line on a raw socket, and `java.net.URL` keeps a CRLF in `file`, so a certificate's
|
|
246
|
+
* AIA URL could otherwise inject request lines to any host and port the device can reach; a
|
|
247
|
+
* space would split the request target from the HTTP version.
|
|
301
248
|
*/
|
|
302
249
|
fun isSafeUrl(url: String): Boolean = url.none { it.code <= 0x20 || it.code == 0x7F }
|
|
303
250
|
|
|
304
|
-
/** [text] with
|
|
251
|
+
/** [text] with what [isSafeUrl] refuses replaced by `?`, so a log line cannot be forged. */
|
|
305
252
|
fun sanitizeForLog(text: String): String =
|
|
306
253
|
text.map { if (it.code <= 0x20 || it.code == 0x7F) '?' else it }.joinToString("")
|
|
307
254
|
|
|
308
255
|
/**
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
* parseable certificates.
|
|
256
|
+
* Every certificate in what a CA Issuers URL serves: a DER certificate, PEM, or a PKCS#7
|
|
257
|
+
* certs-only bundle. Empty if none parse.
|
|
312
258
|
*/
|
|
313
259
|
fun parseCertificates(bytes: ByteArray): List<X509Certificate> =
|
|
314
260
|
try {
|
|
@@ -320,16 +266,10 @@ class CachingCertificateFetcher(
|
|
|
320
266
|
}
|
|
321
267
|
|
|
322
268
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* The byte cap alone would not bound the time. The socket's timeout is per-read, so a server
|
|
329
|
-
* returning one byte just inside it resets the clock on every iteration and holds the handshake
|
|
330
|
-
* thread for as long as it likes — a slow-drip stall in place of the unbounded buffer. Both
|
|
331
|
-
* limits are needed, and the deadline is checked against [nowNanos] (injectable so a test need
|
|
332
|
-
* not actually wait).
|
|
269
|
+
* [input] read to EOF, or null once it passes [limit] bytes or [budgetMs] of wall-clock time,
|
|
270
|
+
* as measured by [nowNanos]. The time cap matters as much as the byte cap: a socket timeout is
|
|
271
|
+
* per-read, so a server sending a byte just inside it would otherwise hold the thread for as
|
|
272
|
+
* long as the byte cap lasts.
|
|
333
273
|
*/
|
|
334
274
|
fun readCapped(
|
|
335
275
|
input: InputStream,
|
|
@@ -350,19 +290,16 @@ class CachingCertificateFetcher(
|
|
|
350
290
|
}
|
|
351
291
|
}
|
|
352
292
|
|
|
353
|
-
/** Status code, `Location` header (if any), and decoded body of a raw HTTP response. */
|
|
354
293
|
data class HttpResponse(val status: Int, val location: String?, val body: ByteArray)
|
|
355
294
|
|
|
356
295
|
/**
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
* recognisable HTTP response.
|
|
296
|
+
* Status, `Location` and body of a raw HTTP response, with a chunked body decoded. Null if
|
|
297
|
+
* there is no header terminator or no numeric status.
|
|
360
298
|
*/
|
|
361
299
|
fun parseHttpResponse(raw: ByteArray): HttpResponse? {
|
|
362
300
|
val headerEnd = indexOfCrlfCrlf(raw)
|
|
363
301
|
if (headerEnd < 0) return null
|
|
364
302
|
val lines = String(raw, 0, headerEnd, Charsets.ISO_8859_1).split("\r\n")
|
|
365
|
-
// Status line: "HTTP/1.1 200 OK" — the code is the second token.
|
|
366
303
|
val status = lines.firstOrNull()?.split(' ')?.getOrNull(1)?.toIntOrNull() ?: return null
|
|
367
304
|
var location: String? = null
|
|
368
305
|
var chunked = false
|
|
@@ -386,19 +323,17 @@ class CachingCertificateFetcher(
|
|
|
386
323
|
while (pos < body.size) {
|
|
387
324
|
val eol = indexOfCrlf(body, pos)
|
|
388
325
|
if (eol < 0) break
|
|
389
|
-
// chunk-size line may carry a `;chunk-extension` suffix; the size is hex before the `;`.
|
|
390
326
|
val size =
|
|
391
327
|
String(body, pos, eol - pos, Charsets.ISO_8859_1)
|
|
392
328
|
.substringBefore(';')
|
|
393
329
|
.trim()
|
|
394
330
|
.toIntOrNull(16) ?: break
|
|
395
|
-
// `<= 0
|
|
396
|
-
|
|
397
|
-
if (size <= 0) break // last chunk, or malformed
|
|
331
|
+
// `<= 0`: 0 is the last chunk, and toIntOrNull accepts a `-` that would move `pos` back.
|
|
332
|
+
if (size <= 0) break
|
|
398
333
|
val dataStart = eol + 2
|
|
399
334
|
if (dataStart + size > body.size) break
|
|
400
335
|
out.write(body, dataStart, size)
|
|
401
|
-
pos = dataStart + size + 2 //
|
|
336
|
+
pos = dataStart + size + 2 // past the chunk's trailing CRLF
|
|
402
337
|
}
|
|
403
338
|
return out.toByteArray()
|
|
404
339
|
}
|
|
@@ -16,27 +16,16 @@ import kotlinx.coroutines.withTimeout
|
|
|
16
16
|
import timber.log.Timber
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* used as a fetch proxy / SSRF vector. http(s)-only on the registered finalUrl is defense-in-depth.
|
|
19
|
+
* Serves browse artwork to Android Auto and AAOS as PNG files. It is exported because both run in
|
|
20
|
+
* another uid and Media3 issues no URI grant. So it never fetches a URL the caller supplies: the
|
|
21
|
+
* URI carries an opaque token, and only a token in [com.audiobrowser.browser.BrowseArtworkRegistry]
|
|
22
|
+
* whose URL is http(s) resolves; anything else returns null.
|
|
24
23
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* Bug fixes over the previous pipe/coroutine design: B (FD leak): eliminated — no coroutine
|
|
29
|
-
* launched from deps.scope; no writer that could fail to close the write-end of a pipe when the
|
|
30
|
-
* scope is already cancelled. C (wedge DoS): eliminated — the Semaphore permit is released in a
|
|
31
|
-
* try/finally BEFORE the file is opened for the caller; no blocking write to a pipe while holding
|
|
32
|
-
* the permit. D (per-request re-encode): eliminated — on-disk file IS the cache; re-requests are a
|
|
33
|
-
* cheap file open (fast path, zero decode, zero network). E (non-seekable pipe): eliminated —
|
|
34
|
-
* ParcelFileDescriptor.open returns a regular file FD; statSize is valid; the car's image loader
|
|
35
|
-
* can seek.
|
|
24
|
+
* The response is an on-disk file in [ARTWORK_SUBDIR], not a pipe: the car's image loader seeks and
|
|
25
|
+
* reads statSize, which a pipe reports as -1. The file doubles as the cache, keyed by token.
|
|
36
26
|
*/
|
|
37
27
|
class ArtworkContentProvider : ContentProvider() {
|
|
38
28
|
|
|
39
|
-
// java.util.concurrent.Semaphore — works on binder threads without a coroutine scope.
|
|
40
29
|
private val gate = Semaphore(MAX_CONCURRENT)
|
|
41
30
|
|
|
42
31
|
override fun onCreate(): Boolean = true
|
|
@@ -53,7 +42,6 @@ class ArtworkContentProvider : ContentProvider() {
|
|
|
53
42
|
val artworkDir = File(context!!.cacheDir, ARTWORK_SUBDIR)
|
|
54
43
|
val file = File(artworkDir, "$token.png")
|
|
55
44
|
|
|
56
|
-
// Fast path: file already cached on disk — no permit, no decode, no network.
|
|
57
45
|
if (file.exists() && file.length() > 0) {
|
|
58
46
|
return try {
|
|
59
47
|
ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY)
|
|
@@ -63,13 +51,13 @@ class ArtworkContentProvider : ContentProvider() {
|
|
|
63
51
|
}
|
|
64
52
|
}
|
|
65
53
|
|
|
66
|
-
//
|
|
54
|
+
// openFile runs on a binder thread, which may block; the gate keeps loads from taking them all.
|
|
67
55
|
if (!gate.tryAcquire(1, GATE_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
|
|
68
56
|
Timber.w("Artwork gate timeout for token=$token — returning null")
|
|
69
57
|
return null
|
|
70
58
|
}
|
|
71
59
|
try {
|
|
72
|
-
//
|
|
60
|
+
// Another request may have produced the file while this one waited; if pruned since, produce.
|
|
73
61
|
if (file.exists() && file.length() > 0) {
|
|
74
62
|
val fd =
|
|
75
63
|
try {
|
|
@@ -79,10 +67,10 @@ class ArtworkContentProvider : ContentProvider() {
|
|
|
79
67
|
null
|
|
80
68
|
}
|
|
81
69
|
if (fd != null) return fd
|
|
82
|
-
// else: file was pruned/deleted concurrently — fall through to produce
|
|
83
70
|
}
|
|
84
71
|
|
|
85
72
|
artworkDir.mkdirs()
|
|
73
|
+
// Written aside and renamed, so the unlocked fast path never opens a half-written file.
|
|
86
74
|
val tmp = File.createTempFile(token, ".png.tmp", artworkDir)
|
|
87
75
|
|
|
88
76
|
val bitmap: Bitmap =
|
|
@@ -145,7 +133,7 @@ class ArtworkContentProvider : ContentProvider() {
|
|
|
145
133
|
private const val LOAD_TIMEOUT_MS = 8_000L
|
|
146
134
|
internal const val ARTWORK_SUBDIR = "audiobrowser-artwork"
|
|
147
135
|
const val MAX_CACHE_FILES = 512
|
|
148
|
-
/**
|
|
136
|
+
/** Tests only. */
|
|
149
137
|
@JvmField internal var maxCacheFilesOverride: Int? = null
|
|
150
138
|
}
|
|
151
139
|
|
|
@@ -4,12 +4,12 @@ import android.net.Uri
|
|
|
4
4
|
import com.audiobrowser.browser.BrowseArtworkRegistry
|
|
5
5
|
import com.audiobrowser.browser.ResolvedArtwork
|
|
6
6
|
|
|
7
|
-
/** Routes artwork URLs through the [ArtworkContentProvider]
|
|
7
|
+
/** Routes artwork URLs through the [ArtworkContentProvider] at [authority], via its [registry]. */
|
|
8
8
|
class ArtworkRoutes(val registry: BrowseArtworkRegistry, val authority: String) {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* provider's own.
|
|
10
|
+
* Registers http(s) [url] and returns the `content://` URI the provider serves it at; any other
|
|
11
|
+
* URL comes back unchanged. [pinned] artwork survives [BrowseArtworkRegistry.clear]; pinning one
|
|
12
|
+
* of this provider's own URIs re-pins the artwork it already holds.
|
|
13
13
|
*/
|
|
14
14
|
fun route(url: String, headers: Map<String, String>?, isSvg: Boolean, pinned: Boolean): String {
|
|
15
15
|
val uri = Uri.parse(url)
|
|
@@ -29,8 +29,8 @@ class ArtworkRoutes(val registry: BrowseArtworkRegistry, val authority: String)
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* The URL
|
|
33
|
-
* registry has
|
|
32
|
+
* The URL to show JS for [uri]: for this provider's URIs the URL it serves, or null once the
|
|
33
|
+
* registry has dropped it; any other URI as its string.
|
|
34
34
|
*/
|
|
35
35
|
fun publicUrl(uri: Uri): String? {
|
|
36
36
|
if (uri.authority != authority) return uri.toString()
|
|
@@ -3,14 +3,15 @@ package com.audiobrowser.util
|
|
|
3
3
|
import android.net.Uri
|
|
4
4
|
import java.security.MessageDigest
|
|
5
5
|
|
|
6
|
-
/** Builds and parses the
|
|
6
|
+
/** Builds and parses the `content://<pkg>.audiobrowser.artwork/art/<token>` artwork URIs. */
|
|
7
7
|
object ArtworkUris {
|
|
8
|
+
// Must match the provider's `android:authorities` in AndroidManifest.xml.
|
|
8
9
|
const val AUTHORITY_SUFFIX = "audiobrowser.artwork"
|
|
9
10
|
private const val PATH = "art"
|
|
10
11
|
|
|
11
12
|
fun authorityFor(packageName: String): String = "$packageName.$AUTHORITY_SUFFIX"
|
|
12
13
|
|
|
13
|
-
/**
|
|
14
|
+
/** A stable token for [url] that does not reveal it to whoever sees the URI (SHA-256 hex). */
|
|
14
15
|
fun tokenFor(url: String): String {
|
|
15
16
|
val digest = MessageDigest.getInstance("SHA-256").digest(url.toByteArray(Charsets.UTF_8))
|
|
16
17
|
return digest.joinToString("") { "%02x".format(it) }
|
|
@@ -18,7 +19,7 @@ object ArtworkUris {
|
|
|
18
19
|
|
|
19
20
|
fun contentUri(authority: String, token: String): String = "content://$authority/$PATH/$token"
|
|
20
21
|
|
|
21
|
-
/** The `<token>`
|
|
22
|
+
/** The `<token>` of a `content://…/art/<token>` URI, whatever its authority; else null. */
|
|
22
23
|
fun parseToken(uri: Uri): String? {
|
|
23
24
|
if (uri.scheme != "content") return null
|
|
24
25
|
val segments = uri.pathSegments
|
|
@@ -3,22 +3,11 @@ package com.audiobrowser.util
|
|
|
3
3
|
import com.margelo.nitro.audiobrowser.Variant_String_ArtworkVariants
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Android Auto is dark-only, so there is nothing here to choose: a pair always resolves to its dark
|
|
9
|
-
* URL, which is also what a single-URL track would have shipped. The per-appearance half of the
|
|
10
|
-
* feature is iOS/CarPlay only — see `ios/Extension/Variant+Artwork.swift`, where both URLs are kept
|
|
11
|
-
* so a `UIImageAsset` can swap them without a re-fetch.
|
|
6
|
+
* The URL Android shows: the single URL, or the pair's `dark` one, since Android Auto is dark-only.
|
|
7
|
+
* iOS keeps both (`ios/Extension/Variant+Artwork.swift`).
|
|
12
8
|
*/
|
|
13
9
|
val Variant_String_ArtworkVariants.url: String
|
|
14
10
|
get() = match(first = { it }, second = { it.dark })
|
|
15
11
|
|
|
16
|
-
/**
|
|
17
|
-
* Wraps a plain URL as the single-URL side of the union.
|
|
18
|
-
*
|
|
19
|
-
* For the places that build a `Track` from something that only ever has one image — restored
|
|
20
|
-
* persistence, a `MediaMetadata` handed back by the platform. Restoring collapses a pair to its
|
|
21
|
-
* dark URL, which costs nothing here: Android Auto would have rendered that one anyway.
|
|
22
|
-
*/
|
|
23
12
|
fun artworkOf(url: String?): Variant_String_ArtworkVariants? =
|
|
24
13
|
url?.let { Variant_String_ArtworkVariants.First(it) }
|
|
@@ -3,13 +3,11 @@ package com.audiobrowser.util
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.content.pm.PackageManager
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Whether this is an Android Automotive OS device, as opposed to a phone projecting Android Auto.
|
|
8
|
-
*/
|
|
6
|
+
/** True on Android Automotive OS, not on a phone projecting Android Auto. */
|
|
9
7
|
val Context.isAutomotive: Boolean
|
|
10
8
|
get() = packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)
|
|
11
9
|
|
|
12
|
-
/**
|
|
10
|
+
/** [isAutomotive] for code without a Context: false until the Player sets it. */
|
|
13
11
|
object Automotive {
|
|
14
12
|
@Volatile var device = false
|
|
15
13
|
}
|
|
@@ -28,11 +28,7 @@ object BatteryOptimizationHelper {
|
|
|
28
28
|
RESTRICTED,
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
/**
|
|
32
|
-
* Get the current battery optimization status.
|
|
33
|
-
*
|
|
34
|
-
* Priority: Background restriction > Battery optimization whitelist
|
|
35
|
-
*/
|
|
31
|
+
/** A background restriction outranks a Doze exemption: the result is then [Status.RESTRICTED]. */
|
|
36
32
|
fun getStatus(context: Context): Status {
|
|
37
33
|
val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager
|
|
38
34
|
val isIgnoring = pm.isIgnoringBatteryOptimizations(context.packageName)
|
|
@@ -55,10 +51,8 @@ object BatteryOptimizationHelper {
|
|
|
55
51
|
}
|
|
56
52
|
|
|
57
53
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* For OPTIMIZED status: Shows a quick dialog to disable battery optimization (one tap). For
|
|
61
|
-
* RESTRICTED status: Opens app settings where user must manually change battery setting.
|
|
54
|
+
* When [Status.OPTIMIZED], shows the system's one-tap exemption dialog; otherwise opens the app's
|
|
55
|
+
* settings page, since the dialog cannot lift a background restriction.
|
|
62
56
|
*/
|
|
63
57
|
fun openSettings(context: Context) {
|
|
64
58
|
when (getStatus(context)) {
|
|
@@ -3,32 +3,22 @@ package com.audiobrowser.util
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* app is killed), we record this failure so the app can show a warning to the user on their next
|
|
10
|
-
* session.
|
|
6
|
+
* Remembers, across process death, that Android 12+ refused to start the foreground service from
|
|
7
|
+
* the background (`ForegroundServiceStartNotAllowedException`, e.g. a Bluetooth resume while the
|
|
8
|
+
* app is killed), so the app can warn the user on its next session.
|
|
11
9
|
*/
|
|
12
10
|
object BatteryWarningStore {
|
|
13
11
|
private const val PREFS_NAME = "audio_browser_battery"
|
|
14
12
|
private const val KEY_WARNING_PENDING = "warning_pending"
|
|
15
13
|
|
|
16
|
-
/**
|
|
17
|
-
* Record that a foreground service start failure occurred. Called when
|
|
18
|
-
* ForegroundServiceStartNotAllowedException is caught.
|
|
19
|
-
*/
|
|
20
14
|
fun recordFailure(context: Context) {
|
|
21
15
|
getPrefs(context).edit().putBoolean(KEY_WARNING_PENDING, true).apply()
|
|
22
16
|
}
|
|
23
17
|
|
|
24
|
-
/**
|
|
18
|
+
/** True from [recordFailure] until [clearWarning]. */
|
|
25
19
|
fun isWarningPending(context: Context): Boolean =
|
|
26
20
|
getPrefs(context).getBoolean(KEY_WARNING_PENDING, false)
|
|
27
21
|
|
|
28
|
-
/**
|
|
29
|
-
* Clear the pending warning. Called when user dismisses warning or when battery status becomes
|
|
30
|
-
* unrestricted.
|
|
31
|
-
*/
|
|
32
22
|
fun clearWarning(context: Context) {
|
|
33
23
|
getPrefs(context).edit().putBoolean(KEY_WARNING_PENDING, false).apply()
|
|
34
24
|
}
|