客户需求:手机可以旋转到180度

代码路径: frameworks/base/policy/src/com/android/interal/policy/impl/PhoneWindowManager.java

 public int rotationForOrientationLw(int orientation, int lastRotation) {if (false) {Slog.v(TAG, "rotationForOrientationLw(orient="+ orientation + ", last=" + lastRotation+ "); user=" + mUserRotation + " "+ ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED)? "USER_ROTATION_LOCKED" : ""));}        if (mForceDefaultOrientation) {return Surface.ROTATION_0;}synchronized (mLock) {int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1if (sensorRotation < 0) {sensorRotation = lastRotation;}final int preferredRotation;if (mLidState == LID_OPEN && mLidOpenRotation >= 0) {// Ignore sensor when lid switch is open and rotation is forced.preferredRotation = mLidOpenRotation;} else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR&& (mCarDockEnablesAccelerometer || mCarDockRotation >= 0)) {// Ignore sensor when in car dock unless explicitly enabled.// This case can override the behavior of NOSENSOR, and can also// enable 180 degree rotation while docked.preferredRotation = mCarDockEnablesAccelerometer? sensorRotation : mCarDockRotation;} else if ((mDockMode == Intent.EXTRA_DOCK_STATE_DESK|| mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK|| mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK)&& (mDeskDockEnablesAccelerometer || mDeskDockRotation >= 0)) {// Ignore sensor when in desk dock unless explicitly enabled.// This case can override the behavior of NOSENSOR, and can also// enable 180 degree rotation while docked.preferredRotation = mDeskDockEnablesAccelerometer? sensorRotation : mDeskDockRotation;} else if (mHdmiPlugged && mDemoHdmiRotationLock) {// Ignore sensor when plugged into HDMI when demo HDMI rotation lock enabled.// Note that the dock orientation overrides the HDMI orientation.preferredRotation = mDemoHdmiRotation;} else if (mHdmiPlugged && mDockMode == Intent.EXTRA_DOCK_STATE_UNDOCKED&& mUndockedHdmiRotation >= 0) {// Ignore sensor when plugged into HDMI and an undocked orientation has// been specified in the configuration (only for legacy devices without// full multi-display support).// Note that the dock orientation overrides the HDMI orientation.preferredRotation = mUndockedHdmiRotation;} else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) {// Application just wants to remain locked in the last rotation.preferredRotation = lastRotation;} else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE&& (orientation == ActivityInfo.SCREEN_ORIENTATION_USER|| orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED|| orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE|| orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT|| orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER))|| orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR|| orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR|| orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE|| orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) {// Otherwise, use sensor only if requested by the application or enabled// by default for USER or UNSPECIFIED modes.  Does not apply to NOSENSOR.if (mAllowAllRotations < 0) {// Can't read this during init() because the context doesn't// have display metrics at that time so we cannot determine// tablet vs. phone then.mAllowAllRotations = mContext.getResources().getBoolean(com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0;
//可以修改 config_allowAllRotations ,core/res/res/values/config.xml:    <bool name="config_allowAllRotations">false</bool>设置成ture,即 mAllowAllRotations == 1;}
//这里是判断旋转是否是180度,如果是,执行else内容preferredRotation = sensorRotation;
//                if (sensorRotation != Surface.ROTATION_180
//                        || mAllowAllRotations == 1
//                        || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
//                        || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) {
//                    preferredRotation = sensorRotation;
//                } else {
//                    preferredRotation = lastRotation;
//                }} else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED&& orientation != ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) {// Apply rotation lock.  Does not apply to NOSENSOR.// The idea is that the user rotation expresses a weak preference for the direction// of gravity and as NOSENSOR is never affected by gravity, then neither should// NOSENSOR be affected by rotation lock (although it will be affected by docks).preferredRotation = mUserRotation;} else {// No overriding preference.// We will do exactly what the application asked us to do.preferredRotation = -1;}switch (orientation) {case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:// Return portrait unless overridden.if (isAnyPortrait(preferredRotation)) {return preferredRotation;}return mPortraitRotation;case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:// Return landscape unless overridden.if (isLandscapeOrSeascape(preferredRotation)) {return preferredRotation;}return mLandscapeRotation;case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT:// Return reverse portrait unless overridden.if (isAnyPortrait(preferredRotation)) {return preferredRotation;}return mUpsideDownRotation;case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE:// Return seascape unless overridden.if (isLandscapeOrSeascape(preferredRotation)) {return preferredRotation;}return mSeascapeRotation;case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE:case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE:// Return either landscape rotation.if (isLandscapeOrSeascape(preferredRotation)) {return preferredRotation;}if (isLandscapeOrSeascape(lastRotation)) {return lastRotation;}return mLandscapeRotation;case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT:case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT:// Return either portrait rotation.if (isAnyPortrait(preferredRotation)) {return preferredRotation;}if (isAnyPortrait(lastRotation)) {return lastRotation;}return mPortraitRotation;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;}}}

手机屏幕旋转180度相关推荐

  1. android 屏幕旋转180度

    //横屏正方向if(getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {setRequestedOrien ...

  2. 【Android RTMP】NV21 图像旋转处理 ( 问题描述 | 图像顺时针旋转 90 度方案 | YUV 图像旋转细节 | 手机屏幕旋转方向 )

    文章目录 安卓直播推流专栏博客总结 一. NV21 图像格式与 Camera图像传感器方向问题 二. NV21 图像格式视频旋转 1. 图像旋转问题及解决方案 ( 顺时针旋转 90 度 ) 2. NV ...

  3. 高通平台android7.1系统显示旋转180度

    实现方法 内核层修改 kernel\msm-3.18\arch\arm\boot\dts\qcom\dsi-panel-lm215w-lvds-1080p-video.dtsi增加qcom,mdss- ...

  4. 苹果屏幕旋转怎么设置_笔记本电脑维修|笔记本电脑屏幕旋转90度怎么复原

    大家在使用笔记本电脑的时候,有没有遇到过这样一个问题.在某一次打开电脑的时候,突然就发现笔记本电脑的屏幕旋转了90度,而且不管打开哪个界面,都是旋转了90度的.遇到这个问题的时候,有小伙伴不知道怎么解 ...

  5. 让整个页面旋转180度

    做了个签字板,现在使用APAD,工作人员和客户经常要转来转去屏幕,解决这个问题,就是让页面旋转180度. 跑吧签字板 CSS3的transform功能实现旋转,再配合transition实现动画. 先 ...

  6. 什么!卷积要旋转180度?!

    全文共988个字,6张图,预计阅读时间8分钟. 一看这个标题就会想,这有什么大惊小怪的,可能好多人觉得这是个脑残话题,但我确实误解了两三年-- 今天在读<OpenCV算法精解>的时候,发现 ...

  7. 在html中让图片旋转180度,gif图片旋转教程:怎么把gif旋转90度/180度 附gif图片旋转软件...

    视频可以用视频编辑软件将视频旋转90度>>gif旋转90度或180度呢,往下看,你可在本文中找到答案. 先睹为快,看看旋转的效果对比图: 原图                    顺时旋 ...

  8. 基于html+css的盒子内容旋转180度

    准备项目 项目开发工具 Visual Studio Code 1.44.2 版本: 1.44.2 提交: ff915844119ce9485abfe8aa9076ec76b5300ddd 日期: 20 ...

  9. cv2 图像逆时针旋转180度

    使用 OpenCV 的 Python 库时,可以使用 cv2.rotate() 函数来旋转图像.具体地,可以使用以下代码将图像逆时针旋转 180 度: import cv2# 读入图像 img = c ...

最新文章

  1. 网站收录工具(php导航自动收录源码)_网站如何快速收录,网站不收录怎么办?...
  2. 让你真正体验一次主板超频的步骤以及成功的快乐
  3. 图文并茂,万字详解,带你掌握 JVM 垃圾回收!
  4. 查看mysql 的配置文件位置_查看当前mysql使用的配置文件是哪个
  5. 李飞飞的斯坦福 HAI 招人了,薪资丰厚科研经费管够
  6. HihoCoder - 1174 拓扑排序·一
  7. 线上日志分析与其他一些脚本
  8. vue如何使浏览器url固定_怎么给 vue的 vue-router url地址最后加上 / 斜杠
  9. 透过 In-memory Channel 看 Knative Eventing 中 Broker/Trigger 工作机制
  10. Spring Boot 后台验证 Hibernate Validation
  11. es6 Class 的 new.target 属性
  12. ASP.NET前台table通过Ajax获取绑定后台查询的json数据
  13. ZOJ 3229 有上下界最大流
  14. matlab fsolve fzero,Matlab中的fzero和fsolve函数
  15. android 禁止获得焦点,防止EditText自动获取焦点
  16. Anaconda 安装及验证是否安装成功
  17. vc中 volatile 的作用
  18. 台式计算机硬盘英寸,浅谈3.5英寸硬盘与2.5英寸硬盘的区别
  19. Qt安装时No suitable kits found解决办法
  20. Openmv入门01——HAL库stm32

热门文章

  1. 《30岁前的每一天》读书笔记(二)
  2. 数据库连接池使用(三):通过线程实现数据库连接池
  3. Virtualbox共享文件夹
  4. 黑狐木马最新变种——“肥兔”详细分析
  5. 【无标题】《科技传播》国家级科学类期刊征稿
  6. 使用postfix和dovecot搭建邮件服务器
  7. 斜率优化详解(超详细, 有图有代码有注释)
  8. 操作系统 -- 中断
  9. Zbar 安装与使用
  10. 802 11协议介绍