audioProfilesList);
// Items shared with audio service
/**
* @hide
* The delay before playing a sound. This small period exists so the user
* can press another key (non-volume keys, too) to have it NOT be audible.
*
* PhoneWindow will implement this part.
*/
public static final int PLAY_SOUND_DELAY = 300;
/**
* @hide
* Constant to identify a focus stack entry that is used to hold the focus while the phone
* is ringing or during a call. Used by com.android.internal.telephony.CallManager when
* entering and exiting calls.
*/
public final static String IN_VOICE_COMM_FOCUS_ID = "AudioFocus_For_Phone_Ring_And_Calls";
/**
* @hide
* @see AudioManager#setVibrateSetting(int, int)
*/
public static int getValueForVibrateSetting(int existingValue, int vibrateType,
int vibrateSetting) {
// First clear the existing setting. Each vibrate type has two bits in
// the value. Note '3' is '11' in binary.
existingValue &= ~(3 << (vibrateType * 2));
// Set into the old value
existingValue |= (vibrateSetting & 3) << (vibrateType * 2);
return existingValue;
}
/** @hide */
public static int getDefaultStreamVolume(int streamType) {
return DEFAULT_STREAM_VOLUME[streamType];
}
/** @hide */
public static int[] DEFAULT_STREAM_VOLUME = new int[] {
4, // STREAM_VOICE_CALL
7, // STREAM_SYSTEM
5, // STREAM_RING // configured in AudioService by config_audio_notif_vol_default
5, // STREAM_MUSIC
6, // STREAM_ALARM
5, // STREAM_NOTIFICATION // configured in AudioService by config_audio_ring_vol_default
7, // STREAM_BLUETOOTH_SCO
7, // STREAM_SYSTEM_ENFORCED
5, // STREAM_DTMF
5, // STREAM_TTS
5, // STREAM_ACCESSIBILITY
5, // STREAM_ASSISTANT
};
/** @hide */
@TestApi
public static @NonNull String streamToString(int stream) {
if (stream >= 0 && stream < STREAM_NAMES.length) return STREAM_NAMES[stream];
if (stream == AudioManager.USE_DEFAULT_STREAM_TYPE) return "USE_DEFAULT_STREAM_TYPE";
return "UNKNOWN_STREAM_" + stream;
}
/** @hide The platform has no specific capabilities */
public static final int PLATFORM_DEFAULT = 0;
/** @hide The platform is voice call capable (a phone) */
public static final int PLATFORM_VOICE = 1;
/** @hide The platform is a television or a set-top box */
public static final int PLATFORM_TELEVISION = 2;
/** @hide The platform is automotive */
public static final int PLATFORM_AUTOMOTIVE = 3;
/**
* @hide
* Return the platform type that this is running on. One of:
*
* - {@link #PLATFORM_VOICE}
* - {@link #PLATFORM_TELEVISION}
* - {@link #PLATFORM_DEFAULT}
*
*/
public static int getPlatformType(Context context) {
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
return PLATFORM_AUTOMOTIVE;
} else if ((context.getSystemService(TelephonyManager.class)).isVoiceCapable()) {
return PLATFORM_VOICE;
} else if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
return PLATFORM_TELEVISION;
} else {
return PLATFORM_DEFAULT;
}
}
/**
* @hide
* @return whether the system uses a single volume stream.
*/
public static boolean isSingleVolume(Context context) {
boolean forceSingleVolume = context.getResources().getBoolean(
com.android.internal.R.bool.config_single_volume);
return getPlatformType(context) == PLATFORM_TELEVISION || forceSingleVolume;
}
/**
* @hide
* Return a set of audio device types from a list of audio device attributes, which may
* represent multiple audio device types.
*/
@NonNull
public static Set generateAudioDeviceTypesSet(
@NonNull List deviceList) {
Set deviceTypes = new TreeSet<>();
for (AudioDeviceAttributes device : deviceList) {
deviceTypes.add(device.getInternalType());
}
return deviceTypes;
}
/**
* @hide
* Return the intersection of two audio device types collections.
*/
public static Set intersectionAudioDeviceTypes(
@NonNull Set a, @NonNull Set b) {
Set intersection = new TreeSet<>(a);
intersection.retainAll(b);
return intersection;
}
/**
* @hide
* Return true if the audio device types collection only contains the given device type.
*/
public static boolean isSingleAudioDeviceType(@NonNull Set types, int type) {
return types.size() == 1 && types.contains(type);
}
/**
* @hide
* Return true if the audio device type is a Bluetooth LE Audio device.
*/
public static boolean isLeAudioDeviceType(int type) {
return DEVICE_OUT_ALL_BLE_SET.contains(type);
}
/** @hide */
public static final int DEFAULT_MUTE_STREAMS_AFFECTED =
(1 << STREAM_MUSIC) |
(1 << STREAM_RING) |
(1 << STREAM_NOTIFICATION) |
(1 << STREAM_SYSTEM) |
(1 << STREAM_VOICE_CALL) |
(1 << STREAM_BLUETOOTH_SCO);
/**
* @hide
* Event posted by AudioTrack and AudioRecord JNI (JNIDeviceCallback) when routing changes.
* Keep in sync with core/jni/android_media_DeviceCallback.h.
*/
final static int NATIVE_EVENT_ROUTING_CHANGE = 1000;
/**
* @hide
* Query the mixer attributes that can be set as preferred mixer attributes for the given
* device.
*/
public static native int getSupportedMixerAttributes(
int deviceId, @NonNull List mixerAttrs);
/**
* @hide
* Set preferred mixer attributes for a given device when playing particular
* audio attributes.
*/
public static native int setPreferredMixerAttributes(
@NonNull AudioAttributes attributes,
int portId,
int uid,
@NonNull AudioMixerAttributes mixerAttributes);
/**
* @hide
* Get preferred mixer attributes that is previously set via
* {link #setPreferredMixerAttributes}.
*/
public static native int getPreferredMixerAttributes(
@NonNull AudioAttributes attributes, int portId,
List mixerAttributesList);
/**
* @hide
* Clear preferred mixer attributes that is previously set via
* {@link #setPreferredMixerAttributes}
*/
public static native int clearPreferredMixerAttributes(
@NonNull AudioAttributes attributes, int portId, int uid);
/**
* Requests if the implementation supports controlling the latency modes
* over the Bluetooth A2DP or LE Audio links.
*
* @return true if supported, false otherwise
*
* @hide
*/
public static native boolean supportsBluetoothVariableLatency();
/**
* Enables or disables the variable Bluetooth latency control mechanism in the
* audio framework and the audio HAL. This does not apply to the latency mode control
* on the spatializer output as this is a built-in feature.
*
* @hide
*/
public static native int setBluetoothVariableLatencyEnabled(boolean enabled);
/**
* Indicates if the variable Bluetooth latency control mechanism is enabled or disabled.
* @hide
*/
public static native boolean isBluetoothVariableLatencyEnabled();
}