landscape screen

frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp

void SurfaceFlinger::onInitializeDisplays() {
    ...

    d.layerStack = 0;

    // Chenlei add
    int rotation = 0;
    char value[PROPERTY_VALUE_MAX];
    property_get("ro.sf.rotation", value, "");
    rotation = atoi(value);
    // get ro.sf.rotation property and set orientation
    if(rotation == DisplayState::eOrientation90 )
        d.orientation = DisplayState::eOrientation90;
    else if( rotation == DisplayState::eOrientation270 )
        d.orientation = DisplayState::eOrientation270;
    else if( rotation == DisplayState::eOrientation180 )
        d.orientation = DisplayState::eOrientation180;
    else
        d.orientation = DisplayState::eOrientationDefault;
    // End
    d.frame.makeInvalid();
    ...
}

frameworks/native/services/surfaceflinger/DisplayDevice.cpp

void DisplayDevice::setProjection(int orientation,
        const Rect& newViewport, const Rect& newFrame) {
    ...

    if (!frame.isValid()) {
        // the destination frame can be invalid if it has never been set,
        // in that case we assume the whole display frame.

        // chenlei modify
        int rotation = 0;
        char value[PROPERTY_VALUE_MAX];
        property_get("ro.sf.rotation", value, "0");
        rotation = atoi(value);
        if(rotation == DisplayState::eOrientation90 || rotation == DisplayState::eOrientation270) {
            frame = Rect(h, w);
        } else {
           frame = Rect(w, h);
        }
        // End
    }

    if (viewport.isEmpty()) {
        // viewport can be invalid if it has never been set, in that case
        // we assume the whole display size.
        // it's also invalid to have an empty viewport, so we handle that
        // case in the same way.
        viewport = Rect(w, h);
        if (R.getOrientation() & Transform::ROT_90) {
            // viewport is always specified in the logical orientation
            // of the display (ie: post-rotation).
            swap(viewport.right, viewport.bottom);
        }
    }
    ...
}

frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java

private WindowManagerService(Context context, InputManagerService inputManager,
            boolean haveInputMethods, boolean showBootMsgs, boolean onlyCore) {
        mContext = context;
        mHaveInputMethods = haveInputMethods;
        mAllowBootMessages = showBootMsgs;
        mOnlyCore = onlyCore;
        ...

        mActivityManager = ActivityManagerNative.getDefault();
        mBatteryStats = BatteryStatsService.getService();

        //Chenlei add
        if(SystemProperties.getInt("ro.sf.rotation",0) == Surface.ROTATION_90){
            mRotation = Surface.ROTATION_90;
        } else if (SystemProperties.getInt("ro.sf.rotation",0) == Surface.ROTATION_270) {
            mRotation = Surface.ROTATION_270;
        } else if (SystemProperties.getInt("ro.sf.rotation",0) == Surface.ROTATION_180) {
            mRotation = Surface.ROTATION_180;
        } else {
            mRotation = Surface.ROTATION_0;
        }
        // End

        mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
        ...
}

frameworks/base/cmds/bootanimation/BootAnimation.cpp

status_t BootAnimation::readyToRun() {
    mAssets.addDefaultAssets();

    ...

    // Chenlei add
    int rotation = 0, varswap = 0;
    char value[PROPERTY_VALUE_MAX];
    property_get("ro.sf.rotation", value, "0");
    rotation = atoi(value);
    if(rotation == DisplayState::eOrientation90 || rotation == DisplayState::eOrientation270) {
        varswap = dinfo.w;
        dinfo.w = dinfo.h;
        dinfo.h = varswap;
    }
    // End

    // create the native surface
    sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),
            dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);

    ...

    return NO_ERROR;
}

设置锁定屏幕旋转:

persist.demo.rotationlock=true

设置此属性可以是Android屏幕水平,垂直,可以同时使用

persist.demo.remoterotation=portrait

这几个config当然也可以尝试:

<bool name="config_forceDefaultOrientation">true</bool>
<bool name="config_supportAutoRotation">false</bool>
<bool name="config_deskDockEnablesAccelerometer">false</bool>

results matching ""

    No results matching ""