该函数是设置是否需要在通话是锁屏(双击屏幕解锁)的, 因为在通话时脸颊会贴近电容屏,导致误操作
如果参数enable为真,
1,如果不在通话,直接返回
2,扬声器工作,返回,因为扬声器工作的话脸颊不用贴近
3,如果锁没有构造,则构造一个锁
4,消失菜单
5,将锁淡入
如果参数为假,且锁不为null,使锁消失,函数源代码如下
private void enableTouchLock(boolean enable) {
if (VDBG) log("enableTouchLock(" + enable + ")...");
if (enable) {
// The "touch lock" overlay is only ever used on top of the
// DTMF dialpad.
if (!mDialer.isOpened()) {
if (VDBG) log("enableTouchLock: dialpad isn't up, no need to lock screen.");
return;
}
// Also, the "touch lock" overlay NEVER appears if the speaker is in use.
if (PhoneUtils.isSpeakerOn(getApplicationContext())) {
if (VDBG) log("enableTouchLock: speaker is on, no need to lock screen.");
return;
}
// Initialize the UI elements if necessary.
if (mTouchLockOverlay == null) {
initTouchLock();
}
// First take down the menu if it's up (since it's confusing
// to see a touchable menu *above* the touch lock overlay.)
// Note dismissMenu() has no effect if the menu is already closed.
dismissMenu(true); // dismissImmediate = true
// Bring up the touch lock overlay (with an animated fade)
mTouchLockOverlay.setVisibility(View.VISIBLE);
mTouchLockOverlay.startAnimation(mTouchLockFadeIn);
} else {
// TODO: it might be nice to immediately kill the animation if
// we're in the middle of fading-in:
// if (mTouchLockFadeIn.hasStarted() && !mTouchLockFadeIn.hasEnded()) {
// mTouchLockOverlay.clearAnimation();
// }
// but the fade-in is so quick that this probably isn't necessary.
// Take down the touch lock overlay (immediately)
if (mTouchLockOverlay != null) mTouchLockOverlay.setVisibility(View.GONE);
}
}