使用系統管理員權限開啟 cmd.exe,
執行powercfg /energy
會產生一個report的網頁:
C:\Windows\system32\energy-report.html
2011年5月14日 星期六
2011年5月11日 星期三
bluetooth debug
可以使用hcidump擷取所有hci層的資料
直接觀看:
hcidump -XVt
存成binary,使用FTS4BT觀看
hcidump -B -w /tmp/XXX.cfa
直接觀看:
hcidump -XVt
存成binary,使用FTS4BT觀看
hcidump -B -w /tmp/XXX.cfa
2011年4月20日 星期三
android 使用標示為hide的API
framework中,有許多function上面使用@hide標示為隱藏,
在eclipse上面使用也無法編譯
不過可以使用下列方法解決:
http://eeepage.info/java-hide-class/
http://java.sun.com/developer/technicalArticles/ALT/Reflection/
舉例來說,開關softap使用wifiManager.setWifiApEnabled(),
但setWifiApEnabled()標示hide
可以用下列方法直接呼叫:
Method mMethod = mWifiManager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
mMethod.invoke(mWifiManager, new Object[] { null, true });
class.getMethod()的第一個參數為method名稱(字串),後面為這個method自己所需的參數(args)
method.invoke的第一個參數為執行這個method的class, 第二個參數為物件陣列,內容是要傳進此method的參數
在eclipse上面使用也無法編譯
不過可以使用下列方法解決:
http://eeepage.info/java-hide-class/
http://java.sun.com/developer/technicalArticles/ALT/Reflection/
舉例來說,開關softap使用wifiManager.setWifiApEnabled(),
但setWifiApEnabled()標示hide
可以用下列方法直接呼叫:
Method mMethod = mWifiManager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
mMethod.invoke(mWifiManager, new Object[] { null, true });
class.getMethod()的第一個參數為method名稱(字串),後面為這個method自己所需的參數(args)
method.invoke的第一個參數為執行這個method的class, 第二個參數為物件陣列,內容是要傳進此method的參數
標籤:
程式設計,
android,
android app
2011年4月19日 星期二
android 將檔案放入程式在/data下的目錄中
在專案的res下面增加raw資料夾
將需要的檔案放進去(不要包含".")
使用 copyFile("XXX.sh", R.raw.XXX);
存放進去的路徑可使用this.getFilesDir()取得
目錄應該是/data/data/com.YYY.ZZZ/files
將需要的檔案放進去(不要包含".")
使用 copyFile("XXX.sh", R.raw.XXX);
存放進去的路徑可使用this.getFilesDir()取得
目錄應該是/data/data/com.YYY.ZZZ/files
private boolean copyFile(String fName, int rawId){
InputStream inS = null;
OutputStream outS = null;
byte [] buf = new byte[1024];
int readByte = 0;
try {
inS = getApplicationContext().getResources().openRawResource(rawId);
outS = openFileOutput(fName,MODE_PRIVATE);
while((readByte = inS.read(buf, 0, 1024)) != -1){
outS.write(buf, 0, readByte);
}
inS.close();
outS.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
標籤:
程式設計,
android,
android app
2011年4月2日 星期六
android 使用proxy連接至網路
http://forum.xda-developers.com/showthread.php?t=766569
http://darkk.net.ru/redsocks/
in nexus one(cyanogenmod 7):
eth0/wl0.1
wifi/softap(BCM4329)
lo
loopback
rmnet0
3G
in rooted and installed superuser phone, if run "su root", the superuser program will ask user to confirm root access via UI.
transproxy.apk
This program use redsock internal
This tool allows you to redirect any TCP connection to SOCKS or HTTPS proxy using your firewall, so redirection is system-wide.
after install this program, some file will be placed in data/data/com.hasbox.tproxy/, I found there are some scripts in "files" directory
enable transproxy
sh data/data/com.hasbox.tproxy/files/proxy.sh start /data/data/com.hasbox.tproxy/files type=http host= port= auth=false user= pass=
sh data/data/com.hasbox.tproxy/files/redirect.sh start http
disable transproxy
sh data/data/com.hasbox.tproxy/files/proxy.sh stop /data/data/com.hasbox.tproxy/files
sh data/data/com.hasbox.tproxy/files/redirect.sh stop
when execution /data/data/com.hasbox.tproxy/files/redirect.sh,because android bionic libc not implement getprotobyname(), so there some warning messabe
in my environment, 3G need use proxy but wifi can direct access , so modify redirect.sh, add " -o rmnet0" in each rule, only 3G access use proxy
bugs
android's netd will reset ipatbles when disable tethering(ether wifi or usb), so the setting by transproxy will gone.
must set transproxy.apk after disable tethering
http://darkk.net.ru/redsocks/
in nexus one(cyanogenmod 7):
eth0/wl0.1
wifi/softap(BCM4329)
lo
loopback
rmnet0
3G
in rooted and installed superuser phone, if run "su root", the superuser program will ask user to confirm root access via UI.
transproxy.apk
This program use redsock internal
This tool allows you to redirect any TCP connection to SOCKS or HTTPS proxy using your firewall, so redirection is system-wide.
after install this program, some file will be placed in data/data/com.hasbox.tproxy/, I found there are some scripts in "files" directory
enable transproxy
sh data/data/com.hasbox.tproxy/files/proxy.sh start /data/data/com.hasbox.tproxy/files type=http host= port= auth=false user= pass=
sh data/data/com.hasbox.tproxy/files/redirect.sh start http
disable transproxy
sh data/data/com.hasbox.tproxy/files/proxy.sh stop /data/data/com.hasbox.tproxy/files
sh data/data/com.hasbox.tproxy/files/redirect.sh stop
when execution /data/data/com.hasbox.tproxy/files/redirect.sh,because android bionic libc not implement getprotobyname(), so there some warning messabe
in my environment, 3G need use proxy but wifi can direct access , so modify redirect.sh, add " -o rmnet0" in each rule, only 3G access use proxy
bugs
android's netd will reset ipatbles when disable tethering(ether wifi or usb), so the setting by transproxy will gone.
must set transproxy.apk after disable tethering
標籤:
android,
android app,
linux,
shell script
2011年3月29日 星期二
使用批次檔修改proxy與ip
http://www.robvanderwoude.com/regedit.php
登錄編輯程式: regedit
想要做一個修改某機碼的.reg檔案
可以先開啟登錄編輯程式找到要改的資料夾,匯出後再修改匯出的內容會比較快
============================
判斷目前proxy是否有開啟並反向設定
@ECHO OFF
FOR /F %%A IN ('REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable ^| grep ProxyEnable ^| awk "{print $3}"' ) DO IF "%%A"=="0x1" (call:on) ELSE (call:off)
GOTO:EOF
:on
ECHO =================
ECHO proxy狀態: 開啟
ECHO 關閉proxy中...
regedit /s proxy_off.reg
ECHO 完成
ECHO =================
pause
GOTO:EOF
:off
ECHO =================
ECHO proxy狀態: 關閉
ECHO 開啟proxy中...
regedit /s proxy_on.reg
ECHO 完成
ECHO =================
pause
GOTO:EOF
登錄編輯程式: regedit
想要做一個修改某機碼的.reg檔案
可以先開啟登錄編輯程式找到要改的資料夾,匯出後再修改匯出的內容會比較快
============================
判斷目前proxy是否有開啟並反向設定
@ECHO OFF
FOR /F %%A IN ('REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable ^| grep ProxyEnable ^| awk "{print $3}"' ) DO IF "%%A"=="0x1" (call:on) ELSE (call:off)
GOTO:EOF
:on
ECHO =================
ECHO proxy狀態: 開啟
ECHO 關閉proxy中...
regedit /s proxy_off.reg
ECHO 完成
ECHO =================
pause
GOTO:EOF
:off
ECHO =================
ECHO proxy狀態: 關閉
ECHO 開啟proxy中...
regedit /s proxy_on.reg
ECHO 完成
ECHO =================
pause
GOTO:EOF
2011年3月2日 星期三
避免編譯時產生錯誤 - error: void value not ignored as it ought to be
假設...
int aaa(){
...
}
void bbb(){
...
}
若遇到下面這種寫法
ret=flag? aaa(): bbb();
編譯時會發生錯誤:
error: void value not ignored as it ought to be
因為此時若flag為0,則ret=bbb();
但是bbb()沒有回傳東西(void),
此時可以使用下面這種寫法:
ret=flag? aaa(): (bbb(),NULL);
其中(bbb(),NULL)永遠回傳0(NULL)
http://en.wikipedia.org/wiki/Comma_operator
int aaa(){
...
}
void bbb(){
...
}
若遇到下面這種寫法
ret=flag? aaa(): bbb();
編譯時會發生錯誤:
error: void value not ignored as it ought to be
因為此時若flag為0,則ret=bbb();
但是bbb()沒有回傳東西(void),
此時可以使用下面這種寫法:
ret=flag? aaa(): (bbb(),NULL);
其中(bbb(),NULL)永遠回傳0(NULL)
http://en.wikipedia.org/wiki/Comma_operator
標籤:
C programming
訂閱:
文章 (Atom)
