2016年2月13日土曜日

Android M Fingerprint APIについて調べてみた

関西モバイル研究会で発表した内容です。

Android M FingerPrint(public)
http://www.slideshare.net/baroqueworksdev/android-m-finger-printpublic

簡易クラス図

アプリからHAL層までの簡易クラス図です。



アプリケーションから使用する場合

  • Context#getSystemService()でFragmentprintManagerにアクセス 
  • コールバックで結果を受け取る

FingerprintManagerクラス

  • アプリケーションから要求を受け取る
  • Android Frameworksのサービス群にある、FingerprintServiceに連携
  • 認証結果をFingerprintServiceから受け取り、アプリケーションに通知する

FingerprintServiceクラス

  • SystemServiceクラスを継承
  • Android Systemとして指紋認証機能を実行
  • Native(JNI->HAL)につなぐ
  • 認証要求時にFingerprintDeamonクラスをとおして、Native層に通知 アプリケーションの突然死の際、unbindする(IBinder.DeathRecipient)

JNI / HAL層

  • HAL層(ライブラリ)をとおして、Kernelに通知、ハードウェアの制御を行う
  • 認証結果をKeystoreServiceに通知

2015年10月22日木曜日

[Swift][GCM]iOSでGoogle Cloud Messageを使う

iOSでGoogle Cloud Message 3.0を使ったので、はまりどころのメモです。
基本的なことは本家サイトを参照ください。
https://developers.google.com/cloud-messaging/ios/client?ver=swift

APNs用にデータを追加する

データ構造はGCM 2.0に以下のAPNsでも使用できるパラメータを追加すればデバイスに届きます。
  "content_available" : "true"
  "notification" : {
    "body" : "great match!",
    "title" : "Portugal vs. Denmark"
    }

もし、デバイスに届かない場合はcontent_availableの値を確認しましょう。"true"というStringではなく、true / falseのBoolが正しいです。

Push受信しても鳴動しない

notificationにsoundパラメータを追加しましょう。
https://developers.google.com/cloud-messaging/http-server-ref
https://developer.apple.com/jp/documentation/RemoteNotificationsPG.pdf

アプリ起動していない状態でバックグラウンド受信しない

priorityの追加
priorityパラメータを追加して、10を指定しましょう。
https://developers.google.com/cloud-messaging/http-server-ref
https://developer.apple.com/jp/documentation/RemoteNotificationsPG.pdf
iOSアプリ側の設定
Background fetch modeをONにしましょう。
AppDelegateにて、MinimumBackgroundFetchIntervalをセットします。DefaultはNeverになっているため、Background fetchしません。
  application.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)

2015年10月14日水曜日

[Swift][GoogleAnalytics]CustomDimensionを追加してイベント送信する

Google Analyticsのイベント送信時にCustomDimensionを追加する方法です。

        let tracker = GAI.sharedInstance().defaultTracker
        let params = GAIDictionaryBuilder.createEventWithCategory(
            category,
            action: action,
            label: label,
            value: value)
            .set(_corpId, forKey: GAIFields.customDimensionForIndex(1))
            .build() as [NSObject : AnyObject]
        
        tracker.send(params)


set(_corpId, forKey: GAIFields.customDimensionForIndex(1))でCustomDimensionの要素を追加しています。

2015年10月7日水曜日

[Nexus5][Android 6.0]OTAを手動でUpdateする

Android 6.0のOTA配信が始まりました。
XDAでOTA URLが投稿されています。

http://forum.xda-developers.com/google-nexus-5/general/ref-nexus-5-stock-ota-urls-t2475327

と、いうことでadbコマンドを使用して手動でUpdateしました。


curl -L https://android.googleapis.com/packages/ota/google_hammerhead/8f8cc12f7a9d7561be21f95914f289bda86e402b.signed-hammerhead-MRA58K-from-LMY48M.zip > 8f8cc12f7a9d7561be21f95914f289bda86e402b.signed-hammerhead-MRA58K-from-LMY48M.zip
adb reboot bootloader 
adb sideload 8f8cc12f7a9d7561be21f95914f289bda86e402b.signed-hammerhead-MRA58K-from-LMY48M.zip


2015年9月16日水曜日

Android Mリリース目前のAOSP mirrorの容量



久々にAOSP mirrorを作ってみました。
(備考:ローカルにAOSPのミラーを作成)


容量80GB超えたよ

上記の画像を見ていただければ、お分かり頂けると思いますが、容量が81.25GBと良い勢いで増えています。
いまSSD 128GB上に作成していますが、Android Mがリリースされると100GBまで行くんじゃないかと心配です。



とはいえ、頻繁にAOSPのソースを取得する現場ですと、mirrorがある方が効率的ですので導入を推奨いたします。

2015年9月15日火曜日

AOSP mirrorのrepo syncエラー: GPGが更新されない

久々にAOSP mirrorのrepo syncを実行したところ、エラーとなりました。
どうも、repoの更新ができていないよう。

info: A new version of repo is available


object 5ea32d135963da5542b78895f95332c6a17bbe11
type commit
tag v1.12.31
tagger Dan Willemsen  1441912006 -0700

repo v1.12.31

error: cannot run gpg: No such file or directory
error: could not run gpg.
error: could not verify the tag 'v1.12.31'


warning: Skipped upgrade to unverified version

ググってみたところ、次の方法で解決できるとのこと。
https://groups.google.com/forum/#!searchin/android-building/repo/android-building/ICajKIQlwC8/hxKulJLZ278J

mv ~/.repoconfig/gnupg ~/.repoconfig/gnupg_OLD

repoのconfig内のgnupgが更新されていないようなので、新規で取ってこいってことかな???
mv実行後、repo syncは無事に完遂しました。

2015年8月21日金曜日

iOS8.xでUITableViewAutomaticDimensionを使うと、セル位置が正常にならない

iOS8.xでTableViewのセル高さの自動調整が可能です。

    self.tableView.rowHeight = UITableViewAutomaticDimension



ただし、TableViewからセル選択により画面遷移後、戻ってきたときなど再表示をするとセル位置が調整されていないことがあります。 対策として、一度表示したセルの高さを保持しておいて、estimatedHeightForRowAtIndexPathで値を返します。

    var cellHeight:Dictionary = ["":0]
    
    override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
        
        cell.contentView.updateConstraints()
        self.cellHeight[String(indexPath.item )] = Float(cell.frame.size.height)
        
    }
    
    override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        if(self.cellHeight[String(indexPath.item )] != nil){
            return CGFloat(self.cellHeight[String(indexPath.item )]!)
        }
        return self.tableView.estimatedRowHeight
        
    }