最近遇到首页按键无反应问题,错误提示主要为 V/KeyguardServiceDelegate( 443): **** onKeyguardExitResult(false) CALLED **** ,搜索资料找到问题所在。
问题定位在源码frameworks\base\policy\src\com\android\internal\policy\impl 文件下PhoneWindowManager.java中interceptKeyBeforeDispatching方法下,处理按键消息时,执行launchHomeFromHotKey()函数。跟踪launchHomeFromHotKey()函数时:
<pre name="code" class="java">else if (!mHideLockScreen && mKeyguardMediator.isInputRestricted()) {
//Log.d(TAG,"----------------before launching home" + mHideLockScreen+"isInputRestricted:"+ mKeyguardMediator.isInputRestricted());
// when in keyguard restricted mode, must first verify unlock // before launching home
mKeyguardMediator.verifyUnlock(new OnKeyguardExitResult() {
public void onKeyguardExitResult(boolean success) {
Log.d(TAG,"------------onKeyguardExitResult: "+success);
if (true) {
try {
ActivityManagerNative.getDefault().stopAppSwitches();
} catch (RemoteException e) { }
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
//Log.i("11111111111111111111111111111","launchHomeFromHotKey 111111");
startDockOrHome(); }
}
});
}
NOTE: This form is only for reporting bugs found while working with the Android Open-Source Project. For all other AOSP discussions please visit the appropriate mailing lists. Please describe the problem in detail. Be sure to include: - Steps to reproduce the problem. Do factory reset and reboot the phone. - What happened. Press HOME or Search key, the phone can vibrate ,but have not other response. And after press the power key, the phone cann't locked and the screen turns off. - What you think the correct behavior should be. The HOME/Search/Power key has the right response. This bug is hard to reproduced but it did happen. Google "Home/Search not responding android", we can see that lots of people have got this problem. Analyse: I have add debug log and reproduce it. The root cause is that KeyguardUpdateMonitor.mDeviceProvisioned stays false, so mKeyguardMediator.isInputRestricted() returns true and PhoneWindowManager.launchHomeFromHotKey() will go into the unnormal case. After factory reset, the provision app will set Settings.Secure.DEVICE_PROVISIONED to 1. But the Settings.Secure.DEVICE_PROVISIONED's value is cached by Settings.Secure When SettingsProvider update Settings.Secure.DEVICE_PROVISIONED, it will update systemproperty "sys.settings_secure_version", and then KeyguardUpdateMonitor is notified to read Settings.Secure.DEVICE_PROVISIONED from Settings.Secure. But Settings.Secure try to read sys.settings_secure_version and find it unchanged and return cached Settings.Secure.DEVICE_PROVISIONED value to KeyguardUpdateMonitor. So that KeyguardUpdateMonitor.mDeviceProvisioned stays false, and the HOME key will not response. The real cause is that SettingsProvider update the "sys.settings_secure_version", and soon afterwards Settings.Secure try to read "sys.settings_secure_version" but get the old value. SystemProperties is managed by native.The update operation is done by socket and is asynchronous.
主要问题原因为工厂复位后
Settings.Secure.DEVICE_PROVISIONED被设置为1,但是S
ettings.Secure.DEVICE_PROVISIONED已经被
Settings.Secure缓存读取了,所以当
KeyguardUpdateMonitor去取值的时候还是保持以前的false值,导致HOME不响应。