Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c63fe36c authored by Raff Tsai's avatar Raff Tsai Committed by Android (Google) Code Review
Browse files

Merge "Revert "Address API feedback on setOnRtpRxNoticeListener""

parents 00789382 0ca7f047
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -4423,11 +4423,11 @@ package android.media {
  }
  public class MediaPlayer implements android.media.AudioRouting android.media.VolumeAutomation {
    method @RequiresPermission("android.permission.BIND_IMS_SERVICE") public void setOnRtpRxNoticeListener(@NonNull android.content.Context, @NonNull android.media.MediaPlayer.OnRtpRxNoticeListener, @Nullable android.os.Handler);
    method @RequiresPermission("android.permission.BIND_IMS_SERVICE") public void setOnImsRxNoticeListener(@Nullable android.media.MediaPlayer.OnImsRxNoticeListener, @Nullable android.os.Handler);
  }
  public static interface MediaPlayer.OnRtpRxNoticeListener {
    method public void onRtpRxNotice(@NonNull android.media.MediaPlayer, int, @NonNull int[]);
  public static interface MediaPlayer.OnImsRxNoticeListener {
    method public void onImsRxNotice(@NonNull android.media.MediaPlayer, @NonNull byte[]);
  }
  public final class MediaRecorder.AudioSource {
+4 −4
Original line number Diff line number Diff line
@@ -41,8 +41,8 @@ BuilderSetStyle: android.net.IpSecTransform.Builder#buildTunnelModeTransform(jav
    Builder methods names should use setFoo() / addFoo() / clearFoo() style: method android.net.IpSecTransform.Builder.buildTunnelModeTransform(java.net.InetAddress,android.net.IpSecManager.SecurityParameterIndex)


ExecutorRegistration: android.media.MediaPlayer#setOnRtpRxNoticeListener(android.content.Context, android.media.MediaPlayer.OnRtpRxNoticeListener, android.os.Handler):
    Registration methods should have overload that accepts delivery Executor: `setOnRtpRxNoticeListener`
ExecutorRegistration: android.media.MediaPlayer#setOnImsRxNoticeListener(android.media.MediaPlayer.OnImsRxNoticeListener, android.os.Handler):
    Registration methods should have overload that accepts delivery Executor: `setOnImsRxNoticeListener`
ExecutorRegistration: android.net.wifi.p2p.WifiP2pManager#deletePersistentGroup(android.net.wifi.p2p.WifiP2pManager.Channel, int, android.net.wifi.p2p.WifiP2pManager.ActionListener):
    
ExecutorRegistration: android.net.wifi.p2p.WifiP2pManager#factoryReset(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener):
@@ -377,8 +377,8 @@ SamShouldBeLast: android.media.AudioRouting#addOnRoutingChangedListener(android.
    
SamShouldBeLast: android.media.AudioTrack#addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler):
    SAM-compatible parameters (such as parameter 1, "listener", in android.media.AudioTrack.addOnRoutingChangedListener) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions
SamShouldBeLast: android.media.MediaPlayer#setOnRtpRxNoticeListener(android.content.Context, android.media.MediaPlayer.OnRtpRxNoticeListener, android.os.Handler):
    SAM-compatible parameters (such as parameter 2, "listener", in android.media.MediaPlayer.setOnRtpRxNoticeListener) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions
SamShouldBeLast: android.media.MediaPlayer#setOnImsRxNoticeListener(android.media.MediaPlayer.OnImsRxNoticeListener, android.os.Handler):
    SAM-compatible parameters (such as parameter 1, "listener", in android.media.MediaPlayer.setOnImsRxNoticeListener) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions
SamShouldBeLast: android.media.MediaRecorder#addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler):
    
SamShouldBeLast: android.media.MediaRecorder#registerAudioRecordingCallback(java.util.concurrent.Executor, android.media.AudioManager.AudioRecordingCallback):
+3 −3
Original line number Diff line number Diff line
@@ -4363,11 +4363,11 @@ package android.media {
  }
  public class MediaPlayer implements android.media.AudioRouting android.media.VolumeAutomation {
    method @RequiresPermission("android.permission.BIND_IMS_SERVICE") public void setOnRtpRxNoticeListener(@NonNull android.content.Context, @NonNull android.media.MediaPlayer.OnRtpRxNoticeListener, @Nullable android.os.Handler);
    method @RequiresPermission("android.permission.BIND_IMS_SERVICE") public void setOnImsRxNoticeListener(@Nullable android.media.MediaPlayer.OnImsRxNoticeListener, @Nullable android.os.Handler);
  }
  public static interface MediaPlayer.OnRtpRxNoticeListener {
    method public void onRtpRxNotice(@NonNull android.media.MediaPlayer, int, @NonNull int[]);
  public static interface MediaPlayer.OnImsRxNoticeListener {
    method public void onImsRxNotice(@NonNull android.media.MediaPlayer, @NonNull byte[]);
  }
  public final class MediaRecorder.AudioSource {
+2 −4
Original line number Diff line number Diff line
@@ -6,8 +6,7 @@ ArrayReturn: android.view.contentcapture.ViewNode#getAutofillOptions():
BuilderSetStyle: android.net.IpSecTransform.Builder#buildTunnelModeTransform(java.net.InetAddress, android.net.IpSecManager.SecurityParameterIndex):
    Builder methods names should use setFoo() / addFoo() / clearFoo() style: method android.net.IpSecTransform.Builder.buildTunnelModeTransform(java.net.InetAddress,android.net.IpSecManager.SecurityParameterIndex)

ExecutorRegistration: android.media.MediaPlayer#setOnRtpRxNoticeListener(android.content.Context, android.media.MediaPlayer.OnRtpRxNoticeListener, android.os.Handler):
    Registration methods should have overload that accepts delivery Executor: `setOnRtpRxNoticeListener`
ExecutorRegistration: android.media.MediaPlayer#setOnImsRxNoticeListener(android.media.MediaPlayer.OnImsRxNoticeListener, android.os.Handler):
    
GenericException: android.app.prediction.AppPredictor#finalize():
    
@@ -183,8 +182,7 @@ SamShouldBeLast: android.media.AudioRecordingMonitor#registerAudioRecordingCallb
    
SamShouldBeLast: android.media.AudioRouting#addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler):
    
SamShouldBeLast: android.media.MediaPlayer#setOnRtpRxNoticeListener(android.content.Context, android.media.MediaPlayer.OnRtpRxNoticeListener, android.os.Handler):
    SAM-compatible parameters (such as parameter 2, "listener", in android.media.MediaPlayer.setOnRtpRxNoticeListener) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions
SamShouldBeLast: android.media.MediaPlayer#setOnImsRxNoticeListener(android.media.MediaPlayer.OnImsRxNoticeListener, android.os.Handler):
    
SamShouldBeLast: android.media.AudioTrack#addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler):
    
+47 −59
Original line number Diff line number Diff line
@@ -16,9 +16,6 @@

package android.media;

import static android.Manifest.permission.BIND_IMS_SERVICE;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -86,7 +83,6 @@ import java.util.BitSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.Set;
import java.util.UUID;
@@ -2113,8 +2109,8 @@ public class MediaPlayer extends PlayerBase
        mOnInfoListener = null;
        mOnVideoSizeChangedListener = null;
        mOnTimedTextListener = null;
        mOnRtpRxNoticeListener = null;
        mOnRtpRxNoticeHandler = null;
        mOnImsRxNoticeListener = null;
        mOnImsRxNoticeHandler = null;
        synchronized (mTimeProviderLock) {
            if (mTimeProvider != null) {
                mTimeProvider.close();
@@ -3327,7 +3323,7 @@ public class MediaPlayer extends PlayerBase
    private static final int MEDIA_META_DATA = 202;
    private static final int MEDIA_DRM_INFO = 210;
    private static final int MEDIA_TIME_DISCONTINUITY = 211;
    private static final int MEDIA_RTP_RX_NOTICE = 300;
    private static final int MEDIA_IMS_RX_NOTICE = 300;
    private static final int MEDIA_AUDIO_ROUTING_CHANGED = 10000;

    private TimeProvider mTimeProvider;
@@ -3637,34 +3633,31 @@ public class MediaPlayer extends PlayerBase
                }
                return;

            case MEDIA_RTP_RX_NOTICE:
                final OnRtpRxNoticeListener rtpRxNoticeListener = mOnRtpRxNoticeListener;
                final Handler rtpRxNoticeHandler = mOnRtpRxNoticeHandler;
                if (rtpRxNoticeListener == null) {
            case MEDIA_IMS_RX_NOTICE:
                final OnImsRxNoticeListener imsRxNoticeListener;
                final Handler imsRxNoticeHandler;
                imsRxNoticeListener = mOnImsRxNoticeListener;
                imsRxNoticeHandler = mOnImsRxNoticeHandler;
                if (imsRxNoticeListener == null) {
                    return;
                }
                if (msg.obj instanceof Parcel) {
                    Parcel parcel = (Parcel) msg.obj;
                    parcel.setDataPosition(0);
                    int noticeType;
                    int[] data;
                    byte[] event;
                    try {
                        noticeType = parcel.readInt();
                        int numOfArgs = parcel.dataAvail() / 4;
                        data = new int[numOfArgs];
                        for (int i = 0; i < numOfArgs; i++) {
                            data[i] = parcel.readInt();
                        }
                        event = parcel.marshall();
                    } finally {
                        parcel.recycle();
                    }
                    if (rtpRxNoticeHandler == null) {
                        rtpRxNoticeListener.onRtpRxNotice(mMediaPlayer, noticeType, data);
                    if (imsRxNoticeHandler == null) {
                        imsRxNoticeListener.onImsRxNotice(mMediaPlayer, event);
                    } else {
                        rtpRxNoticeHandler.post(
                                () ->
                                        rtpRxNoticeListener
                                                .onRtpRxNotice(mMediaPlayer, noticeType, data));
                        imsRxNoticeHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                imsRxNoticeListener.onImsRxNotice(mMediaPlayer, event);
                            }
                        });
                    }
                }
                return;
@@ -4110,18 +4103,18 @@ public class MediaPlayer extends PlayerBase

    /**
     * Interface definition of a callback to be invoked when
     * RTP Rx connection has a notice.
     * IMS Rx connection has a notice.
     *
     * @see #setOnRtpRxNoticeListener
     * @see MediaPlayer.setOnImsRxNoticeListener
     *
     * @hide
     */
    @SystemApi
    public interface OnRtpRxNoticeListener
    public interface OnImsRxNoticeListener
    {
        /**
         * Called when an RTP Rx connection has a notice.
         * <p>
         * Called to indicate an IMS event noticed from native media frameworks.
         * <p></p>
         * Basic format. All TYPE and ARG are 4 bytes unsigned integer in native byte order.
         * <pre>{@code
         * 0                4               8                12
@@ -4176,14 +4169,14 @@ public class MediaPlayer extends PlayerBase
         * TYPE 205 - Transport layer Feedback message. (RFC-5104 Sec.4.2)
         * 0                4               8                12
         * +----------------+---------------+----------------+----------------+
         * |      205       |FB type(1 or 3)|      SSRC      |      Value     |
         * |      205       |      SSRC     | FB type(1 or 3)|     value      |
         * +----------------+---------------+----------------+----------------+
         * SSRC
         *      - Remote side's SSRC value of the media sender (RFC-3550 Sec.5.1)
         * Feedback (FB) type: determines the type of the event.
         *      - if 1, we received a NACK request from the remote side.
         *      - if 3, we received a TMMBR (Temporary Maximum Media Stream Bit Rate Request) from
         *        the remote side.
         * SSRC
         *      - Remote side's SSRC value of the media sender (RFC-3550 Sec.5.1)
         * Value: the FCI (Feedback Control Information) depending on the value of FB type
         *      - if FB type is 1, the Generic NACK as specified in RFC-4585 Sec.6.2.1
         *      - if FB type is 3, the TMMBR as specified in RFC-5104 Sec.4.2.1.1
@@ -4192,13 +4185,13 @@ public class MediaPlayer extends PlayerBase
         * TYPE 206 - Payload-specific Feedback message. (RFC-5104 Sec.4.3)
         * 0                4               8
         * +----------------+---------------+----------------+
         * |      206       |FB type(1 or 4)|      SSRC      |
         * |      206       |      SSRC     | FB type(1 or 4)|
         * +----------------+---------------+----------------+
         * SSRC
         *      - Remote side's SSRC value of the media sender (RFC-3550 Sec.5.1)
         * Feedback (FB) type: determines the type of the event.
         *      - if 1, we received a PLI request from the remote side.
         *      - if 4, we received a FIR request from the remote side.
         * SSRC
         *      - Remote side's SSRC value of the media sender (RFC-3550 Sec.5.1)
         *
         *
         * TYPE 300 - CVO (RTP Extension) message.
@@ -4219,39 +4212,34 @@ public class MediaPlayer extends PlayerBase
         * }</pre>
         *
         * @param mp the {@code MediaPlayer} associated with this callback.
         * @param noticeType TYPE of the event.
         * @param params RTP Rx media data serialized as int[] array.
         * @param event an IMS media event serialized as byte[] array.
         */
        void onRtpRxNotice(@NonNull MediaPlayer mp, int noticeType, @NonNull int[] params);
        void onImsRxNotice(@NonNull MediaPlayer mp, @NonNull byte[] event);
    }

    /**
     * Sets the listener to be invoked when an RTP Rx connection has a notice.
     * The listener is required if MediaPlayer is configured for RTPSource by
     * MediaPlayer.setDataSource(String8 rtpParams) of mediaplayer.h.
     * Register a callback to be invoked when IMS Rx connection has a notice.
     * The callback required if mediaplayer configured for RTPSource by
     * MediaPlayer.setDataSource(String8 rtpParams) of mediaplayer.h
     *
     * @see OnRtpRxNoticeListener
     * @see MediaPlayer.OnImsRxNoticeListener
     *
     * @param listener the listener called after a notice from RTP Rx
     * @param handler the {@link Handler} that receives RTP Tx events
     * @param listener the callback that will be run
     * @param handler Specifies Handler object for the thread on which to execute
     * the callback. If null, the handler on the main looper will be used.
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission("android.permission.BIND_IMS_SERVICE")
    public void setOnRtpRxNoticeListener(
            @NonNull Context context,
            @NonNull OnRtpRxNoticeListener listener, @Nullable Handler handler) {
        Objects.requireNonNull(context);
        Preconditions.checkArgument(
                context.checkSelfPermission(BIND_IMS_SERVICE) == PERMISSION_GRANTED,
                "android.permission.BIND_IMS_SERVICE permission not granted.");
        mOnRtpRxNoticeListener = Objects.requireNonNull(listener);
        mOnRtpRxNoticeHandler = handler;
    }

    private OnRtpRxNoticeListener mOnRtpRxNoticeListener;
    private Handler mOnRtpRxNoticeHandler;
    public void setOnImsRxNoticeListener(
        @Nullable OnImsRxNoticeListener listener, @Nullable Handler handler) {
        mOnImsRxNoticeListener = listener;
        mOnImsRxNoticeHandler = handler;
    }

    private OnImsRxNoticeListener mOnImsRxNoticeListener;
    private Handler mOnImsRxNoticeHandler;

    /**
     * Register a callback to be invoked when a selected track has timed metadata available.