关于Android4.x系统默认显示方向各种修改
1.设置属性值
在device.mk文件中加入
PRODUCT_PROPERTY_OVERRIDES += \
ro.sf.hwrotation=180
2.设置屏幕默认显示方向
在frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp文件中找到方法
GraphicPlane::setDisplayHardware(DisplayHardware *hw)
if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
//displayOrientation
switch (atoi(property)) {
case 90:
displayOrientation = ISurfaceComposer::eOrientation90;
break;
case 270:
displayOrientation = ISurfaceComposer::eOrientation270;
break;
case 180://=============add========
displayOrientation = ISurfaceComposer::eOrientation180;
break;//=============add========
}
}
3.设置屏幕显示动画旋转方向
1).在frameworks/base/core/java/android/view/Surface.java 加入方法
/**
* @hide
*/
public static int getDefaultRotation() {
return android.os.SystemProperties.getInt("ro.sf.hwrotation", 0);
}
/**
* @hide
*/
public static int getDefaultRotationIndex() {
int rotation = getDefaultRotation();
switch(rotation) {
case 0:
return ROTATION_0;
case 90:
return ROTATION_90;
case 180:
return ROTATION_180;
case 270:
return ROTATION_270;
}
return ROTATION_0;
}
2).在frameworks/base/services/java/com/android/server/wm/ScreenRotationAnimation.java
文件中找到(android4.1) 方法setRotation
或(android4.2)方法setRotationInTransaction
修改 deltaRotation(rotation,Surface.ROTATION_0);
为deltaRotation(rotation,Surface. getDefaultRotationIndex());
3 .长按Home键,最近程序视图方向
在frameworks/base/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java 文件中修改如下
private int mThumbnailHeight;//================add============
在方法中添加
public void updateValuesFromResources() {
final Resources res = mContext.getResources();
mThumbnailWidth = Math.round(res.getDimension(R.dimen.status_bar_recents_thumbnail_width));
//==========================xjf=========================
mThumbnailHeight = Math.round(res.getDimension(R.dimen.status_bar_recents_thumbnail_height));
//==========================xjf=========================
mFitThumbnailToXY = res.getBoolean(R.bool.config_recents_thumbnail_image_fits_to_xy);
}
在方法中添加
private void updateThumbnail(ViewHolder h, Bitmap thumbnail, boolean show, boolean anim) {
。。。。。。。。。。。。。。。。
if (mFitThumbnailToXY) {
h.thumbnailViewImage.setScaleType(ScaleType.FIT_XY);
} else {
Matrix scaleMatrix = new Matrix();
float scale = mThumbnailWidth / (float) thumbnail.getWidth();
scaleMatrix.setScale(scale, scale);
h.thumbnailViewImage.setScaleType(ScaleType.MATRIX);
h.thumbnailViewImage.setImageMatrix(scaleMatrix);
//==========================xjf=========================
if(android.view.Surface.getDefaultRotation() > 0){
Matrix rotateMatrix = new Matrix();
rotateMatrix.setRotate(android.view.Surface.getDefaultRotation(),mThumbnailWidth/2, mThumbnailHeight/2);
h.thumbnailViewImage.setImageMatrix(rotateMatrix);
}
//==========================xjf=========================
}
}
4.电源键加音量减,截屏图片方向
在/opt/xiejifu/20141005/20141005/frameworks/base/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java 文件中找到takeScreenshot方法
修改 float degrees = getDegreesForRotation(mDisplay.getRotation());
void takeScreenshot(Runnable finisher, boolean statusBarVisible, boolean navBarVisible) {
// We need to orient the screenshot correctly (and the Surface api seems to take screenshots
// only in the natural orientation of the device :!)
mDisplay.getRealMetrics(mDisplayMetrics);
float[] dims = {mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels};
//==========================xjf=========================
//float degrees = getDegreesForRotation(mDisplay.getRotation());
int rotation = mDisplay.getRotation();
if(Surface.getDefaultRotation() > 0){
rotation = (rotation + Surface.getDefaultRotationIndex())%4;
}//get def rotation
float degrees = getDegreesForRotation(rotation);
//==========================xjf=========================
boolean requiresRotation = (degrees > 0);
if (requiresRotation) {
// Get the dimensions of the device in its native orientation
mDisplayMatrix.reset();
mDisplayMatrix.preRotate(-degrees);
mDisplayMatrix.mapPoints(dims);
dims[0] = Math.abs(dims[0]);
dims[1] = Math.abs(dims[1]);
}
.........
}
5.NFC点对点,发送截屏图片
packages/apps/Nfc/src/com/android/nfc/SendUi.java
Bitmap createScreenshot() {
.......
//==========================xjf=========================
//float degrees = getDegreesForRotation(mDisplay.getRotation());
int rotation = mDisplay.getRotation();
if(Surface.getDefaultRotation() > 0){
rotation = (rotation + Surface.getDefaultRotationIndex())%4;
}//get def rotation
float degrees = getDegreesForRotation(rotation);
//==========================xjf=========================
.......
}
除了截图,其他修改应该都是全局的。
关于Android4.x系统默认显示方向各种修改的更多相关文章
- Android系统移植与调试之------->如何修改Android系统默认显示【开发者选项】并默认打开【USB调试】和【未知来源】开关
今天有个用户对[设置]有个特殊的要求,即: 1.开机的时候默认显示[开发者选项]并打开[USB调试]开关 ([Developer options]-->[USB debugging]) 2 ...
- 「linux」win+linux 双系统 默认启动项 的修改
修改/etc/default/grub文件,其中的GRUB_DEFAULT表示默认启动项: sudo gedit /etc/default/grub 注意:启动项是从0开始计数. 要使修改生效需要运行 ...
- linux上修改系统默认语言设置
locale命令设置语言环境(临时修改) [keysystem@localhost ~]$ date Fri Feb :: CST [keysystem@localhost ~]$ locale LA ...
- Django - 权限(4)- queryset、二级菜单的默认显示、动态显示按钮权限
一.queryset Queryset是django中构建的一种数据结构,ORM查询集往往是queryset数据类型,我们来进一步了解一下queryset的特点. 1.可切片 使用Python 的切片 ...
- android如何调用显示和隐藏系统默认的输入法(一)
1.调用显示系统默认的输入法 方法一. InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_MET ...
- 使用storyboard显示UITableView时,如果不修改系统默认生成的tableView:cellForRowAtIndexPath:方法中的代码,则必须为UITableViewCell注册(填写)重用标识符:identifier.必须要代码方法中的标识符一致.
CHENYILONG Blog 使用storyboard显示UITableView时,如果不修改系统默认生成的tableView:cellForRowAtIndexPath:方法中的代码,则必须为UI ...
- 时间操作(JavaScript版)—年月日三级联动(默认显示系统时间)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/wangshuxuncom/article/details/35263317 这个功能 ...
- Ubuntu18.04系统下安装Pycharm&vim设置自动缩进及默认显示行号
Ubuntu18.04系统自带python3.6及python2.7,Pycharm是一款非常强大的IDE.目前Pycharm有两个版本:专业版和Community社区,区别是专业版是收费,而且功能更 ...
- Android 系统默认参数的修改
转自: http://www.th7.cn/Program/Android/201505/447097.shtml 写在前面的话 一般在新项目开始之初,我们需要针对客户需求进行各种系统默认属性的配置, ...
随机推荐
- PHP 之 Laravel 框架安装及相关开源软件
Laravel 被称为简洁.优雅的PHP开发框架,但第一次接触此框架的人有不少都卡在了安装上,其实在 Linux 下只需要很简单的几步就可以搞定,这里我们以 CentOS 下 PHP + Nginx ...
- Sed&awk笔记之sed篇
http://blog.csdn.net/a81895898/article/details/8482387 Sed是什么 <sed and awk>一书中(1.2 A Stream Ed ...
- Android List<Map<String,String>转json(例子)
package com.armslee.json.test.cases; import java.util.ArrayList; import java.util.HashMap; import ja ...
- js对ajax返回数组的处理
引言: ajax异步传输,可以传输字符串,但是数组这样的数据,就不太好传递了,这个时候怎么办呢? 答案是可以通过json来处理,后台将数据数据进行json编码! 然后客户端,通过js来进行解析. 这样 ...
- Eclipse没法自动补全代码解决
Eclipse没法自动补全代码解决 Eclipse无法自动补全代码解决 Window->Java->Editor->Content Assist->Advanced
- bzoj3631
其实这道题其实可以转化为这样一个问题 给定n-1对点,将这两点x,y间简单路径上的点(包括起点终点)权值+1 (最后再把除了起点外的点的权值-1,注意终点没糖吃) 求每个点的权值 首先想到的是先找LC ...
- 【转】vc中使用SendMessage正确发送自定义消息的方法--不错
原文网址:http://zhoumf1214.blog.163.com/blog/static/5241940200910265532959/ 最近在用VC2008做开发,后来由于要用到消息的发送,而 ...
- HDOJ1002题A + B Problem II,2个大数相加
Problem Description I have a very simple problem for you. Given two integers A and B, your job is to ...
- struts2 最新S2-016-S2-017漏洞通杀struts2所有版本及修复方法
详情查看http://zone.wooyun.org/content/5159 官方漏洞说明 http://struts.apache.org/release/2.3.x/docs/s2-016.ht ...
- java第四周学习
这一周学习的还是面向对象的方法和应用 Java中方法的使用和注意事项 如果没有返回值,就不允许通过return关键字返回结果 方法中不允许嵌套使用 Return返回值只允许返回一个值,不允许返回多个 ...