Android9.0MTK平板横屏方案修改

更新时间:2023-06-17 11:17:28 阅读: 评论:0

Android9.0MTK平板横屏⽅案修改
引⾔
强制app横屏 + 开机logo/动画+关机充电横屏 + RecoveryUI 横屏
拆解步骤
1、app 强制横屏显⽰,⽆视 android:screenOrientation=“portrait” 属性
2、屏幕触摸坐标修改为横屏
3、开机动画横屏
4、开机logo、关机充电动画横屏
5、RecoveryUI 横屏
上代码
1、app 强制横屏显⽰
修改 rotationForOrientationLw(), 默认返回 270
frameworks\ba\rvices\core\java\com\android\rver\policy\PhoneWindowManager.java
@Override
lifespanpublic int rotationForOrientationLw(int orientation,int lastRotation,boolean defaultDisplay){
....
synchronized(mLock){
...
default:
// For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR,
have fun// just return the preferred orientation we already calculated.
if(preferredRotation >=0){
return preferredRotation;
}
// return Surface.ROTATION_0;
return Surface.ROTATION_270;//cczheng add for land scap
}
}
}
activity 默认强制属性为 SCREEN_ORIENTATION_LANDSCAPE
frameworks\ba\rvices\core\java\com\android\rver\wm\WindowManagerService.java
boolean updateOrientationFromAppTokensLocked(int displayId,boolean forceUpdate){
long ident = Binder.clearCallingIdentity();
try{
final DisplayContent dc = DisplayContent(displayId);
// final int req = dc.getOrientation();
int req =ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;//cczheng add for land scap if(req != dc.getLastOrientation()|| forceUpdate){
if(DEBUG_ORIENTATION){
Slog.v(TAG,"updateOrientation: req= "+ req +", mLastOrientation= "
+ dc.getLastOrientation(),new Throwable("updateOrientation"));
}
dc.tLastOrientation(req);
//nd a message to Policy indicating orientation change to take
//action like disabling/enabling nsors etc.,
// TODO(multi-display): Implement policy for condary displays.
if(dc.isDefaultDisplay){
mPolicy.tCurrentOrientationLw(req);
}
return dc.updateRotationUnchecked(forceUpdate);
}
return fal;
}finally{
历届奥斯卡获奖影片
}
}
DisPlayContent 显⽰ mRotation 默认改为 3 (270)
frameworks\ba\rvices\core\java\com\android\rver\wm\DisplayContent.java
/**
* Current rotation of the display.
* Constants as per {@link android.view.Surface.Rotation}.
takko*
* @e #updateRotationUnchecked()
*/
// private int mRotation = 0;
private int mRotation =3;//cczheng add for land scap
item test修改默认值 config_reverDefaultRotation 为 true,翻转显⽰⾓度
frameworks\ba\core\res\res\l
<!-- If true, the direction rotation is applied to to application's requested
orientation is  Normally, the model is that landscape is
clockwi from portrait; thus on a portrait device an app requesting
landscape will cau a clockwi rotation, and on a landscape device an
简体中文的英文app requesting portrait will cau a counter-clockwi  Setting
true here revers that logic.-->
<!-- cczheng add for land scap -->
<bool name="config_reverDefaultRotation">true</bool>
<!-- The number of degrees to the display when the keyboard is
A value of -1 means no change in orientation by default.-->
<!-- cczheng add for land scap -->
<integer name="config_lidOpenRotation">270</integer>
2、屏幕触摸坐标修改为横屏
对调 frame 的宽和⾼,设置⽅向为 270
frameworks\native\rvices\surfaceflinger\DisplayDevice.cpp
void DisplayDevice::tProjection(int orientation,
const Rect& newViewport,const Rect& newFrame){
Rect viewport(newViewport);
Rect frame(newFrame);
const int w = mDisplayWidth;
const int h = mDisplayHeight;
Transform R;
DisplayDevice::orientationToTransfrom(orientation, w, h,&R);
if(!frame.isValid()){
// the destination frame can be invalid if it has never been t,
// in that ca we assume the whole display frame.
//cczheng add for land scap
// frame = Rect(w, h);
if(w < h)
frame = Rect(h, w);
el
frame = Rect(w, h);
}
....
}
// clang-format off
DisplayDevice::DisplayDevice(
const sp<SurfaceFlinger>& flinger,
DisplayType type,
int32_t hwcId,
bool isSecure,
const wp<IBinder>& displayToken,
const sp<ANativeWindow>& nativeWindow,
const sp<DisplaySurface>& displaySurface,
std::unique_ptr<RE::Surface> renderSurface,
int displayWidth,
int displayHeight,
bool hasWideColorGamut,
const HdrCapabilities& hdrCapabilities,
const int32_t supportedPerFrameMetadata,
const std::unordered_map<ColorMode, std::vector<RenderIntent>>& hwcColorModes,
int initialPowerMode)
.....
mHdrCapabilities = HdrCapabilities(types, maxLuminance, maxAverageLuminance, minLuminance);
// initialize the display orientation transform.
// tProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
//cczheng add for land scap
tProjection(DisplayState::eOrientation270, mViewport, mFrame);
#ifdef MTK_SF_DEBUG_SUPPORT
mFps = FpsCounterLoader::getInstance().create();
#endif
}
frameworks\native\rvices\surfaceflinger\SurfaceFlinger.cpp
void SurfaceFlinger::onInitializeDisplays(){
/
/ ret screen orientation and u primary layer stack
Vector<ComporState> state;
Vector<DisplayState> displays;
DisplayState d;
d.what = DisplayState::eDisplayProjectionChanged|
DisplayState::eLayerStackChanged;
d.layerStack =0;
//d.orientation = DisplayState::eOrientationDefault;
//cczheng add for land scap
d.fram
e.makeInvalid();
d.viewport.makeInvalid();
d.width =0;
d.height =0;
displays.add(d);
....
}
3、开机动画横屏
对调 createSurface() 的 w 和 h
frameworks\ba\cmds\bootanimation\BootAnimation.cpp
status_t BootAnimation::readyToRun(){
mAsts.addDefaultAsts();
sp<IBinder>dtoken(SurfaceComporClient::getBuiltInDisplay(
ISurfaceCompor::eDisplayIdMain));
DisplayInfo dinfo;
status_t status = SurfaceComporClient::getDisplayInfo(dtoken,&dinfo);
if(status)
return-1;
鸟的英文
// create the native surface
/*sp<SurfaceControl> control = ssion()->createSurface(String8("BootAnimation"),            dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);*/
//cczheng add for land scap  [S]
sp<SurfaceControl> control;
成人高考辅导班if(dinfo.w < dinfo.h)
control =ssion()->createSurface(String8("BootAnimation"),
dinfo.h, dinfo.w, PIXEL_FORMAT_RGB_565);
el
control =ssion()->createSurface(String8("BootAnimation"),
dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
//cczheng add for land scap  [E]
SurfaceComporClient::Transaction t;
t.tLayer(control,0x40000000)
.apply();
.
....有道下载
}
开机动画制作替换后⾯补充。。。
4、开机logo、关机充电动画横屏
开机logo定义屏幕分辨率以对应资源⽂件夹的位置为
vendor\mediatek\proprietary\bootable\bootloader\lk\project\xxxx.mk 没有则看下⾯的
device\mediateksample\xxxx\ProjectConfig.mk
mk 中的 BOOT_LOGO = wxga
对应的资源⽂件位置在 vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/wxga
可以看到 wxga 中都是竖屏的图⽚,⽽ wxganl 中已经是横屏的图⽚
则我们将 BOOT_LOGO 修改为 wxganl 即可
接下来还需要继续修改显⽰的⾓度,依旧改成 270,不然会出现花屏的现象
开机第⼀张图⽚ uboot 对应显⽰
vendor\mediatek\proprietary\bootable\bootloader\lk\platform\mt6765\mt_logo.c
void init_fb_screen()
{
.....
// in JB2.MP need to allign width and height to 32 ,but jb5.mp needn't
dAllign =1;
phical_screen.allignWidth =ALIGN_TO(CFG_DISPLAY_WIDTH, MTK_FB_ALIGNMENT);
/* In GB, no need to adjust 180 showing logo ,for fb driver dealing the change */
/* but in JB, need adjust it for screen 180 roration          */
d180Adjust =0;// need sync with chip driver
dprintf(INFO,"[lk logo: %s %d]MTK_LCM_PHYSICAL_ROTATION = %s\n",__FUNCTION__,__LINE__, MTK_LCM_PHYSICAL_ROTATION);
if(0==strncmp(MTK_LCM_PHYSICAL_ROTATION,"270",3)){
ation =270;
}el if(0==strncmp(MTK_LCM_PHYSICAL_ROTATION,"90",2)){
ation =90;
}el if(0==strncmp(MTK_LCM_PHYSICAL_ROTATION,"180",3)&&(d180Adjust ==1)){
ation =180;
}el{
blaspheme
ation =270;//cczheng add for land scap
}
开机第⼆张图⽚ kernel 对应显⽰
vendor\mediatek\proprietary\external\libshowlogo\charging_animation.cpp

本文发布于:2023-06-17 11:17:28,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/148136.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:横屏   动画   开机
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图