最近升级了codebase之后遇到了第一次开机后无法使用home和app_switch key,追踪这两个key在哪里被disable如下
home追踪:
void launchHomeFromHotKey() {
Slog.e(TAG, "matt-launchHomeFromHotKey-()");
launchHomeFromHotKey(true /* awakenFromDreams */, true /*respectKeyguard*/);
}
之后
void launchHomeFromHotKey(final boolean awakenFromDreams, final boolean respectKeyguard) {
Slog.e(TAG, "matt-respectKeyguard:="+respectKeyguard);
if (respectKeyguard) {
if (isKeyguardShowingAndNotOccluded()) {
Slog.e(TAG, "matt-launchHomeFromHotKey return");
// don't launch home if keyguard showing
return;
}
Slog.e(TAG, "matt-mHideLockScreen:="+mHideLockScreen);
Slog.e(TAG, "matt-mKeyguardDelegate.isInputRestricted():="+mKeyguardDelegate.isInputRestricted());
if (mHideLockScreen && mKeyguardDelegate.isInputRestricted()) { //这边的mKeyguardDelegate.isInputRestricted()在正常刚开机情况下是不会进去的,也就是说mKeyguardDelegate.isInputRestricted()=false
// when in keyguard restricted mode, must first verify unlock
// before launching home
Slog.e(TAG, "matt-launchHomeFromHotKey1");
mKeyguardDelegate.verifyUnlock(new OnKeyguardExitResult() {
@Override
public void onKeyguardExitResult(boolean success) {
Slog.e(TAG, "matt-launchHomeFromHotKey1:="+success);
if (success) {
try {
ActivityManagerNative.getDefault().stopAppSwitches();
} catch (RemoteException e) {
}
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
}
}
});
return;
}
}
Slog.e(TAG, "matt-PhoneWindowManager.java-run to step2");
// no keyguard stuff to worry about, just launch home!
try {
ActivityManagerNative.getDefault().stopAppSwitches();
} catch (RemoteException e) {
}
Slog.e(TAG, "matt-PhoneWindowManager.java-run to step3");
if (mRecentsVisible) {
// Hide Recents and notify it to launch Home
if (awakenFromDreams) {
awakenDreams();
}
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
hideRecentApps(false, true);
} else {
Slog.e(TAG, "matt-PhoneWindowManager.java-run to step4");
// Otherwise, just launch Home
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
}
}
private final Runnable mClearHideNavigationFlag = new Runnable() {
@Override
public void run() {
synchronized (mWindowManagerFuncs.getWindowManagerLock()) {
// Clear flags.
mForceClearedSystemUiFlags &=
~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
}
mWindowManagerFuncs.reevaluateStatusBarVisibility();
}
};
之后
public boolean isInputRestricted() {
Log.e(TAG, "matt-KeyguardServiceDelegate.java-isInputRestricted:mKeyguardState.inputRestricted::"+mKeyguardState.inputRestricted);
Log.e(TAG, "matt-KeyguardServiceDelegate.java-mKeyguardService.isInputRestricted()::"+mKeyguardService.isInputRestricted());
if (mKeyguardService != null) {
Log.e(TAG, "matt-KeyguardServiceDelegate.java-isInputRestricted+1");
mKeyguardState.inputRestricted = mKeyguardService.isInputRestricted();
}
return mKeyguardState.inputRestricted;
}
之后
public boolean isInputRestricted() {
return mKeyguardStateMonitor.isInputRestricted();
}
之后
public boolean isInputRestricted() {
return mInputRestricted;
}
之后
private volatile boolean mInputRestricted = true; //初始值是true
public void onInputRestrictedStateChanged(boolean inputRestricted) {
Slog.e(TAG, "matt-KeyguardStateMonitor.java-onInputRestrictedStateChanged-inputRestricted:"+inputRestricted); //解锁后这边写了false
mInputRestricted = inputRestricted; //这里唯一改了这个值 ,正常的或许在开机过程中在这里改了,异常的也许没改
}
解锁后相应的log
01-01 07:03:32.969 1585 3092 D WindowManager: matt-inKeyguardRestrictedKeyInputMode-return ::true
01-01 07:03:33.052 1585 3092 D WindowManager: matt-inKeyguardRestrictedKeyInputMode-return ::true
01-01 07:03:41.776 1585 1585 D WindowManager: matt-inKeyguardRestrictedKeyInputMode-return ::true
01-01 07:03:54.429 1585 3329 E KeyguardStateMonitor: matt-onInputRestrictedStateChanged-inputRestricted::false
01-01 07:03:54.430 1585 1585 D WindowManager: matt-inKeyguardRestrictedKeyInputMode-return ::false
01-01 07:03:54.475 1585 3962 D WindowManager: matt-inKeyguardRestrictedKeyInputMode-return ::false
01-01 07:03:54.877 1585 3974 D WindowManager: matt-inKeyguardRestrictedKeyInputMode-return ::false
01-01 07:03:54.939 1585 3961 D WindowManager: matt-inKeyguardRestrictedKeyInputMode-return ::false
app_swich追踪
(keyCode == KeyEvent.KEYCODE_APP_SWITCH) {
// +++ Willie_Huang, disable virtual key if cover is closed.
if (mHasTranscoverFeature && mLidState == LID_CLOSED) {
return -1;
}
// ---
//Begin: [email protected]
if (down && repeatCount == 0) {
if (!keyguardOn) { //正常启动这个keyguardOn=false
preloadRecentApps();
}
// BEIGN: [email protected]
if (mAccessibilityManager.isEnabled()) {
mHandler.postDelayed(mScreenUnpinningRunnable, ViewConfiguration.getLongPressTimeout());
}
mSwitchKeyHandled = false;
if (mFuncWhenLongPressAppSwitch != Settings.System.LONG_PRESSED_FUNC_RECENTLIST) {
mHandler.postDelayed(mRecentLongPressRunnable, getScreenshotChordLongPressDelay());
}
} else if (!down) {
//Begin: [email protected]
cancelPendingScreenUnpinningAction();
//End: [email protected]
if (!mSwitchKeyHandled) {
mHandler.removeCallbacks(mRecentLongPressRunnable);
if (!keyguardOn) { //正常启动这个keyguardOn=false
toggleRecentApps();
}
} else {
cancelPreloadRecentApps();
}
}
//End: [email protected]
return -1;
之后
boolean keyguardOn() {
return isKeyguardShowingAndNotOccluded() || inKeyguardRestrictedKeyInputMode();
}
之后
public boolean inKeyguardRestrictedKeyInputMode() {
if (mKeyguardDelegate == null) return false;
return mKeyguardDelegate.isInputRestricted();
}
之后
public boolean isInputRestricted() {
if (mKeyguardService != null) {
mKeyguardState.inputRestricted = mKeyguardService.isInputRestricted();
}
return mKeyguardState.inputRestricted;
}
之后
public boolean isInputRestricted() {
return mKeyguardStateMonitor.isInputRestricted();
}
之后
public boolean isInputRestricted() {
return mInputRestricted;
}
也就是最好都是在这个地方初值有问题
之后
public void onInputRestrictedStateChanged(boolean inputRestricted) {
Slog.e(TAG, "matt-onInputRestrictedStateChanged-inputRestricted::"+inputRestricted);
mInputRestricted = inputRestricted;
}还是在这改
全部在KeyguardViewMediator.java 里
private void updateInputRestrictedLocked() {
boolean inputRestricted = isInputRestricted();//只有这里被赋值
if (mInputRestricted != inputRestricted) {
mInputRestricted = inputRestricted; //只有这里被赋值
int size = mKeyguardStateCallbacks.size();
for (int i = size - 1; i >= 0; i--) {
try {
mKeyguardStateCallbacks.get(i).onInputRestrictedStateChanged(inputRestricted);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onDeviceProvisioned", e);
if (e instanceof DeadObjectException) {
mKeyguardStateCallbacks.remove(i);
}
}
}
}
}
和
public void addStateMonitorCallback(IKeyguardStateCallback callback) {
synchronized (this) {
mKeyguardStateCallbacks.add(callback);
try {
callback.onSimSecureStateChanged(mUpdateMonitor.isSimPinSecure());
callback.onShowingStateChanged(mShowing);
callback.onInputRestrictedStateChanged(mInputRestricted);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onShowingStateChanged or onSimSecureStateChanged or onInputRestrictedStateChanged", e);
}
}
}
之后到
public boolean isInputRestricted() {
return mShowing || mNeedToReshowWhenReenabled;
}
关于mShowing:
private void setShowingLocked(boolean showing) {
if (showing != mShowing) {
mShowing = showing;
int size = mKeyguardStateCallbacks.size();
for (int i = size - 1; i >= 0; i--) {
try {
mKeyguardStateCallbacks.get(i).onShowingStateChanged(showing);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to call onShowingStateChanged", e);
if (e instanceof DeadObjectException) {
mKeyguardStateCallbacks.remove(i);
}
}
}
updateInputRestrictedLocked();
mTrustManager.reportKeyguardShowingChanged();
}
}
其实上面调用onShowingStateChanged的是android自带的systemui,而我们用的是自己改过的systemui,所以结果就是我们的systemui在处理初值时没有跟上codebase,所以初值错误。android自带的是正确的。在system/app目录下把AsusSystemUi文件夹删除后,系统开机就会用system/pri_app/里的SystemUI,这个时候没有问题
一开始怀疑是setupwizard的问题,但是把setupwizard都删了发现没有奏效,setupwizad和systemui一样都有google自己的和我们自己的,目录也一样
关于mNeedToReshowWhenReenabled:
private boolean mNeedToReshowWhenReenabled = false; //初值