본문 바로가기

개발 이야기

Android Hardware Acceleration 옵션 꺼기

320x100
Android Hardware Acceleration 옵션 꺼기

Target AOSP Version : Android ICS 4.0.4

Android Application 상에서 해당 옵션을 끄는 것은 상당히 많다.
하지만 AOSP 개발자는 어떻게 끌 수 있을 지 확인해 보는 시간을 가져보겠다.

실제적으로 Android HardWare Acceleration을 셋팅을 응용에서 하더라도, 물어보는 곳이 있습니다.
소스 뒤져보니 찾았네요.

ActivityManager.java

**
     * Used by persistent processes to determine if they are running on a
     * higher-end device so should be okay using hardware drawing acceleration
     * (which tends to consume a lot more RAM).
     * @hide
     */
    static public boolean isHighEndGfx(Display display) {
        MemInfoReader reader = new MemInfoReader();
        reader.readMemInfo();
        if (reader.getTotalSize() >= (512*1024*1024)) {
            // If the device has at least 512MB RAM available to the kernel,
            // we can afford the overhead of graphics acceleration.
            return true;
        }
        Point p = new Point();
        display.getRealSize(p);
        int pixels = p.x * p.y;
        if (pixels >= (1024*600)) {
            // If this is a sufficiently large screen, then there are enough
            // pixels on it that we'd really like to use hw drawing.
            return true;
        }
        return false;

    } 



isHighEndGfx() 메소드를 이용해서 최종적으로 HardwareRender를 Disable() 메소드를 호출하여, 비활성화 시키는 구조입니다.
해당 메소드를 검색해 보면, 많은 곳에서 Hardware Acceleration을 체크합니다.

Acitivty, Webview, SystemUI, ScreenShot 등등....


isHighEndGfx() 의 리턴값을 특정 모델의 define 값을 추가해서 false 로 반환처리 해서 Android framework 단에서 
막아주는 것도 좋은 방법일 것 같습니다.




반응형