When the android phone is connected, the shutdown ringtone cannot be output from the outside
In the startOutput method of AudioMTKPolicyManager. cpp, add the following content after obtaining newDevic:
If (stream = AudioSystem: BOOT) newDevice | = AUDIO_DEVICE_OUT_SPEAKER;
Status_t AudioMTKPolicyManager: startOutput (audio_io_handle_t output,
AudioSystem: stream_type stream,
Int session)
{
ALOGD ("startOutput () output % d, stream % d, session % d", output, stream, session );
......
If (outputDesc-> mRefCount [stream] = 1 ){
Audio_devices_t newDevice = getNewDevice (output, false/* fromCache */);
Routing_strategy strategy = getStrategy (stream );
Bool shouldWait = (strategy = STRATEGY_SONIFICATION) |
(Strategy = STRATEGY_SONIFICATION_RESPECTFUL );
Uint32_t waitMs = 0;
Bool force = false;
If (stream = AudioSystem: BOOT) newDevice | = AUDIO_DEVICE_OUT_SPEAKER;
For (size_t I = 0; I <mOutputs. size (); I ++ ){
AudioOutputDescriptor * desc = mOutputs. valueAt (I );
If (desc! = OutputDesc ){
// Force a device change if any other output is managed by the same hw
// Module and has a current device selection that differs from selected device.
// In this case, the audio HAL must receive the new device selection so that it can
// Change the device currently selected by the other active output.
If (outputDesc-> sharesHwModuleWith (desc )&&
Desc-> device ()! = NewDevice ){
Force = true;
}
// Wait for audio on other active outputs to be presented when starting
// A notification so that audio focus effect can propagate.
Uint32_t latency = desc-> latency ();
If (shouldWait & desc-> isActive (latency * 2) & (waitMs <latency )){
WaitMs = latency;
}
}
}
......
}
Return NO_ERROR;
}