Bug: 23003511 Fix CTS: AudioManagerTest#testSoundEffects failing
Added calls to enable app ops for write settings to make sure that
cts tests will not fail.
Change-Id: I82d6aeffef34661b8483a9fcb95b699dae9842ec
diff --git a/tests/tests/media/src/android/media/cts/AudioManagerTest.java b/tests/tests/media/src/android/media/cts/AudioManagerTest.java
index ded0539..a0163e5 100644
--- a/tests/tests/media/src/android/media/cts/AudioManagerTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioManagerTest.java
@@ -45,23 +45,27 @@
import android.os.Vibrator;
import android.provider.Settings;
import android.provider.Settings.System;
-import android.test.AndroidTestCase;
+import android.test.InstrumentationTestCase;
import android.view.SoundEffectConstants;
import java.util.TreeMap;
-public class AudioManagerTest extends AndroidTestCase {
+public class AudioManagerTest extends InstrumentationTestCase {
private final static int MP3_TO_PLAY = R.raw.testmp3;
private final static long TIME_TO_PLAY = 2000;
+ private final static String APPOPS_OP_STR = "android:write_settings";
private AudioManager mAudioManager;
private boolean mHasVibrator;
private boolean mUseFixedVolume;
private boolean mIsTelevision;
+ private Context mContext;
@Override
protected void setUp() throws Exception {
super.setUp();
+ mContext = getInstrumentation().getContext();
+ Utils.enableAppOps(mContext.getPackageName(), APPOPS_OP_STR, getInstrumentation());
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
mHasVibrator = (vibrator != null) && vibrator.hasVibrator();