포럼 회원으로 등록하신분만 다운로드가 가능합니다. 최대 업로드 가능한 용량은 20MB 입니다.

요청하신 분이 계셔서.....메일로 보낸 내용을 간단하게 다시 올립니다.


아주 자세한 내용은 아니지만, 간단하게나마 대략 아실 수 있을겁니다.


========================================================================


일단 input관련해서 간단하게 EventHub.cpp까지 정리된 자료를 보냅니다.

PhoneWindowManager.java관련은 간단하게만 설명드리겠습니다.

==========================================

0. Event를 받아오는 쪽은 첨부 파일을 보시고요.

1. PhoneWindowManager.java를 일단 open하시고요

mLidOpen 이란 변수를 보시기 바랍니다.
이 변수를 추적하면

다음과 같은 함수가 먼저 나올겁니다.

    void readLidState() {
        try {
            int sw = mWindowManager.getSwitchState(SW_LID);
            if (sw >= 0) {
                mLidOpen = sw == 0;
            }
        } catch (RemoteException e) {
            // Ignore
        }
    }

이 함수는 WindowManager에서부터 getSwitchState함수를 이용해서 SW_LID를 읽어옵니다.

이 함수는 결국은 EventHub.cpp에서도 동일한 함수가 있습니다.

int32_t EventHub::getSwitchState(int32_t deviceId, int32_t sw) const {
#ifdef EV_SW
    if (sw >= 0 && sw <= SW_MAX) {
        AutoMutex _l(mLock);

        device_t* device = getDeviceLocked(deviceId);
        if (device != NULL) {
            return getSwitchStateLocked(device, sw);
        }
    }
#endif
    return AKEY_STATE_UNKNOWN;
}

이 함수에서 해당 값을 읽어서 WindowManager쪽으로 건네주는 역할을 합니다.

2. mLidOpen 변수가 사용되는 부분은 다음과 같습니다.

    public int rotationForOrientationLw(int orientation, int lastRotation,
            boolean displayEnabled) {

        if (mPortraitRotation < 0) {
            // Initialize the rotation angles for each orientation once.
            Display d = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
                    .getDefaultDisplay();
            if (d.getWidth() > d.getHeight()) {
                mPortraitRotation = Surface.ROTATION_90;
                mLandscapeRotation = Surface.ROTATION_0;
                mUpsideDownRotation = Surface.ROTATION_270;
                mSeascapeRotation = Surface.ROTATION_180;
            } else {
                mPortraitRotation = Surface.ROTATION_0;
                mLandscapeRotation = Surface.ROTATION_90;
                mUpsideDownRotation = Surface.ROTATION_180;
                mSeascapeRotation = Surface.ROTATION_270;
            }
        }

        synchronized (mLock) {
            switch (orientation) {
                case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
                    //always return portrait if orientation set to portrait
                    return mPortraitRotation;
                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(
                            isLandscapeOrSeascape(Surface.ROTATION_180));
                    return getCurrentLandscapeRotation(lastRotation);
                case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT:
                    mOrientationListener.setAllow180Rotation(
                            !isLandscapeOrSeascape(Surface.ROTATION_180));
                    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) {  //============================================================> 여기서 checking
                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);
                }
                return Surface.ROTATION_0;
            }
        }
    }

이 함수는 화면 rotation을 처리하는 함수입니다.

모든 app는 이 함수에 물어봐서 현재의 rotation상태를 결정하는 함수입니다.

이 때 mLidOpen 이란 변수를 가지고 적절하게, 회전 상태를 결정하게 되는 데........
이게 Motorola droid 폰이나 HTC G1 phone의 qwerty 자판의 slide와 연결되어 있는 변수입니다.

즉, 뚜껑이 열렸느냐 아니냐에 따라 화면 회전을 결정하는 것입니다.


고도리

2011.08.02 09:40:25
*.200.239.234

mLidOpen 변수는 kernel의 input device 중 EV_SW type 특성을 갖는 드라이버에서 SW_LID란 event가 올라오게 되면 set이 되는 것입니다.

kjbf15

2011.08.02 22:40:31
*.94.41.89

감사합니다 ^^

InputDispatcher 단에서 ViewRoot로 이벤트 처리과정에서 InputPublisher와 InputConsumer를 이용한다는걸

겨우 분석했네요 ㅜㅜ 정말 단순 소스코드 분석은 쉬운 일이 아닌듯합니다.

알려주신 자료는 WindowManager, PhoneWindowManager 부분 분석에 많은 도움이 되었습니다.

List of Articles
번호 제목 글쓴이 날짜 조회 수sort
84 [android] mouse right button을 back key 처럼 동작시키는 방법 [1] 고도리 2017-05-28 268
83 [android] hello android application 작성법 관리자 2013-12-11 2440
82 DRM(Digital Rights Management) on Android file [1] 고도리 2012-07-06 5440
81 [자료] Android build system(안드로이드 빌드 시스템) for ICS file [7] 고도리 2012-04-16 7455
80 odroid7에서 KGDB를 이용한 커널 디버깅 방법 [6] 경주현 2011-10-06 7467
79 android boot시 shell script 실행시키기(혹은 binary) [1] 고도리 2011-09-30 7751
78 안드로이드 1.1r1 자바 소스 file 김재훈 2009-04-08 8155
77 Solving an Android Threading Problem file 김재훈 2009-04-06 8307
76 [펌] Android Device driver 정리 - 슬로우부트님 자료 file [3] 고도리 2011-12-01 8728
75 busybox에 대한 질문 [3] 득드로이드 2010-03-24 8881
74 [추가 업데이트]안드로이드 플랫폼 공부를 시작할 수 있는 실습형 ... [17] 이제현 2012-04-11 8942
73 [펌] Android Device Driver 정리 문서 및 Stagefright 개념 ... file [5] 고도리 2011-11-22 9089
72 [안드로이드 분석및포팅 교안] 1장 안드로이드 개요 및 구조 file [2] 고도리 2011-07-19 9494
71 Android 2.3 멀티미디어(Multimedia) framework 구조자료 file [12] 고도리 2011-09-14 9532
70 mv6410 보드에 안드로이드 올렸습니다. . 2009-06-11 9549
69 HTC G2 안드로이드폰 밧데리 시간 [3] 2009-06-25 9720
68 Android Java쪽에서 시작 하는 main()부분... file [1] 2009-07-16 9977
67 Android 커널 2.6.27~28버젼에서 CONFIG_SUSPEND옵션시 죽는 문... [3] 2009-05-08 10026
66 File System 관련 문제 및 power off 문제 해결 [3] 김한철 2009-04-14 10202
65 Android 폰 가지고 놀기^^ [1] 2009-08-07 10211

사용자 로그인