Skip to content
This repository
Browse code

ICS support

Signed-off-by: Shaka Huang <shaka@cs03.org>
  • Loading branch information...
commit 257fc86c0f7746f338870b0f6d2a94d16e56a788 1 parent af5b945
Shaka Huang authored May 06, 2012
0  assets/usb_storage.ko → assets/usb_storage_xperia.ko
File renamed without changes
BIN  assets/usb_storage_xperia_ics.ko
Binary file not shown
2  project.properties
@@ -8,4 +8,4 @@
8 8
 # project structure.
9 9
 
10 10
 # Project target.
11  
-target=android-12
  11
+target=android-15
20  src/com/corner23/android/usb_otg_manager/Main.java
@@ -20,6 +20,7 @@
20 20
 import android.content.SharedPreferences;
21 21
 import android.hardware.usb.UsbManager;
22 22
 import android.os.AsyncTask;
  23
+import android.os.Build;
23 24
 import android.os.Bundle;
24 25
 import android.util.Log;
25 26
 import android.view.View;
@@ -43,7 +44,9 @@
43 44
 	public final static String PREFS_READ_ONLY = "prefs_read_only";
44 45
 
45 46
 	private final static String TAG = "USB_OTG_MANAGER";
46  
-	private final static String FN_STORAGE_DRIVER = "usb_storage.ko";
  47
+	private String storage_km;
  48
+	private final static String FN_STORAGE_DRIVER_XPERIA = "usb_storage_xperia.ko";
  49
+	private final static String FN_STORAGE_DRIVER_XPERIA_ICS = "usb_storage_xperia_ics.ko";
47 50
 	private final static String STORAGE_DEVICE_PATH = "/dev/block/sda1";
48 51
 	
49 52
 	private final static String[] fsTypes = {"vfat"/*, "ntfs" */};
@@ -112,7 +115,14 @@ public void onClick(View v) {
112 115
 		@Override
113 116
 		protected void onPreExecute() {
114 117
 	    	try {
115  
-	    		openFileInput(FN_STORAGE_DRIVER);
  118
+	    		if (bIsXperiaSeries) {
  119
+	    			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
  120
+			    		storage_km = FN_STORAGE_DRIVER_XPERIA_ICS;
  121
+	    			} else {
  122
+	    				storage_km = FN_STORAGE_DRIVER_XPERIA;
  123
+	    			}
  124
+	    		}
  125
+	    		openFileInput(storage_km);
116 126
 	    		Log.d(TAG, "driver file exist, skip copy process..");
117 127
 	    	} catch (FileNotFoundException e) {
118 128
 	    		doCopy = true;
@@ -125,7 +135,7 @@ protected Void doInBackground(Void... params) {
125 135
 			if (doCopy) {
126 136
 	            try {
127 137
 	        		Log.d(TAG, "driver file not found, copy..");
128  
-	            	writeToStream(getAssets().open(FN_STORAGE_DRIVER), openFileOutput(FN_STORAGE_DRIVER, 0));
  138
+	            	writeToStream(getAssets().open(storage_km), openFileOutput(storage_km, 0));
129 139
 	            } catch (Exception e) {
130 140
 	            	e.printStackTrace();
131 141
 	            }    		
@@ -162,7 +172,7 @@ private int doMount() {
162 172
 	        		
163 173
 	        		// load kernel module if needed
164 174
 	        		if (!driverLoaded) {
165  
-			    		response = Root.executeSU("insmod " + mContext.getFileStreamPath(FN_STORAGE_DRIVER));
  175
+			    		response = Root.executeSU("insmod " + mContext.getFileStreamPath(storage_km));
166 176
 			    		if (response != null) {
167 177
 		        			Log.d(TAG, "Error loading kernel module :" + response);
168 178
 			        		ret = STATE_ERROR_MODULE;
@@ -240,7 +250,7 @@ public static boolean doUnmount() {
240 250
         		}
241 251
         		
242 252
         		// TODO: option for user
243  
-//            	response = Root.executeSU("rmmod " + FN_STORAGE_DRIVER);
  253
+//            	response = Root.executeSU("rmmod " + storage_km);
244 254
 //        		if (response != null) {
245 255
 //        			Log.d(TAG, "Error disabling kernel module :" + response);
246 256
 //        			break;

0 notes on commit 257fc86

Please sign in to comment.
Something went wrong with that request. Please try again.