new String("AudioService ctor"),
0);
- mSafeMediaVolumeState = new Integer(Settings.Global.getInt(mContentResolver,
- Settings.Global.AUDIO_SAFE_VOLUME_STATE,
- SAFE_MEDIA_VOLUME_NOT_CONFIGURED));
+ mSafeMediaVolumeState = Settings.Global.getInt(mContentResolver,
+ Settings.Global.AUDIO_SAFE_VOLUME_STATE,
+ SAFE_MEDIA_VOLUME_NOT_CONFIGURED);
// The default safe volume index read here will be replaced by the actual value when
// the mcc is read by onConfigureSafeVolume()
mSafeMediaVolumeIndex = mContext.getResources().getInteger(
}
// reset any pending volume command
- synchronized (mSafeMediaVolumeState) {
+ synchronized (mSafeMediaVolumeStateLock) {
mPendingVolumeCommand = null;
}
return;
}
- synchronized (mSafeMediaVolumeState) {
+ synchronized (mSafeMediaVolumeStateLock) {
// reset any pending volume command
mPendingVolumeCommand = null;
checkAllAliasStreamVolumes();
checkMuteAffectedStreams();
- synchronized (mSafeMediaVolumeState) {
+ synchronized (mSafeMediaVolumeStateLock) {
mMusicActiveMs = MathUtils.constrain(Settings.Secure.getIntForUser(mContentResolver,
Settings.Secure.UNSAFE_VOLUME_MUSIC_ACTIVE_MS, 0, UserHandle.USER_CURRENT),
0, UNSAFE_VOLUME_MUSIC_ACTIVE_MS_MAX);
}
private void onCheckMusicActive(String caller) {
- synchronized (mSafeMediaVolumeState) {
+ synchronized (mSafeMediaVolumeStateLock) {
if (mSafeMediaVolumeState == SAFE_MEDIA_VOLUME_INACTIVE) {
int device = getDeviceForStream(AudioSystem.STREAM_MUSIC);
}
private void onConfigureSafeVolume(boolean force, String caller) {
- synchronized (mSafeMediaVolumeState) {
+ synchronized (mSafeMediaVolumeStateLock) {
int mcc = mContext.getResources().getConfiguration().mcc;
if ((mMcc != mcc) || ((mMcc == 0) && force)) {
mSafeMediaVolumeIndex = mContext.getResources().getInteger(
private static final int SAFE_MEDIA_VOLUME_DISABLED = 1;
private static final int SAFE_MEDIA_VOLUME_INACTIVE = 2; // confirmed
private static final int SAFE_MEDIA_VOLUME_ACTIVE = 3; // unconfirmed
- private Integer mSafeMediaVolumeState;
+ private int mSafeMediaVolumeState;
+ private final Object mSafeMediaVolumeStateLock = new Object();
private int mMcc = 0;
// mSafeMediaVolumeIndex is the cached value of config_safe_media_volume_index property
}
private void setSafeMediaVolumeEnabled(boolean on, String caller) {
- synchronized (mSafeMediaVolumeState) {
+ synchronized (mSafeMediaVolumeStateLock) {
if ((mSafeMediaVolumeState != SAFE_MEDIA_VOLUME_NOT_CONFIGURED) &&
(mSafeMediaVolumeState != SAFE_MEDIA_VOLUME_DISABLED)) {
if (on && (mSafeMediaVolumeState == SAFE_MEDIA_VOLUME_INACTIVE)) {
}
private boolean checkSafeMediaVolume(int streamType, int index, int device) {
- synchronized (mSafeMediaVolumeState) {
+ synchronized (mSafeMediaVolumeStateLock) {
if ((mSafeMediaVolumeState == SAFE_MEDIA_VOLUME_ACTIVE) &&
(mStreamVolumeAlias[streamType] == AudioSystem.STREAM_MUSIC) &&
((device & mSafeMediaVolumeDevices) != 0) &&
@Override
public void disableSafeMediaVolume(String callingPackage) {
enforceVolumeController("disable the safe media volume");
- synchronized (mSafeMediaVolumeState) {
+ synchronized (mSafeMediaVolumeStateLock) {
setSafeMediaVolumeEnabled(false, callingPackage);
if (mPendingVolumeCommand != null) {
onSetStreamVolume(mPendingVolumeCommand.mStreamType,
mVolumeLogger.dump(pw);
}
- private static String safeMediaVolumeStateToString(Integer state) {
+ private static String safeMediaVolumeStateToString(int state) {
switch(state) {
case SAFE_MEDIA_VOLUME_NOT_CONFIGURED: return "SAFE_MEDIA_VOLUME_NOT_CONFIGURED";
case SAFE_MEDIA_VOLUME_DISABLED: return "SAFE_MEDIA_VOLUME_DISABLED";