android 的每個 app 好像都是一個包含完整的 framework 程式。
舉例來說:
framework 的 keyinput 機制,包含在每個 app 中。
所以當按下 HOME 鍵,會因為 app 中的 input framework 會收到 KEYCODE_HOME。
因為 framework 的 input framwework 有處理 HOME key,並且寫好了對 KEYCODE_HOME 的動作: sent intent to HOME。
所以會叫起 Launcher。
....
也就是說,按HOME 鍵,其實是 app 處理 (並沒有一個 處理 home key 的 server process)。
app 裡的 input framework code ,叫起 HOME launcher。
ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上
2011年12月14日 星期三
create button without using xml
完全寫在 code 裡的方法, layout 和 button 都不用 xml 定義。
from : http://toimy.blogspot.com/2010/07/android.html
from : http://toimy.blogspot.com/2010/07/android.html
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.LinearLayout;
import android.view.View;
public class testAndroidActivity extends Activity implements View.OnClickListener
{
final String TAG = "testAndroid";
LinearLayout layout;
Button btn;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
btn = new Button(this);
btn.setText("Button");
btn.setOnClickListener(this);
layout.addView(btn,150,50);
setContentView(layout);
}
public void onClick(View v) {
Log.v(TAG, "onClick");
}
..
2011年12月13日 星期二
create android project from command line
就是 follow 這一篇: http://developer.android.com/guide/developing/projects/projects-cmdline.html
用 android sdk 提供的 tool : android,來 create project ,
也就是說,幫你把 一堆 xml, java, folder 都create 好,然後填一些基本的東西。
command example:
這樣做完後,follow 上一篇,加上 Android.mk ,就可以 build 了。
.. 會出現 error:
把原來寫死的 layout/main.xml 字串,改在 value/string.xml 中,就可以了。
另外這一篇 http://www.kandroid.org/online-pdk/guide/build_cookbook.html 有提供一些 template 寫 Android.mk
用 android sdk 提供的 tool : android,來 create project ,
也就是說,幫你把 一堆 xml, java, folder 都create 好,然後填一些基本的東西。
command example:
android create project \
--target 1 \
--name MyAndroidApp \
--path ./MyAndroidAppProject \
--activity MyAndroidAppActivity \
--package com.example.myandroid
target 的內容可以用 command:
android list targets
----------
id: 1 or "android-3"
Name: Android 1.5
Type: Platform
API level: 3
Revision: 4
Skins: HVGA-L, QVGA-L, HVGA-P, QVGA-P, HVGA (default)
ABIs : armeabi
----------
id: 2 or "Google Inc.:Google APIs:3"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 3
Description: Android + Google APIs
Based on Android 1.5 (API level 3)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: QVGA-P, HVGA (default), HVGA-L, QVGA-L, HVGA-P
ABIs : armeabi
----------
id: 3 or "android-4"
Name: Android 1.6
Type: Platform
API level: 4
Revision: 3
Skins: WVGA800 (default), QVGA, HVGA, WVGA854
ABIs : armeabi
path 選項,如果 path 不存在,就會幫你create。這樣做完後,follow 上一篇,加上 Android.mk ,就可以 build 了。
.. 會出現 error:
Android make apk error:This attribute must be localized.
參考這一篇:http://jjnnykimo.pixnet.net/blog/post/31996155-android-make-apk-error%3Athis-attribute-must-be-localized.把原來寫死的 layout/main.xml 字串,改在 value/string.xml 中,就可以了。
另外這一篇 http://www.kandroid.org/online-pdk/guide/build_cookbook.html 有提供一些 template 寫 Android.mk
2011年12月8日 星期四
some tools from SE released source
Sony-Ericson release 的 source code有一些東西:
2 的話,可能可以用在bluetooth 搖桿上...
bt 搖桿 --> serial 裝置 --> attach 到 kernel input interface
這樣就可以直接 support 利用 kernel input interface 操縱的 ap/system (android support ?)
- kexec-tools : running system 抽換 kernel 的 tool , (當然 kernel 要有 enable kexec 才行)
- inputattach : 把新的 serial input device 加到 kernel 的 input system 中 (例如搖桿)
2 的話,可能可以用在bluetooth 搖桿上...
bt 搖桿 --> serial 裝置 --> attach 到 kernel input interface
這樣就可以直接 support 利用 kernel input interface 操縱的 ap/system (android support ?)
2011年12月7日 星期三
init/main.c 的 start_kernel : setup_arch(&command_line)
kernel/setup.c 的 __init setup_arch(char **cmdline_p)
這裡的 boot loader 好像都沒有用,所以是用 PHYS_OFFSET。
這個 constant 每個 chip 定義不一樣。
kernel/setup.c 的 __init setup_arch(char **cmdline_p)
有加 _init,會不會後來又再 run 一次?code:
struct tag *tags = (struct tag *)&init_tags;
struct machine_desc *mdesc;
char *from = default_command_line;
mdesc = setup_machine(machine_arch_type);
machine_name = mdesc->name;
if (mdesc->soft_reboot)
reboot_setup("s");
if (__atags_pointer)
tags = phys_to_virt(__atags_pointer);
else if (mdesc->boot_params)
tags = phys_to_virt(mdesc->boot_params);
else
init_tags.mem.start = PHYS_OFFSET;
__atags_pointer 是 uboot 傳遞參數的位址,boot_params 也是。這裡的 boot loader 好像都沒有用,所以是用 PHYS_OFFSET。
這個 constant 每個 chip 定義不一樣。
/arch/arm/plat-mxc/include/mach/memory.h:17:#define MX1_PHYS_OFFSET UL(0x08000000)
./arch/arm/plat-mxc/include/mach/memory.h:18:#define MX21_PHYS_OFFSET UL(0xc0000000)
./arch/arm/plat-mxc/include/mach/memory.h:19:#define MX25_PHYS_OFFSET UL(0x80000000)
./arch/arm/plat-mxc/include/mach/memory.h:20:#define MX27_PHYS_OFFSET UL(0xa0000000)
./arch/arm/plat-mxc/include/mach/memory.h:21:#define MX3x_PHYS_OFFSET UL(0x80000000)
./arch/arm/plat-mxc/include/mach/memory.h:22:#define MX37_PHYS_OFFSET UL(0x40000000)
./arch/arm/plat-mxc/include/mach/memory.h:23:#define MX50_PHYS_OFFSET UL(0x70000000)
./arch/arm/plat-mxc/include/mach/memory.h:24:#define MX51_PHYS_OFFSET UL(0x90000000)
./arch/arm/plat-mxc/include/mach/memory.h:25:#define MX53_PHYS_OFFSET UL(0x70000000)
./arch/arm/plat-mxc/include/mach/memory.h:26:#define MXC91231_PHYS_OFFSET UL(0x90000000)
所以是 MX51 是 0x90000000 property_set/get in android
android 的 property 系統也是一種 IPC 的方法 (用在跟 system 溝通上).
一般 c program 可以用 property_set, property_get 來設定/取得 property 值。
property related function 實做在 system/core/libcutils/propertied.c
基本上就是用 local socket 跟 PROP_SERVICE_NAME 溝通。
property service 好像是在 init 就啟動了..
這個 source file : core/init/property_service.c 有所有 property 的操作。
像:
persistant property value (以 persistant. 開頭的 property)存放方式,位置:
一般 c program 可以用 property_set, property_get 來設定/取得 property 值。
property related function 實做在 system/core/libcutils/propertied.c
基本上就是用 local socket 跟 PROP_SERVICE_NAME 溝通。
property service 好像是在 init 就啟動了..
void start_property_service(void)
{
int fd;
load_properties_from_file(PROP_PATH_SYSTEM_BUILD);
load_properties_from_file(PROP_PATH_SYSTEM_DEFAULT);
load_properties_from_file(PROP_PATH_LOCAL_OVERRIDE);
/* Read persistent properties after all default values have been loaded. */
load_persistent_properties();
fd = create_socket(PROP_SERVICE_NAME, SOCK_STREAM, 0666, 0, 0);
if(fd < 0) return;
fcntl(fd, F_SETFD, FD_CLOEXEC);
fcntl(fd, F_SETFL, O_NONBLOCK);
listen(fd, 8);
property_set_fd = fd;
}
core/init 這個 process 最後,好像就是在做 property_service.. main() 的最後:
for(;;) {
...
...
nr = poll(ufds, fd_count, timeout);
if (nr <= 0)
continue;
for (i = 0; i < fd_count; i++) {
if (ufds[i].revents == POLLIN) {
if (ufds[i].fd == get_property_set_fd())
handle_property_set_fd();
else if (ufds[i].fd == get_keychord_fd())
handle_keychord();
else if (ufds[i].fd == get_signal_fd())
handle_signal();
}
}
}
ufds 就是剛剛 create_socket(PROP_SERVICE_NAME...) 的 fd這個 source file : core/init/property_service.c 有所有 property 的操作。
像:
persistant property value (以 persistant. 開頭的 property)存放方式,位置:
#define PERSISTENT_PROPERTY_DIR "/data/property"
2011年12月5日 星期一
"adb server is out of date. killing"
啟動 adb 時,會出現:"adb server is out of date. killing"。
因為 adb server 被重啟動,所以沒有辦法建立兩個連線。
查這段 message "adb server is out of date. killing",是在
不一樣就 print msg & restart
就在我加上 debug message (print out version),重新 run 後,就 OK 了
===> 所以說,我 pc 上的 adb 版本太舊了...
因為 adb server 被重啟動,所以沒有辦法建立兩個連線。
查這段 message "adb server is out of date. killing",是在
./system/core/adb/adb_client.c:251: printf("adb server is out of date. killing...\n");
是 compare version:
int adb_connect(const char *service)
{
// first query the adb server's version
int fd = _adb_connect("host:version");
....
char buf[100];
int n;
int version = ADB_SERVER_VERSION - 1;
// if we have a file descriptor, then parse version result
if(readx(fd, buf, 4)) goto error;
buf[4] = 0;
n = strtoul(buf, 0, 16);
if(readx(fd, buf, n)) goto error;
adb_close(fd);
if (sscanf(buf, "%04x", &version) != 1) goto error;
} else {
........
}
....
if(version != ADB_SERVER_VERSION) {
printf("adb server is out of date. killing...\n");
就是去詢問 host adb server 的版本,然後和自己比較。不一樣就 print msg & restart
就在我加上 debug message (print out version),重新 run 後,就 OK 了
===> 所以說,我 pc 上的 adb 版本太舊了...
標籤
- 3g (19)
- 工作的備worklog (93)
- 自言自語 (36)
- 草稿 (1)
- 亂亂寫 (8)
- 翻譯 (3)
- administration (76)
- alsa (7)
- android (299)
- apple (5)
- application (42)
- archlinux (1)
- audio (3)
- avr (6)
- backup_restore (2)
- bluetooth (5)
- bookmark (38)
- bootloader (21)
- browser (5)
- cellphone (28)
- command (8)
- Configuration (27)
- debug (7)
- django (1)
- driver (15)
- earphone (1)
- editor (1)
- EFL (1)
- ffmpeg (18)
- Filesystem (4)
- GCC (8)
- Gentoo (1)
- google (1)
- Graphic (3)
- hardware (40)
- hero (7)
- hibernation (9)
- iMX51 (38)
- Info (3)
- Install (30)
- java (4)
- Kernel (102)
- language (2)
- life (2)
- make (11)
- MantainLog (38)
- MCU_P (9)
- memo (8)
- microcontroller (3)
- MINGW (7)
- network (19)
- OpenCL (1)
- OS (11)
- package (3)
- pad (1)
- ProblemAndSolve (15)
- programming (8)
- Python (7)
- raspberry_pi (23)
- SDL (2)
- sensation (13)
- setup (3)
- software_package (36)
- SQL (1)
- suspend (2)
- ToDo (5)
- tool (3)
- ubuntu (1)
- VersionControl (45)
- Virtualization (15)
- VLC (5)
- wheezy (1)
- wifi (3)
- Windows (16)
- xiaomi (1)
- xperia (1)