1. 程式人生 > >android 學習記錄待整理

android 學習記錄待整理

JNI 向上提供本地函式,向下載入HAL檔案並呼叫HAL 函式

HAL負責訪問驅動程式執行硬體操作

HAL

1、dlopen載入    

    delopen(filename)


vendor/lib/hw   system/lib/hw

安卓的屬性系統

led.XXX.so---->XXX就是某個屬性值

hw_get_module("led")

  hw_module_exists()

JNI 怎麼使用HAL

1、hw_get_module:獲得hw_module_t的結構體

2、hw_module_t->methods->open()獲得he_device_t

HAL 怎麼寫

1、實現一個名為HMI 的hw_module_t結構體

2、實現一個open 函式,返回一個裝置自定義的結構體hw_device_t

可參考:hardware\libhardware\modules\vibrator\vibrator.c