use of com.android.systemui.statusbar.MediaExpandableNotificationRow in project android_frameworks_base by crdroidandroid.
the class PhoneStatusBar method findAndUpdateMediaNotifications.
public void findAndUpdateMediaNotifications() {
boolean metaDataChanged = false;
synchronized (mNotificationData) {
ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
final int N = activeNotifications.size();
// Promote the media notification with a controller in 'playing' state, if any.
Entry mediaNotification = null;
MediaController controller = null;
for (int i = 0; i < N; i++) {
final Entry entry = activeNotifications.get(i);
if (isMediaNotification(entry)) {
final MediaSession.Token token = entry.notification.getNotification().extras.getParcelable(Notification.EXTRA_MEDIA_SESSION);
if (token != null) {
MediaController aController = new MediaController(mContext, token);
if (PlaybackState.STATE_PLAYING == getMediaControllerPlaybackState(aController)) {
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: found mediastyle controller matching " + entry.notification.getKey());
}
mediaNotification = entry;
controller = aController;
break;
}
}
}
}
if (mediaNotification == null) {
if (mMediaSessionManager != null) {
final List<MediaController> sessions = mMediaSessionManager.getActiveSessionsForUser(null, UserHandle.USER_ALL);
for (MediaController aController : sessions) {
if (PlaybackState.STATE_PLAYING == getMediaControllerPlaybackState(aController)) {
// now to see if we have one like this
final String pkg = aController.getPackageName();
for (int i = 0; i < N; i++) {
final Entry entry = activeNotifications.get(i);
if (entry.notification.getPackageName().equals(pkg)) {
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: found controller matching " + entry.notification.getKey());
}
controller = aController;
mediaNotification = entry;
break;
}
}
}
}
}
}
if (controller != null && !sameSessions(mMediaController, controller)) {
// We have a new media session
clearCurrentMediaNotification();
mMediaController = controller;
mMediaController.registerCallback(mMediaListener);
mMediaMetadata = mMediaController.getMetadata();
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: insert listener, receive metadata: " + mMediaMetadata);
}
if (mediaNotification != null && mediaNotification.row != null && mediaNotification.row instanceof MediaExpandableNotificationRow) {
((MediaExpandableNotificationRow) mediaNotification.row).setMediaController(controller);
}
if (mediaNotification != null) {
mMediaNotificationKey = mediaNotification.notification.getKey();
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key=" + mMediaNotificationKey + " controller=" + mMediaController);
}
}
metaDataChanged = true;
}
}
if (metaDataChanged) {
updateNotifications();
}
updateMediaMetaData(metaDataChanged, true);
}
use of com.android.systemui.statusbar.MediaExpandableNotificationRow in project android_frameworks_base by ResurrectionRemix.
the class PhoneStatusBar method findAndUpdateMediaNotifications.
public void findAndUpdateMediaNotifications() {
boolean metaDataChanged = false;
synchronized (mNotificationData) {
ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
final int N = activeNotifications.size();
// Promote the media notification with a controller in 'playing' state, if any.
Entry mediaNotification = null;
MediaController controller = null;
for (int i = 0; i < N; i++) {
final Entry entry = activeNotifications.get(i);
if (isMediaNotification(entry)) {
final MediaSession.Token token = entry.notification.getNotification().extras.getParcelable(Notification.EXTRA_MEDIA_SESSION);
if (token != null) {
MediaController aController = new MediaController(mContext, token);
if (PlaybackState.STATE_PLAYING == getMediaControllerPlaybackState(aController)) {
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: found mediastyle controller matching " + entry.notification.getKey());
}
mediaNotification = entry;
controller = aController;
break;
}
}
}
}
if (mediaNotification == null) {
if (mMediaSessionManager != null) {
final List<MediaController> sessions = mMediaSessionManager.getActiveSessionsForUser(null, UserHandle.USER_ALL);
for (MediaController aController : sessions) {
if (PlaybackState.STATE_PLAYING == getMediaControllerPlaybackState(aController)) {
// now to see if we have one like this
final String pkg = aController.getPackageName();
for (int i = 0; i < N; i++) {
final Entry entry = activeNotifications.get(i);
if (entry.notification.getPackageName().equals(pkg)) {
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: found controller matching " + entry.notification.getKey());
}
controller = aController;
mediaNotification = entry;
break;
}
}
}
}
}
}
if (controller != null && !sameSessions(mMediaController, controller)) {
// We have a new media session
clearCurrentMediaNotification();
mMediaController = controller;
mMediaController.registerCallback(mMediaListener);
mMediaMetadata = mMediaController.getMetadata();
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: insert listener, receive metadata: " + mMediaMetadata);
}
if (mediaNotification != null && mediaNotification.row != null && mediaNotification.row instanceof MediaExpandableNotificationRow) {
((MediaExpandableNotificationRow) mediaNotification.row).setMediaController(controller);
}
if (mediaNotification != null) {
mMediaNotificationKey = mediaNotification.notification.getKey();
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key=" + mMediaNotificationKey + " controller=" + mMediaController);
}
}
metaDataChanged = true;
}
}
if (metaDataChanged) {
updateNotifications();
}
updateMediaMetaData(metaDataChanged, true);
}
Aggregations