|
22 | 22 |
|
23 | 23 | import android.annotation.Nullable; |
24 | 24 | import android.annotation.RawRes; |
| 25 | +import android.content.pm.PackageManager; |
25 | 26 | import android.content.res.AssetFileDescriptor; |
26 | 27 | import android.media.AudioAttributes; |
27 | 28 | import android.media.AudioFormat; |
@@ -59,6 +60,19 @@ public class AudioTrackOffloadTest extends CtsAndroidTestCase { |
59 | 60 |
|
60 | 61 | private static final AudioAttributes DEFAULT_ATTR = new AudioAttributes.Builder().build(); |
61 | 62 |
|
| 63 | + // flag to indicate if AAC related tests need to be run or not. |
| 64 | + private boolean mTestAacSupport = false; |
| 65 | + |
| 66 | + @Override |
| 67 | + protected void setUp() throws Exception { |
| 68 | + super.setUp(); |
| 69 | + boolean isWatch = getContext().getPackageManager() |
| 70 | + .hasSystemFeature(PackageManager.FEATURE_WATCH); |
| 71 | + if (isWatch) { |
| 72 | + mTestAacSupport = true; |
| 73 | + } |
| 74 | + } |
| 75 | + |
62 | 76 | public void testIsOffloadSupportedNullFormat() throws Exception { |
63 | 77 | try { |
64 | 78 | final boolean offloadableFormat = AudioManager.isOffloadedPlaybackSupported(null, |
@@ -125,6 +139,15 @@ public void testOpusAudioTrackOffload() throws Exception { |
125 | 139 | getAudioFormatWithEncoding(AudioFormat.ENCODING_OPUS)); |
126 | 140 | } |
127 | 141 |
|
| 142 | + public void testAacLCAudioTrackOffload() throws Exception { |
| 143 | + if (!mTestAacSupport) { |
| 144 | + return; |
| 145 | + } |
| 146 | + testAudioTrackOffload(R.raw.sine40dblong_44k_128kbps_LC, |
| 147 | + /* bitRateInkbps= */ 128, |
| 148 | + getAudioFormatWithEncoding(AudioFormat.ENCODING_AAC_LC)); |
| 149 | + } |
| 150 | + |
128 | 151 | @CddTest(requirement="5.5.4") |
129 | 152 | public void testGaplessMP3AudioTrackOffload() throws Exception { |
130 | 153 | // sine882hz3s has a gapless delay of 576 and padding of 756. |
|
0 commit comments