packages\services\Telephony\src\com\android\phone\Ringer.java
private void makeLooper() {
if (mRingThread == null) {// create the ringtone with the uri
if (DBG) log("creating ringtone: " + mCustomRingtoneUri);
r = RingtoneManager.getRingtone(mContext, mCustomRingtoneUri);
synchronized (Ringer.this) {
if (!hasMessages(STOP_RING)) {
mRingtone = r;
}
}
}
r = mRingtone;
// add by xuxin20130906 to fix no ring for incoming call when first reboot +
boolean shouldRing = (!hasMessages(STOP_RING));
if(shouldRing){
shouldRing){
if (r != null && !r.isPlaying() && !isMpPlaying() ) {
if(begintoRing){
PhoneUtils.setAudioMode();
playRingbyForce();
synchronized (Ringer.this) {
if (mFirstRingStartTime < 0) {
mFirstRingStartTime = SystemClock.elapsedRealtime();
}
}
}else{
begintoRing = true;
PhoneUtils.setAudioMode();
r.play();
synchronized (Ringer.this) {
if (mFirstRingStartTime < 0) {
mFirstRingStartTime = SystemClock.elapsedRealtime();
}
}
}
}else if((r == null || (r!=null && !r.isPlaying())) && !isMpPlaying()){
PhoneUtils.setAudioMode();
playRingbyForce();
synchronized (Ringer.this) {
if (mFirstRingStartTime < 0) {
mFirstRingStartTime = SystemClock.elapsedRealtime();
}
}
}
// add by xuxin20130906 to fix no ring for incoming call when first reboot -
}
break;
case STOP_RING:
// add by xuxin20130906 to fix no ring for incoming call when first reboot
begintoRing = false;
if (DBG) log("mRingHandler: STOP_RING...");
r = (Ringtone) msg.obj;
if (r != null) {
r.stop();
} else {
if (DBG) log("- STOP_RING with null ringtone! msg = " + msg);
}
// add by xuxin20130906 to fix no ring for incoming call when first reboot
stopRingbyForce();
getLooper().quit();
break;
}
}
};
}
}