4.22.2009

android permission

我試著建立一個假的character device.
然後想讓它可以被使用在 Android emulator上。

首先, 我在.config 檔加了CONFIG_MODULES,並重編譯了Android Kernel
然後, 我寫了個module 來控制"/dev/mydev"(它扮演著一個 80char 的buffer),並跨平台組譯成arm 架構。

我ran了emulator ,然後將 busybox 放進去(用來建立/dev/mydev 透過 mknod),並用insmod 載入module

目前,透過使用 open/close/write/等.. shell 和 common activities 都可以對它互動

我想要建一個特別的permission給這個device,然後人不能透過 common Activities 來讀取它。
有任何的文件/提醒/連結嘛?

我知道Android 有一個特別的HAL,但沒有文件。

I'm trying to create a fake character device.
I want to make it usable within the provided Android emulator.

Firstly, I recompiled the Android Kernel editing the .config file,
adding CONFIG_MODULES.
Then, I wrote a module managing "/dev/mydev" (it acts as a 80 char
buffer) and crosscompiled it for arm architecture.
I ran the emulator and pushed busybox (for creating the /dev/mydev
with mknod) and loaded the module with insmod.


Now, both shell and common activities can interact with it, by using
standard open/close/write/etc...


I would like to create a specific permission for that device and make
it not readable from common Activities.
Is there some documentation/hints/links?


I know Android has a specific HAL but there's no documentation.




就application style permissions來說,你一般要做的就是去define一個新的gid, 就是你的device 會被發布的gid(如此它就不會被讀/寫),
加一個entry 在 \frameworks\base\data\etc\permissions.xml 去對映到 permission string,
然後加一個item在 frameworks/base/core/res/AndroidManifest.xml 來描述這個permission.
gid 的group 是被defined 在user space, 有個 system/init 來defines 這些standard groups.

For application style permissions, what you generally do is define a new gid
that your device is published under (so it is not world readable/writeable),
add an entry to etc/permissions.xml mapping that gid to a permission string,
and add an item in the frameworks AndroidManifest.xml describing that
permission.

The meaning of groups is purely defined by user space. There is a
system/init header that defines the standard groups.

4.19.2009

股票模擬遊戲

最近開始再研究股票

就再想怎麼沒有一個網站模擬台股來弄個線上遊戲,每天life 跟真實台股連線
每個人從20萬台幣開始玩,最後也有融資融卷等工具可用

這樣就有地方可以練習,又可累積經驗,但又不用擔心真的了錢
等練到贏率大於80%時就可真的下場投資了

最好是可以真的摸擬實際的市場機制,也就是說當這個遊戲愈多人玩,表示愈多散戶投入,那也應該要反應在遊戲裡面
或者不要反應,也許會比較準對於練習來說


找了一下,如果要玩美股的話有這個網站

Practice Investing, Stock Market Game


如果不用自己的錢去玩,真的可以學到東西嘛?
如何讓人真的serious 去玩就像真的一樣?

4.13.2009

How Linux kernel Init

要了解kernel 如何init
先了解kernel image 的架構


vmlinux 是kernel 本身再加了一些符號什麼的
然後把那些符號拿掉就成了image 的binary
之後用gzip 壓成piggy.gz
然後用asmbaly build 成piggy.o


*bootstrap loader and bootloader的不同
bootloader 只負責POWER ON

*bootstrap loader(second-stage loader),head.o @bootstrap loader
1.creat the proper environment to decompress,
2.relocate the kernel,
3.pass control to head.o@kernel




*head.o @kernel

1.Checks for valid processor and architecture
2.Creates initial page table entries
3.Enables the processor's memory management unit (MMU)
4.Establishes limited error detection and reporting
5.Jumps to the start of the kernel proper, main.c

在這個時候只有有限的memory maping.. 所以如果想在這加個firmwave 去down load到特定的device,是會crash的
要init driver 就透過device driver model

*start_kernel() @ .../init/main.c

USB 裝置會挑電腦?

常聽人說我的手機接我的電腦不能連 ActiveSync,但接別台電腦就可連
就說這隻手機會挑電腦

其實這只說對了一部份

當連線的時候,如果USB的訊號差,則USB的protocol 一般都可cover 掉,只要重傳就好了,只是效能沒那麼好而已
但如果訊號差都一定的程度,那就會連不起來
所以我們知道USB的protocol 對壞的訊號有一定的容忍度。

而訊號的好壞取決於三個部份,手機端(device), cable/cradle, 電腦端(host)
手機的lay out 是不是符合標準
cable/ cradle 是不是有太多connector 轉接
電腦端是不是也轉接connector (一般桌機,USB port 前面的比後面的訊號差 )
這三個部份加起來,如果訊號壞到超過potocol的容忍度,就連不起來了

而理論上來說,device 及cable 再出貨時就是要有最佳的匹配,將errors 降到最低,
這樣就有空間,留給電腦的部份,也就比較不會挑電腦了

4.12.2009

用英文,而不是學英文

一直覺得英文只是個工具
而工具,有人用的好,也有人用的不好
重點就是"用"

一個字或片語或句子結構 會不會用就決定你英文的好壞

但沒人規定說要用一個工具就一定要很會用
重點就是看你用它來做什麼


以TOEFL 為例,
就是要了解各個學科的字
及熟練如何表達自己的意思

而TOEIC,
則要多了解商業領域的字
及日常生活的用語


一些有趣的元素可以加入
1. 玩-動機, 新奇好玩
2. 演戲-角色扮演
3.

4.09.2009

工人還是功能

最近同事去巴里島度蜜月,回來帶了些雕刻飾品。
說到,當地的人雕刻東西很厲害,一面石牆不打草稿,就刻出了很漂亮的圖案。

我想這有兩種形況
1. 他已經看到他想要的圖案在石牆上,所以他就刻出他要的東西,而且也可以刻出任何他想要的東西,是藝術家,東西是藝術品。
2. 這個圖案他已經做了很多遍,已經很熟每個需要刻的位置,他只是repeat 出每個動作,可以做的很快,甚至於可以寫出SOP,只是會的圖案有限,這種人是工人,東西是產品。

我相信很多時候,是兩個同時存在在同一個人上,只是比例問題而已。
想想自己,身為工程師,有多少時間是再trace code, debug, try and error, 又有多少時間是真的從無到有做出自己想要的東西出來。