Loading media/java/android/media/AudioManager.java +17 −93 Original line number Diff line number Diff line Loading @@ -50,12 +50,6 @@ import java.util.ArrayList; */ public class AudioManager { // If we should use the new sessions APIs. private final static boolean USE_SESSIONS = true; // If we should use the legacy APIs. If both are true information will be // duplicated through both paths. Currently this flag isn't used. private final static boolean USE_LEGACY = true; private final Context mContext; private long mVolumeKeyUpTime; private final boolean mUseMasterVolume; Loading Loading @@ -483,17 +477,8 @@ public class AudioManager { * or {@link KeyEvent#KEYCODE_MEDIA_AUDIO_TRACK}. */ public void dispatchMediaKeyEvent(KeyEvent keyEvent) { if (USE_SESSIONS) { MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); helper.sendMediaButtonEvent(keyEvent, false); } else { IAudioService service = getService(); try { service.dispatchMediaKeyEvent(keyEvent); } catch (RemoteException e) { Log.e(TAG, "dispatchMediaKeyEvent threw exception ", e); } } } /** Loading Loading @@ -644,12 +629,8 @@ public class AudioManager { if (mUseMasterVolume) { service.adjustMasterVolume(direction, flags, mContext.getOpPackageName()); } else { if (USE_SESSIONS) { MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); helper.sendAdjustVolumeBy(USE_DEFAULT_STREAM_TYPE, direction, flags); } else { service.adjustVolume(direction, flags, mContext.getOpPackageName()); } } } catch (RemoteException e) { Log.e(TAG, "Dead object in adjustVolume", e); Loading Loading @@ -679,13 +660,8 @@ public class AudioManager { if (mUseMasterVolume) { service.adjustMasterVolume(direction, flags, mContext.getOpPackageName()); } else { if (USE_SESSIONS) { MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); helper.sendAdjustVolumeBy(suggestedStreamType, direction, flags); } else { service.adjustSuggestedStreamVolume(direction, suggestedStreamType, flags, mContext.getOpPackageName()); } } } catch (RemoteException e) { Log.e(TAG, "Dead object in adjustSuggestedStreamVolume", e); Loading Loading @@ -2215,17 +2191,16 @@ public class AudioManager { } IAudioService service = getService(); try { // pi != null // pi != null, this is currently still needed to support across // reboot launching of the last app. service.registerMediaButtonIntent(pi, eventReceiver, eventReceiver == null ? mToken : null); } catch (RemoteException e) { Log.e(TAG, "Dead object in registerMediaButtonIntent"+e); } if (USE_SESSIONS) { MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); helper.addMediaButtonListener(pi, mContext); } } /** * @hide Loading Loading @@ -2298,11 +2273,9 @@ public class AudioManager { } catch (RemoteException e) { Log.e(TAG, "Dead object in unregisterMediaButtonIntent"+e); } if (USE_SESSIONS) { MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); helper.removeMediaButtonListener(pi); } } /** * Registers the remote control client for providing information to display on the remote Loading @@ -2315,21 +2288,8 @@ public class AudioManager { if ((rcClient == null) || (rcClient.getRcMediaIntent() == null)) { return; } IAudioService service = getService(); try { int rcseId = service.registerRemoteControlClient( rcClient.getRcMediaIntent(), /* mediaIntent */ rcClient.getIRemoteControlClient(),/* rcClient */ // used to match media button event receiver and audio focus mContext.getPackageName()); /* packageName */ rcClient.setRcseId(rcseId); } catch (RemoteException e) { Log.e(TAG, "Dead object in registerRemoteControlClient"+e); } if (USE_SESSIONS) { rcClient.registerWithSession(MediaSessionLegacyHelper.getHelper(mContext)); } } /** * Unregisters the remote control client that was providing information to display on the Loading @@ -2341,17 +2301,8 @@ public class AudioManager { if ((rcClient == null) || (rcClient.getRcMediaIntent() == null)) { return; } IAudioService service = getService(); try { service.unregisterRemoteControlClient(rcClient.getRcMediaIntent(), /* mediaIntent */ rcClient.getIRemoteControlClient()); /* rcClient */ } catch (RemoteException e) { Log.e(TAG, "Dead object in unregisterRemoteControlClient"+e); } if (USE_SESSIONS) { rcClient.unregisterWithSession(MediaSessionLegacyHelper.getHelper(mContext)); } } /** * Registers a {@link RemoteController} instance for it to receive media metadata updates Loading @@ -2368,25 +2319,8 @@ public class AudioManager { if (rctlr == null) { return false; } if (USE_SESSIONS) { rctlr.startListeningToSessions(); return true; } else { IAudioService service = getService(); final RemoteController.OnClientUpdateListener l = rctlr.getUpdateListener(); final ComponentName listenerComponent = new ComponentName(mContext, l.getClass()); try { int[] artworkDimensions = rctlr.getArtworkSize(); boolean reg = service.registerRemoteController(rctlr.getRcDisplay(), artworkDimensions[0]/* w */, artworkDimensions[1]/* h */, listenerComponent); rctlr.setIsRegistered(reg); return reg; } catch (RemoteException e) { Log.e(TAG, "Dead object in registerRemoteController " + e); return false; } } } /** Loading @@ -2398,17 +2332,7 @@ public class AudioManager { if (rctlr == null) { return; } if (USE_SESSIONS) { rctlr.stopListeningToSessions(); } else { IAudioService service = getService(); try { service.unregisterRemoteControlDisplay(rctlr.getRcDisplay()); rctlr.setIsRegistered(false); } catch (RemoteException e) { Log.e(TAG, "Dead object in unregisterRemoteControlDisplay " + e); } } } /** Loading media/java/android/media/AudioService.java +9 −18 Original line number Diff line number Diff line Loading @@ -108,8 +108,7 @@ public class AudioService extends IAudioService.Stub { /** Debug volumes */ protected static final boolean DEBUG_VOL = false; /** Reroute calls to media session apis */ private static final boolean USE_SESSIONS = true; /** debug calls to media session apis */ private static final boolean DEBUG_SESSIONS = true; /** Allow volume changes to set ringer mode to silent? */ Loading Loading @@ -4484,27 +4483,19 @@ public class AudioService extends IAudioService.Stub { } public void dispatchMediaKeyEvent(KeyEvent keyEvent) { if (USE_SESSIONS) { if (DEBUG_SESSIONS) { int pid = getCallingPid(); Log.w(TAG, "Call to dispatchMediaKeyEvent from " + pid); } MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(keyEvent, false); } else { mMediaFocusControl.dispatchMediaKeyEvent(keyEvent); } } public void dispatchMediaKeyEventUnderWakelock(KeyEvent keyEvent) { if (USE_SESSIONS) { if (DEBUG_SESSIONS) { int pid = getCallingPid(); Log.w(TAG, "Call to dispatchMediaKeyEventUnderWakelock from " + pid); } MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(keyEvent, true); } else { mMediaFocusControl.dispatchMediaKeyEventUnderWakelock(keyEvent); } } //========================================================================================== Loading media/java/android/media/MediaRouter.java +7 −59 Original line number Diff line number Diff line Loading @@ -60,7 +60,6 @@ import java.util.concurrent.CopyOnWriteArrayList; public class MediaRouter { private static final String TAG = "MediaRouter"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final boolean USE_SESSIONS = true; static class Static implements DisplayManager.DisplayListener { final Context mAppContext; Loading Loading @@ -2104,11 +2103,7 @@ public class MediaRouter { public void setPlaybackType(int type) { if (mPlaybackType != type) { mPlaybackType = type; if (USE_SESSIONS) { configureSessionVolume(); } else { setPlaybackInfoOnRcc(RemoteControlClient.PLAYBACKINFO_PLAYBACK_TYPE, type); } } } Loading @@ -2121,12 +2116,7 @@ public class MediaRouter { public void setVolumeHandling(int volumeHandling) { if (mVolumeHandling != volumeHandling) { mVolumeHandling = volumeHandling; if (USE_SESSIONS) { configureSessionVolume(); } else { setPlaybackInfoOnRcc( RemoteControlClient.PLAYBACKINFO_VOLUME_HANDLING, volumeHandling); } } } Loading @@ -2139,13 +2129,9 @@ public class MediaRouter { volume = Math.max(0, Math.min(volume, getVolumeMax())); if (mVolume != volume) { mVolume = volume; if (USE_SESSIONS) { if (mSvp != null) { mSvp.notifyVolumeChanged(); } } else { setPlaybackInfoOnRcc(RemoteControlClient.PLAYBACKINFO_VOLUME, volume); } dispatchRouteVolumeChanged(this); if (mGroup != null) { mGroup.memberVolumeChanged(this); Loading Loading @@ -2184,11 +2170,7 @@ public class MediaRouter { public void setVolumeMax(int volumeMax) { if (mVolumeMax != volumeMax) { mVolumeMax = volumeMax; if (USE_SESSIONS) { configureSessionVolume(); } else { setPlaybackInfoOnRcc(RemoteControlClient.PLAYBACKINFO_VOLUME_MAX, volumeMax); } } } Loading @@ -2199,40 +2181,12 @@ public class MediaRouter { public void setPlaybackStream(int stream) { if (mPlaybackStream != stream) { mPlaybackStream = stream; if (USE_SESSIONS) { configureSessionVolume(); } else { setPlaybackInfoOnRcc(RemoteControlClient.PLAYBACKINFO_USES_STREAM, stream); } } } private void updatePlaybackInfoOnRcc() { if (USE_SESSIONS) { configureSessionVolume(); } else { if ((mRcc != null) && (mRcc.getRcseId() != RemoteControlClient.RCSE_ID_UNREGISTERED)) { mRcc.setPlaybackInformation( RemoteControlClient.PLAYBACKINFO_VOLUME_MAX, mVolumeMax); mRcc.setPlaybackInformation( RemoteControlClient.PLAYBACKINFO_VOLUME, mVolume); mRcc.setPlaybackInformation( RemoteControlClient.PLAYBACKINFO_VOLUME_HANDLING, mVolumeHandling); mRcc.setPlaybackInformation( RemoteControlClient.PLAYBACKINFO_USES_STREAM, mPlaybackStream); mRcc.setPlaybackInformation( RemoteControlClient.PLAYBACKINFO_PLAYBACK_TYPE, mPlaybackType); // let AudioService know whom to call when remote volume // needs to be updated try { sStatic.mAudioService.registerRemoteVolumeObserverForRcc( mRcc.getRcseId() /* rccId */, mRemoteVolObserver /* rvo */); } catch (RemoteException e) { Log.e(TAG, "Error registering remote volume observer", e); } } } } private void configureSessionVolume() { Loading Loading @@ -2272,12 +2226,6 @@ public class MediaRouter { } } private void setPlaybackInfoOnRcc(int what, int value) { if (mRcc != null) { mRcc.setPlaybackInformation(what, value); } } class SessionVolumeProvider extends RemoteVolumeProvider { public SessionVolumeProvider(int volumeControl, int maxVolume) { Loading media/java/android/media/PlayerRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ class PlayerRecord implements DeathRecipient { */ final private ComponentName mReceiverComponent; private int mRccId = RemoteControlClient.RCSE_ID_UNREGISTERED; private int mRccId = -1; /** * A non-null token implies this record tracks a "live" player whose death is being monitored. Loading media/java/android/media/RemoteControlClient.java +4 −798 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
media/java/android/media/AudioManager.java +17 −93 Original line number Diff line number Diff line Loading @@ -50,12 +50,6 @@ import java.util.ArrayList; */ public class AudioManager { // If we should use the new sessions APIs. private final static boolean USE_SESSIONS = true; // If we should use the legacy APIs. If both are true information will be // duplicated through both paths. Currently this flag isn't used. private final static boolean USE_LEGACY = true; private final Context mContext; private long mVolumeKeyUpTime; private final boolean mUseMasterVolume; Loading Loading @@ -483,17 +477,8 @@ public class AudioManager { * or {@link KeyEvent#KEYCODE_MEDIA_AUDIO_TRACK}. */ public void dispatchMediaKeyEvent(KeyEvent keyEvent) { if (USE_SESSIONS) { MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); helper.sendMediaButtonEvent(keyEvent, false); } else { IAudioService service = getService(); try { service.dispatchMediaKeyEvent(keyEvent); } catch (RemoteException e) { Log.e(TAG, "dispatchMediaKeyEvent threw exception ", e); } } } /** Loading Loading @@ -644,12 +629,8 @@ public class AudioManager { if (mUseMasterVolume) { service.adjustMasterVolume(direction, flags, mContext.getOpPackageName()); } else { if (USE_SESSIONS) { MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); helper.sendAdjustVolumeBy(USE_DEFAULT_STREAM_TYPE, direction, flags); } else { service.adjustVolume(direction, flags, mContext.getOpPackageName()); } } } catch (RemoteException e) { Log.e(TAG, "Dead object in adjustVolume", e); Loading Loading @@ -679,13 +660,8 @@ public class AudioManager { if (mUseMasterVolume) { service.adjustMasterVolume(direction, flags, mContext.getOpPackageName()); } else { if (USE_SESSIONS) { MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); helper.sendAdjustVolumeBy(suggestedStreamType, direction, flags); } else { service.adjustSuggestedStreamVolume(direction, suggestedStreamType, flags, mContext.getOpPackageName()); } } } catch (RemoteException e) { Log.e(TAG, "Dead object in adjustSuggestedStreamVolume", e); Loading Loading @@ -2215,17 +2191,16 @@ public class AudioManager { } IAudioService service = getService(); try { // pi != null // pi != null, this is currently still needed to support across // reboot launching of the last app. service.registerMediaButtonIntent(pi, eventReceiver, eventReceiver == null ? mToken : null); } catch (RemoteException e) { Log.e(TAG, "Dead object in registerMediaButtonIntent"+e); } if (USE_SESSIONS) { MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); helper.addMediaButtonListener(pi, mContext); } } /** * @hide Loading Loading @@ -2298,11 +2273,9 @@ public class AudioManager { } catch (RemoteException e) { Log.e(TAG, "Dead object in unregisterMediaButtonIntent"+e); } if (USE_SESSIONS) { MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); helper.removeMediaButtonListener(pi); } } /** * Registers the remote control client for providing information to display on the remote Loading @@ -2315,21 +2288,8 @@ public class AudioManager { if ((rcClient == null) || (rcClient.getRcMediaIntent() == null)) { return; } IAudioService service = getService(); try { int rcseId = service.registerRemoteControlClient( rcClient.getRcMediaIntent(), /* mediaIntent */ rcClient.getIRemoteControlClient(),/* rcClient */ // used to match media button event receiver and audio focus mContext.getPackageName()); /* packageName */ rcClient.setRcseId(rcseId); } catch (RemoteException e) { Log.e(TAG, "Dead object in registerRemoteControlClient"+e); } if (USE_SESSIONS) { rcClient.registerWithSession(MediaSessionLegacyHelper.getHelper(mContext)); } } /** * Unregisters the remote control client that was providing information to display on the Loading @@ -2341,17 +2301,8 @@ public class AudioManager { if ((rcClient == null) || (rcClient.getRcMediaIntent() == null)) { return; } IAudioService service = getService(); try { service.unregisterRemoteControlClient(rcClient.getRcMediaIntent(), /* mediaIntent */ rcClient.getIRemoteControlClient()); /* rcClient */ } catch (RemoteException e) { Log.e(TAG, "Dead object in unregisterRemoteControlClient"+e); } if (USE_SESSIONS) { rcClient.unregisterWithSession(MediaSessionLegacyHelper.getHelper(mContext)); } } /** * Registers a {@link RemoteController} instance for it to receive media metadata updates Loading @@ -2368,25 +2319,8 @@ public class AudioManager { if (rctlr == null) { return false; } if (USE_SESSIONS) { rctlr.startListeningToSessions(); return true; } else { IAudioService service = getService(); final RemoteController.OnClientUpdateListener l = rctlr.getUpdateListener(); final ComponentName listenerComponent = new ComponentName(mContext, l.getClass()); try { int[] artworkDimensions = rctlr.getArtworkSize(); boolean reg = service.registerRemoteController(rctlr.getRcDisplay(), artworkDimensions[0]/* w */, artworkDimensions[1]/* h */, listenerComponent); rctlr.setIsRegistered(reg); return reg; } catch (RemoteException e) { Log.e(TAG, "Dead object in registerRemoteController " + e); return false; } } } /** Loading @@ -2398,17 +2332,7 @@ public class AudioManager { if (rctlr == null) { return; } if (USE_SESSIONS) { rctlr.stopListeningToSessions(); } else { IAudioService service = getService(); try { service.unregisterRemoteControlDisplay(rctlr.getRcDisplay()); rctlr.setIsRegistered(false); } catch (RemoteException e) { Log.e(TAG, "Dead object in unregisterRemoteControlDisplay " + e); } } } /** Loading
media/java/android/media/AudioService.java +9 −18 Original line number Diff line number Diff line Loading @@ -108,8 +108,7 @@ public class AudioService extends IAudioService.Stub { /** Debug volumes */ protected static final boolean DEBUG_VOL = false; /** Reroute calls to media session apis */ private static final boolean USE_SESSIONS = true; /** debug calls to media session apis */ private static final boolean DEBUG_SESSIONS = true; /** Allow volume changes to set ringer mode to silent? */ Loading Loading @@ -4484,27 +4483,19 @@ public class AudioService extends IAudioService.Stub { } public void dispatchMediaKeyEvent(KeyEvent keyEvent) { if (USE_SESSIONS) { if (DEBUG_SESSIONS) { int pid = getCallingPid(); Log.w(TAG, "Call to dispatchMediaKeyEvent from " + pid); } MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(keyEvent, false); } else { mMediaFocusControl.dispatchMediaKeyEvent(keyEvent); } } public void dispatchMediaKeyEventUnderWakelock(KeyEvent keyEvent) { if (USE_SESSIONS) { if (DEBUG_SESSIONS) { int pid = getCallingPid(); Log.w(TAG, "Call to dispatchMediaKeyEventUnderWakelock from " + pid); } MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(keyEvent, true); } else { mMediaFocusControl.dispatchMediaKeyEventUnderWakelock(keyEvent); } } //========================================================================================== Loading
media/java/android/media/MediaRouter.java +7 −59 Original line number Diff line number Diff line Loading @@ -60,7 +60,6 @@ import java.util.concurrent.CopyOnWriteArrayList; public class MediaRouter { private static final String TAG = "MediaRouter"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final boolean USE_SESSIONS = true; static class Static implements DisplayManager.DisplayListener { final Context mAppContext; Loading Loading @@ -2104,11 +2103,7 @@ public class MediaRouter { public void setPlaybackType(int type) { if (mPlaybackType != type) { mPlaybackType = type; if (USE_SESSIONS) { configureSessionVolume(); } else { setPlaybackInfoOnRcc(RemoteControlClient.PLAYBACKINFO_PLAYBACK_TYPE, type); } } } Loading @@ -2121,12 +2116,7 @@ public class MediaRouter { public void setVolumeHandling(int volumeHandling) { if (mVolumeHandling != volumeHandling) { mVolumeHandling = volumeHandling; if (USE_SESSIONS) { configureSessionVolume(); } else { setPlaybackInfoOnRcc( RemoteControlClient.PLAYBACKINFO_VOLUME_HANDLING, volumeHandling); } } } Loading @@ -2139,13 +2129,9 @@ public class MediaRouter { volume = Math.max(0, Math.min(volume, getVolumeMax())); if (mVolume != volume) { mVolume = volume; if (USE_SESSIONS) { if (mSvp != null) { mSvp.notifyVolumeChanged(); } } else { setPlaybackInfoOnRcc(RemoteControlClient.PLAYBACKINFO_VOLUME, volume); } dispatchRouteVolumeChanged(this); if (mGroup != null) { mGroup.memberVolumeChanged(this); Loading Loading @@ -2184,11 +2170,7 @@ public class MediaRouter { public void setVolumeMax(int volumeMax) { if (mVolumeMax != volumeMax) { mVolumeMax = volumeMax; if (USE_SESSIONS) { configureSessionVolume(); } else { setPlaybackInfoOnRcc(RemoteControlClient.PLAYBACKINFO_VOLUME_MAX, volumeMax); } } } Loading @@ -2199,40 +2181,12 @@ public class MediaRouter { public void setPlaybackStream(int stream) { if (mPlaybackStream != stream) { mPlaybackStream = stream; if (USE_SESSIONS) { configureSessionVolume(); } else { setPlaybackInfoOnRcc(RemoteControlClient.PLAYBACKINFO_USES_STREAM, stream); } } } private void updatePlaybackInfoOnRcc() { if (USE_SESSIONS) { configureSessionVolume(); } else { if ((mRcc != null) && (mRcc.getRcseId() != RemoteControlClient.RCSE_ID_UNREGISTERED)) { mRcc.setPlaybackInformation( RemoteControlClient.PLAYBACKINFO_VOLUME_MAX, mVolumeMax); mRcc.setPlaybackInformation( RemoteControlClient.PLAYBACKINFO_VOLUME, mVolume); mRcc.setPlaybackInformation( RemoteControlClient.PLAYBACKINFO_VOLUME_HANDLING, mVolumeHandling); mRcc.setPlaybackInformation( RemoteControlClient.PLAYBACKINFO_USES_STREAM, mPlaybackStream); mRcc.setPlaybackInformation( RemoteControlClient.PLAYBACKINFO_PLAYBACK_TYPE, mPlaybackType); // let AudioService know whom to call when remote volume // needs to be updated try { sStatic.mAudioService.registerRemoteVolumeObserverForRcc( mRcc.getRcseId() /* rccId */, mRemoteVolObserver /* rvo */); } catch (RemoteException e) { Log.e(TAG, "Error registering remote volume observer", e); } } } } private void configureSessionVolume() { Loading Loading @@ -2272,12 +2226,6 @@ public class MediaRouter { } } private void setPlaybackInfoOnRcc(int what, int value) { if (mRcc != null) { mRcc.setPlaybackInformation(what, value); } } class SessionVolumeProvider extends RemoteVolumeProvider { public SessionVolumeProvider(int volumeControl, int maxVolume) { Loading
media/java/android/media/PlayerRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ class PlayerRecord implements DeathRecipient { */ final private ComponentName mReceiverComponent; private int mRccId = RemoteControlClient.RCSE_ID_UNREGISTERED; private int mRccId = -1; /** * A non-null token implies this record tracks a "live" player whose death is being monitored. Loading
media/java/android/media/RemoteControlClient.java +4 −798 File changed.Preview size limit exceeded, changes collapsed. Show changes