Fix AudioGroupTest on Q
The AudioGroup constructor with a Context parameter does not exist on Q devices. Use the previous constructor on older devices. Test: atest CtsNetTestCasesLatestSdk on Q and R devices Bug: 150918852 Merged-In: I24c3e7ab8c7219d6f345943ead3e3b6418fa7f47 Change-Id: I24c3e7ab8c7219d6f345943ead3e3b6418fa7f47
This commit is contained in:
committed by
Remi NGUYEN VAN
parent
bfc182300b
commit
31097ecbb6
@@ -21,9 +21,12 @@ import android.net.rtp.AudioCodec;
|
||||
import android.net.rtp.AudioGroup;
|
||||
import android.net.rtp.AudioStream;
|
||||
import android.net.rtp.RtpStream;
|
||||
import android.os.Build;
|
||||
import android.platform.test.annotations.AppModeFull;
|
||||
import android.test.AndroidTestCase;
|
||||
|
||||
import androidx.core.os.BuildCompat;
|
||||
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
@@ -62,7 +65,10 @@ public class AudioGroupTest extends AndroidTestCase {
|
||||
mSocketB.connect(mStreamB.getLocalAddress(), mStreamB.getLocalPort());
|
||||
mStreamB.associate(mSocketB.getLocalAddress(), mSocketB.getLocalPort());
|
||||
|
||||
mGroup = new AudioGroup(mContext);
|
||||
// BuildCompat.isAtLeastR is documented to return false on release SDKs (including R)
|
||||
mGroup = Build.VERSION.SDK_INT > Build.VERSION_CODES.Q || BuildCompat.isAtLeastR()
|
||||
? new AudioGroup(mContext)
|
||||
: new AudioGroup(); // Constructor with context argument was introduced in R
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user