From c2cb22a05687d36d842c7049753a7c8ab34d5053 Mon Sep 17 00:00:00 2001 From: olly Date: Mon, 7 Feb 2022 21:14:14 +0000 Subject: [PATCH] Rollback of https://github.com/androidx/media/commit/1521e50307bb74983ecef1fc2ddf5f996f27468b *** Original commit *** Wire up MediaMetricsListener and add configuration to disable it. The listener will automatically forward diagnostics info to the Android platform. ExoPlayer.Builder gets a new setter that allows to disable this feature if required. #minor-release *** PiperOrigin-RevId: 426997342 --- .../androidx/media3/exoplayer/ExoPlayer.java | 25 ------------------- .../media3/exoplayer/ExoPlayerImpl.java | 21 +++------------- 2 files changed, 4 insertions(+), 42 deletions(-) diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java index ab755cbc26..7269e6c6c5 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java @@ -400,7 +400,6 @@ public interface ExoPlayer extends Player { /* package */ long releaseTimeoutMs; /* package */ long detachSurfaceTimeoutMs; /* package */ boolean pauseAtEndOfMediaItems; - /* package */ boolean usePlatformDiagnostics; /* package */ boolean buildCalled; /** @@ -441,7 +440,6 @@ public interface ExoPlayer extends Player { *
  • {@code releaseTimeoutMs}: {@link #DEFAULT_RELEASE_TIMEOUT_MS} *
  • {@code detachSurfaceTimeoutMs}: {@link #DEFAULT_DETACH_SURFACE_TIMEOUT_MS} *
  • {@code pauseAtEndOfMediaItems}: {@code false} - *
  • {@code usePlatformDiagnostics}: {@code true} *
  • {@link Clock}: {@link Clock#DEFAULT} * * @@ -594,7 +592,6 @@ public interface ExoPlayer extends Player { clock = Clock.DEFAULT; releaseTimeoutMs = DEFAULT_RELEASE_TIMEOUT_MS; detachSurfaceTimeoutMs = DEFAULT_DETACH_SURFACE_TIMEOUT_MS; - usePlatformDiagnostics = true; } /** @@ -974,28 +971,6 @@ public interface ExoPlayer extends Player { return this; } - /** - * Sets whether the player reports diagnostics data to the Android platform. - * - *

    If enabled, the player will use the {@link android.media.metrics.MediaMetricsManager} to - * create a {@link android.media.metrics.PlaybackSession} and forward playback events and - * performance data to this session. This helps to provide system performance and debugging - * information for media playback on the device. This data may also be collected by Google if sharing usage and diagnostics - * data is enabled by the user of the device. - * - * @param usePlatformDiagnostics Whether the player reports diagnostics data to the Android - * platform. - * @return This builder. - * @throws IllegalStateException If {@link #build()} has already been called. - */ - @UnstableApi - public Builder setUsePlatformDiagnostics(boolean usePlatformDiagnostics) { - checkState(!buildCalled); - this.usePlatformDiagnostics = usePlatformDiagnostics; - return this; - } - /** * Sets the {@link Clock} that will be used by the player. Should only be set for testing * purposes. diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java index e076dad419..6cfdc10e35 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java @@ -139,7 +139,6 @@ import androidx.media3.exoplayer.PlayerMessage.Target; import androidx.media3.exoplayer.Renderer.MessageType; import androidx.media3.exoplayer.analytics.AnalyticsCollector; import androidx.media3.exoplayer.analytics.AnalyticsListener; -import androidx.media3.exoplayer.analytics.MediaMetricsListener; import androidx.media3.exoplayer.analytics.PlayerId; import androidx.media3.exoplayer.audio.AudioRendererEventListener; import androidx.media3.exoplayer.metadata.MetadataOutput; @@ -372,11 +371,7 @@ import java.util.concurrent.TimeoutException; playbackInfoUpdateHandler.post(() -> handlePlaybackInfo(playbackInfoUpdate)); playbackInfo = PlaybackInfo.createDummy(emptyTrackSelectorResult); analyticsCollector.setPlayer(wrappingPlayer, applicationLooper); - PlayerId playerId = - Util.SDK_INT < 31 - ? new PlayerId() - : Api31.registerMediaMetricsListener( - applicationContext, /* player= */ this, builder.usePlatformDiagnostics); + PlayerId playerId = Util.SDK_INT < 31 ? new PlayerId() : Api31.createPlayerId(); internalPlayer = new ExoPlayerImplInternal( renderers, @@ -3062,17 +3057,9 @@ import java.util.concurrent.TimeoutException; private Api31() {} @DoNotInline - public static PlayerId registerMediaMetricsListener( - Context context, ExoPlayerImpl player, boolean usePlatformDiagnostics) { - @Nullable MediaMetricsListener listener = MediaMetricsListener.create(context); - if (listener == null) { - Log.w(TAG, "MediaMetricsService unavailable."); - return new PlayerId(LogSessionId.LOG_SESSION_ID_NONE); - } - if (usePlatformDiagnostics) { - player.addAnalyticsListener(listener); - } - return new PlayerId(listener.getLogSessionId()); + public static PlayerId createPlayerId() { + // TODO: Create a MediaMetricsListener and obtain LogSessionId from it. + return new PlayerId(LogSessionId.LOG_SESSION_ID_NONE); } } }