<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
   <title>Jollen&apos;s Blog</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/" />
   <link rel="self" type="application/atom+xml" href="http://www.jollen.org/blog/atom.xml" />
   <id>tag:www.jollen.org,2009:/blog//2</id>
   <updated>2009-06-21T05:41:27Z</updated>
   
   <generator uri="http://www.sixapart.com/movabletype/">Movable Type 3.32</generator>

<entry>
   <title>Jollen 的 Android 教學,#18: 佈景（Theme）初體驗</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/2009/06/jollen-android-programming-18.html" />
   <id>tag:www.jollen.org,2009:/blog//2.643</id>
   
   <published>2009-06-21T05:30:00Z</published>
   <updated>2009-06-21T05:41:27Z</updated>
   
   <summary><![CDATA[上一節提到佈景（theme）是可以大範圍套用的UI美化功能，其套用範圍為「整個螢幕」，從程式碼的角度來看，佈景可以套用到以下二個範圍： 整個應用程式（application） 整個activity 接下來，我們以一個很簡單的例子，來說明如何套用佈景到application。在一些應用，我們可能不想要顯示視窗標題（title），怎麼做出這個功能呢？利用佈景設定的方式即可達成。以下是實作方法。 在styles.xml裡加入以下內容： &lt;?xml version="1.0" encoding="utf-8"?> &lt;resources> &lt;style name="myTheme"> &lt;item name="android:windowNoTitle">true &lt;/style> &lt;/resources> 修改AndroidManifest.xml，在標籤裡加上「theme」屬性： &lt;?xml version="1.0" encoding="utf-8"?> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.moko.hellotheme" android:versionCode="1" android:versionName="1.0.0"> &lt;application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/myTheme"> &lt;activity android:name=".HelloTheme" android:label="@string/app_name"> &lt;intent-filter> &lt;action android:name="android.intent.action.MAIN" /> &lt;category android:name="android.intent.category.LAUNCHER" /> &lt;/intent-filter> &lt;/activity>...]]></summary>
   <author>
      <name>jollen</name>
      <uri>http://www.jollen.org</uri>
   </author>
         <category term="Open Mobile Platform" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.jollen.org/blog/">
      <![CDATA[上一節提到佈景（theme）是可以大範圍套用的UI美化功能，其套用範圍為「整個螢幕」，從程式碼的角度來看，佈景可以套用到以下二個範圍：

<ul><li>整個應用程式（application）</li>
<li>整個activity</li>
</ul>

接下來，我們以一個很簡單的例子，來說明如何套用佈景到application。在一些應用，我們可能不想要顯示視窗標題（title），怎麼做出這個功能呢？利用佈景設定的方式即可達成。以下是實作方法。

在styles.xml裡加入以下內容：

<pre>&lt;?xml version="1.0" encoding="utf-8"?>
&lt;resources>
    &lt;style name="myTheme">
    	&lt;item name="android:windowNoTitle">true</item>        
    &lt;/style> 
&lt;/resources></pre>

修改AndroidManifest.xml，在<application>標籤裡加上「theme」屬性：

<pre>&lt;?xml version="1.0" encoding="utf-8"?>
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.moko.hellotheme"
      android:versionCode="1"
      android:versionName="1.0.0">
    &lt;application android:icon="@drawable/icon" android:label="@string/app_name"
    	<strong>android:theme="@style/myTheme"</strong>>
        &lt;activity android:name=".HelloTheme"
                  android:label="@string/app_name">
            &lt;intent-filter>
                &lt;action android:name="android.intent.action.MAIN" />
                &lt;category android:name="android.intent.category.LAUNCHER" />
            &lt;/intent-filter>
        &lt;/activity>
    &lt;/application>
&lt;/manifest></pre>

執行結果：

<img alt="theme-1.png" src="http://www.jollen.org/blog/2009/06/21/theme-1.png" width="320" height="480" />
圖1: HelloTheme的執行結果

在這個範例裡，我們並沒有修改任何的程式碼，其原理是透過佈景設定的方法。定義佈景的方式與定義樣式（styles）相同，同樣是在styles.xml裡以&lt;item>標籤來定義。

以下是使用HelloTheme的說明：

1. &lt;item>的name屬性為android:windowNoTitle時，表示定義是否要顯示視窗標題，在此設定為true，表示不要有視窗標題
2. 在&lt;application>標籤裡加上theme屬性，將佈景套用到應用程式

佈景除了能套用到應用程式外，也能套用到activity。如何套用佈景到activity呢？只要在&lt;activity>裡加入theme屬性即可，做法與&lt;application>相同。]]>
      
   </content>
</entry>
<entry>
   <title>Jollen 的 Android 教學,#17: 樣式設計（Styles）初體驗</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/2009/06/jollen-android-programming-17.html" />
   <id>tag:www.jollen.org,2009:/blog//2.642</id>
   
   <published>2009-06-20T07:20:45Z</published>
   <updated>2009-06-21T05:41:42Z</updated>
   
   <summary><![CDATA[在這篇教學裡，我們將用一個非常簡單的範例來初步體驗Android的「styles」功能。 什麼是樣式（Styles）？ Android的樣式設計（style）是一個很重要的功能，因為它可以讓應用程式裡的元件（widget）「長」得跟別人很不一樣。樣式設計的使用規定如下： 在Android專案裡以XML資源檔來定義「樣式」 一個Android專案可以定義多個樣式 讓widget套用其中一個樣式 Android的styles功能，主要的對象是widget，樣式是為了套用到widget上；另外Android還提供佈景（theme）功能，可以做更大範圍的套用。 如何定義樣式 定義樣式的方式如下： 1. 在Android專案的「res/values」資料夾裡建立styles.xml樣式定義檔。如圖1。 圖1: 建立styles.xml 2.在styles.xml裡定義樣式，以下是一個範例： &lt;?xml version="1.0" encoding="utf-8"?> &lt;resources> &lt;style name="myText"> &lt;item name="android:textSize">18sp&lt;/item> &lt;item name="android:textColor">#880&lt;/item> &lt;/style> &lt;/resources> styles.xml的寫法說明如下： 1. 在 &lt;resource>標籤裡定義資源項目， &lt;style>標籤用來定義樣式資源 2. &lt;style>的name屬性定義此樣式的名字，widget使用此名字以套用樣式 3. &lt;item>標籤定義此樣式的內容 4. &lt;item>的name屬性為android:textSize時，表示定義此樣式的字體大小，在此設定字體大小為18sp 5. &lt;item>的name屬性為android:textColor時，表示定義此樣式的字體顏色，在此設定字體顏色為#880（RGB） 6....]]></summary>
   <author>
      <name>jollen</name>
      <uri>http://www.jollen.org</uri>
   </author>
         <category term="Open Mobile Platform" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.jollen.org/blog/">
      <![CDATA[在這篇教學裡，我們將用一個非常簡單的範例來初步體驗Android的「styles」功能。

<strong>什麼是樣式（Styles）？</strong>

Android的樣式設計（style）是一個很重要的功能，因為它可以讓應用程式裡的元件（widget）「長」得跟別人很不一樣。樣式設計的使用規定如下：

<ul><li>在Android專案裡以XML資源檔來定義「樣式」</li>
<li>一個Android專案可以定義多個樣式</li>
<li>讓widget套用其中一個樣式</li>
</ul>

Android的styles功能，主要的對象是widget，樣式是為了套用到widget上；另外Android還提供佈景（theme）功能，可以做更大範圍的套用。

<strong>如何定義樣式</strong>

定義樣式的方式如下：

1. 在Android專案的「res/values」資料夾裡建立styles.xml樣式定義檔。如圖1。

<img alt="styles-1.png" src="http://www.jollen.org/blog/2009/06/20/styles-1.png" width="525" height="592" />
圖1: 建立styles.xml

2.在styles.xml裡定義樣式，以下是一個範例：

<blockquote><pre>&lt;?xml version="1.0" encoding="utf-8"?>
&lt;resources>
    &lt;style name="myText">
        &lt;item name="android:textSize">18sp&lt;/item>
        &lt;item name="android:textColor">#880&lt;/item>
    &lt;/style>
&lt;/resources></pre></blockquote>

styles.xml的寫法說明如下：

1. 在 &lt;resource>標籤裡定義資源項目， &lt;style>標籤用來定義樣式資源
2.  &lt;style>的name屬性定義此樣式的名字，widget使用此名字以套用樣式
3.  &lt;item>標籤定義此樣式的內容
4.  &lt;item>的name屬性為android:textSize時，表示定義此樣式的字體大小，在此設定字體大小為18sp
5.  &lt;item>的name屬性為android:textColor時，表示定義此樣式的字體顏色，在此設定字體顏色為#880（RGB）
6. 更多的樣式屬性，請參考Android Reference

定義好樣式後，就可以讓widget套用樣式。

<strong>Widget如何套用樣式</strong>

如何讓widget套用上述定義的「myText」樣式，方法很簡單。還記得UI layout檔main.xml嗎？只要在widget的項目裡，加上style屬性，並指定樣式名稱即可。以下是HelloStyles範例：

<blockquote> <pre>&lt;?xml version="1.0" encoding="utf-8"?>
 &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
 &lt;TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Hello, this is HelloStyles."
<strong>    style="@style/myText"</strong>
    />
 &lt;/LinearLayout></pre></blockquote>

「@style/myText」表示要指定一個style的名稱，此名稱為myText。

執行結果：

<img alt="styles-2.png" src="http://www.jollen.org/blog/2009/06/20/styles-2.png" width="320" height="480" />
圖2: HelloStyles的執行畫面]]>
      
   </content>
</entry>
<entry>
   <title>Jollen 的 Android 教學,#16: Event Listener的用法: 以Click Listener為例</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/2009/06/jollen-android-programming-16.html" />
   <id>tag:www.jollen.org,2009:/blog//2.641</id>
   
   <published>2009-06-18T15:18:30Z</published>
   <updated>2009-06-18T15:42:44Z</updated>
   
   <summary>Event Listener的用法: 以Click Listener為例 以Android所提供的View.OnClickListener來說明程式實作方法。一個較為良好的實作方法是在我們的Acitivty類別裡實作View.OnClickListener介面，即： import android.view.View; public class HelloClickListener extends Activity implements View.OnClickListener { ... } 每一個View都可以註冊一個event listener，當Android框架收到「click」事件後，便回呼event listener的callback method。以Button類別（按鈕元件）為例，當我們想要處理使用者觸控按鈕的事件時，就要呼叫Button類別的setOnClickListener()方法來註冊click listener。上述的實作方方法是，直接在我們的Activity類別HelloClickListener裡實作View.OnClickListener，因此上述Button類別的click listener為「this」。 上述的實作觀念，可用圖1來表示。 圖1: HelloClickListener類別實作View.OnClickListener介面 註冊click listener的程式碼如下： public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button)findViewById(R.id.btn); button.setOnClickListener(this);...</summary>
   <author>
      <name>jollen</name>
      <uri>http://www.jollen.org</uri>
   </author>
         <category term="Open Mobile Platform" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.jollen.org/blog/">
      <![CDATA[<strong>Event Listener的用法: 以Click Listener為例</strong>

以Android所提供的View.OnClickListener來說明程式實作方法。一個較為良好的實作方法是在我們的Acitivty類別裡實作View.OnClickListener介面，即：

<pre>import android.view.View;
  
public class HelloClickListener extends Activity implements View.OnClickListener {
   ...
}</pre>

每一個View都可以註冊一個event listener，當Android框架收到「click」事件後，便回呼event listener的callback method。以Button類別（按鈕元件）為例，當我們想要處理使用者觸控按鈕的事件時，就要呼叫Button類別的setOnClickListener()方法來註冊click listener。上述的實作方方法是，直接在我們的Activity類別HelloClickListener裡實作View.OnClickListener，因此上述Button類別的click listener為「this」。

上述的實作觀念，可用圖1來表示。

<img alt="HelloClickListener.png" src="http://www.jollen.org/blog/2009/06/18/HelloClickListener.png" width="385" height="393" />
圖1: HelloClickListener類別實作View.OnClickListener介面

註冊click listener的程式碼如下：

<pre>   public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button button = (Button)findViewById(R.id.btn);
        button.setOnClickListener(this);
    }</pre>

在onCreate()裡先找到Button元件，它的click listener為this為，接著在我們的Activity類別裡實作onClick()。onClick()方法的程式碼如下，我們以Toast類別來回應訊息給使用者：

<pre>   public void onClick(View v) {
        Toast.makeText(
                this,
                "Yes.",
                Toast.LENGTH_LONG).show();  
    }</pre>

<strong>完整程式碼: HelloClickListener.java</strong>

<pre>package com.moko.helloclicklistener;
   
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;
import android.view.View;
   
public class HelloClickListener extends Activity <strong>implements View.OnClickListener</strong> {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button button = (Button)findViewById(R.id.btn);
        button.setOnClickListener(this);
    }
    
<strong>    public void onClick(View v) {
        Toast.makeText(
                this,
                "Yes.",
                Toast.LENGTH_LONG).show();  
    }</strong>
}</pre>

<strong>執行結果</strong>

<img alt="clicklistener-1.png" src="http://www.jollen.org/blog/2009/06/18/clicklistener-1.png" width="320" height="480" />
圖2: HelloClickListener的執行結果

當使用者觸碰畫面上的按鈕時，便以Toast類別在畫面上顯示「Yes」。

]]>
      
   </content>
</entry>
<entry>
   <title>Jollen 的 Android 教學,#15: 什麼是事件監聽器(Event Listener)？</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/2009/06/jollen-android-programming-15.html" />
   <id>tag:www.jollen.org,2009:/blog//2.640</id>
   
   <published>2009-06-18T15:15:37Z</published>
   <updated>2009-06-18T15:18:08Z</updated>
   
   <summary>學會產生基本的UI後，接著就要學習UI的事件處理(UI Events)，才能讓UI與使用者「互動」。 什麼是事件監聽器(Event Listener) UI的使用者事件處理，即View如何處理使用者的操作，是一個重要的課題。View是重要的類別，它是與使用者互動的前線；在Android框架的設計中，以事件監聽器（event listener）的方式來處理UI的使用者事件。 Android框架提供了非常良好的UI事件處理機制。先前的教學提到，View是繪製UI的類別，每個View物件都可以向Android框架註冊一個事件監聽器。每個事件監聽器都包含一個回呼函數（callback method）， 這個回呼函數（callback method）主要的工作就是回應或處理使用者的操作。 Event Listener: 以Click Listener為例 以「使用者觸碰（touch）」的動作來說，當View要處理使用者觸碰的事件時，就要向Android框架註冊View.OnClickListener事件監聽器；當「touch」事件發生時，Android框架便回呼事件監聽器裡的回呼函數。 View.OnClickListener是click listener，故名思意，這是UI的「Click動作監聽器」；當使用者對View進行Click操作時（即觸控畫面上的UI元件），Android框架便會回呼這個View.OnClickListener的回呼函數。 View.OnClickListerner的回呼函數為OnClick()。 這裡所提到的監聽器泛指event listener，主要用來「監聽」使用者的各種動作。除了View.OnClickListener外，Android框架還有以下的event listener（及其callback method）： View.OnLongClickListener: onLongClick() View.OnFocusChangeListener: onFocusChange() View.OnKeyListener: onKey() View.OnTouchListener: onTouch() View.OnCreateContextMenuListener: onCreateContextMenu() 另外一種處理UI事件的機制為事件處理器（event handler），event handler與event listener是不一樣的二種處理機制。在自訂Android component的教學裡，再介紹這個部份。...</summary>
   <author>
      <name>jollen</name>
      <uri>http://www.jollen.org</uri>
   </author>
         <category term="Open Mobile Platform" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.jollen.org/blog/">
      <![CDATA[學會產生基本的UI後，接著就要學習UI的事件處理(UI Events)，才能讓UI與使用者「互動」。

<strong>什麼是事件監聽器(Event Listener)</strong>

UI的使用者事件處理，即View如何處理使用者的操作，是一個重要的課題。View是重要的類別，它是與使用者互動的前線；在Android框架的設計中，以事件監聽器（event listener）的方式來處理UI的使用者事件。

Android框架提供了非常良好的UI事件處理機制。先前的教學提到，View是繪製UI的類別，每個View物件都可以向Android框架註冊一個事件監聽器。每個事件監聽器都包含一個回呼函數（callback method），

這個回呼函數（callback method）主要的工作就是回應或處理使用者的操作。

<strong>Event Listener: 以Click Listener為例</strong>

以「使用者觸碰（touch）」的動作來說，當View要處理使用者觸碰的事件時，就要向Android框架註冊View.OnClickListener事件監聽器；當「touch」事件發生時，Android框架便回呼事件監聽器裡的回呼函數。

View.OnClickListener是click listener，故名思意，這是UI的「Click動作監聽器」；當使用者對View進行Click操作時（即觸控畫面上的UI元件），Android框架便會回呼這個View.OnClickListener的回呼函數。

View.OnClickListerner的回呼函數為OnClick()。

這裡所提到的監聽器泛指event listener，主要用來「監聽」使用者的各種動作。除了View.OnClickListener外，Android框架還有以下的event listener（及其callback method）：

<ul><li>View.OnLongClickListener: onLongClick()</li>
<li>View.OnFocusChangeListener: onFocusChange()</li>
<li>View.OnKeyListener: onKey()</li>
<li>View.OnTouchListener: onTouch()</li>
<li>View.OnCreateContextMenuListener: onCreateContextMenu()</li>
</ul>

另外一種處理UI事件的機制為事件處理器（event handler），event handler與event listener是不一樣的二種處理機制。在自訂Android component的教學裡，再介紹這個部份。]]>
      
   </content>
</entry>
<entry>
   <title>Garmin-Asus的nuvifone G60改用Android作業系統</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/2009/06/garmin-asus-nuvifone-g60-android.html" />
   <id>tag:www.jollen.org,2009:/blog//2.639</id>
   
   <published>2009-06-17T02:46:29Z</published>
   <updated>2009-06-19T01:47:39Z</updated>
   
   <summary>CNET ASIA上的一則報導[Android to replace Garmin-Asus&apos; current Linux platform]指出，Garmin-Asus的nuvifone G60將改採Android作業系統。 (圖片來源：CNET) 2009年二月，Garmin與Asus正式宣佈策略聯盟，並以「Garmin-Asus」雙品牌策略進行行銷。nuvifone G60是Garmin-Asus雙品牌行銷策略下的第一個產物，nuvifone G60則是以導航功能為主軸的手機。 根據報導指出，Garmin-Asus現有的Linux平臺將只使用在G60裝置上，未來的裝置會採用Windows Mobile或者是Android作業系統。 如同Garmin的PND產品都是採用Linux作業系統一樣，原本nuvifone G60也計畫採用Linux作業系統，不久前，在engadget上的報導也出現實機照片；但是，隨著CNET這則報導的出現，整個開發計畫是否有了改變，頗令人好奇。 Android原本就對Google Map有很好的支援，再加上nuvifone G60是以導航以及地圖應用為主的手機，若是改採Android作業系統，也是一個合理的做法。 * Update: 2009/6/19...</summary>
   <author>
      <name>jollen</name>
      <uri>http://www.jollen.org</uri>
   </author>
         <category term="Open Mobile Platform" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.jollen.org/blog/">
      <![CDATA[CNET ASIA上的一則報導[<a href="http://asia.cnet.com/crave/2009/06/16/android-to-replace-garmin-asus-current-linux-platform/" target="_blank">Android to replace Garmin-Asus' current Linux platform</a>]指出，<strike>Garmin-Asus的nuvifone G60將改採Android作業系統</strike>。

<img alt="nuvifone-g60.jpg" src="http://www.jollen.org/blog/2009/06/17/nuvifone-g60.jpg" width="500" height="375" />
(圖片來源：CNET)

2009年二月，Garmin與Asus正式宣佈策略聯盟，並以「Garmin-Asus」雙品牌策略進行行銷。nuvifone G60是Garmin-Asus雙品牌行銷策略下的第一個產物，nuvifone G60則是以導航功能為主軸的手機。

<font color="#ff0000">根據報導指出，Garmin-Asus現有的Linux平臺將只使用在G60裝置上，未來的裝置會採用Windows Mobile或者是Android作業系統。</font>

<strike>如同Garmin的PND產品都是採用Linux作業系統一樣，原本nuvifone G60也計畫採用Linux作業系統，</strike>不久前，在<a href="http://chinese.engadget.com/2009/05/26/garmin-asus-nuvifone-g60-hands-on/" target="_blank">engadget</a>上的報導也出現實機照片<strike>；但是，隨著CNET這則報導的出現，整個開發計畫是否有了改變，頗令人好奇。</strike>

<strike>Android原本就對Google Map有很好的支援，再加上nuvifone G60是以導航以及地圖應用為主的手機，若是改採Android作業系統，也是一個合理的做法。</strike>

* Update: 2009/6/19
]]>
      
   </content>
</entry>
<entry>
   <title>Linux 2.6.30 釋出</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/2009/06/linux-2-6-30-announced.html" />
   <id>tag:www.jollen.org,2009:/blog//2.638</id>
   
   <published>2009-06-16T02:56:10Z</published>
   <updated>2009-06-16T04:11:15Z</updated>
   
   <summary>Linux 2.6.30於2009年6月9日釋出，Linux kernel的發展進入了Linux 2.6.3x的時代。最近一年的 Linux 2.6核心發展有相當重大的進展，除了幾個知名大廠不斷貢獻程式碼外，新產品的開發，也帶動Linux kernel的快速發展。 Linux 2.6.30加入了新的filesystem： 1. NILFS2 一種log-structured filesystem，由John K. Ousterhout與Fred Douglis於1988年提出的設計，主要針對high write throughput的應用。 2. POHMELFS (Parallel Optimized Host Message Exchange Layered File System) 一個分散式平行處理的檔案系統，在讀寫操作方面，根據[POHMELFS]官方的數據指出，POHMELFS的效能比NFS還好。 3. DST（Distributed STorage） 一個具高效能與可信賴的網路儲存檔案系統。 4. EXOFS（Object-Based Storage Devices） 支援OSD protocol的檔案系統。 5....</summary>
   <author>
      <name>jollen</name>
      <uri>http://www.jollen.org</uri>
   </author>
         <category term="Linux Device Drivers &amp; Kernel" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.jollen.org/blog/">
      <![CDATA[Linux 2.6.30於2009年6月9日釋出，Linux kernel的發展進入了Linux 2.6.3x的時代。最近一年的 Linux 2.6核心發展有相當重大的進展，除了幾個知名大廠不斷貢獻程式碼外，新產品的開發，也帶動Linux kernel的快速發展。

Linux 2.6.30加入了新的filesystem：

1. NILFS2

一種log-structured filesystem，由John K. Ousterhout與Fred Douglis於1988年提出的設計，主要針對high write throughput的應用。

2. POHMELFS (Parallel Optimized Host Message Exchange Layered File System)

一個分散式平行處理的檔案系統，在讀寫操作方面，根據[<a href="http://www.ioremap.net/projects/pohmelfs" target="_blank">POHMELFS</a>]官方的<a href="http://www.ioremap.net/node/134" target="_blank">數據</a>指出，POHMELFS的效能比NFS還好。

3. DST（Distributed STorage）

一個具高效能與可信賴的網路儲存檔案系統。

4. EXOFS（Object-Based Storage Devices）

支援OSD protocol的檔案系統。

5. FS-Cache

這是一個網路檔案系統（networking filesystem）的cache layer，FS-Cache可以將網路檔案系統的資料 cache 在磁碟裡。

<strong>其他更新</strong>

另外，Intel也貢獻了fastboot（快速開機）程式碼，過去kernel在開機時花費許多時間在處理 I/O 上，例如：儲存裝置的I/O，由Intel貢獻的fastboot以asynchronous function call的觀念解決此問題。其原理在kernel/async.c裡的註解有很清楚的說明：

<pre>14 /*
15
16 Goals and Theory of Operation
17
18 The primary goal of this feature is to reduce the kernel boot time,
19 by doing various independent hardware delays and discovery operations
20 decoupled and not strictly serialized.
21
22 More specifically, the asynchronous function call concept allows
23 certain operations (primarily during system boot) to happen
24 asynchronously, out of order, while these operations still
25 have their externally visible parts happen sequentially and in-order.
26 (not unlike how out-of-order CPUs retire their instructions in order)
27
28 Key to the asynchronous function call implementation is the concept of
29 a "sequence cookie" (which, although it has an abstracted type, can be
30 thought of as a monotonically incrementing number).
31
32 The async core will assign each scheduled event such a sequence cookie and
33 pass this to the called functions.
34
35 The asynchronously called function should before doing a globally visible
36 operation, such as registering device numbers, call the
37 async_synchronize_cookie() function and pass in its own cookie. The
38 async_synchronize_cookie() function will make sure that all asynchronous
39 operations that were scheduled prior to the operation corresponding with the
40 cookie have completed.
41
42 Subsystem/driver initialization code that scheduled asynchronous probe
43 functions, but which shares global resources with other drivers/subsystems
44 that do not use the asynchronous call feature, need to do a full
45 synchronization with the async_synchronize_full() function, before returning
46 from their init function. This is to maintain strict ordering between the
47 asynchronous and synchronous parts of the kernel.
48
49 */</pre>

關於 fastboot 的做法，在LWN上的一篇文章[<a href="http://lwn.net/Articles/314808" target="_blank">An asynchronous function call infrastructure</a>]有很不錯的介紹。

Red Hat也貢獻了二個新的system call：preadv()與pwritev()。其他更多Linux 2.6.30的變更，可參考[<a href="http://kernelnewbies.org/LinuxChanges" target="_blank">kernelnewbies</a>]上的說明。]]>
      
   </content>
</entry>
<entry>
   <title>Jollen 的 Android 教學,#14: 什麼是對話盒 (Dialog)？如何建立對話盒？</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/2009/06/jollen-android-programming-14.html" />
   <id>tag:www.jollen.org,2009:/blog//2.637</id>
   
   <published>2009-06-10T06:56:50Z</published>
   <updated>2009-06-10T07:06:34Z</updated>
   
   <summary>最少的元件、最舒適的介面 自從有了圖形化應用程式之後，對話盒（dialog）一直是元老級的元件（widget）；智慧型手機開始流行後，對話盒仍然是手機介面的重要圖形元件。 在Apple的iPhone問世後，觸控螢幕（touch screen）一直是智慧型手機的標準規格，因此傳統的滑鼠點擊（click）式介面，並不完全適合手指觸控的操作方式，再加上手機觸控螢幕尺吋較小，因此手機應用程式的介面設計，已經與傳統的桌面環境相當不同。 Android的元件庫考量了小尺吋的觸控螢幕，在基本元件的設計上，Android也為使用者做了很體貼的考量。以Android手機應用程式來說，經常使用的元件已經不再像過去的點擊式系統那麼多又複雜；以使用性的角度來看，常被使用的元件如下： * 選單（Menu） * 對話盒（Dialog） * 快顯訊息（Toast） 使用以上三個元件，以及其「變化形」，就能建構一個好用的應用程式介面；再加上Android針對上述的手機操作特性，對其元件庫做了很好的使用設計，因此使用很少的元件，也能提供使用者一個舒適好用的操作介面。 何謂對話盒？ 對話盒，故名其思，是一個讓應用程式與使用者「對話」的元件。應用程式透過對話盒與使用者進行下述的對話： * 詢問問題：使用者回答 Yes/No * 詢問偏好：使用者選擇自已偏好的項目，可以是單選，也可以是複選 * 說明狀態：讓使用者知道應用程式目前的狀態，例如：顯示「處理中」、「載入中」等訊息 Android提供的對話盒物件為android.app.Dialog，實作上繼承自Dialog的AlertDialog物件是最基本的對話盒物件。使用AlertDialog對話盒，可以詢問使用者問題，也可以詢問使用者偏好。接下來介紹AlertDialog對話盒的設計方法。 建立AlertDialog對話盒 延續「HelloMenu」範例，現在我們想要加入以下的使用情境： * 使用者按下Menu鍵 * 使用者觸壓 “New Message” 選項 * 出現對話盒、詢問使用者 “Yes/No” 由以上的使用情境來看，應該在onOptionsItemSelected()裡判斷到R.id.new_message項目時，在UI上建立一個對話盒。以下是修改後的onOptionsItemSelected()完整程式碼，完整範例名稱為HelloAlertDialog： public boolean onOptionsItemSelected(MenuItem item) {...</summary>
   <author>
      <name>jollen</name>
      <uri>http://www.jollen.org</uri>
   </author>
         <category term="Open Mobile Platform" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.jollen.org/blog/">
      <![CDATA[<strong>最少的元件、最舒適的介面</strong>

自從有了圖形化應用程式之後，對話盒（dialog）一直是元老級的元件（widget）；智慧型手機開始流行後，對話盒仍然是手機介面的重要圖形元件。

在Apple的iPhone問世後，觸控螢幕（touch screen）一直是智慧型手機的標準規格，因此傳統的滑鼠點擊（click）式介面，並不完全適合手指觸控的操作方式，再加上手機觸控螢幕尺吋較小，因此手機應用程式的介面設計，已經與傳統的桌面環境相當不同。

Android的元件庫考量了小尺吋的觸控螢幕，在基本元件的設計上，Android也為使用者做了很體貼的考量。以Android手機應用程式來說，經常使用的元件已經不再像過去的點擊式系統那麼多又複雜；以使用性的角度來看，常被使用的元件如下：

* 選單（Menu）
* 對話盒（Dialog）
* 快顯訊息（Toast）

使用以上三個元件，以及其「變化形」，就能建構一個好用的應用程式介面；再加上Android針對上述的手機操作特性，對其元件庫做了很好的使用設計，因此使用很少的元件，也能提供使用者一個舒適好用的操作介面。

<strong>何謂對話盒？</strong>

對話盒，故名其思，是一個讓應用程式與使用者「對話」的元件。應用程式透過對話盒與使用者進行下述的對話：

* 詢問問題：使用者回答 Yes/No
* 詢問偏好：使用者選擇自已偏好的項目，可以是單選，也可以是複選
* 說明狀態：讓使用者知道應用程式目前的狀態，例如：顯示「處理中」、「載入中」等訊息

Android提供的對話盒物件為android.app.Dialog，實作上繼承自Dialog的AlertDialog物件是最基本的對話盒物件。使用AlertDialog對話盒，可以詢問使用者問題，也可以詢問使用者偏好。接下來介紹AlertDialog對話盒的設計方法。

<strong>建立AlertDialog對話盒</strong>

延續「HelloMenu」範例，現在我們想要加入以下的使用情境：

* 使用者按下Menu鍵
* 使用者觸壓 “New Message” 選項
* 出現對話盒、詢問使用者 “Yes/No”

由以上的使用情境來看，應該在onOptionsItemSelected()裡判斷到R.id.new_message項目時，在UI上建立一個對話盒。以下是修改後的onOptionsItemSelected()完整程式碼，完整範例名稱為HelloAlertDialog：

<pre>public boolean onOptionsItemSelected(MenuItem item) {
    	int item_id = item.getItemId();
    	
    	switch (item_id){
    		case R.id.new_message: 
	    	        AlertDialog.Builder builder = new AlertDialog.Builder(this);
	    	        
	    	        builder.setMessage("Also post your message to Twitter?");
	    	        builder.setCancelable(false);
	    	        
	    	        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
	    	        	public void onClick(DialogInterface dialog, int id) {
	    	        	}
	    	        });
	    	        
	    	        builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
	    	        	public void onClick(DialogInterface dialog, int id) {
	    	        	}
	    	        });   
	    	        
	    	        AlertDialog alert = builder.create();
	    	        alert.show();
    			break;
    		case R.id.quit: 
                Toast.makeText(
                        this,
                        "Going to quit.",
                        Toast.LENGTH_LONG).show();    			
    			break;
    		default: return false;
    	}
    	return true;
 }</pre>

<img alt="dialog-1.png" src="http://www.jollen.org/blog/2009/06/10/dialog-1.png" width="300" height="433" />
圖1: Android的AlertDialog對話盒

產生AlertDialog物件的說明：

1. 產生AlertDialog.builder物件（dialog builder），這是一個用來建立對話盒內容的產生器物件

2. 設定dialog builder的顯示訊息-builder.setMessage()

3. 設定對話盒能不能被「取消」-builder.setCancelable()

4. 利用dialog builder在對話盒裡產生二個按鈕「Yes與No」-builder.setPositiveButton()與builder.setNegativeButton()
使用dialog builder來建立AlertDialog物件，AlertDialog是真正的對話盒物件-builder.create()

5. 將AlertDialog顯示在UI上-alert.show()

產生「Yes按鈕」的程式如下：

<pre>builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
	public void onClick(DialogInterface dialog, int id) {
		}
});</pre>

呼叫builder.setPositiveButton()方法建立一個「正面（Yes）」的按鈕，參數說明如下：

1. 第一個參數：顯示在按鈕上的文字
2. 第二個參數：指定 click listener

每一個按鈕都需要一個click listener，當使用者觸壓按鈕時，click listener便被回呼。android.content.DialogInterface類別提供click listener物件。]]>
      
   </content>
</entry>
<entry>
   <title>Jollen 的 Android 教學,#13: 快顯訊息 android.widget.Toast</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/2009/06/jollen-android-programming-13.html" />
   <id>tag:www.jollen.org,2009:/blog//2.636</id>
   
   <published>2009-06-03T16:20:03Z</published>
   <updated>2009-06-03T16:30:16Z</updated>
   
   <summary>Toast是Android提供「快顯訊息」類別，使用時請import以下套件： import android.widget.Toast; 這是一個很好用的類別，特別是在初步建立Android應用程式的控制或行為時，可以輔助我們進行初步的測試工作。 配合上述的選單範例，我們將onOptionsItemSelected()回呼函數實作修改如下： public boolean onOptionsItemSelected(MenuItem item) { int item_id = item.getItemId(); switch (item_id){ case R.id.new_message: Toast.makeText( this, &quot;Please enter your message.&quot; + &quot; Your message is at max 255 characters.&quot;, Toast.LENGTH_LONG).show(); break; case R.id.quit: Toast.makeText( this, &quot;Going...</summary>
   <author>
      <name>jollen</name>
      <uri>http://www.jollen.org</uri>
   </author>
         <category term="Open Mobile Platform" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.jollen.org/blog/">
      <![CDATA[<p>Toast是Android提供「快顯訊息」類別，使用時請import以下套件：</p>

<blockquote><pre>import android.widget.Toast;</pre></blockquote>

<p>這是一個很好用的類別，特別是在初步建立Android應用程式的控制或行為時，可以輔助我們進行初步的測試工作。</p>

<p>配合上述的選單範例，我們將onOptionsItemSelected()回呼函數實作修改如下：</p>

<blockquote><pre>    public boolean onOptionsItemSelected(MenuItem item) {
    	int item_id = item.getItemId();
    	
    	switch (item_id){
    		case R.id.new_message: 
                Toast.makeText(
                        this,
                        "Please enter your message."
                                + " Your message is at max 255 characters.",
                        Toast.LENGTH_LONG).show();
    			break;
    		case R.id.quit: 
                Toast.makeText(
                        this,
                        "Going to quit.",
                        Toast.LENGTH_LONG).show();    			
    			break;
    		default: return false;
    	}</pre></blockquote>
    	
<p>此範例以Toast快顯訊息類別來顯示簡短訊息，以驗證上一個選單範例的功能是否正常。</p>

<img alt="toast-1.png" src="http://www.jollen.org/blog/2009/06/04/toast-1.png" width="354" height="679" />]]>
      
   </content>
</entry>
<entry>
   <title>Jollen 的 Android 教學,#12: 如何建立選單 Menu</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/2009/06/jollen-android-programming-12.html" />
   <id>tag:www.jollen.org,2009:/blog//2.635</id>
   
   <published>2009-06-03T09:21:32Z</published>
   <updated>2009-06-03T09:30:46Z</updated>
   
   <summary><![CDATA[Android應用程式的UI可以使用XML來定義，這個部份在前面的教學裡介紹過。要定義Android應用程式的選單，我們同樣可以使用XML來做描述，請看以下的說明。 建立 Menu 步驟 1. 建立選單的XML檔 在Android專案的res/目錄下新增一個menu/子目錄，然後建立options_menu.xml文件。 圖1: 建立menu/目錄 圖2: 建立options_menu.xml文件 2. 以XML定義選單內容 在options_menu.xml檔案裡，定義我們想要的選單內容。以下是一個範例： &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"> &lt;item android:id="@+id/new_message" android:title="New Message" /> &lt;item android:id="@+id/quit" android:title="Quit" /> &lt;/menu> 3. 將選單加入應用程式 要如何在應用程式啟動時加入我們定義好的選單呢？在onCreateOptionsMenu()事件裡以MenuInflater類別將定義好的選單加入應用程式： public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu);...]]></summary>
   <author>
      <name>jollen</name>
      <uri>http://www.jollen.org</uri>
   </author>
         <category term="Open Mobile Platform" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.jollen.org/blog/">
      <![CDATA[<p>Android應用程式的UI可以使用XML來定義，這個部份在前面的教學裡介紹過。要定義Android應用程式的選單，我們同樣可以使用XML來做描述，請看以下的說明。</p>

<strong>建立 Menu 步驟</strong>

<p>1. 建立選單的XML檔</p>

<p>在Android專案的res/目錄下新增一個menu/子目錄，然後建立options_menu.xml文件。</p>
<img alt="menu-1.png" src="http://www.jollen.org/blog/2009/06/03/menu-1.png" width="589" height="674" />
<p>圖1: 建立menu/目錄</p>

<img alt="menu-2.png" src="http://www.jollen.org/blog/2009/06/03/menu-2.png" width="525" height="592" />
<p>圖2: 建立options_menu.xml文件</p>

<p>2. 以XML定義選單內容</p>

<p>在options_menu.xml檔案裡，定義我們想要的選單內容。以下是一個範例：</p>

<blockquote><pre>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android">
    &lt;item android:id="@+id/new_message"
          android:title="New Message" />
    &lt;item android:id="@+id/quit"
          android:title="Quit" />
&lt;/menu></pre></blockquote>

<p>3. 將選單加入應用程式</p>

<p>要如何在應用程式啟動時加入我們定義好的選單呢？在onCreateOptionsMenu()事件裡以MenuInflater類別將定義好的選單加入應用程式：</p>

<blockquote><pre>public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);
    return true;
}</pre></blockquote>

<p>在這個範例裡，我們使用到二個類別：Menu與MenuInflater，因此記得import這二個套件：</p>

<blockquote><pre>import android.view.Menu;
import android.view.MenuInflater;</pre></blockquote>

<strong>執行結果</strong>

<p>按下手機上的Menu鍵後，出現我們所設計的選單，如圖3。</p>

<img alt="menu-3.png" src="http://www.jollen.org/blog/2009/06/03/menu-3.png" width="900" height="752" />
<p>圖3: HelloMenu範例的選單畫面</p>

<strong>處理選單</strong>

<p>最後一個問題是，當使用者觸壓選單上的選項時，Android應用程式要如何處理？方法是透過onOptionsItemSelected()事件：</p>

<blockquote><pre>    public boolean onOptionsItemSelected(MenuItem item) {
    	return true;
    }</pre></blockquote>

<p>當此事件被回呼時，Android框架傳入被觸壓的選項物件，其類別為MenuItem；請import此套件：</p>

<blockquote><pre>import android.view.MenuItem;</pre></blockquote>

<p>前述的教學提到，Android應用程式編譯時，會自動產生R類別，即描述UI的類別。我們所定義的選單UI也會被放到R類別裡，如下：</p>

<blockquote><pre>package com.moko.hellomenu;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int icon=0x7f020000;
    }
<strong>    public static final class id {
        public static final int new_message=0x7f060000;
        public static final int quit=0x7f060001;
    }</strong>
    public static final class layout {
        public static final int main=0x7f030000;
    }
    public static final class menu {
        public static final int options_menu=0x7f050000;
    }
    public static final class string {
        public static final int app_name=0x7f040001;
        public static final int hello=0x7f040000;
    }
}</pre></blockquote>

<p>以下是處理MenuItem的程式範例：</p>

<blockquote><pre>    public boolean onOptionsItemSelected(MenuItem item) {
    	int item_id = item.getItemId();
    	
    	switch (item_id){
    		case R.id.new_message: break;
    		case R.id.quit: break;
    		default: return false;
    	}
    	return true;
    }</pre></blockquote>

<p>呼叫MenuItem的getItemId()方法，可取得該選項的ID，如此一來便能得知使用者所觸壓的選項。</p>

<strong>完整程式列表</strong>

<blockquote><pre>/* 範例檔名：HelloMenu.java */
package com.moko.hellomenu;

import android.app.Activity;
import android.os.Bundle;
<strong>import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;</strong>

public class HelloMenu extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    
<strong>    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.options_menu, menu);
        return true;
    }</strong>
    
    public boolean onOptionsItemSelected(MenuItem item) {
    	int item_id = item.getItemId();
    	
    	switch (item_id){
    		case R.id.new_message: break;
    		case R.id.quit: break;
    		default: return false;
    	}
    	return true;
    }
}</pre></blockquote>]]>
      
   </content>
</entry>
<entry>
   <title>「Android Porting Highlights」簡報上線</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/2009/05/android-porting-highlights.html" />
   <id>tag:www.jollen.org,2009:/blog//2.625</id>
   
   <published>2009-05-22T02:55:37Z</published>
   <updated>2009-05-22T03:25:09Z</updated>
   
   <summary>上週受邀至「首屆亞太區 Android 技術大會」發表演說，由於大會希望能多著重在技術層面的主題，因此整理了過去研究 Android/FreeRunner 的一些資料，並將「重點」部份做了一次概念性的說明。Android 的分支（branch）是以「產品」的概念做維護，因此若在目前 Cupcake 能支援的平臺（architecture）上做移植的話，是一個較簡單的工作，只需要在 vendor/ 裡新增自已的 product 並修改 AndroidBoard.mk、AndroidProducts.mk 以及 BoardConfig.mk 即可完成一個 Board/Product 的新分支。 關於底層的部份，以 armv4（如 s3c2443）的 architecture 為例，將重要的工作項目做了整理式的說明。在此提供簡報電子檔下載 [Android Porting Highlights]。...</summary>
   <author>
      <name>jollen</name>
      <uri>http://www.jollen.org</uri>
   </author>
         <category term="Open Mobile Platform" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.jollen.org/blog/">
      <![CDATA[上週受邀至「首屆亞太區 Android 技術大會」發表演說，由於大會希望能多著重在技術層面的主題，因此整理了過去研究 Android/FreeRunner 的一些資料，並將「重點」部份做了一次概念性的說明。Android 的分支（branch）是以「產品」的概念做維護，因此若在目前 Cupcake 能支援的平臺（architecture）上做移植的話，是一個較簡單的工作，只需要在 vendor/ 裡新增自已的 product 並修改 AndroidBoard.mk、AndroidProducts.mk 以及 BoardConfig.mk 即可完成一個 Board/Product 的新分支。

關於底層的部份，以 armv4（如 s3c2443）的 architecture 為例，將重要的工作項目做了整理式的說明。在此提供簡報電子檔下載 [<a href="http://www.jollen.org/slides/apac-android-porting-r2.pdf">Android Porting Highlights</a>]。]]>
      
   </content>
</entry>
<entry>
   <title>中國移動 OPhone 現身：採用 OMS 系統的 Android 手機（實機附圖）</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/2009/05/china-mobile-ophone-oms.html" />
   <id>tag:www.jollen.org,2009:/blog//2.623</id>
   
   <published>2009-05-19T14:57:08Z</published>
   <updated>2009-05-19T15:13:34Z</updated>
   
   <summary>中國版的 Android 系統 OMS 現身 (China&apos;s Android OS，OMS - Open Mobile System)。 日前一則新聞 [大陸OPhone商機 台商幕後推手] 以及 [中移動5月中下旬發佈Ophone手機 主介面已可上網流覽] 報導了中國移動（China Mobile）所推出的 OPhone 手機，採用 OMS 作業系統。本週在北京與 OMS（Open Mobile System）的開發商「播思通讯（BORQS）」人員餐敘，OMS 的開發者也拿出了 OMS 的參考設計（reference design）實機讓現場朋友實機操作。 OMS 採用的正是 Google 的 Android 作業系統，如同上述報導所提，OMS 是 BORQS 與...</summary>
   <author>
      <name>jollen</name>
      <uri>http://www.jollen.org</uri>
   </author>
         <category term="Openmoko" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.jollen.org/blog/">
      <![CDATA[中國版的 Android 系統 OMS 現身 (China's Android OS，OMS - Open Mobile System)。

日前一則新聞 [<a href="http://news.chinatimes.com/CMoney/News/News-Page-content/0,4993,11050701+122009051000204,00.html" target="_blank">大陸OPhone商機 台商幕後推手</a>] 以及 [<a href="http://news.cnyes.com/stock/dspnewsS.asp?fi=\NEWSBASE\20090511\WEB782&vi=32214&date=20090511&time=10:54:45&pagetype=usastock&subtype=home&cls=usastock_totalnews" target="_blank">中移動5月中下旬發佈Ophone手機 主介面已可上網流覽</a>] 報導了中國移動（China Mobile）所推出的 OPhone 手機，採用 OMS 作業系統。本週在北京與 OMS（Open Mobile System）的開發商「<a href="http://www.borqs.com" target="_blank">播思通讯（BORQS）</a>」人員餐敘，OMS 的開發者也拿出了 OMS 的參考設計（reference design）實機讓現場朋友實機操作。

OMS 採用的正是 Google 的 Android 作業系統，如同上述報導所提，OMS 是 BORQS 與 Google 共同合作開發的中國版 Android 作業系統。OMS 專門針對中國移動做了許多客製化的應用程式。由於機會難得，因此特別拍了一些照片，在這裡跟大家分享。另外也看到了另外一支「很快就要上市」的 Android 手機，同樣也是採用 OMS 系統，但礙於一些因素，無法多做說明，當然也沒辦法照像了。

<img alt="China Mobile OPhone" src="http://www.jollen.org/blog/2009/05/19/china-mobile-ophone-1.jpg" />
主畫面的部份比 G1 還美觀，整體 UI 給我的感覺很不錯。

<img alt="China Mobile OPhone" src="http://www.jollen.org/blog/2009/05/19/china-mobile-ophone-2.jpg" />
看得出來 OMS 在介面設計上下了一些工夫。

<img alt="China Mobile OPhone" src="http://www.jollen.org/blog/2009/05/19/china-mobile-ophone-3.jpg" />
最特別的地方是 OMS 有「桌面切換」的功能，整體操作性做得不錯。

<img alt="China Mobile OPhone" src="http://www.jollen.org/blog/2009/05/19/china-mobile-ophone-4.jpg" />
某一個選單 UI。

<img alt="China Mobile OPhone" src="http://www.jollen.org/blog/2009/05/19/china-mobile-ophone-5.jpg" />
找了一下，果然沒錯，有導航功能！

<img alt="China Mobile OPhone" src="http://www.jollen.org/blog/2009/05/19/china-mobile-ophone-6.jpg" />
找到了手機電視功能。

<img alt="China Mobile OPhone" src="http://www.jollen.org/blog/2009/05/19/china-mobile-ophone-7.jpg" />
訊息雖然微弱，不過畫面還挺流暢的。

<img alt="China Mobile OPhone" src="http://www.jollen.org/blog/2009/05/19/china-mobile-ophone-8.jpg" />
音樂撥放器。

<img alt="China Mobile OPhone" src="http://www.jollen.org/blog/2009/05/19/china-mobile-ophone-9.jpg" />
雖然是參考設計，不過外觀（ID）做得算不錯。

用過 T-Mobile G1 以及 OPhone 後，總結來看，OPhone 的介面給我的感覺更好：

1. 操作性流暢許多
2. 多桌面（主屏）切換功能比 G1 更加好用
3. 觀看手機電視時畫面非常流暢、介面佈署（UI layout）還不錯 
4. 整體的視覺效果更華麗、畫面更美觀

隨著越來越多的 OPhone 新聞出現，這款由中國自主開發的「O1」頗令人期待，這是 Android 作業系統繼「G1」後，最令人期待的另一個事件。

OPhone 的出現，還代表了一件重要的事情。過去電信營運商，並不掌握手機軟體平臺的技術能力，因此「為自已量身打造」手機軟體、結合自家的服務，並推出實體手機，是一件不容易的事情。如今，藉由「Open Mobile System」的出現，電信營運商能取得開放的手機平臺，並自行發展手機服務應用程式。這是首次，電信營運商能真正掌握整體手機軟體的技術。掌握了電信、用戶、服務與手機軟體等關鍵能力，看來，一些有趣的事情正要開始發生。對於 OPhone 的出線，中國移動扮演了一個重要的角色，身為最重要的電信營運商，此舉必然有登高一呼的效應。]]>
      
   </content>
</entry>
<entry>
   <title>Jollen 的 Android Porting 手札 #1: Android 移植概觀</title>
   <link rel="alternate" type="text/html" href="http://www.jollen.org/blog/2009/05/android-porting-introduction.html" />
   <id>tag:www.jollen.org,2009:/blog//2.622</id>
   
   <published>2009-05-10T13:58:29Z</published>
   <updated>2009-05-10T14:54:54Z</updated>
   
   <summary>本週六將於北京舉行的「Android 技術大會」上發表有關「Android 移植」的技術演說，配合該演講，最近將陸續整理一些筆記以搭配講稿供與會朋友參考。 Android 的技術優點 Android 平臺的好處是「將開發者侷限在應用層（application level）」的開發，並透過一個設計良好的 application framework 將 library 層「包裝起來」。傳統 GNU/Linux 系統的「開源模式」是「從裡到外」全面開放，應用程式來自四面八方，每個應用程式底層使用到的 library 並不相同，這讓 Linux 平臺的軟體發展容易失控，造成 Linux distribution 上雖然收錄了豐富的應用程式，但相對的也要包山包海地納入非常多的 shared library。 Android 雖然也採用了其他 open source 的專案成果，但 Android 以很聰明的方式，解決傳統 Linux 開放手機平臺的「相依性」問題，這也是過去長久以來，匯整使用（leverage）開放源碼專案開發產品的大問題。Application framework 採用 Java 程式語言，並軟性的將開發者限制在 application level 是...</summary>
   <author>
      <name>jollen</name>
      <uri>http://www.jollen.org</uri>
   </author>
         <category term="Open Mobile Platform" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.jollen.org/blog/">
      <![CDATA[本週六將於北京舉行的「Android 技術大會」上發表有關「Android 移植」的技術演說，配合該演講，最近將陸續整理一些筆記以搭配講稿供與會朋友參考。

<strong>Android 的技術優點</strong>

Android 平臺的好處是「將開發者侷限在應用層（application level）」的開發，並透過一個設計良好的 application framework 將 library 層「包裝起來」。傳統 GNU/Linux 系統的「開源模式」是「從裡到外」全面開放，應用程式來自四面八方，每個應用程式底層使用到的 library 並不相同，這讓 Linux 平臺的軟體發展容易失控，造成 Linux distribution 上雖然收錄了豐富的應用程式，但相對的也要包山包海地納入非常多的 shared library。

Android 雖然也採用了其他 open source 的專案成果，但 Android 以很聰明的方式，解決傳統 Linux 開放手機平臺的「相依性」問題，這也是過去長久以來，匯整使用（leverage）開放源碼專案開發產品的大問題。Application framework 採用 Java 程式語言，並軟性的將開發者限制在 application level 是 Android 解決上述技術難題的一個關鍵。

網路上有著數以萬計的 Free & Open Source Software 專案，而被 Android 採納的 FOSS 專案僅有約 60 個左右，比起傳統 Linux distribution 必須收錄上千個套件的數量來看，Android 未來若能發揚光大，能是扮演「收斂」開源軟體發展模式的推手。

傳統的 Embedded Linux 系統程式基於 GNU libc 以及大量的相依程式庫（library dependencies），因此很容易有「牽一髮而動全身」的問題出現。例如：某一個library的API變動（可能是函數改名或移除）將使得其它程式庫與應用程式執行錯誤，這時就必須修改原始程式碼並重新編譯才能解決問題。

這個問題的主因，是因為 Linux 系統是採取動態程式庫（shared libraries）的機制，程式庫的變更雖然只需要「抽換」掉動態程式庫檔，但是應用程式在執行時，才會產生「無法載入符號」的錯誤，除非是「定期」進行「系統重編譯」，否則很難即時修正此錯誤。

Android 的底層並無太複雜的「程式庫相依」問題，這使得 Android 可以比較容易將系統與 IDE 開發工具做整合。在標準 C 程式庫（C library）方面，Google 則是採用 BSD 授權實作了一份適合手機系統使用的版本，無疑是一個值得稱許的做法。

由上述的分析來看，Android 平臺在系統層（library、kernel）的移植工作將不再花費工程人員大量的時間，同時就系統層的調校工作來看，也能有更具體明確的調校項目。

<strong>移植項目概述</strong>

從 Google 發佈的標準 Android 系統架構圖來說，Application framework 以及 application 二層並沒有重要的移植工作需要進行，以下以系統架構的角度來簡介 Android 移植技術的重要事項。

1. Application

應用程式層並移植的工作需要進行，但是因為 Android 每個版本的 API level 都不一樣，因此需要進行 API 相容性的測試。例如，Android 1.1 的 API level 為 2、Android 1.5 的 API level 為 3，需要根據 Google 發佈的 API change 文件進行 application 的相容性測試。

2. Application Framework

以大方向來看，加入新的 library 時需要擴充 application framework；Android framework 以 JNI 呼叫下一層的 library，但是 application 不直接呼叫 library，因此讓 Android framework 的設計更嚴謹。

3. Library

Android 的「external library」裡包含部份現有的 FOSS 專案成果，有些 library 的實作為 machine-dependent，針對 machine-dependent 的實作必須修改其程式碼。例如，android.media.MediaPlayer 的底層為 OpenCore 程式庫，而 OpenCore 的 MP3 decode 部份演算法以 assembly 實作。

4. Dalvik VM

JNI 與 interpreter 是 Android runtimer（Dalvik VM）的移植重點。新版本的 Cupcake（Android 1.5）在 JNI 的部份加入了 x86 的支援，interpreter 目前則是支援 armv4、armv5te 以及 x86。

5. Bionic

Bionic 是 Android 專屬的小型客製化 C library，主要是由 BSD C library 移植而來。支援 Linux kernel 的重要實作，像是：system call、dynamic linker & loader、thread 等等都是檢查的重點。Bionic 裡有一個 libthread_db 是基於 Linux futexes 的 thread 實作，很適合像是手機這樣的小型系統使用。

6. 其它

Android framework 的實作，部份需要考量硬體的規格，例如：Surface Manager 需要考量是否有 GPU 或硬體加速。但你在 Android application 建立一個 Surface holder 時，若是將 Surface 的類型設定為 SURFACE_TYPE_HARDWARE，就必須針對硬體加速與 DMA 做移植工作。

<strong>小結</strong>

Android 平臺的移植技術仍屬重要，主要的技術能力著重於 Android framework（例如：加入新的 external library）以及 Linux device driver 上。本次 Android 技術大會除了介紹 Android 移植的重點（highlights）以及具體實作方向外，也會展示近期的小小實作成果。

雖然一開始提到，Android 平臺的好處是「將開發者侷限在應用層（application level）」的開發，但是 Android framework 與 Android 移植的能力仍然重要，畢竟這是直接影響產品開發的關鍵力之一。

]]>
      
   </content>
</entry>

</feed>