»
S
I
D
E
B
A
R
«
啟用 mobile 版面
May 23rd, 2010 by kanru

偶爾也想在手機上看自己的 blog (?!) 所以裝了個行動版的 plugin WPTouch

Blog 手機版

看起來還不賴!

AndroidDev: Recent progress on Gallery3D
May 19th, 2010 by kanru

Gallery3D is the gallery application released with Éclair, contributed by Cooliris.

This application heavily uses OpenGL to render the scenes. It looks great on Nexus One. But 0xdroid does not yet support hardware accelerated 3D graphics and rely on libagl to rasterize the 3D graph.

Agl is the software OpenGL rendering engine used by android emulator. Gallery3D assumes there is hardware support and this caused a lot of trouble when one want to run it with agl. Even if the libagl implementation is correct and complete, Gallery3D may also assumes some implementation depended behavior. Not to mention the fundamental libagl implementations may have problems.

Anyway, we have some progress and I’d like to share the screenshots. Devkit8000 DVI output, 640×480 resolution, captured by DDMS.

I have a feeling there are more OpenGL tricks inside the source code then I’d expected.

AndroidDev: Provision the device
May 12th, 2010 by kanru

在 Devkit8000 上把 HOME key 設定好後卻無法作用,仔細看了下處理 HOME key 的地方是 polices 下的 PhoneWindowManager.java,會去檢查這個 device 是否被 “Provision” 了。

這個 Provision 的動作其實就是 Device 第一次啟用時做初始設定,在 Google phone 上面就是 SetupWizard,在 emulator 裏面則有簡單的 Provision.apk,之前無法作用就是因為一直沒有把 Provision.apk 放進去…

Provision.apk 做了什麼事呢?其實很簡短:

public class DefaultActivity extends Activity {

    @Override
    protected void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        // Add a persistent setting to allow other apps to know
        // the device has been provisioned.
        Settings.Secure.putInt(getContentResolver(),
                               Settings.Secure.DEVICE_PROVISIONED, 1);

        // remove this activity from the package manager.
        PackageManager pm = getPackageManager();
        ComponentName name = new ComponentName(this,
                                     DefaultActivity.class);
        pm.setComponentEnabledSetting(name,
                   PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);

        // terminate the activity.
        finish();
    }
}

因此若要提供一個類似 SetupWizard 的初始化介面在 Devit8000 上面,只要延伸這個 Provision.apk 做的事,提供 GUI 等等,最重要的就是設定這個 “Settings.Secure.DEVICE_PROVISIONED”

這是一個筆記。

Fourth 0xdroid Release for BeagleBoard and Devkit8000!
Apr 27th, 2010 by kanru

Today we are celebrating the 0xLab’s one year old birthday! I’d like to write about the recently announced fourth 0xdroid release.

What’s new in this release? The biggest one is that it is based on Éclair code base! While Éclair uses a lot more 3D stuff for its UI, the performance drop between Donut and Éclair is huge. After lots of testing and hacking, we finally bought the Éclair performance back to its original level. For detailed benchmark results, checkout the wiki page Benchmarks.

Second is new hardware support. 0xdroid now officially supports Devkit8000, a BeagleBoard clone. Developers did many works to bring up the all functionality include LCD/DVI output, touchscreen calibration, USB, Ethernet, etc. Running Éclair on Devkit8000 looks great!

Oh, and the new installer! The new installer used in this release supports both BeagleBoard and Devkit8000, with different display resolution and hardware revision. It can do a lot more than previous installer can do, for example it can download images from network, install to SD/MMC card and indicate progress via graphic display or via blinking LEDs. All of this will fit into a 1MB binary!

Enjoy the release video on the youtube:

Want to contribute? Download it and try now!

The good old xorg.conf and the new xorg.conf.d
Apr 8th, 2010 by kanru

自從 Xorg xserver 宣佈要放棄使用 hal 的自動設定機制後,Xorg 開發者們就開始討論與實做各種可能的 config backend。最後定案的是在 Linux 上直接使用 udev 來偵測 input device,在這個後端實做的早期也想把設定的工作一起做在 udev rules 裡,但顯然這樣的做法是有其侷限的。很多人說這只是把 hal 的 .fdi 換個寫法放到 udev rules 裡罷了,同樣是對 user 極不友善的做法,而且使用 udev 在非 Linux 的平台就不能用了。

最後一個很聰明的辦法是把 auto probe 與 config 這兩個行為分開,讓 udev 只管找到新的裝置,config 則集中放在 xorg.conf.d 中。xorg.conf.d 中設定檔的格式和 xorg.conf 是一樣的,因此不但 code 可以重用,使用者也不用學新的語法,其他平台則可以用不同的 backend。

因為 udev backend 是以 Debian Developer – Julien Cristau 為主開發的, Debian 很早就可以使用 udev backend 了,最近 Debian 更從 xorg-xserver 1.8 backport 了 xorg.conf.d 的修改,所以設定方式又不太一樣了。(大概只有 Debian 是這樣一改再改吧,其他 distro 應是無痛升級)

參考 xorg.conf(5),X 在啟動時會去找

           /etc/X11/<cmdline>
           /usr/etc/X11/<cmdline>
           /etc/X11/$XORGCONFIG
           /usr/etc/X11/$XORGCONFIG
           /etc/X11/xorg.conf-4
           /etc/X11/xorg.conf
           /etc/xorg.conf
           /usr/etc/X11/xorg.conf.<hostname>
           /usr/etc/X11/xorg.conf-4
           /usr/etc/X11/xorg.conf
           /usr/lib/X11/xorg.conf.<hostname>
           /usr/lib/X11/xorg.conf-4
           /usr/lib/X11/xorg.conf

這些地方的設定檔,因此設定不用全放在一個檔案裡了。這也是近來很多 daemon 要支援多重設定檔常用的方法,可以讓 vendor 或 distro 的設定與 user 的設定可以各自獨立出來。

接下來我們有興趣的地方是 InputClass 這個新的 Section,就是它讓我們可以設定隨插即用裝置。

           Section "InputClass"
               Identifier  "name"
               entries
               ...
               options
               ...
           EndSection

就像 xorg.conf 內其他 Section 一樣,Identifier 是必需的,我們可以用各種 Match rule 去比對裝置的特性並用 Option 加以設定。所有的 InputClass 都可以被其之後的 InputClass 取代,因此使用者可以用新設定檔取代系統的設定。

現在可以用的 Match rule 有

MatchProduct        "matchproduct"
MatchVendor         "matchvendor"
MatchDevicePath     "matchdevice"
MatchTag            "matchtag"
MatchIsKeyboard     "bool"
MatchIsPointer      "bool"
MatchIsJoystick     "bool"
MatchIsTablet       "bool"
MatchIsTouchpad     "bool"
MatchIsTouchscreen  "bool"

前四個可以用來 match 特定的裝置名稱、路徑,其他的則可以用來 match 一般的裝置特性如滑鼠、鍵盤等。如我要設定 touchpad 的話,可以用

# /etc/X11/xorg.conf.d/10-synaptics.conf
Section "InputClass"
    Identifier "Synaptics"
    MatchIsTouchpad "true"

    Option "TapButton1" "1"
    Option "HorizEdgeScroll" "true"
EndSection

來設定。再加上 X 會自己找到可以用的 driver,和以前方法比起來,是不是簡單很多呢? :)

Got one A1 from Broncho
Mar 15th, 2010 by kanru

上週末下班前,在桌上發現一個包裹,原來是渡海而來的兩隻 A1!這兩隻 A1 是 Broncho 的產品,詳細規格可以參考 Broncho 的網頁

大伙興奮的開箱啦!

開箱 開箱

包裝和 Hero 的很像。3.2 寸 LCD, 480×320 的解析度,200 萬畫素的相機鏡頭,CPU 是 Marvell 300 (624 MHz),記憶體是 256 + 128 MB,支援 WIFI, Bluetooth, FM, GPS。不是使用標準的 USB 接口,但同一個接口可以接 USB、耳機、變壓器。觸控螢幕使用起來的感覺像是電容式的,反應非常靈敏,輕輕的觸摸就有反應。

系統是 Android Cupcake,內建軟體有不少 Google App,最另人驚訝旳是上面有 Android Market 可以用,試著從 Market 上面下載了一些小遊戲下來玩,完全沒有問題,真是太牛了!另外一點就是有內建手寫輸入,速度不快但是準確度不錯。除此之外還有谷歌拼音可以用。

測試的途中無線網路與 GPS 不是很穩,除此之外以一隻中低價位的手機來說表現的相當不錯。

Debian 用 wpa_cli 之 romaning mode,不用 network-manager
Mar 9th, 2010 by kanru

/etc/wpa_supplicant/wpa_supplicant.conf 加入 network 設定

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    network={
            ssid="Example"
            psk="password"
            id_str="office"
    }

    network={
        key_mgmt=NONE
    }
    # 可以參考 /usr/share/doc/wpasupplicant/examples/wpa-roam.conf

然後在 /etc/network/interfaces 加加 mapping

    allow-hotplug wlan0
    iface wlan0 inet manual
            wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

    iface office inet dhcp

之後開機就會自動 connect 到合適的 AP 了

Back to Debian from the Arch Linux World
Jan 9th, 2010 by kanru

在退伍後買了新電腦,裝的不是 Debian 而是 Arch Linux,主要是因為在當兵期間參與 Debian 的活動少了,並看看這個新興的 distro 有什麼有趣的地方,讓我在網路上總是遇上 Arch 的使用者。結果一用之下竟能快速上手,還加了幾個套件到 AUR 中,用著用著有些不想換了。以下寫寫我在用 Arch 時最想念 Debian 的地方,還有希望 Debian 也有的特色。

最想念 Debian 的:

  1. 廣大的使用者與開發者社群:

    Arch 的使用者也許不少,但開發者就不多了。看看 devel 的 mailing list,上面活躍的只有幾位,所謂的 TU 也是不多。再加上我所知道的 hacker,或是同 project 的 developer,很多都是 Debian 的使用者或是開發者…

  2. 行之有年的社群管理制度:

    Arch 除了 TU 和幾位 core developer… 其他都是渾沌不明的狀態

  3. 好用的 Bug Report 系統:

    debbugs 太好用了,flyspray 的介面我還是很不習慣

  4. 社群契約:

    這很重要,定出了 Debian Project 的目標,是一種信念

  5. 支援的 architecture 衆多:

    名為 Arch 的只支援 2 種 arh..

希望 Debian 有的:

  1. 快速的套件管理系統:

    這其實包含很多層面;Arch 只用 pacmanmakepkg 就可以打理一切,反觀 Debian,套件管理分成 dpkg-*, dselect, apt-*, aptitude,建構套件又有 dpkg-buildpackage, debuild, *build, *-buildpackage

    Arch 的使用者雖說 pacman 的 db 沒效率,可在我來看己是飛快了, Debian 的 dpkg, apt 在套件多起來時真是慢的可以…

  2. 極新的 userspace:

    Debian 的也是更新很快,但會有週期性的 slowdown,到現在 python 2.6 還在 experimental…

  3. Artworks:

    Arch 的使用者很會打造網站,桌面,Logo,Icon 等,非常用心,Debian 似乎就弱了點…

在使用 Arch 的這段時間,我體驗到的 DIY 的樂趣,發現原來 Debian 的套件做了這多事。比起 Arch 要自己去 /boot, /etc, /usr/bin 下東改西改,Debian 會用各種 script 如 update-* 來幫你。用久了 Debian 真的變成只會用的 script… 戒之戒之。

得知申請己久的 DD 資格終於有進展,我決定回到 Debian,並把在 Arch 學到的優點在 Debian 實現,打造我的 Debian :-)

iotop – monitor your disk usage
Dec 2nd, 2009 by kanru

Disk I/O 往往是效能的殺手,但是我們卻很難抓出現在到底是哪個程式正在 I/O。 iotop 是一隻 python script,用類似 top 的介面顯示各 process 的 I/O 狀況,還會顯示每個process 的 throughput 是多少。

要使用 iotop,編譯 kernel 時要選 CONFIG_TASKSTATS 與 CONFIG_TASK_IO_ACCOUNTING。

以下是截圖: iotop screenshot

註:PowerTop 將內建類似功能,參考 http://blog.fenrus.org/?p=38

Created a 4096 bit GPG key to replace my 1024 bit one
Nov 21st, 2009 by kanru

In light recent new attacks against SHA-1 [1,2], and the NIST guidance on 1024 bit keys and SHA-1 hashes [3,4], I have decided to move to a new OpenPGP key of a larger size. As such, I will be slowly transitioning away from my old key.

因應最近的幾起 SHA-1 攻擊 [1,2], 興起了一陣更新 OpenPGP 金鑰的風潮. 我也會慢慢過渡到新的金鑰.

My old key will continue to be valid for some time to come, but I’d prefer all new correspondence to use the new one. I’ll also be switching my outgoing signatures (email and code) onto the new key. For this to work well, I’d like my new key to be re-integrated into the web of trust. So, I’ve signed this message with both the old and the new keys, to certify the transaction.

舊的金鑰還可以持續使用一陣子, 但我還是希望未來大家都可以改用新的金鑰. 我也會改用新的金鑰來簽署 email 和文件. 為了讓一切順利進行, 最好是新的金鑰可以被加到信任網中.

the old key was:

舊的金鑰是:

pub   1024D/365CC7A2 2004-06-28 Kanru Chen (koster)
 Primary key fingerprint: 3278 DFB4 BB28 6E8C 9E1F  1ECB B1B7 5B5F 365C C7A2

And the new key is:

新的金鑰是:

pub   4096R/CEC6AD46 2009-10-19 Kan-Ru Chen (陳侃如)
 Primary key fingerprint: 374F F2AD 0A12 935F D0B0  C84F 1B13 2E01 CEC6 AD46

To fetch my new key from a public key server, you can simply do:

使用以下命令, 可以從公開金鑰伺服器取得我的新金鑰:

  gpg --keyserver pgp.mit.edu --recv-key CEC6AD46

If you already know my old key, you can now verify that the new key is signed by the old one:

如果您己經有我的舊鑰, 您可以確認我的新鑰己由舊鑰簽名.

  gpg --check-sigs CEC6AD46

If you don’t already know my old key, or you just want to be double extra paranoid, you can check the fingerprint against the one above:

如果您不知道我的舊鑰, 或只是想再次確認, 您可以檢查上面的指紋.

  gpg --fingerprint CEC6AD46

If you are satisfied that you’ve got the right key, and the UIDs match what you expect, I’d appreciate it if you would sign my key:

如您確定拿到對的金鑰了, UIDs 也如預期, 能就此簽署我的新鑰是在好不過.

  gpg --sign-key CEC6AD46

Lastly, if you could upload these signatures, I would appreciate it. Please could you just upload the signatures to a public keyserver directly:

若您簽署之後可以把簽名上傳到公開金鑰伺服器就太好了.

  gpg --keyserver pgp.mit.edu --send-key CEC6AD46

Please let me know if there is any trouble, and sorry for the inconvenience.

過程中若有什麼問題請讓我知道, 抱歉帶來不便.

Thanks, Kanru

Sign 過的版本, 用 gpg --verify 驗證

  1. http://eurocrypt2009rump.cr.yp.to/837a0a8086fa6ca714249409ddfae43d.pdf
  2. http://www.debian-administration.org/users/dkg/weblog/48
  3. http://csrc.nist.gov/groups/ST/hash/statement.html
  4. http://csrc.nist.gov/publications/nistpubs/800-57/SP800-57-Part1.pdf
»  Substance: WordPress   »  Style: Ahren Ahimsa
© Copyright 2004-2009 Kan-Ru Chen