개요
안드로이드 기본 소스코드는 밧데리가 없으면 시작되자마자 바로 꺼지도록 되어있다.
그래서 타겟보드에서 작업할 때에는 가장 먼저 이 밧데리 부분을 주석걸어 주어야지 꺼지지않고 실행이 된다.
이번 포스트에서는 그 방법을 알아보도록 하자.


밧데리 패치
"frameworks/base/services/java/com/android/server/BatteryService.java" 파일을 열어자.

     private final void shutdownIfNoPower() {

        // shut down gracefully if our battery is critically low and we are not powered.

        // wait until the system has booted before attempting to display the shutdown dialog.

        /*

        if (mBatteryLevel == 0 && !isPowered() && ActivityManagerNative.isSystemReady()) {

            Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);

            intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);

            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            mContext.startActivity(intent);

        }

        */

    }


    private native void native_update();


    private synchronized final void update() {

        //native_update();


        boolean logOutlier = false;

        long dischargeDuration = 0;

        ...
약 186 라인쯤에 위와 같은 부분을 찾을 수 있는데 위처럼 주석을 걸어주자.
이제 컴파일하고 타겟보드에 올리고 실행하면 제대로 될 것이다.
by cranix 2010. 3. 30. 12:50