1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.media.cts;
18 
19 import android.content.Context;
20 import android.content.pm.PackageManager;
21 import android.media.AudioManager;
22 import android.media.audiofx.AudioEffect;
23 import android.os.Looper;
24 import android.test.AndroidTestCase;
25 
26 public class PostProcTestBase extends AndroidTestCase {
27     protected int mSession = -1;
28     protected boolean mHasControl = false;
29     protected boolean mIsEnabled = false;
30     protected boolean mInitialized = false;
31     protected Looper mLooper = null;
32     protected final Object mLock = new Object();
33     protected int mChangedParameter = -1;
34     protected final static String BUNDLE_VOLUME_EFFECT_UUID =
35             "119341a0-8469-11df-81f9-0002a5d5c51b";
36 
hasAudioOutput()37     protected boolean hasAudioOutput() {
38         return getContext().getPackageManager().hasSystemFeature(
39                 PackageManager.FEATURE_AUDIO_OUTPUT);
40     }
41 
isBassBoostAvailable()42     protected boolean isBassBoostAvailable() {
43         return AudioEffect.isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_BASS_BOOST);
44     }
45 
isVirtualizerAvailable()46     protected boolean isVirtualizerAvailable() {
47         return AudioEffect.isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_VIRTUALIZER);
48     }
49 
isPresetReverbAvailable()50     protected boolean isPresetReverbAvailable() {
51         return AudioEffect.isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_PRESET_REVERB);
52     }
53 
isEnvReverbAvailable()54     protected boolean isEnvReverbAvailable() {
55         return AudioEffect.isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_ENV_REVERB);
56     }
57 
getSessionId()58     protected int getSessionId() {
59         AudioManager am = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
60         assertNotNull("could not get AudioManager", am);
61         int sessionId = am.generateAudioSessionId();
62         assertTrue("Could not generate session id", sessionId>0);
63         return sessionId;
64     }
65 
66 }
67