2013年5月9日木曜日

FireFoxOS(B2G)のPeak用ビルド

ソース取得

ソースの取得方法はこちら。
https://developer.mozilla.org/ja/docs/Mozilla/Boot_to_Gecko/Preparing_for_your_first_B2G_build

git cloneでベース環境を取得。
git clone git://github.com/mozilla-b2g/B2G.git
cd B2G

次のスクリプトを実行。

./config.sh peak

実行すると、、、
Get git://github.com/mozilla-b2g/b2g-manifest
remote: Counting objects: 620, done.
remote: Compressing objects: 100% (319/319), done.
remote: Total 620 (delta 402), reused 487 (delta 283)
Receiving objects: 100% (620/620), 126.73 KiB | 113 KiB/s, done.
Resolving deltas: 100% (402/402), done.
From git://github.com/mozilla-b2g/b2g-manifest
 * [new branch]      master     -> origin/master
 * [new branch]      v1-train   -> origin/v1-train
 * [new branch]      v1.0.0     -> origin/v1.0.0
 * [new branch]      v1.0.1     -> origin/v1.0.1
 * [new tag]         B2G_1_0_1_20130213094222 -> B2G_1_0_1_20130213094222
 * [new tag]         closing-nightly -> closing-nightly
fatal: manifest 'peak.xml' not available
fatal: manifest peak.xml not found
Repo sync failed

上記のエラーが出てしまいました。
peak.xmlがないとおっしゃっています。
config.shの中身をみると、以下のようにbranchが指定されています。
GITREPO=${GITREPO:-"git://github.com/mozilla-b2g/b2g-manifest"}
BRANCH=${BRANCH:-v1-train}
以下のgitとみると、確かにない。
https://github.com/mozilla-b2g/b2g-manifest/tree/v1-train


でも、masterブランチには存在しています。
https://github.com/mozilla-b2g/b2g-manifest


ブランチの切り替えは、以下のように公式ページに書かれています。
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Preparing_for_your_first_B2G_build
Building a branch
If you want to build for a branch other than the trunk, you will need to prefix your call to config.sh with a branch name, like this:
BRANCH=branch-name ./config.sh target


と、いうことで次のコマンドを実行。
BRANCH=master ./config.sh peak



ビルド実行

次のスクリプトを実行。

./build.sh


extract-files.shが実行され、端末からライブラリを引っこ抜こうとしています。
build.shの内容を確認すると、以下のような感じ。

    # Select which blob setup script to use, if any.  We currently
    # assume that $DEVICE maps to the filesystem location, which is true
    # for the devices we support now (oct 2012) that do not require blobs.
    # The emulator uses a $DEVICE of 'emulator' but its device/ directory
    # uses the 'goldfish' name.
    if [ -f device/*/$DEVICE/download-blobs.sh ] ; then
        important_files="device/*/$DEVICE/download-blobs.sh"
        script="cd device/*/$DEVICE && ./download-blobs.sh"
    elif [ -f device/*/$DEVICE/extract-files.sh ] ; then
        important_files="device/*/$DEVICE/extract-files.sh"
        script="cd device/*/$DEVICE && ./extract-files.sh"
    else
        important_files=
        script=
    fi

ビルド時間です。
VMware Player上ですが8スレッド認識、Corei7でSSDの環境です。

Creating filesystem with parameters:
    Size: 471859200
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 7200
    Inode size: 256
    Journal blocks: 1800
    Label: 
    Blocks: 115200
    Block groups: 4
    Reserved block group size: 31
Created filesystem with 776/28800 inodes and 26358/115200 blocks
Install system fs image: out/target/product/peak/system.img
out/target/product/peak/system.img+out/target/product/peak/obj/PACKAGING/recovery_patch_intermediates/recovery_from_boot.p total size is 102366980

real 29m22.116s
user 184m19.700s
sys 24m10.780s
Run |./flash.sh| to flash all partitions of your device

real 29m24.542s
user 184m23.600s
sys 24m11.160s

2013年5月8日水曜日

GeeksPhoneでFireFoxOS端末 Peakを買ってみた

GeeksPhoneでFireFoxOS端末を購入しました。
4/23に注文、5/7に届きました。

http://www.geeksphone.com/


Peakの端末購入価格

Peakの価格は149ユーロでした。
6台購入で894ユーロ、これに送料83.55ユーロを加算して、計977.55ユーロでした。

クレジットの請求は、129,924円。(1ユーロ = 132.9円換算)
UPSの配達時に税金5,700円を支払。
合計:135,624円

Peak 1台あたり、22,604円


端末が届いた

UPSから届いた時の写真。




UPSの袋はズタボロです。
中身が心配になりながら、袋を開けると、、、




こんな感じで、またもやUPSの袋。2重ですよ、2重。
で、もう一度、ふくろを開けると、、、



なんと、端末の箱がそのまま入っていました。
ええ、袋2枚に”だけ”覆われて、スペインから日本にまで送られてきました。


UPSの記録

参考までに、UPSの配達記録を晒しておきます。
大阪市内に住んでいるため、UPS直轄地域で土日祝日には届けてくれません。


場所 日付 現地時間 状況
Osaka-shi, Japan 2013/05/07 10:56 お客様は1回目の配達時にご不在でした。 2回目の配達が行われます。
2013/05/07 7:45 配達を手配しました
Osaka, Japan 2013/05/07 6:20 空港出発時刻
Osaka, Japan 2013/05/06 13:46 空港上屋スキャン(輸入)
2013/05/06 9:16 空港到着時刻
Narita, Japan 2013/05/06 7:52 空港出発時刻
2013/05/06 6:44 空港到着時刻
Shenzhen, China 2013/05/06 1:28 空港出発時刻
Osaka, Japan 2013/05/05 16:51 通関業者により登録されました。貨物リリースは通関業者の確認が保留されています / 貨物は通関業者に提出されました。最終リリースを待っています
2013/05/05 16:51 通関業者により登録されました。貨物リリースは通関業者の確認が保留されています / 通関業者によってリリースされました。現在輸送中です
Shenzhen, China 2013/05/04 0:19 空港到着時刻
Koeln, Germany 2013/05/03 6:24 空港出発時刻
2013/05/03 0:46 空港到着時刻
Madrid, Spain 2013/05/02 22:34 空港出発時刻
2013/05/02 22:03 空港到着時刻
2013/05/02 21:45 空港出発時刻
2013/05/02 20:09 発地国センタースキャン
2013/05/02 18:18 集荷スキャン
Spain 2013/05/02 13:32 処理完了: UPSへの引渡し準備ができました                                                                          

2013年4月7日日曜日

FireFoxOS(B2G)のビルド

FireFoxOS(B2G)をビルドしてみました。

ビルド環境構築

ビルド環境の構築方法はこちら。
https://developer.mozilla.org/ja/docs/Mozilla/Boot_to_Gecko/B2G_build_prerequisites

Androidのビルド環境がある方は、次のパッケージを追加すればいけるはず。(Ubuntu10.04で確認)

追加でインストールしたパッケージ
ccache autoconf2.13

ソース取得

ソースの取得方法はこちら。
https://developer.mozilla.org/ja/docs/Mozilla/Boot_to_Gecko/Preparing_for_your_first_B2G_build

git cloneでベース環境を取得。
git clone git://github.com/mozilla-b2g/B2G.git
cd B2G

Nexus Sのビルド環境は次のスクリプトを実行。config.shの中身をみれば、対応デバイスがわかります。

./config.sh nexus-s


ビルド実行

次のスクリプトを実行。
./build.sh


次のスクリプトでproprietary binariesの取得を行っています。
    # Select which blob setup script to use, if any.  We currently
    # assume that $DEVICE maps to the filesystem location, which is true
    # for the devices we support now (oct 2012) that do not require blobs.
    # The emulator uses a $DEVICE of 'emulator' but its device/ directory
    # uses the 'goldfish' name.
    if [ -f device/*/$DEVICE/download-blobs.sh ] ; then
        important_files="device/*/$DEVICE/download-blobs.sh"
        script="cd device/*/$DEVICE && ./download-blobs.sh"
    elif [ -f device/*/$DEVICE/extract-files.sh ] ; then
        important_files="device/*/$DEVICE/extract-files.sh"
        script="cd device/*/$DEVICE && ./extract-files.sh"
    else
        important_files=
        script=
    fi


ビルドが成功すると、こんな感じ。

Creating filesystem with parameters:
    Size: 536870912
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8192
    Inode size: 256
    Journal blocks: 2048
    Label: 
    Blocks: 131072
    Block groups: 4
    Reserved block group size: 31
Created filesystem with 873/32768 inodes and 24287/131072 blocks
Install system fs image: out/target/product/crespo/system.img
out/target/product/crespo/system.img+out/target/product/crespo/obj/PACKAGING/recovery_patch_intermediates/recovery_from_boot.p total size is 93266198

real 19m22.266s
user 110m3.480s
sys 14m37.520s
Run |./flash.sh| to flash all partitions of your device

real 19m25.213s
user 110m7.650s
sys 14m37.910s


Corei7&VMware上(メモリ12GB)で、約20分でフルビルドができました。

2013年3月25日月曜日

Nexus 4でNFCタグが読み込めない?

Galaxy Nexusで正常に読み込めていたNFCタグが、Nexus 4で読み込めませんでした。
とりあえず、デバッグ。

ディスパッチシステムで配信されるNFCのデータを確認
 
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
GNとN4のログを取ると、、、
 
Galaxy Nexus
TAG: Tech [android.nfc.tech.MifareClassic, android.nfc.tech.NfcA, android.nfc.tech.Ndef]

Nexus4
TAG: Tech [android.nfc.tech.NfcA]

ようするに、Nexus 4はMifareClassicは対応してないよ!ってことでした。

以下の2点を忘れていました。。。

  • MifareClassicとMifareUltralightはオプション
  • Nexus 4 /10のNFCチップはBroadcom製に変わった

以下のサイトも読んでおきましょう。


http://www.nfcbrief.com/2012/11/nexus-4-and-10-incompatible-with-mifare.html
http://developer.android.com/about/versions/jelly-bean.html

2013年2月4日月曜日

Google Playに誘導するNFCタグを作る




Google Playに誘導するNFCタグを作りました。
イベントなどで自作アプリを紹介する際、実際にダウンロードしてもらう良い手段だと思います。


Google PlayへのURL

Google PlayへのURLはこちらを参照。
Linking to Product Detail Page:
http://developer.android.com/distribute/googleplay/promote/linking.html


以下は詳細画面へのURLの例です。
From a web site:
http://play.google.com/store/apps/details?id=<package_name>
From an Android app:
market://details?id=<package_name>


Google Playアプリは「http:」でも反応します。Android端末以外のユーザーにも見てもらうために、「market:」ではなく「http:」を使用することをお薦めします。


NFCタグへの書き込み

Google Playアプリ詳細画面へのURLをNFCタグに書き込みます。
NDEF規格への書き込み例です。
手順
  1. NdefRecord#createUriでNDEFレコードを生成
  2. NDEFメッセージを生成
  3. Writeする

        NdefRecord rtdUriRecords[] = {
                // Google Playの詳細ページURL
                NdefRecord.createUri("http://play.google.com/store/apps/details?id=jp.baroqueworksdev.twiccamushroom")
        };
        NdefMessage ndefMsg = new NdefMessage(rtdUriRecords);
        Ndef ndef = Ndef.get(tag);

        if (ndef.isWritable()) {
            try {
                ndef.connect();
                ndef.writeNdefMessage(ndefMsg);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (FormatException e) {
                e.printStackTrace();
            } finally {
                try {
                    ndef.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

2013年2月3日日曜日

NFCタグを読み込む NdefMessage編

NDEF規格のNFCタグを読み込む方法をまとめます。

参考:NFCタグにURLを書き込む
http://baroqueworksdevjp.blogspot.jp/2013/02/nfcurl.html


Intent-filterの記載

NDEF規格のNFCタグをハンドリングするために、android.nfc.action.NDEF_DISCOVEREDを追加
<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="http" />
</intent-filter>



IntentからNDEF情報を取得する

IntentのExtra情報:NfcAdapter.EXTRA_NDEF_MESSAGESから、NdefRecordを取得する。
if (getIntent().getAction().equals(NfcAdapter.ACTION_NDEF_DISCOVERED)) {
    Parcelable[] rawMsgs = getIntent().getParcelableArrayExtra(
            NfcAdapter.EXTRA_NDEF_MESSAGES);
    if (rawMsgs != null) {
        for (Parcelable pa : rawMsgs) {
            NdefMessage ndefMsg = (NdefMessage) pa;
            NdefRecord[] records = ndefMsg.getRecords();
            for (NdefRecord rec : records) {
                android.util.Log.e("", "NDEF toString = " + rec.toString());
                // Added in API level 16
                android.util.Log.e("", "NDEF toMimeType = " + rec.toMimeType());
                // Added in API level 16
                android.util.Log.e("", "NDEF toUri = " + rec.toUri());
            }
        }
    }
}

NdefRecord#toMimeType()とNdefRecord#toUri()はAPI Level 16から使用可能。
それ以前のAndroid versionの場合、自分で生成しないといけません。
以下のソースが参考になるかも。
\frameworks\base\core\java\android\nfc\NdefRecord.java


注意点

こんなバグがあるから気を付けよう。
Issue 36968: Scanning an NFC tag without a ndef record results in null pointer exception
http://code.google.com/p/android/issues/detail?id=36968

2013年2月2日土曜日

NFCタグにURLを書き込む

NFCタグシールを購入しました。
価格は一枚あたり約300円でした




このNFCタグへURLの書き込みを行いました。

NdefFormatableのハンドリング

NdefFormatableのTag配信をハンドリングするための準備
AndroidManifest.xmlの記載
NFCを使うためのPermision
<uses-permission android:name="android.permission.NFC" />

<uses-feature
    android:name="android.hardware.nfc"
    android:required="true" />


Intent-filterの追加
<intent-filter>
    <action android:name="android.nfc.action.TECH_DISCOVERED" />

    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<meta-data
    android:name="android.nfc.action.TECH_DISCOVERED"
    android:resource="@xml/nfc_tech_list" />


Tech-ListのXmlを作成
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <tech-list>
        <tech>android.nfc.tech.NdefFormatable</tech>
    </tech-list>
</resources>


Activity側でTagを受信
IntentからTag情報を取得
if (getIntent().getAction().equals(NfcAdapter.ACTION_TECH_DISCOVERED)) {
    Tag tag = getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG);
}


NFCタグへURLを書き込む
NdefFormatable.get(tag)でNdefFormatableクラスを取得し、write処理を行う。
    public void write(Tag tag, String uri) {
        NdefRecord rtdUriRecords[] = {
                NdefRecord.createUri(uri)
        };
        NdefFormatable ndef = NdefFormatable.get(tag);
        NdefMessage message = new NdefMessage(rtdUriRecords);
        try {
            ndef.connect();
            ndef.format(message);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (FormatException e) {
            e.printStackTrace();
        } finally {
            try {
                ndef.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }