上次有說到 怎麼安裝 Java6與 Java7
http://esmondjhchang.blogspot.tw/2014/11/ubuntu-12-java67.html
因為我常常要在 JAVA6與JAVA7之間切換...
因此, 本篇只是分享一個個人的切換script
請先到 https://code.google.com/p/webupd8/downloads/detail?name=update-java-0.5b
下載一個 update-java-0.5b的script (這個直接使用就可以了, 不過需要在GUI環境)
因為我不知我的PC被我怎麼搞的, 所以上面的 update-java-0.5b 居然只能切換部份環境
所以...
使用時, 直接在GUI裡的 console 輸入 java_swap後,
若輸入 Y, 則系統會切換成JAVA6 (compile Android 4.4.4-)
若輸入 N, 則系統會切換成 JAVA7 (compile Android 5+)
接著會出現一個對話框, 再選擇 JAVA的位置即可
如: JAVA6 就選 java-6-oracle (小心選, 不然會只切一半)
java_swap 的 Script 如下 (小弟是把兩個檔, update-java-0.5b 與 此script 放到 /bin 裡)
記得要 chmod 成可執行狀態唷~
#!/bin/bash
JAVA6_PATH=/usr/lib/jvm/java-6-oracle
JAVA7_PATH=/usr/lib/jvm/java-7-openjdk-amd64
read -t 30 -n 3 -p "Set Environment to JAVA6? (Y for 6/N for 7) " ANS_YN
sudo /bin/update-java-0.5b
case $ANS_YN in
"NO"|"No"|"no"|"nO"|"N"|"n")
echo "Set to JAVA7 ..."
sudo update-alternatives --set java $JAVA7_PATH/jre/bin/java
sudo update-alternatives --set javac $JAVA7_PATH/bin/javac
sudo update-alternatives --set javadoc $JAVA7_PATH/bin/javadoc
sudo update-alternatives --set javah $JAVA7_PATH/bin/javah
sudo update-alternatives --set javap $JAVA7_PATH/bin/javap
sudo update-alternatives --set javaws $JAVA7_PATH/jre/bin/javaws
# sudo echo "export J2SDKDIR=/usr/lib/jvm/java-7-openjdk-amd64" > /etc/profile.d/jdk.sh
# sudo echo "export J2REDIR=/usr/lib/jvm/java-7-openjdk-amd64/jre" >> /etc/profile.d/jdk.sh
sudo echo "export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64">> /etc/profile.d/jdk.sh
# sudo echo "export PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/jvm/java-7-openjdk-amd64/bin:/usr/lib/jvm/java-7-openjdk-amd64/jre/bin:/usr/lib/jvm/java-6-oracle/db">> /etc/profile.d/jdk.sh
sudo echo "export DERBY_HOME=/usr/lib/jvm/java-6-oracle/db" >> /etc/profile.d/jdk.sh
echo "Set to JAVA7 completed... Please REBOOT manually..."
;;
*)
echo "Set to JAVA6..."
sudo update-alternatives --set java $JAVA6_PATH/jre/bin/java
sudo update-alternatives --set javac $JAVA6_PATH/bin/javac
sudo update-alternatives --set javadoc $JAVA6_PATH/bin/javadoc
sudo update-alternatives --set javah $JAVA6_PATH/bin/javah
sudo update-alternatives --set javap $JAVA6_PATH/bin/javap
sudo update-alternatives --set javaws $JAVA6_PATH/jre/bin/javaws
# sudo echo "export J2SDKDIR=/usr/lib/jvm/java-6-openjdk-amd64" > /etc/profile.d/jdk.sh
# sudo echo "export J2REDIR=/usr/lib/jvm/java-6-openjdk-amd64/jre" >> /etc/profile.d/jdk.sh
sudo echo "export JAVA_HOME=/usr/lib/jvm/java-6-oracle">> /etc/profile.d/jdk.sh
# sudo echo "export PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/jvm/java-6-openjdk-amd64/bin:/usr/lib/jvm/java-6-openjdk-amd64/jre/bin:/usr/lib/jvm/java-6-oracle/db">> /etc/profile.d/jdk.sh
# sudo echo "export DERBY_HOME=/usr/lib/jvm/java-6-oracle/db" >> /etc/profile.d/jdk.sh
echo "Set to JAVA6 completed... Please REBOOT manually..."
;;
esac
2014年12月16日 星期二
如何產生update.zip for recovery (二)
之前曾講過 update.zip 的產生,
請參考: http://esmondjhchang.blogspot.tw/2014/07/qc-updatezip-for-recovery.html
不過有試過的人應該會發現, 它.. 只能update HLOS(Android與kernel)部份,
對於Qualcomm 的non-Hlos (chipcode, 即 boot_image, rpm_proc, modem_proc, tz... 等等)是無效的
因為最後所產生的 update.zip 居然並沒有把 non-Hlos的部份包進去 (檔案 size明顯小很多)
因此, 本篇只是對於 non-Hlos的部份做補完
步驟:
1. 先依前篇方式compile HLOS+nonHLOS 的部份
2. 將nonHLOS 的檔 copy 到 [HLOS]/device/qcom/msm8974/radio 中
檔案位置:
3. 修改 [HLOS]/device/qcom/msm8974/radio/filesmap 檔 (描述資料夾內的檔所對映的partition)
如:
NON-HLOS.bin /dev/block/platform/msm_sdcc.1/by-name/modem
sbl1.mbn /dev/block/platform/msm_sdcc.1/by-name/sbl1
tz.mbn /dev/block/platform/msm_sdcc.1/by-name/tz
rpm.mbn /dev/block/platform/msm_sdcc.1/by-name/rpm
emmc_appsboot.mbn /dev/block/platform/msm_sdcc.1/bt-name/aboot
sdi.mbn /dev/block/platform/msm_sdcc.1/by-name/dbi
4. make otapackage
update.zip 會在 [HLOS]/out/target/product/msm8974/
請參考: http://esmondjhchang.blogspot.tw/2014/07/qc-updatezip-for-recovery.html
不過有試過的人應該會發現, 它.. 只能update HLOS(Android與kernel)部份,
對於Qualcomm 的non-Hlos (chipcode, 即 boot_image, rpm_proc, modem_proc, tz... 等等)是無效的
因為最後所產生的 update.zip 居然並沒有把 non-Hlos的部份包進去 (檔案 size明顯小很多)
因此, 本篇只是對於 non-Hlos的部份做補完
步驟:
1. 先依前篇方式compile HLOS+nonHLOS 的部份
2. 將nonHLOS 的檔 copy 到 [HLOS]/device/qcom/msm8974/radio 中
檔案位置:
NON-HLOS.bin [NON-HLOS]/common/build/bin/asic/NON-HLOS.bin (內含
modem/tz/adsp/wcnss..)
sbl1.mbn [NON-HLOS]/boot_images/build/ms/bin/8974/sbl1.mbn
tz.mbn [NON-HLOS]/trustzone_images/build/ms/bin/AAAAANAA/tz.mbn
rpm.mbn [NON-HLOS]/rpm_proc/build/ms/bin/AAAAANAAR/rpm.mbn
emmc_appsboot.mbn [HLOS]/out/target/product/vgs8974/emmc_appsboot.mbn
sdi.mbn [HLOS]/debug_image/build/ms/bin/AAAAANAZ/sdi.mbn3. 修改 [HLOS]/device/qcom/msm8974/radio/filesmap 檔 (描述資料夾內的檔所對映的partition)
如:
NON-HLOS.bin /dev/block/platform/msm_sdcc.1/by-name/modem
sbl1.mbn /dev/block/platform/msm_sdcc.1/by-name/sbl1
tz.mbn /dev/block/platform/msm_sdcc.1/by-name/tz
rpm.mbn /dev/block/platform/msm_sdcc.1/by-name/rpm
emmc_appsboot.mbn /dev/block/platform/msm_sdcc.1/bt-name/aboot
sdi.mbn /dev/block/platform/msm_sdcc.1/by-name/dbi
4. make otapackage
update.zip 會在 [HLOS]/out/target/product/msm8974/
2014年11月27日 星期四
Ubuntu 12 安裝 Java6/7
文章來源:
https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get
全程只需用 apt-get 安裝即可, 便利且穩定。
指令:
sudo apt-get update
sudo apt-get install default-jre
sudo apt-get install default-jdk
sudo apt-get install openjdk-7-jre
sudo apt-get install openjdk-7-jdk
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
安裝Oracle JDK 6:
sudo apt-get install oracle-java-6-installer
安裝Oracle JDK 7:
sudo apt-get install oracle-java-7-installer
安裝Oracle JDK 8:
sudo apt-get install oracle-java-8-installer
sudo update-alternatives --config java
sudo update-alternatives --config javac
設定 JAVA_HOME
vi /etc/environment
修改 JAVA_HOME="想採用的java path"
如: JAVA_HOME="/usr/lib/jvm/java-7-oracle"
Installing Java with
All other steps are optional and must only be executed when needed.
You can still install it using apt-get. To install any version, first execute the following commands:
文章來源:
https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get
https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get
安裝原生 default 的 JRE/JDK
這是較佳且容義的選擇,在 Ubuntu 12.04~ 會安裝 OpenJDK 6,而 Ubuntu 12.10+ 則會安裝 OpenJDK 7全程只需用 apt-get 安裝即可, 便利且穩定。
指令:
sudo apt-get update
sudo apt-get install default-jre
sudo apt-get install default-jdk
安裝 OpenJDK 7
指令:sudo apt-get install openjdk-7-jre
sudo apt-get install openjdk-7-jdk
安裝 Oracle JDK
前置工作:sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
安裝Oracle JDK 6:
sudo apt-get install oracle-java-6-installer
安裝Oracle JDK 7:
sudo apt-get install oracle-java-7-installer
安裝Oracle JDK 8:
sudo apt-get install oracle-java-8-installer
管理 JAVA使用版本
設定 java 與 javacsudo update-alternatives --config java
sudo update-alternatives --config javac
設定 JAVA_HOME
vi /etc/environment
修改 JAVA_HOME="想採用的java path"
如: JAVA_HOME="/usr/lib/jvm/java-7-oracle"
原文如下:
This is the recommended and easiest option. This will install OpenJDK 6 on Ubuntu 12.04 and earlier and on 12.10+ it will install OpenJDK 7.Installing Java with
apt-get
is easy. First, update the package index:sudo apt-get update
Then, check if Java is not already installed:java -version
If it returns "The program java can be found in the following
packages", Java hasn't been installed yet, so execute the following
command:sudo apt-get install default-jre
This will install the Java Runtime Environment (JRE). If you instead
need the Java Development Kit (JDK), which is usually needed to compile
Java applications (for example Apache Ant, Apache Maven, Eclipse and IntelliJ IDEA execute the following command:sudo apt-get install default-jdk
That is everything that is needed to install Java. All other steps are optional and must only be executed when needed.
Installing OpenJDK 7 (optional)
To install OpenJDK 7, execute the following command:sudo apt-get install openjdk-7-jre
This will install the Java Runtime Environment (JRE). If you instead
need the Java Development Kit (JDK), execute the following command:sudo apt-get install openjdk-7-jdk
Installing Oracle JDK (optional)
The Oracle JDK is the official JDK; however, it is no longer provided by Oracle as a default installation for Ubuntu.You can still install it using apt-get. To install any version, first execute the following commands:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
Then, depending on the version you want to install, execute one of the following commands:Oracle JDK 6
This is an old version but still in use.sudo apt-get install oracle-java6-installer
Oracle JDK 7
This is the latest stable version.sudo apt-get install oracle-java7-installer
Oracle JDK 8
This is a developer preview, the general release is scheduled for March 2014. This external article about Java 8 may help you to understand what it's all about.sudo apt-get install oracle-java8-installer
Managing Java (optional)
When there are multiple Java installations on your Droplet, the Java version to use as default can be chosen. To do this, execute the following command:sudo update-alternatives --config java
It will usually return something like this if you have 2 installations (if you have more, it will of course return more):There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 manual mode
Press enter to keep the current choice[*], or type selection number:
You can now choose the number to use as default. This can also be done for the Java compiler (javac
):sudo update-alternatives --config javac
It is the same selection screen as the previous command and should be
used in the same way. This command can be executed for all other
commands which have different installations. In Java, this includes but
is not limited to: keytool
, javadoc
and jarsigner
.Setting the "JAVA_HOME" environment variable
To set theJAVA_HOME
environment variable, which is needed for some programs, first find out the path of your Java installation:sudo update-alternatives --config java
It returns something like:There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 manual mode
Press enter to keep the current choice[*], or type selection number:
The path of the installation is for each:/usr/lib/jvm/java-7-oracle
/usr/lib/jvm/java-6-openjdk-amd64
/usr/lib/jvm/java-7-oracle
/etc/environment
:sudo nano /etc/environment
In this file, add the following line (replacing YOUR_PATH by the just copied path):JAVA_HOME="YOUR_PATH"
That should be enough to set the environment variable. Now reload this file:source /etc/environment
Test it by executing:echo $JAVA_HOME
If it returns the just set path, the environment variable has been
set successfully. If it doesn't, please make sure you followed all steps
correctly.文章來源:
https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get
2014年11月4日 星期二
Android 4.4 CTS Test (二)
五、測試命令的執行
1.進入CTS測試環境
開啟終端輸入命令:
/home/android-cts/tools/cts-tradefed (注意權限問題)
如果權限不夠的話輸入:sudo /home/android-cts/tools/cts-tradefed
輸入用戶密碼
當出現
cts_tf >
就代表已經進入CTS測試環境
2.CTS測試的方法:
完整測試(依硬體裝置的不同, 需6~12小時):
run
cts --plan CTS
查看測試計劃: list p/plans
Ex: l p
查看測試包: list packages
執行測試計劃: run cts --plan [test_plan_name]
舉例:
run cts --plan Android
測試某個測試 package:
run cts --package/-p [package_name]
例如android.bluetooth
run cts -p android.bluetooth
測試某個測試類: run cts --class/-c [class_name]
例如android.bluetooth.cts.BasicAdapterTest
run cts -c android.bluetooth.cts.BasicAdapterTest
測試某個測試類的某方法, run cts --class/-c [class_name] --method/-m [method_name]
例如android.bluetooth.cts.BasicAdapterTest測試類的test_checkBluetoothAddress方法:
run cts -c android.bluetooth.cts.BasicAdapterTest -m
test_checkBluetoothAddress
list/l results/r (查詢未完成的
session ID)
Session Pass
Fail Not Executed Start
time Planname
0 7 0 0 2012.01.16_16.09.19 NA
1 13 0 0 2012.01.16_16.13.01 NA
2 19 9 17120 2012.01.18_13.43.56 CTS
(依Start time找出您需要的session ID)
繼續之前未完成的測試:
run cts --continue-session session_id
如: run cts --continue-session 3
測試某個plan中所有的
fail/notExecuted/timeout項:
指令: add derivedplan --plan plan_name -s sessionID -r [fail/notExecuted/timeout]
如: 要測 session 2的所有fail/notExecuted/timeout項
add derivedplan --plan
test_session_2_all (plan_name請自訂)
若只想測fail項:
add
derivedplan --plan test_session_2_fail -r fail
4.Android-CTS用戶指南
網址: https://source.android.com/compatibility/downloads.html
5. cts-media 媒體影音測試檔 (放在網頁最底部)
網址: https://source.android.com/compatibility/downloads.html
六、測試結果分析
Android-CTS運行後會產生一測試報告,測試報告以測試開始的日期+時間命名,如:
2011.12.21_12.09.44, 一般只要查看testresult.xml文件就可對測試結果進行分析。由於CTS測試所需要花的時間比較長,當對測試進行調試時可針對的進行測試可節約大量時間。
以下將介紹幾種常用的方法:
(1).
測試摘要報告 (在/home/android-cts/repository/results/2014.11.03_08.56.16)
(2). log檔: 在 /home/android-cts/repository/logs
(3). 測試與debug
a. 首先確定是哪個測試package出現失敗,然後針對該測試package進行重新測試
$ adb install /android-cts/repository/testcases/package.apk
$ adb shell pm list instrumentation pm
用於管理 package,看當前機器安裝了什麼
用例
$ adb shell am instrument
w
android.tests.sigtest/.InstrumentationRunner
b. 定位某個測試失敗項進行單獨運行
Start –plan [test plan name] –t
[plan_package_name].[class_name]#[plan_package_test_name]
注意尋找class_name,可從測試報告中找到
舉例:
測試某個class:
cd /home/android-cts/tools
./cts-tradefed
入指令:run cts -c
package_name -m method
此例: run cts -c
android.app.cts.SystemFeaturesTest -m testLocationFeatures
七、簡易處理
1. 處理 Not executed的方法:
Android 4.4 full test 需進12小時測試, 若中間出現 not
executed項, 不需要再重跑另一次12小時全部重測, 可以使用一下命令, 針對not
executed項測試, 並更新報告內容
run cts --continue-session session_ID (session_ID可用 list
results查)
若是跑完還有, 可再進行一次上述步驟, 直到所有NotExecuted項都run過。
獨家密籍: 開始執行後, CTS開始跑了, 輸入指令: l r,找出所有session ID,
此時可用 run cts
--continue-session session_ID_+1 , 重覆此指令3次, 保證第一次測試不會出現Not Executed項。
2. 處理因操作不當造成的失敗項處理法:
當測完時, Failed項比較多時, 可針對Failed項單測
指令: add derivedplan --plan plan_name -s
sessionID -r [pass/fail/notExecuted]
如: 測項SessionID = 2 的所有fail項:
add derivedplan --plan user123 -s 2 -r fail
run cts --plan user123
此法不會更新報告, 而是重新單測這些失敗項, 並另產生報告
3. 需要連Google等網路測試項的處理法:
因VPN的不穩定, 無法確保連續12小時的測試過程中, 可完全對外連線正常, 因此連網測試常常會無法Pass, 此部份可在全測結束後, 單獨測試這些網路相依的項目
打開testResult.xml, 找到測項失敗原因是” www.xxx.com”的項, 用文字編輯器打開testResult.xml,
找到這些失敗項, 並將測試結果由 Fail改成notExecuted並存檔, 然後連好VPN, 再用第一解法(處理 Not executed的方法)處理.
4. 寫入測試結果時報Toomany open
files的錯誤,這是因為網絡請求過多,也就導致了系統打開的文件過多。每一個連接都會當成「文件」看待的。
解決方案:用ulimit –a 命令查看每個用戶允許打開的最大文件數,
看到是的1024,把它改大點,用命令:ulimit-n
4096
5. 為了避免一些沒必要的錯誤,在測試前先更改一下設備設置:
(a). Make sure the」Wi-Fi」 development option is
checked(Settings->Wireless and network->Wi-Fi).
(b). Make sure the 「Wi-Fi」 is connected (Settings->Wireless and
network->Wi-Fi settings).
(c). Make sure 「Bluetooth」 development option is
checked(Settings->Wireless and network->Bluetooth).
(d). Make sure the「Wi-Fi sleep policy」is set to 「Never」(Settings->Wireless and
network->Wi-Fi settings->Menu->Advanced->Wi-Fi sleep policy).
(d). Make sure the "Screen
Timeout" is set to "Never "or 「The max time
of time out」(Setting->Display settings->Screen
timeout).
(e). Check "Stay Awake",
"Allow mock locations" and "User Debugging" from
Settings->Application->Development
(f). Make sure "Use wireless networks
" development option is checked (Settings->Location and
security->Use wireless networks ).
(g). Set the language to
English(Settings->Locale and text-Select language).
(h). Copy the “svox” file to the
device,make sure the “English(United States)”and “English (United Kingdom)”has
been Installed.(Settings->Voice input and output settings->Text-to-speech
settings->Pico TTs)
(i). Install CtsDelegatingAccessibilityService.apk,
then the “Accessibility” and” Delegating Accessibility Service” development
options are checked (Settings->Accessibility->Delegating Accessibility
Service) (Android 2.3~4.0.3 only)
(j). Set the Date and Time.(Settings ->
Date&time ->Set date / Set time),set the “Select time zone” to
“Beijing”(Setting->Select time zone).
(k). Clear browser cache and history
(Internet->Menu->Settings)
(l). SD card and have enough space and copy
smaple audio and video media files
(m). Make sure no lock pattern is set on
the device.
(n). Make sure the device is at the home
screen at the start of CTS (Press the home button).
(o). Do not press any keys on the device
while CTS is running.
(p). Click the voice Recorder
application,to record and save.
(q). Make sure My location is Located on
“Maps”
(r). Make sure “turn off USB”
八、 GTS測項
須向Google取得, 與CTS相似, 但GTS頂多測試一個半小時, 多為播放線上影音測試, 因此, 對VPN與網路的要求較高。
九、CTS Verifier測試
1. 首先測 Data backup test,
否則後來就無法測此項:
adb shell bmgr enable true
adb shell bmgr transport android/com.cndroid.internal.backup.LocalTransport
adb shell bmgr run
adb uninstall com.android.cts.verifier
adb install
/home/android-cts-verifier/CTSVerifier_4.0.3_r1.apk
2. CTS Verifier測試工具在Google官網可下載
https://source.android.com/compatibility/downloads.html
3. CTS Verifier 需要VPN 線上播放影片
十、自行compile CTS測試 packages
想深入了解怎麼測試, 詳細測試步驟, 測試內容, 甚至想修改測試者。
不過.... 自己改了也沒用, 因為測試是以Google官方提供的 bin 為主。
1) 先上網抓包 Android Source (詳細方法請上Google查查) (假設download到/home/android4.4/
https://source.android.com/source/building.html
2) 先compile 一般Android code
cd /home/android4.4
source build/envsetup.sh
lunch (選好平台)
make
3) compile CTS packages
make cts
4) CTS 結果說明:
compiled CTS packages在 /home/android4.4/out/host/linux-x86/ (以下以[P]代表)
Package CTS(Google官網的那個android-cts.zip): [P]/out/host/linux-x86/cts/android-cts.zip
cts make file: /home/android4.4/build/core/tasks/cts.mk
run cts program: [P]/bin/cts
test plans: [P]/cts/android-cts/repository/plans
test packages: [P]/cts/android-cts/repository/testcases
test results: [P]/cts/android-cts/repository/results
CTS program setting value: /home/android4.4/cts/tools/util/host_config.xml
REF:
http://wenku.baidu.com/view/88b3089a6137ee06eef9181d.html
http://wenku.baidu.com/view/443310ed5ef7ba0d4a733ba7.html
訂閱:
文章 (Atom)