Program: 195256
Project: 195256
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MSG_SET_DEVICE_VOLUME:
    setDeviceVolume((VolumeStreamState)msg.obj,msg.arg1);
  break;
case MSG_SET_ALL_VOLUMES:
setAllVolumes((VolumeStreamState)msg.obj);
break;
case MSG_PERSIST_VOLUME:
persistVolume((VolumeStreamState)msg.obj,msg.arg1);
break;
case MSG_PERSIST_MASTER_VOLUME_MUTE:
if (mUseFixedVolume) {
return;
}
Settings.System.putIntForUser(mContentResolver,Settings.System.VOLUME_MASTER_MUTE,msg.arg1,msg.arg2);
break;
case MSG_PERSIST_RINGER_MODE:
persistRingerMode(getRingerModeInternal());
break;
case MSG_MEDIA_SERVER_DIED:
if (!mSystemReady || (AudioSystem.checkAudioFlinger() != AudioSystem.AUDIO_STATUS_OK)) {
Log.e(TAG,"String_Node_Str");
sendMsg(mAudioHandler,MSG_MEDIA_SERVER_DIED,SENDMSG_NOOP,0,0,null,500);
break;
}
Log.e(TAG,"String_Node_Str");
AudioSystem.setParameters("String_Node_Str");
readAndSetLowRamDevice();
synchronized (mConnectedDevices) {
Set set=mConnectedDevices.entrySet();
Iterator i=set.iterator();
while (i.hasNext()) {
Map.Entry device=(Map.Entry)i.next();
DeviceListSpec spec=(DeviceListSpec)device.getValue();
AudioSystem.setDeviceConnectionState(spec.mDeviceType,AudioSystem.DEVICE_STATE_AVAILABLE,spec.mDeviceAddress,spec.mDeviceName);
}
}
AudioSystem.setPhoneState(mMode);
AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,mForcedUseForComm);
AudioSystem.setForceUse(AudioSystem.FOR_RECORD,mForcedUseForComm);
AudioSystem.setForceUse(AudioSystem.FOR_SYSTEM,mCameraSoundForced ? AudioSystem.FORCE_SYSTEM_ENFORCED : AudioSystem.FORCE_NONE);
int numStreamTypes=AudioSystem.getNumStreamTypes();
for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
VolumeStreamState streamState=mStreamStates[streamType];
AudioSystem.initStreamVolume(streamType,0,(streamState.mIndexMax + 5) / 10);
streamState.applyAllVolumes();
}
setRingerModeInt(getRingerModeInternal(),false);
if (mMonitorOrientation) {
setOrientationForAudioSystem();
}
if (mMonitorRotation) {
setRotationForAudioSystem();
}
synchronized (mBluetoothA2dpEnabledLock) {
AudioSystem.setForceUse(AudioSystem.FOR_MEDIA,mBluetoothA2dpEnabled ? AudioSystem.FORCE_NONE : AudioSystem.FORCE_NO_BT_A2DP);
}
synchronized (mSettingsLock) {
AudioSystem.setForceUse(AudioSystem.FOR_DOCK,mDockAudioMediaEnabled ? AudioSystem.FORCE_ANALOG_DOCK : AudioSystem.FORCE_NONE);
}
if (mHdmiManager != null) {
synchronized (mHdmiManager) {
if (mHdmiTvClient != null) {
setHdmiSystemAudioSupported(mHdmiSystemAudioSupported);
}
}
}
synchronized (mAudioPolicies) {
for (AudioPolicyProxy policy : mAudioPolicies.values()) {
policy.connectMixes();
}
}
AudioSystem.setParameters("String_Node_Str");
break;
case MSG_UNLOAD_SOUND_EFFECTS:
onUnloadSoundEffects();
break;
case MSG_LOAD_SOUND_EFFECTS:
boolean loaded=onLoadSoundEffects();
if (msg.obj != null) {
LoadSoundEffectReply reply=(LoadSoundEffectReply)msg.obj;
synchronized (reply) {
reply.mStatus=loaded ? 0 : -1;
reply.notify();
}
}
break;
case MSG_PLAY_SOUND_EFFECT:
onPlaySoundEffect(msg.arg1,msg.arg2);
break;
case MSG_BTA2DP_DOCK_TIMEOUT:
synchronized (mConnectedDevices) {
makeA2dpDeviceUnavailableNow((String)msg.obj);
}
break;
case MSG_SET_FORCE_USE:
case MSG_SET_FORCE_BT_A2DP_USE:
setForceUse(msg.arg1,msg.arg2);
break;
case MSG_BT_HEADSET_CNCT_FAILED:
resetBluetoothSco();
break;
case MSG_SET_WIRED_DEVICE_CONNECTION_STATE:
{
WiredDeviceConnectionState connectState=(WiredDeviceConnectionState)msg.obj;
onSetWiredDeviceConnectionState(connectState.mType,connectState.mState,connectState.mAddress,connectState.mName,connectState.mCaller);
mAudioEventWakeLock.release();
}
break;
case MSG_SET_A2DP_SRC_CONNECTION_STATE:
onSetA2dpSourceConnectionState((BluetoothDevice)msg.obj,msg.arg1);
mAudioEventWakeLock.release();
break;
case MSG_SET_A2DP_SINK_CONNECTION_STATE:
onSetA2dpSinkConnectionState((BluetoothDevice)msg.obj,msg.arg1);
mAudioEventWakeLock.release();
break;
case MSG_REPORT_NEW_ROUTES:
{
int N=mRoutesObservers.beginBroadcast();
if (N > 0) {
AudioRoutesInfo routes;
synchronized (mCurAudioRoutes) {
routes=new AudioRoutesInfo(mCurAudioRoutes);
}
while (N > 0) {
N--;
IAudioRoutesObserver obs=mRoutesObservers.getBroadcastItem(N);
try {
obs.dispatchAudioRoutesChanged(routes);
}
 catch (RemoteException e) {
}
}
}
mRoutesObservers.finishBroadcast();
observeDevicesForStreams(-1);
break;
}
case MSG_CHECK_MUSIC_ACTIVE:
onCheckMusicActive((String)msg.obj);
break;
case MSG_BROADCAST_AUDIO_BECOMING_NOISY:
onSendBecomingNoisyIntent();
break;
case MSG_CONFIGURE_SAFE_MEDIA_VOLUME_FORCED:
case MSG_CONFIGURE_SAFE_MEDIA_VOLUME:
onConfigureSafeVolume((msg.what == MSG_CONFIGURE_SAFE_MEDIA_VOLUME_FORCED),(String)msg.obj);
break;
case MSG_PERSIST_SAFE_VOLUME_STATE:
onPersistSafeVolumeState(msg.arg1);
break;
case MSG_BROADCAST_BT_CONNECTION_STATE:
onBroadcastScoConnectionState(msg.arg1);
break;
case MSG_SYSTEM_READY:
onSystemReady();
break;
case MSG_PERSIST_MUSIC_ACTIVE_MS:
final int musicActiveMs=msg.arg1;
Settings.Secure.putIntForUser(mContentResolver,Settings.Secure.UNSAFE_VOLUME_MUSIC_ACTIVE_MS,musicActiveMs,UserHandle.USER_CURRENT);
break;
case MSG_PERSIST_MICROPHONE_MUTE:
Settings.System.putIntForUser(mContentResolver,Settings.System.MICROPHONE_MUTE,msg.arg1,msg.arg2);
break;
case MSG_UNMUTE_STREAM:
onUnmuteStream(msg.arg1,msg.arg2);
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MSG_SET_DEVICE_VOLUME:
    setDeviceVolume((VolumeStreamState)msg.obj,msg.arg1);
  break;
case MSG_SET_ALL_VOLUMES:
setAllVolumes((VolumeStreamState)msg.obj);
break;
case MSG_PERSIST_VOLUME:
persistVolume((VolumeStreamState)msg.obj,msg.arg1);
break;
case MSG_PERSIST_MASTER_VOLUME_MUTE:
if (mUseFixedVolume) {
return;
}
Settings.System.putIntForUser(mContentResolver,Settings.System.VOLUME_MASTER_MUTE,msg.arg1,msg.arg2);
break;
case MSG_PERSIST_RINGER_MODE:
persistRingerMode(getRingerModeInternal());
break;
case MSG_MEDIA_SERVER_DIED:
if (!mSystemReady || (AudioSystem.checkAudioFlinger() != AudioSystem.AUDIO_STATUS_OK)) {
Log.e(TAG,"String_Node_Str");
sendMsg(mAudioHandler,MSG_MEDIA_SERVER_DIED,SENDMSG_NOOP,0,0,null,500);
break;
}
Log.e(TAG,"String_Node_Str");
AudioSystem.setParameters("String_Node_Str");
readAndSetLowRamDevice();
synchronized (mConnectedDevices) {
for (int i=0; i < mConnectedDevices.size(); i++) {
DeviceListSpec spec=mConnectedDevices.valueAt(i);
AudioSystem.setDeviceConnectionState(spec.mDeviceType,AudioSystem.DEVICE_STATE_AVAILABLE,spec.mDeviceAddress,spec.mDeviceName);
}
}
AudioSystem.setPhoneState(mMode);
AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,mForcedUseForComm);
AudioSystem.setForceUse(AudioSystem.FOR_RECORD,mForcedUseForComm);
AudioSystem.setForceUse(AudioSystem.FOR_SYSTEM,mCameraSoundForced ? AudioSystem.FORCE_SYSTEM_ENFORCED : AudioSystem.FORCE_NONE);
int numStreamTypes=AudioSystem.getNumStreamTypes();
for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
VolumeStreamState streamState=mStreamStates[streamType];
AudioSystem.initStreamVolume(streamType,0,(streamState.mIndexMax + 5) / 10);
streamState.applyAllVolumes();
}
setRingerModeInt(getRingerModeInternal(),false);
if (mMonitorOrientation) {
setOrientationForAudioSystem();
}
if (mMonitorRotation) {
setRotationForAudioSystem();
}
synchronized (mBluetoothA2dpEnabledLock) {
AudioSystem.setForceUse(AudioSystem.FOR_MEDIA,mBluetoothA2dpEnabled ? AudioSystem.FORCE_NONE : AudioSystem.FORCE_NO_BT_A2DP);
}
synchronized (mSettingsLock) {
AudioSystem.setForceUse(AudioSystem.FOR_DOCK,mDockAudioMediaEnabled ? AudioSystem.FORCE_ANALOG_DOCK : AudioSystem.FORCE_NONE);
}
if (mHdmiManager != null) {
synchronized (mHdmiManager) {
if (mHdmiTvClient != null) {
setHdmiSystemAudioSupported(mHdmiSystemAudioSupported);
}
}
}
synchronized (mAudioPolicies) {
for (AudioPolicyProxy policy : mAudioPolicies.values()) {
policy.connectMixes();
}
}
AudioSystem.setParameters("String_Node_Str");
break;
case MSG_UNLOAD_SOUND_EFFECTS:
onUnloadSoundEffects();
break;
case MSG_LOAD_SOUND_EFFECTS:
boolean loaded=onLoadSoundEffects();
if (msg.obj != null) {
LoadSoundEffectReply reply=(LoadSoundEffectReply)msg.obj;
synchronized (reply) {
reply.mStatus=loaded ? 0 : -1;
reply.notify();
}
}
break;
case MSG_PLAY_SOUND_EFFECT:
onPlaySoundEffect(msg.arg1,msg.arg2);
break;
case MSG_BTA2DP_DOCK_TIMEOUT:
synchronized (mConnectedDevices) {
makeA2dpDeviceUnavailableNow((String)msg.obj);
}
break;
case MSG_SET_FORCE_USE:
case MSG_SET_FORCE_BT_A2DP_USE:
setForceUse(msg.arg1,msg.arg2);
break;
case MSG_BT_HEADSET_CNCT_FAILED:
resetBluetoothSco();
break;
case MSG_SET_WIRED_DEVICE_CONNECTION_STATE:
{
WiredDeviceConnectionState connectState=(WiredDeviceConnectionState)msg.obj;
onSetWiredDeviceConnectionState(connectState.mType,connectState.mState,connectState.mAddress,connectState.mName,connectState.mCaller);
mAudioEventWakeLock.release();
}
break;
case MSG_SET_A2DP_SRC_CONNECTION_STATE:
onSetA2dpSourceConnectionState((BluetoothDevice)msg.obj,msg.arg1);
mAudioEventWakeLock.release();
break;
case MSG_SET_A2DP_SINK_CONNECTION_STATE:
onSetA2dpSinkConnectionState((BluetoothDevice)msg.obj,msg.arg1);
mAudioEventWakeLock.release();
break;
case MSG_REPORT_NEW_ROUTES:
{
int N=mRoutesObservers.beginBroadcast();
if (N > 0) {
AudioRoutesInfo routes;
synchronized (mCurAudioRoutes) {
routes=new AudioRoutesInfo(mCurAudioRoutes);
}
while (N > 0) {
N--;
IAudioRoutesObserver obs=mRoutesObservers.getBroadcastItem(N);
try {
obs.dispatchAudioRoutesChanged(routes);
}
 catch (RemoteException e) {
}
}
}
mRoutesObservers.finishBroadcast();
observeDevicesForStreams(-1);
break;
}
case MSG_CHECK_MUSIC_ACTIVE:
onCheckMusicActive((String)msg.obj);
break;
case MSG_BROADCAST_AUDIO_BECOMING_NOISY:
onSendBecomingNoisyIntent();
break;
case MSG_CONFIGURE_SAFE_MEDIA_VOLUME_FORCED:
case MSG_CONFIGURE_SAFE_MEDIA_VOLUME:
onConfigureSafeVolume((msg.what == MSG_CONFIGURE_SAFE_MEDIA_VOLUME_FORCED),(String)msg.obj);
break;
case MSG_PERSIST_SAFE_VOLUME_STATE:
onPersistSafeVolumeState(msg.arg1);
break;
case MSG_BROADCAST_BT_CONNECTION_STATE:
onBroadcastScoConnectionState(msg.arg1);
break;
case MSG_SYSTEM_READY:
onSystemReady();
break;
case MSG_PERSIST_MUSIC_ACTIVE_MS:
final int musicActiveMs=msg.arg1;
Settings.Secure.putIntForUser(mContentResolver,Settings.Secure.UNSAFE_VOLUME_MUSIC_ACTIVE_MS,musicActiveMs,UserHandle.USER_CURRENT);
break;
case MSG_PERSIST_MICROPHONE_MUTE:
Settings.System.putIntForUser(mContentResolver,Settings.System.MICROPHONE_MUTE,msg.arg1,msg.arg2);
break;
case MSG_UNMUTE_STREAM:
onUnmuteStream(msg.arg1,msg.arg2);
break;
}
}