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系统默认显示方向各种修改的更多相关文章

  1. Android系统移植与调试之------->如何修改Android系统默认显示【开发者选项】并默认打开【USB调试】和【未知来源】开关

    今天有个用户对[设置]有个特殊的要求,即: 1.开机的时候默认显示[开发者选项]并打开[USB调试]开关    ([Developer options]-->[USB debugging]) 2 ...

  2. 「linux」win+linux 双系统 默认启动项 的修改

    修改/etc/default/grub文件,其中的GRUB_DEFAULT表示默认启动项: sudo gedit /etc/default/grub 注意:启动项是从0开始计数. 要使修改生效需要运行 ...

  3. linux上修改系统默认语言设置

    locale命令设置语言环境(临时修改) [keysystem@localhost ~]$ date Fri Feb :: CST [keysystem@localhost ~]$ locale LA ...

  4. Django - 权限(4)- queryset、二级菜单的默认显示、动态显示按钮权限

    一.queryset Queryset是django中构建的一种数据结构,ORM查询集往往是queryset数据类型,我们来进一步了解一下queryset的特点. 1.可切片 使用Python 的切片 ...

  5. android如何调用显示和隐藏系统默认的输入法(一)

    1.调用显示系统默认的输入法 方法一. InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_MET ...

  6. 使用storyboard显示UITableView时,如果不修改系统默认生成的tableView:cellForRowAtIndexPath:方法中的代码,则必须为UITableViewCell注册(填写)重用标识符:identifier.必须要代码方法中的标识符一致.

    CHENYILONG Blog 使用storyboard显示UITableView时,如果不修改系统默认生成的tableView:cellForRowAtIndexPath:方法中的代码,则必须为UI ...

  7. 时间操作(JavaScript版)—年月日三级联动(默认显示系统时间)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/wangshuxuncom/article/details/35263317         这个功能 ...

  8. Ubuntu18.04系统下安装Pycharm&vim设置自动缩进及默认显示行号

    Ubuntu18.04系统自带python3.6及python2.7,Pycharm是一款非常强大的IDE.目前Pycharm有两个版本:专业版和Community社区,区别是专业版是收费,而且功能更 ...

  9. Android 系统默认参数的修改

    转自: http://www.th7.cn/Program/Android/201505/447097.shtml 写在前面的话 一般在新项目开始之初,我们需要针对客户需求进行各种系统默认属性的配置, ...

随机推荐

  1. 如何解决 Java 安全问题?

    如何解决 Java 安全问题,目前的应对策略都十分笨拙,往往适得其反.幸运的是,有一种新的方法可以将安全机制嵌入 Java 执行平台--或者更具体地说,嵌入 Java 虚拟机中,进而规避一些「Big ...

  2. h.264并行解码算法2D-Wave实现(基于多核非共享内存系统)

    在<Scalable Parallel Programming Applied to H.264/AVC Decoding>书中,作者基于双芯片18核的Cell BE系统实现了2D-Wav ...

  3. <转>SFTP 和FTPS的区别是什么?

    SFTP 和FTPS都是为ftp连接加密,协议非常相似. 一个是借助ssl协议加密,一个时借助ssh加密. ssl是为http/smtp等加密设计的,ssh是为telnet/ftp等加密.建立传输通道 ...

  4. jQuery&HTML&CSS3实现垂直手风琴折叠菜单方法讲解

    在网页制作中我们常常需要折叠式的菜单,在折叠菜单中,手风琴特效的菜单是非常受欢迎,下面就讲解使用jQuery+HTML+CSS3实现垂直手风琴折叠菜单的方法. jQuery实现垂直手风琴折叠菜单示例代 ...

  5. Hibernate+jxl+excel导入数据库

    在将excel中的10w行数据导入数据库中时,总发生内存溢出,一开始使用的Spring+Hibernate;不知如何使用批处理,后来只是用Hibernate,10W行数据几分钟完成, 代码如下: pu ...

  6. BZOJ1465: 糖果传递

    1465: 糖果传递 Time Limit: 2 Sec  Memory Limit: 64 MBSubmit: 277  Solved: 105[Submit][Status] Descriptio ...

  7. Solr -- Solr Facet 2

    solr将以导航为目的的查询结果称为facet. 它并不会修改查询结果信息, 只是在查询结果上根据分类添加了count信息, 然后用户根据count信息做进一步的查询, 比如淘宝的查询列表中, 上面会 ...

  8. Solr -- Solr Facet 1

    一.Facet介绍 solr facet 是solr搜索的一大特色,facet不好翻译,有说是垂直搜索,有说是分片搜索,但都不是很好,还是懒得翻译了,就叫facet ,具体功能看下面的例子意会吧. 比 ...

  9. ♫【模式】自定义函数(self-defining function)

    <JavaScript模式> /** * 如果创建了一个新函数并且将其分配给保存了另外函数的同一个变量,那么就以一个新函数覆盖旧函数. * 在某种程度上,回收旧函数指针以指向一个新函数.而 ...

  10. Hibernate 以流的方式获取数据

    hibernateQuery.setFetchSize(Integer.MIN_VALUE); results = hibernateQuery.scroll(ScrollMode.FORWARD_O ...