InputStream in = getResources().getAssets().open("iperf");
OutputStream out = new FileOutputStream("/data/data/iperf-project/iperf", false);
byte[] buf = new byte[1024];
int len;
while ((len=in.read(buf)) > 0) {
out.write(buf,0,len);
}
in.close();
out.close();
然後 chmod +x :
Process processchmod = runtime.GetRuntime().exec("/system/bin/chmod 744 /data/data/iperf.project/iperf");
processchmod.waitFor();
執行 iperf 和取得結果的動作在令一個 , AsyncTask 做:
先把 command process 做出來,執行。
List<String> commandList = new ArrayList<String>(Arrays.asList(commands));
commandsList.add(0,"/data/data/iperf.project/iperf");
Process process = new ProcessBuilder().command(commandList).redirectErrorStream(true).start();
然後拿到這個 process 的 output, 接到一個 InputStream 來讀:
BufferReader reader = new BufferReader(new InputStreamReader(process.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while((read = reader.read(buffer)) > 0) {
output.append(buffer,0,read);
publishProgress(output.toString());
output.delete(0,output.length());
}
reader.close();
process.destroy();
[14771.500536] usb 3-1.4: new full-speed USB device number 8 using xhci_hcd
[14771.959368] usb 3-1.4: New USB device found, idVendor=0403, idProduct=0000
[14771.959374] usb 3-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[14771.959378] usb 3-1.4: Product: FT232R USB UART
[14771.959381] usb 3-1.4: Manufacturer: FTDI
[14771.959384] usb 3-1.4: SerialNumber: A92X933R
[16240.939782] usbcore: registered new interface driver usbserial
[16240.939807] usbcore: registered new interface driver usbserial_generic
[16240.939827] usbserial: USB Serial support registered for generic
[16240.950945] usbcore: registered new interface driver ftdi_sio
[16240.950969] usbserial: USB Serial support registered for FTDI USB Serial Device
[16281.458752] usbserial: USB Serial deregistering driver FTDI USB Serial Device
[16281.458807] usbcore: deregistering interface driver ftdi_sio
[16580.239129] usbcore: registered new interface driver ftdi_sio
[16580.239174] usbserial: USB Serial support registered for FTDI USB Serial Device
[16660.940658] ftdi_sio 3-1.4:1.0: FTDI USB Serial Device converter detected
[16660.940749] usb 3-1.4: Detected FT232RL
[16660.940754] usb 3-1.4: Number of endpoints 2
[16660.940758] usb 3-1.4: Endpoint 1 MaxPacketSize 64
[16660.940762] usb 3-1.4: Endpoint 2 MaxPacketSize 64
[16660.940766] usb 3-1.4: Setting MaxPacketSize 64
[16660.941420] usb 3-1.4: FTDI USB Serial Device converter now attached to ttyUSB0
sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev x11proto-core-dev libx11-dev libreadline6-dev libgl1-mesa-glx libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev
libz.so.1: lib32z1 lib32ncurses5
add squeeze main non-free, install sun-java6-jdk -- not work, break a lot packages dependency.
add wheezy main, install openjdk-6-jdk, downgrade jre to 6
sudo update-alternatives --config java
正式安裝。
裝在 HD 上,用 jessie Oct.5 的 image 直接安裝就可以。
將 iso dd 到 usb 上,開機近bios 選 startup..當插兩隻 usb 時,如果開機順續錯,就交換。
usb 3.0 port 的 boot pri 好像比較高。
proxy 時,要用 http://192.168.100.132:3128
不可以家字串符號,也不可以不加 http
裝完也可以開機。
所以可以直接選 MATE, 不要gnome.
先是時間,這次沒看到問 UTC還是 local,就直接用 UTC 了。
但是因為 bios 是 local,所以時間是錯的。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/home/charles-chang/17.2.14/boot/uboot/lib/rsa/rsa-sign.c:12:25: error: openssl/rsa.h: No such file or directory
/home/charles-chang/17.2.14/boot/uboot/lib/rsa/rsa-sign.c:13:25: error: openssl/pem.h: No such file or directory
...
linux-x86/sign/mkimage: error while loading shared libraries: libssl.so.0.9.8: cannot open shared object file: No such file or directory
make: *** [android-recovery] Error 127
查一下,系統的是 .../x86_64-linux-gnu/libssl.so.1.0.0
所以到舊 server 去...copy libssl.so.0.9.8
之後是缺 libcrypto.so.0.9.8
然後是 flash.sh, 新的 fdisk 不吃 tab, 不會自動律調。
所以用
echo "n
p
1
+32M
wq " | fdisk -c -u /dev/sdc
這樣的 command,左邊要對齊。
還是不行耶,jessie shell script 好像會有點重疊。
所以只好改用 ..
echo -e 'n\np\n1\n\n+32M\nwq" | fdisk
這樣的寫法,並且為了減少重疊,把所有 command 都準備好之後再一次使用 fdisk
format 出問題:
常常 format 到 partition 6 的時候出現 resource busy, 所以 part size 是 0 的狀況。
加 delay 也沒用。
Japanese data SIM adventures
I've just arrived in Osaka, and so has my b-mobile Visitor SIM, which promises a prepaid data connection. Unfortunately, my phone doesn't even attempt a data connection, because the SIM won't let the phone register on the network at large - and it just gives up.
I was pretty grumpy at having a non-returnable $30 SIM I can't use. So I booted my phone into baseband mode (where the baseband IC presents itself directly on the phone's USB port, allowing me to send it AT commands). Checking the network registration with AT+CREG yields 3 - registration denied. But the GPRS registration, AT+CGREG, is valid! Evidently not a situation the phone's designers considered. But how do we use it?
The answer is to use the +CGDATA command, which opens a connection we can use for PPP. Now you just need to set up PPP... update: there is a super neat solution by Josua Dietze, check the bottom of this post for the link!
Setting up PPP on Android
To make this work, you need a rooted phone with direct access to your baseband's AT-style port. On my Droid 4 this is /dev/ttyUSB4. If you don't know what this means, stop reading here.
I had to build chat and ended up building my own pppd because the Android one logs to the Android logs (duh), so here they are as binaries for you: chat, and pppd. I put them in /system/xbin.
You then need to write the following files: /etc/ppp/options.mobile, changing ttyUSB4 for your tty:
Now for /etc/ppp/chat.mobile, where you must replace bmobile.ne.jp with your APN:
TIMEOUT 10
ABORT 'ERROR'
ABORT 'BUSY'
ABORT 'NO CARRIER'
'' ATZ OK
'AT+CGDCONT=1,"IP","bmobile.ne.jp"' OK
AT+CGDATA="PPP",1 CONNECT
Finally, /etc/ppp/ip-up, which you must then chmod 755:
#!/system/bin/sh
ip route add default via $4
setprop net.dns1 $DNS1
setprop net.dns2 $DNS2
You should now be able to run the whole shebang with:
/system/xbin/pppd call mobile
If it runs all the way to printing you some IP addresses and running the ip-up script, you are a winner. Note that it may not replace the default route if you already have one (if you're on wifi, for example).
Of course, apps which use the Android network manager to decide if they're connected will still refuse to work - Google Maps won't let you search, for example. Any suggestions for tricking the manager?
The right and obvious answer
The amazing Josua Dietze has already done all this, wrapped it into an app, and sorted out all the network manager issues. Amazing! Get it from the Play Store.