竖屏横用,logo用的还是竖屏资源
1.添加宏控制
- /device/qcom/msm8909/system.prop
persist.panel.orientation=270
2.动画横屏显示
- frameworks/base/cmds/bootanimation/BootAnimation.cpp
status_t BootAnimation::readyToRun() {
mAssets.addDefaultAssets();
sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay(
ISurfaceComposer::eDisplayIdMain));
DisplayInfo dinfo;
status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo);
if (status)
return -1;
int defaultOrientation = 0;
char property[PROPERTY_VALUE_MAX];
property_get("persist.panel.orientation", property, "0");
defaultOrientation = atoi(property)/90;
sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),
(defaultOrientation ==1 || defaultOrientation==3) ?dinfo.h:dinfo.w,
(defaultOrientation ==1 || defaultOrientation==3) ?dinfo.w:dinfo.h, PIXEL_FORMAT_RGB_565);
if (defaultOrientation==1 || defaultOrientation==3){
Rect destRect(dinfo.h, dinfo.w);
mSession->setDisplayProjection(dtoken, defaultOrientation, destRect, destRect);
}
}
3.初始化方向
- frameworks/native/services/surfaceflinger/DisplayDevice.cpp
int defaultOrientation = 0;
char property[PROPERTY_VALUE_MAX];
property_get("persist.panel.orientation", property, "0");
defaultOrientation = atoi(property);
switch(defaultOrientation) {
case 0:
defaultOrientation = DisplayState::eOrientationDefault;
break;
case 90:
defaultOrientation = DisplayState::eOrientation90;
break;
case 180:
defaultOrientation = DisplayState::eOrientation180;
break;
case 270:
defaultOrientation = DisplayState::eOrientation270;
break;
default:
defaultOrientation = DisplayState::eOrientationDefault;
break;
}
setProjection(defaultOrientation, mViewport, mFrame);
4.上层方向修改
- frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
private int mDefaultOrientation = Surface.ROTATION_0;
public void setInitialDisplaySize(Display display, int width, int height, int density) {
if (mContext == null || display.getDisplayId() != Display.DEFAULT_DISPLAY) {
return;
}
mDisplay = display;
...
mForceDefaultOrientation = longSizeDp >= 960 && shortSizeDp >= 720 &&
res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation) &&
!"true".equals(SystemProperties.get("config.override_forced_orient"));
String defaultOrientation = SystemProperties.get("persist.panel.orientation", "0");
if("0".equals(defaultOrientation)) {
mDefaultOrientation = Surface.ROTATION_0;
} else if("90".equals(defaultOrientation)) {
mDefaultOrientation = Surface.ROTATION_90;
} else if("180".equals(defaultOrientation)) {
mDefaultOrientation = Surface.ROTATION_180;
} else if("270".equals(defaultOrientation)) {
mDefaultOrientation = Surface.ROTATION_270;
} else {
mDefaultOrientation = Surface.ROTATION_0;
}
}
...
@Override
public int rotationForOrientationLw(int orientation, int lastRotation) {
...
default:
if (preferredRotation >= 0) {
return preferredRotation;
}
return mDefaultOrientation;
}
}
}
- frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
private WindowManagerService(Context context, InputManagerService inputManager,
boolean haveInputMethods, boolean showBootMsgs, boolean onlyCore) {
...
String defaultOrientation = SystemProperties.get("persist.panel.orientation", "0");
if("0".equals(defaultOrientation)) {
mRotation = Surface.ROTATION_0;
} else if("90".equals(defaultOrientation)) {
mRotation = Surface.ROTATION_90;
} else if("180".equals(defaultOrientation)) {
mRotation = Surface.ROTATION_180;
} else if("270".equals(defaultOrientation)) {
mRotation = Surface.ROTATION_270;
} else {
mRotation = Surface.ROTATION_0;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)