http://source.android.com/devices/low-ram.html
PRODUCT_PROPERTY_OVERRIDES += ro.config.low_ram=true \ wifi.interface=wlan0 \ dalvik.vm.jit.codecachesize=0
property_get("ro.config.low_ram", propBuf, ""); if (strcmp(propBuf, "true") == 0) { opt.optionString = "-XX:LowMemoryMode"; mOptions.add(opt); }
public static boolean isLowRamDeviceStatic() { return "true".equals(SystemProperties.get("ro.config.low_ram", "false")); }
public boolean isLowRamDevice() { return isLowRamDeviceStatic(); }
/** * 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() { return !isLowRamDeviceStatic() && !Resources.getSystem().getBoolean(com.android.internal.R.bool.config_avoidGfxAccel); }
@Override public void onCreate() { super.onCreate(); mWallpaperManager = (WallpaperManager) getSystemService(WALLPAPER_SERVICE); //noinspection PointlessBooleanExpression,ConstantConditions if (FIXED_SIZED_SURFACE && USE_OPENGL) { if (!isEmulator()) { mIsHwAccelerated = ActivityManager.isHighEndGfx(); } } }
if (mIsHwAccelerated) { if (!drawWallpaperWithOpenGL(sh, availw, availh, xPixels, yPixels)) { drawWallpaperWithCanvas(sh, availw, availh, xPixels, yPixels); } } else { drawWallpaperWithCanvas(sh, availw, availh, xPixels, yPixels); if (FIXED_SIZED_SURFACE) { // If the surface is fixed-size, we should only need to // draw it once and then we'll let the window manager // position it appropriately. As such, we no longer needed // the loaded bitmap. Yay! // hw-accelerated path retains bitmap for faster rotation mBackground = null; mWallpaperManager.forgetLoadedWallpaper(); } } }