• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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         if (!hasAudioOutput()) {
44             return false;
45         }
46         return AudioEffect.isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_BASS_BOOST);
47     }
48 
isVirtualizerAvailable()49     protected boolean isVirtualizerAvailable() {
50         if (!hasAudioOutput()) {
51             return false;
52         }
53         return AudioEffect.isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_VIRTUALIZER);
54     }
55 
isPresetReverbAvailable()56     protected boolean isPresetReverbAvailable() {
57         if (!hasAudioOutput()) {
58             return false;
59         }
60         return AudioEffect.isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_PRESET_REVERB);
61     }
62 
isEnvReverbAvailable()63     protected boolean isEnvReverbAvailable() {
64         if (!hasAudioOutput()) {
65             return false;
66         }
67         return AudioEffect.isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_ENV_REVERB);
68     }
69 
getSessionId()70     protected int getSessionId() {
71         AudioManager am = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
72         assertNotNull("could not get AudioManager", am);
73         int sessionId = am.generateAudioSessionId();
74         assertTrue("Could not generate session id", sessionId>0);
75         return sessionId;
76     }
77 
78 }
79