Android 11默认横屏(高通)

设备开机默认是竖屏的,如果设备有重力感应器,则根据自动旋转和重力感应器,来设置屏幕方向,如果我们需要设备开机就是横屏,或者用户自定义横屏或竖屏切换。需要修改主要包括四大块:

首先增加自定义属性persist.sys.panel.orientation=1,可选值为0,1,2,3 其中0,2是竖屏,1.3是横屏

  1. 开机动画
    //frameworks/base/cmds/bootanimation/BootAnimation.cpp
    status_t BootAnimation::readyToRun() {
        resolution = limitSurfaceSize(resolution.width, resolution.height);
        //phoebe add start
        char rAngleValue[PROPERTY_VALUE_MAX];
        property_get("persist.sys.panel.orientation", rAngleValue, "1");
        int rAngle = atoi(rAngleValue);
        SurfaceComposerClient::Transaction t;
    
    	int temp = resolution.height;
    	ui::Rotation rota;
    
    	switch(rAngle){
    		case 0:
    			rota=ui::ROTATION_0;
    		break;
    		case 1:
    			resolution.height= resolution.width;
                resolution.width= temp;
    			rota=ui::ROTATION_90;
    		break;
    		case 2:
    			rota=ui::ROTATION_180;
    		break;
    		case 3:
    			resolution.height= resolution.width;
                resolution.width= temp;
    			rota=ui::ROTATION_270;
    		break;
    		default:
    			rota=ui::ROTATION_90;
    		break;
    	}
    	Rect destRect(resolution.width, resolution.height);
    	ALOGD("BootAnimation default set rotation to be %d...",rAngle);
    	t.setDisplayProjection(mDisplayToken, rota, destRect, destRect);
    	    //phoebe add end
        // create the native surface
        sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),
                resolution.getWidth(), resolution.getHeight(), PIXEL_FORMAT_RGB_565);
    
       // SurfaceComposerClient::Transaction t;
    
        // this guest property specifies multi-display IDs to show the boot animation
        // multiple ids can be set with comma (,) as separator, for example:
        // setprop persist.boot.animation.displays 19260422155234049,19261083906282754
        Vector<uint64_t> physicalDisplayIds;
       ...
    }

  2. Ui修改
    // frameworks/base/core/res/res/values/config.xml 
    关闭自动旋转
     <bool name="config_supportAutoRotation">false</bool>
     //默认为横屏
     <integer name="config_lidOpenRotation">90</integer>
    //frameworks/base/core/java/android/view/DisplayInfo.java
    //初始值为设置的属性
       public int rotation= SystemProperties.getInt("persist.sys.panel.orien
  • 3
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值