Loading android/app/src/com/android/bluetooth/audio_util/BTAudioEventLogger.java +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ public class BTAudioEventLogger { private final EvictingQueue<Event> mEvents; // Event class contain timestamp and log context. private class Event { private static class Event { private final String mTimeStamp; private final String mMsg; Loading android/app/src/com/android/bluetooth/audio_util/BrowsablePlayerConnector.java +7 −5 Original line number Diff line number Diff line Loading @@ -52,7 +52,6 @@ public class BrowsablePlayerConnector { private static BrowsablePlayerConnector sInjectConnector; private Handler mHandler; private Context mContext; private PlayerListCallback mCallback; private List<BrowsedPlayerWrapper> mResults = new ArrayList<BrowsedPlayerWrapper>(); Loading @@ -62,7 +61,11 @@ public class BrowsablePlayerConnector { void run(List<BrowsedPlayerWrapper> result); } private static void setInstanceForTesting(BrowsablePlayerConnector connector) { /** * @hide */ @VisibleForTesting static void setInstanceForTesting(BrowsablePlayerConnector connector) { Utils.enforceInstrumentationTestMode(); sInjectConnector = connector; } Loading @@ -80,7 +83,7 @@ public class BrowsablePlayerConnector { return null; } BrowsablePlayerConnector newWrapper = new BrowsablePlayerConnector(context, looper, cb); BrowsablePlayerConnector newWrapper = new BrowsablePlayerConnector(looper, cb); // Try to start connecting all the browsed player wrappers for (ResolveInfo info : players) { Loading Loading @@ -109,8 +112,7 @@ public class BrowsablePlayerConnector { return newWrapper; } private BrowsablePlayerConnector(Context context, Looper looper, PlayerListCallback cb) { mContext = context; private BrowsablePlayerConnector(Looper looper, PlayerListCallback cb) { mCallback = cb; mHandler = new Handler(looper) { public void handleMessage(Message msg) { Loading android/app/src/com/android/bluetooth/audio_util/BrowsedPlayerWrapper.java +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ import java.util.Map; * Right now this is ok because the BrowsablePlayerConnector will handle timeouts. */ class BrowsedPlayerWrapper { private static final String TAG = "AvrcpBrowsedPlayerWrapper"; private static final String TAG = "BrowsedPlayerWrapper"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); enum ConnectionState { Loading android/app/src/com/android/bluetooth/audio_util/MediaPlayerList.java +2 −4 Original line number Diff line number Diff line Loading @@ -85,7 +85,6 @@ public class MediaPlayerList { private Context mContext; private Looper mLooper; // Thread all media player callbacks and timeouts happen on private PackageManager mPackageManager; private MediaSessionManager mMediaSessionManager; private MediaData mCurrMediaData = null; private final AudioManager mAudioManager; Loading Loading @@ -731,7 +730,7 @@ public class MediaPlayerList { if (getActivePlayer() == null) { Log.d(TAG, "updateMediaForAudioPlayback: no active player"); PlaybackState.Builder builder = new PlaybackState.Builder() .setState(PlaybackState.STATE_STOPPED, 0L, 0L); .setState(PlaybackState.STATE_STOPPED, 0L, 0f); List<Metadata> queue = new ArrayList<Metadata>(); queue.add(Util.empty_data()); currMediaData = new MediaData( Loading Loading @@ -838,8 +837,7 @@ public class MediaPlayerList { MediaSession.Token token) { if (mMediaSessionManager == null) { Log.w(TAG, "onMediaKeyEventSessionChanged(): Unexpected callback " + "from the MediaSessionManager, pkg" + packageName + ", token=" + token); + "from the MediaSessionManager, pkg" + packageName); return; } if (TextUtils.isEmpty(packageName)) { Loading android/app/src/com/android/bluetooth/audio_util/MediaPlayerWrapper.java +24 −20 Original line number Diff line number Diff line Loading @@ -288,8 +288,10 @@ public class MediaPlayerWrapper { getPlaybackState(), Util.toMetadataList(mContext, getQueue())); synchronized (mCallbackLock) { mControllerCallbacks = new MediaControllerListener(mMediaController, mLooper); } } /** * Unregisters from updates. Note, this doesn't require the looper to be shut down. Loading @@ -298,15 +300,14 @@ public class MediaPlayerWrapper { // Prevent a race condition where a callback could be called while shutting down synchronized (mCallbackLock) { mRegisteredCallback = null; } if (mControllerCallbacks == null) return; mControllerCallbacks.cleanup(); mControllerCallbacks = null; } } void updateMediaController(MediaController newController) { if (newController == mMediaController) return; if (Objects.equals(newController, mMediaController)) return; mMediaController = newController; Loading @@ -315,17 +316,18 @@ public class MediaPlayerWrapper { d("Controller for " + mPackageName + " maybe is not activated."); return; } } mControllerCallbacks.cleanup(); // Update the current data since it could be different on the new controller for the player // Update the current data since it could be different on the new controller for the // player mCurrentData = new MediaData( Util.toMetadata(mContext, getMetadata()), getPlaybackState(), Util.toMetadataList(mContext, getQueue())); mControllerCallbacks = new MediaControllerListener(mMediaController, mLooper); } d("Controller for " + mPackageName + " was updated."); } Loading Loading @@ -429,7 +431,7 @@ public class MediaPlayerWrapper { } @Override public void onMetadataChanged(@Nullable MediaMetadata metadata) { public void onMetadataChanged(@Nullable MediaMetadata mediaMetadata) { if (!isMetadataReady()) { Log.v(TAG, "onMetadataChanged(): " + mPackageName + " tried to update with no queue"); Loading @@ -438,10 +440,10 @@ public class MediaPlayerWrapper { if (DEBUG) { Log.v(TAG, "onMetadataChanged(): " + mPackageName + " : " + Util.toMetadata(mContext, metadata)); + Util.toMetadata(mContext, mediaMetadata)); } if (!Objects.equals(metadata, getMetadata())) { if (!Objects.equals(mediaMetadata, getMetadata())) { e("The callback metadata doesn't match controller metadata"); } Loading @@ -453,7 +455,7 @@ public class MediaPlayerWrapper { // TODO: Spotify needs a metadata update debouncer as it sometimes updates the metadata // twice in a row with the only difference being that the song duration is rounded to // the nearest second. if (Objects.equals(metadata, mCurrentData.metadata)) { if (Objects.equals(Util.toMetadata(mContext, mediaMetadata), mCurrentData.metadata)) { Log.w(TAG, "onMetadataChanged(): " + mPackageName + " tried to update with no new data"); return; Loading Loading @@ -570,9 +572,11 @@ public class MediaPlayerWrapper { @VisibleForTesting Handler getTimeoutHandler() { synchronized (mCallbackLock) { if (mControllerCallbacks == null) return null; return mControllerCallbacks.getTimeoutHandler(); } } @Override public String toString() { Loading Loading
android/app/src/com/android/bluetooth/audio_util/BTAudioEventLogger.java +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ public class BTAudioEventLogger { private final EvictingQueue<Event> mEvents; // Event class contain timestamp and log context. private class Event { private static class Event { private final String mTimeStamp; private final String mMsg; Loading
android/app/src/com/android/bluetooth/audio_util/BrowsablePlayerConnector.java +7 −5 Original line number Diff line number Diff line Loading @@ -52,7 +52,6 @@ public class BrowsablePlayerConnector { private static BrowsablePlayerConnector sInjectConnector; private Handler mHandler; private Context mContext; private PlayerListCallback mCallback; private List<BrowsedPlayerWrapper> mResults = new ArrayList<BrowsedPlayerWrapper>(); Loading @@ -62,7 +61,11 @@ public class BrowsablePlayerConnector { void run(List<BrowsedPlayerWrapper> result); } private static void setInstanceForTesting(BrowsablePlayerConnector connector) { /** * @hide */ @VisibleForTesting static void setInstanceForTesting(BrowsablePlayerConnector connector) { Utils.enforceInstrumentationTestMode(); sInjectConnector = connector; } Loading @@ -80,7 +83,7 @@ public class BrowsablePlayerConnector { return null; } BrowsablePlayerConnector newWrapper = new BrowsablePlayerConnector(context, looper, cb); BrowsablePlayerConnector newWrapper = new BrowsablePlayerConnector(looper, cb); // Try to start connecting all the browsed player wrappers for (ResolveInfo info : players) { Loading Loading @@ -109,8 +112,7 @@ public class BrowsablePlayerConnector { return newWrapper; } private BrowsablePlayerConnector(Context context, Looper looper, PlayerListCallback cb) { mContext = context; private BrowsablePlayerConnector(Looper looper, PlayerListCallback cb) { mCallback = cb; mHandler = new Handler(looper) { public void handleMessage(Message msg) { Loading
android/app/src/com/android/bluetooth/audio_util/BrowsedPlayerWrapper.java +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ import java.util.Map; * Right now this is ok because the BrowsablePlayerConnector will handle timeouts. */ class BrowsedPlayerWrapper { private static final String TAG = "AvrcpBrowsedPlayerWrapper"; private static final String TAG = "BrowsedPlayerWrapper"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); enum ConnectionState { Loading
android/app/src/com/android/bluetooth/audio_util/MediaPlayerList.java +2 −4 Original line number Diff line number Diff line Loading @@ -85,7 +85,6 @@ public class MediaPlayerList { private Context mContext; private Looper mLooper; // Thread all media player callbacks and timeouts happen on private PackageManager mPackageManager; private MediaSessionManager mMediaSessionManager; private MediaData mCurrMediaData = null; private final AudioManager mAudioManager; Loading Loading @@ -731,7 +730,7 @@ public class MediaPlayerList { if (getActivePlayer() == null) { Log.d(TAG, "updateMediaForAudioPlayback: no active player"); PlaybackState.Builder builder = new PlaybackState.Builder() .setState(PlaybackState.STATE_STOPPED, 0L, 0L); .setState(PlaybackState.STATE_STOPPED, 0L, 0f); List<Metadata> queue = new ArrayList<Metadata>(); queue.add(Util.empty_data()); currMediaData = new MediaData( Loading Loading @@ -838,8 +837,7 @@ public class MediaPlayerList { MediaSession.Token token) { if (mMediaSessionManager == null) { Log.w(TAG, "onMediaKeyEventSessionChanged(): Unexpected callback " + "from the MediaSessionManager, pkg" + packageName + ", token=" + token); + "from the MediaSessionManager, pkg" + packageName); return; } if (TextUtils.isEmpty(packageName)) { Loading
android/app/src/com/android/bluetooth/audio_util/MediaPlayerWrapper.java +24 −20 Original line number Diff line number Diff line Loading @@ -288,8 +288,10 @@ public class MediaPlayerWrapper { getPlaybackState(), Util.toMetadataList(mContext, getQueue())); synchronized (mCallbackLock) { mControllerCallbacks = new MediaControllerListener(mMediaController, mLooper); } } /** * Unregisters from updates. Note, this doesn't require the looper to be shut down. Loading @@ -298,15 +300,14 @@ public class MediaPlayerWrapper { // Prevent a race condition where a callback could be called while shutting down synchronized (mCallbackLock) { mRegisteredCallback = null; } if (mControllerCallbacks == null) return; mControllerCallbacks.cleanup(); mControllerCallbacks = null; } } void updateMediaController(MediaController newController) { if (newController == mMediaController) return; if (Objects.equals(newController, mMediaController)) return; mMediaController = newController; Loading @@ -315,17 +316,18 @@ public class MediaPlayerWrapper { d("Controller for " + mPackageName + " maybe is not activated."); return; } } mControllerCallbacks.cleanup(); // Update the current data since it could be different on the new controller for the player // Update the current data since it could be different on the new controller for the // player mCurrentData = new MediaData( Util.toMetadata(mContext, getMetadata()), getPlaybackState(), Util.toMetadataList(mContext, getQueue())); mControllerCallbacks = new MediaControllerListener(mMediaController, mLooper); } d("Controller for " + mPackageName + " was updated."); } Loading Loading @@ -429,7 +431,7 @@ public class MediaPlayerWrapper { } @Override public void onMetadataChanged(@Nullable MediaMetadata metadata) { public void onMetadataChanged(@Nullable MediaMetadata mediaMetadata) { if (!isMetadataReady()) { Log.v(TAG, "onMetadataChanged(): " + mPackageName + " tried to update with no queue"); Loading @@ -438,10 +440,10 @@ public class MediaPlayerWrapper { if (DEBUG) { Log.v(TAG, "onMetadataChanged(): " + mPackageName + " : " + Util.toMetadata(mContext, metadata)); + Util.toMetadata(mContext, mediaMetadata)); } if (!Objects.equals(metadata, getMetadata())) { if (!Objects.equals(mediaMetadata, getMetadata())) { e("The callback metadata doesn't match controller metadata"); } Loading @@ -453,7 +455,7 @@ public class MediaPlayerWrapper { // TODO: Spotify needs a metadata update debouncer as it sometimes updates the metadata // twice in a row with the only difference being that the song duration is rounded to // the nearest second. if (Objects.equals(metadata, mCurrentData.metadata)) { if (Objects.equals(Util.toMetadata(mContext, mediaMetadata), mCurrentData.metadata)) { Log.w(TAG, "onMetadataChanged(): " + mPackageName + " tried to update with no new data"); return; Loading Loading @@ -570,9 +572,11 @@ public class MediaPlayerWrapper { @VisibleForTesting Handler getTimeoutHandler() { synchronized (mCallbackLock) { if (mControllerCallbacks == null) return null; return mControllerCallbacks.getTimeoutHandler(); } } @Override public String toString() { Loading