Settings
AccessibilitySettings.java
mToggleLockScreenRotationPreference.setChecked(false);
锁屏界面的旋转
StatusBarWindowManager.java,解除屏幕旋转,需要连同锁屏的旋转一起解除,否则无法解除
private void adjustScreenOrientation(State state) {
if(isBST()){
mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}else{
if (state.isKeyguardShowingAndNotOccluded()) {
if (mKeyguardScreenRotation) {
mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER;
} else {
mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
}
} else {
mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}
}
}
关于ro.sf.hwrotation
这个值影响开机动画的方向
默认屏幕方向:
WindowManagerService
updateOrientationFromAppTokensLocked
import android.os.SystemProperties;
boolean updateOrientationFromAppTokensLocked(boolean inTransaction) {
long ident = Binder.clearCallingIdentity();
try {
//wfy
int req = getOrientationLocked();
if(isnuanyi()){
req = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
}
if (req != mForcedAppOrientation) {
mForcedAppOrientation = req;
//send a message to Policy indicating orientation change to take
//action like disabling/enabling sensors etc.,
mPolicy.setCurrentOrientationLw(req);
if (updateRotationUncheckedLocked(inTransaction)) {
// changed
return true;
}
}
return false;
} finally {
Binder.restoreCallingIdentity(ident);
}
}
private boolean isnuanyi(){
boolean b=false;
b=SystemProperties.getBoolean("ro.rk.nuanyi",false);
return b;
}