use of android.media.session.MediaController in project android_frameworks_base by DirtyUnicorns.
the class MediaSessions method onUpdateRemoteControllerH.
private void onUpdateRemoteControllerH(ISessionController session) {
final MediaController controller = session != null ? new MediaController(mContext, session) : null;
final String pkg = controller != null ? controller.getPackageName() : null;
if (D.BUG)
Log.d(TAG, "updateRemoteControllerH " + pkg);
// this may be our only indication that a remote session is changed, refresh
postUpdateSessions();
}
use of android.media.session.MediaController in project android_frameworks_base by DirtyUnicorns.
the class MediaSessions method dumpMediaSessions.
public static void dumpMediaSessions(Context context) {
final MediaSessionManager mgr = (MediaSessionManager) context.getSystemService(Context.MEDIA_SESSION_SERVICE);
try {
final List<MediaController> controllers = mgr.getActiveSessions(null);
final int N = controllers.size();
if (D.BUG)
Log.d(TAG, N + " controllers");
for (int i = 0; i < N; i++) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw, true);
dump(i + 1, pw, controllers.get(i));
if (D.BUG)
Log.d(TAG, sw.toString());
}
} catch (SecurityException e) {
Log.w(TAG, "Not allowed to get sessions", e);
}
}
use of android.media.session.MediaController in project android_frameworks_base by AOSPA.
the class MediaSessions method onActiveSessionsUpdatedH.
protected void onActiveSessionsUpdatedH(List<MediaController> controllers) {
if (D.BUG)
Log.d(TAG, "onActiveSessionsUpdatedH n=" + controllers.size());
final Set<Token> toRemove = new HashSet<Token>(mRecords.keySet());
for (MediaController controller : controllers) {
final Token token = controller.getSessionToken();
final PlaybackInfo pi = controller.getPlaybackInfo();
toRemove.remove(token);
if (!mRecords.containsKey(token)) {
final MediaControllerRecord r = new MediaControllerRecord(controller);
r.name = getControllerName(controller);
mRecords.put(token, r);
controller.registerCallback(r, mHandler);
}
final MediaControllerRecord r = mRecords.get(token);
final boolean remote = isRemote(pi);
if (remote) {
updateRemoteH(token, r.name, pi);
r.sentRemote = true;
}
}
for (Token t : toRemove) {
final MediaControllerRecord r = mRecords.get(t);
r.controller.unregisterCallback(r);
mRecords.remove(t);
if (D.BUG)
Log.d(TAG, "Removing " + r.name + " sentRemote=" + r.sentRemote);
if (r.sentRemote) {
mCallbacks.onRemoteRemoved(t);
r.sentRemote = false;
}
}
}
use of android.media.session.MediaController in project android_frameworks_base by AOSPA.
the class MediaSessions method onRemoteVolumeChangedH.
private void onRemoteVolumeChangedH(ISessionController session, int flags) {
final MediaController controller = new MediaController(mContext, session);
if (D.BUG)
Log.d(TAG, "remoteVolumeChangedH " + controller.getPackageName() + " " + Util.audioManagerFlagsToString(flags));
final Token token = controller.getSessionToken();
mCallbacks.onRemoteVolumeChanged(token, flags);
}
use of android.media.session.MediaController in project android_frameworks_base by ResurrectionRemix.
the class MediaSessions method dumpMediaSessions.
public static void dumpMediaSessions(Context context) {
final MediaSessionManager mgr = (MediaSessionManager) context.getSystemService(Context.MEDIA_SESSION_SERVICE);
try {
final List<MediaController> controllers = mgr.getActiveSessions(null);
final int N = controllers.size();
if (D.BUG)
Log.d(TAG, N + " controllers");
for (int i = 0; i < N; i++) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw, true);
dump(i + 1, pw, controllers.get(i));
if (D.BUG)
Log.d(TAG, sw.toString());
}
} catch (SecurityException e) {
Log.w(TAG, "Not allowed to get sessions", e);
}
}
Aggregations