更改android锁屏方向

来源:互联网 发布:如何修改路由器mac地址 编辑:程序博客网 时间:2024/03/29 00:42
 

更改android默认屏幕方向 - [技术]

2011-12-11

分类: 技术

版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://glizardy.blogbus.com/logs/180916299.html

frameworks/policies/base/phone/com/android/internal/policy/impl/PhoneWindow­­Manager.java function: rotationForOrientationLw return a direction of what you want; *the red lines are my change: (in eclair)* */*added by wylhistory for test*/* * Log.d(TAG,"the before switch orientation :"+orientation);* * if(false){* * /*above is added by wylhistory for test*/* synchronized (mLock) { switch (orientation) { case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: //always return landscape if orientation set to landscape return mLandscapeRotation; case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: //always return portrait if orientation set to portrait return mPortraitRotation; } // case for nosensor meaning ignore sensor and consider only lid // or orientation sensor disabled //or case.unspecified if (mLidOpen) { return mLidOpenRotation; } else if (mDockState == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) { return mCarDockRotation; } else if (mDockState == Intent.EXTRA_DOCK_STATE_DESK && mDeskDockRotation > = 0) { return mDeskDockRotation; } else { if (useSensorForOrientationLp(orientation)) { // If the user has enabled auto rotation by default, do it. int curRotation = mOrientationListener.getCurrentRotation(); return curRotation >= 0 ? curRotation : lastRotation; } return Surface.ROTATION_0; } } */*added by wylhistory for test*/* * ** }* * return Surface.ROTATION_90;/here you can change to any other direction of your like;* * /*added by wylhistory */* *

此方法可以修改初始方向。

另外可修改package/apps/launcher2/AndroidManifest.xml

android:screenOrientation

此方法无法更改初始锁屏界面的方向。

 

 

 

 

  synchronized (mLock) {
            switch (orientation) {
                case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
   boolean  isConnected = isHdmiConnected(HdmiState);
   if (isConnected){
    return mLandscapeRotation;
   }else
                        {
                            return mPortraitRotation;
                        }
                    //always return portrait if orientation set to portrait
                case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
                    //always return landscape if orientation set to landscape
                    return mLandscapeRotation;
                case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT:
                    //always return portrait if orientation set to portrait
                    return mUpsideDownRotation;
                case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
                    //always return seascape if orientation set to reverse landscape
                    return mSeascapeRotation;
                case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
                    //return either landscape rotation based on the sensor
                    mOrientationListener.setAllow180Rotation(false);
                    return getCurrentLandscapeRotation(lastRotation);
                case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT:
                    mOrientationListener.setAllow180Rotation(true);
                    return getCurrentPortraitRotation(lastRotation);
            }

            mOrientationListener.setAllow180Rotation(
                    orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);

            // case for nosensor meaning ignore sensor and consider only lid
            // or orientation sensor disabled
            //or case.unspecified
            if (mLidOpen) {
                return mLidOpenRotation;
            } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) {
                return mCarDockRotation;
            } else if (mDockMode == Intent.EXTRA_DOCK_STATE_DESK && mDeskDockRotation >= 0) {
                return mDeskDockRotation;
            } else {
                if (useSensorForOrientationLp(orientation)) {
                    return mOrientationListener.getCurrentRotation(lastRotation);
                }

                if (SystemProperties.get("ro.sf.hwrotation").equals("270")) {
                    //Log.d("------->xzj","ro.sf.hwrotation is set ,care");
                    return Surface.ROTATION_90;
                }
                return Surface.ROTATION_0;                 //  can change lockscreen rotation
            }
        }
    }

 

原创粉丝点击