Permalink
Browse files

ICS support

Signed-off-by: Shaka Huang <shaka@cs03.org>
  • Loading branch information...
1 parent af5b945 commit 257fc86c0f7746f338870b0f6d2a94d16e56a788 @shakalaca committed May 6, 2012
View
0 assets/usb_storage.ko → assets/usb_storage_xperia.ko
File renamed without changes.
View
BIN assets/usb_storage_xperia_ics.ko
Binary file not shown.
View
2 project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-12
+target=android-15
View
20 src/com/corner23/android/usb_otg_manager/Main.java
@@ -20,6 +20,7 @@
import android.content.SharedPreferences;
import android.hardware.usb.UsbManager;
import android.os.AsyncTask;
+import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
@@ -43,7 +44,9 @@
public final static String PREFS_READ_ONLY = "prefs_read_only";
private final static String TAG = "USB_OTG_MANAGER";
- private final static String FN_STORAGE_DRIVER = "usb_storage.ko";
+ private String storage_km;
+ private final static String FN_STORAGE_DRIVER_XPERIA = "usb_storage_xperia.ko";
+ private final static String FN_STORAGE_DRIVER_XPERIA_ICS = "usb_storage_xperia_ics.ko";
private final static String STORAGE_DEVICE_PATH = "/dev/block/sda1";
private final static String[] fsTypes = {"vfat"/*, "ntfs" */};
@@ -112,7 +115,14 @@ public void onClick(View v) {
@Override
protected void onPreExecute() {
try {
- openFileInput(FN_STORAGE_DRIVER);
+ if (bIsXperiaSeries) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ storage_km = FN_STORAGE_DRIVER_XPERIA_ICS;
+ } else {
+ storage_km = FN_STORAGE_DRIVER_XPERIA;
+ }
+ }
+ openFileInput(storage_km);
Log.d(TAG, "driver file exist, skip copy process..");
} catch (FileNotFoundException e) {
doCopy = true;
@@ -125,7 +135,7 @@ protected Void doInBackground(Void... params) {
if (doCopy) {
try {
Log.d(TAG, "driver file not found, copy..");
- writeToStream(getAssets().open(FN_STORAGE_DRIVER), openFileOutput(FN_STORAGE_DRIVER, 0));
+ writeToStream(getAssets().open(storage_km), openFileOutput(storage_km, 0));
} catch (Exception e) {
e.printStackTrace();
}
@@ -162,7 +172,7 @@ private int doMount() {
// load kernel module if needed
if (!driverLoaded) {
- response = Root.executeSU("insmod " + mContext.getFileStreamPath(FN_STORAGE_DRIVER));
+ response = Root.executeSU("insmod " + mContext.getFileStreamPath(storage_km));
if (response != null) {
Log.d(TAG, "Error loading kernel module :" + response);
ret = STATE_ERROR_MODULE;
@@ -240,7 +250,7 @@ public static boolean doUnmount() {
}
// TODO: option for user
-// response = Root.executeSU("rmmod " + FN_STORAGE_DRIVER);
+// response = Root.executeSU("rmmod " + storage_km);
// if (response != null) {
// Log.d(TAG, "Error disabling kernel module :" + response);
// break;

0 comments on commit 257fc86

Please sign in to comment.