diff options
Diffstat (limited to 'media/java/android/media/session/MediaController.java')
-rw-r--r-- | media/java/android/media/session/MediaController.java | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/media/java/android/media/session/MediaController.java b/media/java/android/media/session/MediaController.java index de22fa32c0ac..c4b82c3141d3 100644 --- a/media/java/android/media/session/MediaController.java +++ b/media/java/android/media/session/MediaController.java @@ -18,6 +18,7 @@ package android.media.session; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.UnsupportedAppUsage; import android.app.PendingIntent; import android.content.Context; import android.content.pm.ParceledListSlice; @@ -130,9 +131,7 @@ public final class MediaController { } /** - * Dispatches the media button event as system service to the session. This only effects the - * {@link MediaSession.Callback#getCurrentControllerInfo()} and doesn't bypass any permission - * check done by the system service. + * Dispatches the media button event as system service to the session. * <p> * Should be only called by the {@link com.android.internal.policy.PhoneWindow} when the * foreground activity didn't consume the key from the hardware devices. @@ -154,7 +153,7 @@ public final class MediaController { return false; } try { - return mSessionBinder.sendMediaButton(mContext.getPackageName(), mCbStub, + return mSessionBinder.sendMediaButton(mContext.getOpPackageName(), mCbStub, asSystemService, keyEvent); } catch (RemoteException e) { // System is dead. =( @@ -163,9 +162,7 @@ public final class MediaController { } /** - * Dispatches the volume button event as system service to the session. This only effects the - * {@link MediaSession.Callback#getCurrentControllerInfo()} and doesn't bypass any permission - * check done by the system service. + * Dispatches the volume button event as system service to the session. * <p> * Should be only called by the {@link com.android.internal.policy.PhoneWindow} when the * foreground activity didn't consume the key from the hardware devices. @@ -189,8 +186,8 @@ public final class MediaController { break; } try { - mSessionBinder.adjustVolume(mContext.getPackageName(), mCbStub, true, direction, - AudioManager.FLAG_SHOW_UI); + mSessionBinder.adjustVolume(mContext.getOpPackageName(), mCbStub, true, + direction, AudioManager.FLAG_SHOW_UI); } catch (RemoteException e) { Log.wtf(TAG, "Error calling adjustVolumeBy", e); } @@ -200,7 +197,8 @@ public final class MediaController { final int flags = AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_VIBRATE | AudioManager.FLAG_FROM_KEY; try { - mSessionBinder.adjustVolume(mContext.getPackageName(), mCbStub, true, 0, flags); + mSessionBinder.adjustVolume(mContext.getOpPackageName(), mCbStub, true, 0, + flags); } catch (RemoteException e) { Log.wtf(TAG, "Error calling adjustVolumeBy", e); } @@ -369,7 +367,7 @@ public final class MediaController { */ public void setVolumeTo(int value, int flags) { try { - mSessionBinder.setVolumeTo(mContext.getPackageName(), mCbStub, value, flags); + mSessionBinder.setVolumeTo(mContext.getOpPackageName(), mCbStub, value, flags); } catch (RemoteException e) { Log.wtf(TAG, "Error calling setVolumeTo.", e); } @@ -390,7 +388,7 @@ public final class MediaController { */ public void adjustVolume(int direction, int flags) { try { - mSessionBinder.adjustVolume(mContext.getPackageName(), mCbStub, false, direction, + mSessionBinder.adjustVolume(mContext.getOpPackageName(), mCbStub, false, direction, flags); } catch (RemoteException e) { Log.wtf(TAG, "Error calling adjustVolumeBy.", e); @@ -457,7 +455,7 @@ public final class MediaController { throw new IllegalArgumentException("command cannot be null or empty"); } try { - mSessionBinder.sendCommand(mContext.getPackageName(), mCbStub, command, args, cb); + mSessionBinder.sendCommand(mContext.getOpPackageName(), mCbStub, command, args, cb); } catch (RemoteException e) { Log.d(TAG, "Dead object in sendCommand.", e); } @@ -506,6 +504,7 @@ public final class MediaController { /** * @hide */ + @UnsupportedAppUsage public boolean controlsSameSession(MediaController other) { if (other == null) return false; return mSessionBinder.asBinder() == other.getSessionBinder().asBinder(); @@ -522,7 +521,7 @@ public final class MediaController { if (!mCbRegistered) { try { - mSessionBinder.registerCallbackListener(mContext.getPackageName(), mCbStub); + mSessionBinder.registerCallbackListener(mContext.getOpPackageName(), mCbStub); mCbRegistered = true; } catch (RemoteException e) { Log.e(TAG, "Dead object in registerCallback", e); @@ -669,7 +668,7 @@ public final class MediaController { */ public void prepare() { try { - mSessionBinder.prepare(mContext.getPackageName(), mCbStub); + mSessionBinder.prepare(mContext.getOpPackageName(), mCbStub); } catch (RemoteException e) { Log.wtf(TAG, "Error calling prepare.", e); } @@ -693,7 +692,7 @@ public final class MediaController { "You must specify a non-empty String for prepareFromMediaId."); } try { - mSessionBinder.prepareFromMediaId(mContext.getPackageName(), mCbStub, mediaId, + mSessionBinder.prepareFromMediaId(mContext.getOpPackageName(), mCbStub, mediaId, extras); } catch (RemoteException e) { Log.wtf(TAG, "Error calling prepare(" + mediaId + ").", e); @@ -720,7 +719,8 @@ public final class MediaController { query = ""; } try { - mSessionBinder.prepareFromSearch(mContext.getPackageName(), mCbStub, query, extras); + mSessionBinder.prepareFromSearch(mContext.getOpPackageName(), mCbStub, query, + extras); } catch (RemoteException e) { Log.wtf(TAG, "Error calling prepare(" + query + ").", e); } @@ -744,7 +744,7 @@ public final class MediaController { "You must specify a non-empty Uri for prepareFromUri."); } try { - mSessionBinder.prepareFromUri(mContext.getPackageName(), mCbStub, uri, extras); + mSessionBinder.prepareFromUri(mContext.getOpPackageName(), mCbStub, uri, extras); } catch (RemoteException e) { Log.wtf(TAG, "Error calling prepare(" + uri + ").", e); } @@ -755,7 +755,7 @@ public final class MediaController { */ public void play() { try { - mSessionBinder.play(mContext.getPackageName(), mCbStub); + mSessionBinder.play(mContext.getOpPackageName(), mCbStub); } catch (RemoteException e) { Log.wtf(TAG, "Error calling play.", e); } @@ -774,7 +774,8 @@ public final class MediaController { "You must specify a non-empty String for playFromMediaId."); } try { - mSessionBinder.playFromMediaId(mContext.getPackageName(), mCbStub, mediaId, extras); + mSessionBinder.playFromMediaId(mContext.getOpPackageName(), mCbStub, mediaId, + extras); } catch (RemoteException e) { Log.wtf(TAG, "Error calling play(" + mediaId + ").", e); } @@ -796,7 +797,7 @@ public final class MediaController { query = ""; } try { - mSessionBinder.playFromSearch(mContext.getPackageName(), mCbStub, query, extras); + mSessionBinder.playFromSearch(mContext.getOpPackageName(), mCbStub, query, extras); } catch (RemoteException e) { Log.wtf(TAG, "Error calling play(" + query + ").", e); } @@ -815,7 +816,7 @@ public final class MediaController { "You must specify a non-empty Uri for playFromUri."); } try { - mSessionBinder.playFromUri(mContext.getPackageName(), mCbStub, uri, extras); + mSessionBinder.playFromUri(mContext.getOpPackageName(), mCbStub, uri, extras); } catch (RemoteException e) { Log.wtf(TAG, "Error calling play(" + uri + ").", e); } @@ -827,7 +828,7 @@ public final class MediaController { */ public void skipToQueueItem(long id) { try { - mSessionBinder.skipToQueueItem(mContext.getPackageName(), mCbStub, id); + mSessionBinder.skipToQueueItem(mContext.getOpPackageName(), mCbStub, id); } catch (RemoteException e) { Log.wtf(TAG, "Error calling skipToItem(" + id + ").", e); } @@ -839,7 +840,7 @@ public final class MediaController { */ public void pause() { try { - mSessionBinder.pause(mContext.getPackageName(), mCbStub); + mSessionBinder.pause(mContext.getOpPackageName(), mCbStub); } catch (RemoteException e) { Log.wtf(TAG, "Error calling pause.", e); } @@ -851,7 +852,7 @@ public final class MediaController { */ public void stop() { try { - mSessionBinder.stop(mContext.getPackageName(), mCbStub); + mSessionBinder.stop(mContext.getOpPackageName(), mCbStub); } catch (RemoteException e) { Log.wtf(TAG, "Error calling stop.", e); } @@ -864,7 +865,7 @@ public final class MediaController { */ public void seekTo(long pos) { try { - mSessionBinder.seekTo(mContext.getPackageName(), mCbStub, pos); + mSessionBinder.seekTo(mContext.getOpPackageName(), mCbStub, pos); } catch (RemoteException e) { Log.wtf(TAG, "Error calling seekTo.", e); } @@ -876,7 +877,7 @@ public final class MediaController { */ public void fastForward() { try { - mSessionBinder.fastForward(mContext.getPackageName(), mCbStub); + mSessionBinder.fastForward(mContext.getOpPackageName(), mCbStub); } catch (RemoteException e) { Log.wtf(TAG, "Error calling fastForward.", e); } @@ -887,7 +888,7 @@ public final class MediaController { */ public void skipToNext() { try { - mSessionBinder.next(mContext.getPackageName(), mCbStub); + mSessionBinder.next(mContext.getOpPackageName(), mCbStub); } catch (RemoteException e) { Log.wtf(TAG, "Error calling next.", e); } @@ -899,7 +900,7 @@ public final class MediaController { */ public void rewind() { try { - mSessionBinder.rewind(mContext.getPackageName(), mCbStub); + mSessionBinder.rewind(mContext.getOpPackageName(), mCbStub); } catch (RemoteException e) { Log.wtf(TAG, "Error calling rewind.", e); } @@ -910,7 +911,7 @@ public final class MediaController { */ public void skipToPrevious() { try { - mSessionBinder.previous(mContext.getPackageName(), mCbStub); + mSessionBinder.previous(mContext.getOpPackageName(), mCbStub); } catch (RemoteException e) { Log.wtf(TAG, "Error calling previous.", e); } @@ -925,7 +926,7 @@ public final class MediaController { */ public void setRating(Rating rating) { try { - mSessionBinder.rate(mContext.getPackageName(), mCbStub, rating); + mSessionBinder.rate(mContext.getOpPackageName(), mCbStub, rating); } catch (RemoteException e) { Log.wtf(TAG, "Error calling rate.", e); } @@ -960,7 +961,7 @@ public final class MediaController { throw new IllegalArgumentException("CustomAction cannot be null."); } try { - mSessionBinder.sendCustomAction(mContext.getPackageName(), mCbStub, action, args); + mSessionBinder.sendCustomAction(mContext.getOpPackageName(), mCbStub, action, args); } catch (RemoteException e) { Log.d(TAG, "Dead object in sendCustomAction.", e); } |