mtk使用android开关机动画,Android9.0 MTK 平板横屏方案修改(强制app横屏 + 开机logo/动画+关机充电横屏 + RecoveryUI 横屏)...

文章较长建议先收藏再看

拆解步骤

1、app 强制横屏显示,无视 android:screenOrientation="portrait" 属性

2、屏幕触摸坐标修改为横屏

3、开机动画横屏

4、开机logo、关机充电动画横屏

5、RecoveryUI 横屏

上代码

##1、app 强制横屏显示

修改 rotationForOrientationLw(), 默认返回 270

frameworks\base\services\core\java\com\android\server\policy\PhoneWindowManager.java

@Override

public int rotationForOrientationLw(int orientation, int lastRotation, boolean defaultDisplay) {

....

synchronized (mLock) {

...

default:

// For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR,

// 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\base\services\core\java\com\android\server\wm\WindowManagerService.java

boolean updateOrientationFromAppTokensLocked(int displayId, boolean forceUpdate) {

long ident = Binder.clearCallingIdentity();

try {

final DisplayContent dc = mRoot.getDisplayContent(displayId);

// final int req = dc.getOrientation();

int req = android.content.pm.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.setLastOrientation(req);

//send a message to Policy indicating orientation change to take

//action like disabling/enabling sensors etc.,

// TODO(multi-display): Implement policy for secondary displays.

if (dc.isDefaultDisplay) {

mPolicy.setCurrentOrientationLw(req);

}

return dc.updateRotationUnchecked(forceUpdate);

}

return false;

} finally {

Binder.restoreCallingIdentity(ident);

}

}

DisPlayContent 显示 mRotation 默认改为 3 (270)

frameworks\base\services\core\java\com\android\server\wm\DisplayContent.java

/**

* Current rotation of the display.

* Constants as per {@link android.view.Surface.Rotation}.

*

* @see #updateRotationUnchecked()

*/

// private int mRotation = 0;

private int mRotation = 3;//cczheng add for land scap

修改默认值 config_reverseDefaultRotation 为 true,翻转显示角

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值