@@ -0,0 +1,2273 @@
+package org.literacybridge.acm.mobile;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0A%0Apublic class DeviceImageLoader %7B%0A%09private static volatile DeviceImageLoader singleton;%0A%09%0A%09public static synchronized DeviceImageLoader getInstance() %7B%0A%09%09if (singleton == null) %7B%0A%09%09%09singleton = new DeviceImageLoader();%0A%09%09%7D%0A    %09return singleton;%0A    %7D%0A%09%0A%09public enum Result %7B%0A%09%09SUCCESS,%0A%09%09CORRUPT_MEMORY_CARD,%0A%09%09FAILED%0A%09%7D%0A%0A%09public Result imageDevice() throws IOException %7B%0A%09%09copyStatsFromDevice();%0A%09%09formatDevice();%0A%09%09checkDisk();%0A%09%09copyImageToDevice();%0A%09%09%0A%09%09return Result.SUCCESS;%0A%09%7D%0A%09%0A%09private void copyStatsFromDevice() throws IOException %7B%0A%09%09%0A%09%7D%0A%09%0A%09private void formatDevice() throws IOException %7B%0A%09%09// umount /storage/UsbDriveA  %0A%09%09// mkfs.exfat -t fat32 -c 0 /dev/block/vold/8:1%0A%09%09// mount -t vfat -o rw,users /dev/block/vold/8:1 /mnt/UsbDriveA%0A%09%09executeCommand(%22./fsck.exfat -R /dev/block/vold/8:1%22, false);%0A%09%09%0A%09%7D%0A%09%0A%09private void checkDisk() throws IOException %7B%0A%09%7D%0A%09%0A%09private void copyImageToDevice() throws IOException %7B%0A%09%09%0A%09%7D%0A%09%0A%09static String executeCommand(String cmd, boolean listenToStdErr) %7B%0A%09%09StringBuilder responseBuilder = new StringBuilder();%0A%09%09try %7B%0A%09%09%09Process proc = Runtime.getRuntime().exec(cmd);%0A%09%0A%09%09%09InputStream stderr = listenToStdErr ? proc.getErrorStream() : proc.getInputStream(); %0A%09%09%09InputStreamReader isr = new InputStreamReader(stderr);%0A%09%09%09BufferedReader br = new BufferedReader(isr);%0A%09%09%09String line = null;%0A%09%09%0A%09%09%09while ((line = br.readLine()) != null) %7B%0A%09%09%09%09responseBuilder.append(line);%0A%09%09%09%09responseBuilder.append('%5Cn');%0A%09%09%09%7D%0A%09%09%09%0A%09%09%09// check for converter error%0A%09%09%09if (!(proc.waitFor() == 0)) %7B%0A%09%09%09%09throw new RuntimeException(%22Error while executing command %22 + cmd);%0A%09%09%09%7D%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09throw new RuntimeException(%22Error while executing command %22 + cmd, e);%0A%09%09%7D%0A%09%09%09%0A%09%09return responseBuilder.toString();%0A%09%7D%0A%09%0A%09static void consumeProcessOutput(Process proc, boolean listenToStdErr) throws IOException %7B%0A%09%09InputStream stderr = listenToStdErr ? proc.getErrorStream() : proc.getInputStream(); %0A%09%09InputStreamReader isr = new InputStreamReader(stderr);%0A%09%09BufferedReader br = new BufferedReader(isr);%0A%09%09String line = null;%0A%09%0A%09%09while ((line = br.readLine()) != null);%0A%09%7D%0A%0A%7D%0A

Add DeviceImageLoader