SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
Introduction to
G-Sesnsor and
    E-Compass
           Jiahe Jou
            2, Dec., 2011
Outlines
● Introduction
  ○ Sensor System
● G-Sensor System
  ○ Java Application Layer
  ○ Java Framework Layer
  ○ JNI
  ○ Hardware Abstraction Layer
  ○ Linux Kernel
  ○ Setup G-Sensor Driver
● Conclusion
Introduction
           Sensor System
Sensor System
● Detect the environment to provide better
  user experience
  ○   Accelerometer
  ○   Magnetometer
  ○   Light Sensor
  ○   Temperature Meter
● Application
  ○ Game feature
  ○ Rotate screen
  ○ E-compass
Sensor System
● General architecture of sensor system
Sensor System
● API
  ○ Provide a interface to get system sensor manager
● Framework
  ○ Sensor manager service
  ○ Definitions of sensor, sensor event, event listener
● JNI
  ○ Link the framework layer and HAL
● HAL
  ○ The hardware foundation of Android
Sensor System
● In more detail
G-Sensor
System
          Java Application Layer
          Java Framework Layer
                             JNI
                            HAL
                    Linux Kernel
       Setup the G-Sensor driver
Java Application Layer
● Implement a sensor application
  ○ Get sensor manager
  ○ Get a specific sensor
  ○ Register sensor event listener

     ...

     mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

     mAccerlerometer = mSensorManager.getDefautSensor(
                                  Sensor.TYPE_ACCELEROMETER);

     mSensorManager.registerListener(this, mAccelerometer,
                                     SensorManager.SENSOR_DELAY_GAME);
     ...
Java Application Layer
● Implement event listener
     ...
     // Called when the sensor accuracy changed
     public void onAccuracyChanged(int sensor, int accuracy){
            // You can leave this function empty
     }

     ...
     // Called when the sensor value changed
     public void onSensorChanged(SensorEvent event{
            ...
            Log.d(TAG, "onSensorChanged==> sensor: " + sensor +
                                  ", x: " + event.values[0] +
                                  ", y: " + event.values[1] +
                                  ", z: " + event.values[2]);
            …
     }
     ...
G-Sensor
System
          Java Application Layer
          Java Framework Layer
                             JNI
                            HAL
                    Linux Kernel
       Setup the G-Sensor driver
Java Framework Layer
● Sensor Manager
  ○ getDefautSensor(int type)
     ...
     public Sensor getDefaultSensor( int type){
           // just return the 1st sensor
           List<Sensor> l = getSensorList(type);
           return l.isEmpty() ? null : l.get(0);
     }
     …


  ○ registerListener(SensorEventListener listener,
    Sensor sensor, int rate)
     ...
     public boolean registerListener( (SensorEventListener listener, Sensor sensor, int rate){
              // Another function was return
              return registerListener(listener, sensor, rate, null);
     }
     …
Java Framework Layer
 ○ registerListener( (SensorEventListener listener,
    Sensor sensor, int rate, Handler handler)
    ■ Delegate a listener on a sensor
    ■ Lock the listening thread before sensor enabled
    ■ Enable the sensor
    ■ Unlock the listening thread
    ■ Start polling

    PS. Please refer to the Figure 7 in document
G-Sensor
System
          Java Application Layer
          Java Framework Layer
                             JNI
                            HAL
                    Linux Kernel
       Setup the G-Sensor driver
JNI
● Sensor Manager
  ○ Mapped to the sensor manager in framework layer
    ■ nativeClassInit()
  ○ Provide the native function interface, e.g.:
    ■ sensors_enable_sensor()
    ■ sensors_data_poll()

      PS. Please refer to the Figure 8 and Figure 9 in document
G-Sensor
System
          Java Application Layer
          Java Framework Layer
                             JNI
                            HAL
                    Linux Kernel
       Setup the G-Sensor driver
Hardware Abstraction Layer
● Located in /hardware/STSensors/*
● Built on SensorBase.cpp
  ○ openInput(const char* inpuName)
  ○ Open input device for a given name when
      construction

      P.S. Please refer to the Figure 10 in document
Hardware Abstraction Layer
● AccSensor
  ○ #define INPUT_SYSFS_PATH_ACC "/sys/class/i2c-
    adapter/i2c-4/4-0019/"
  ○ readEvents()
    ■ Get data from sensor event
    ■ Calibrate for real world

    P.S. Please refer to the Figure 12 in document
G-Sensor
System
          Java Application Layer
          Java Framework Layer
                             JNI
                            HAL
                    Linux Kernel
       Setup the G-Sensor driver
Linux Kernel
● User space communicate with kernel space
  by system call
● Hardware drivers
● i2c protocol used
Linux Kernel
● General architecture from user space to
  hardware
Linux Kernel
● i2c driver need implement four methods:
  ○ probe
    ■ Check the i2c functionality
    ■ Initialize the input status
    ■ Register the poll function
    ■ Create the sysfs interface
  ○ remove
    ■ Unregister the poll device
    ■ Shutdown the power
    ■ Remove sysfs interface
    ■ Free the memory
  ○ resume
  ○ suspend
     P.S. Please refer the Figure 16 and Figure 17 in document
Linux Kernel
● lsm303dlh_acc_report_values()
     static void lsm303dlh_acc_report_values(struct lsm303dlh_acc_data *acc, int *xyz)
     {
            struct input_dev *input = acc->input_poll_dev->input;

          input_report_abs(input, ABS_X, xyz[0]);
          input_report_abs(input, ABS_Y, xyz[1]);
          input_report_abs(input, ABS_Z, xyz[2]);
          input_sync(input);
     }


    P.S. Please refer to the Figure 18 and Figure 19 in document
G-Sensor
System
          Java Application Layer
          Java Framework Layer
                             JNI
                            HAL
                    Linux Kernel
       Setup the G-Sensor driver
Setup G-Sensor Driver
● Let Linux kernel load the driver
   ○ innocomm_oracle_deconfig
   ○ KConfig
   ○ Makefile
     P.S. Please refer to Figure 21 in document

● Setup regulator comsumer
   ○ board-oracle.c
     P.S. Please refer to Figure 22 in document

● Setup the i2c between oracle board and chip
   ○ board-oracle-i2c.c
     P.S. Please refer to Figure 23 in document
Conclusion
             Conclusion
Conclusion
● A top-down view:
  ○   Java application layer
  ○   Java framework layer
  ○   HAL
  ○   Linux kernel
● E-Compass system is as same as the G-
  Sensor system

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to CUDA C: NVIDIA : Notes
Introduction to CUDA C: NVIDIA : NotesIntroduction to CUDA C: NVIDIA : Notes
Introduction to CUDA C: NVIDIA : NotesSubhajit Sahu
 
YaST Debugging
YaST DebuggingYaST Debugging
YaST Debugginglslezak
 
Open CL For Speedup Workshop
Open CL For Speedup WorkshopOpen CL For Speedup Workshop
Open CL For Speedup WorkshopOfer Rosenberg
 
Technical Deep Dive into the New Prefab System
Technical Deep Dive into the New Prefab SystemTechnical Deep Dive into the New Prefab System
Technical Deep Dive into the New Prefab SystemUnity Technologies
 
DLL Design with Building Blocks
DLL Design with Building BlocksDLL Design with Building Blocks
DLL Design with Building BlocksMax Kleiner
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCanSecWest
 
PVS-Studio, a solution for resource intensive applications development
PVS-Studio, a solution for resource intensive applications developmentPVS-Studio, a solution for resource intensive applications development
PVS-Studio, a solution for resource intensive applications developmentOOO "Program Verification Systems"
 
Converting Scene Data to DOTS – Unite Copenhagen 2019
Converting Scene Data to DOTS – Unite Copenhagen 2019Converting Scene Data to DOTS – Unite Copenhagen 2019
Converting Scene Data to DOTS – Unite Copenhagen 2019Unity Technologies
 
Paractical Solutions for Multicore Programming
Paractical Solutions for Multicore ProgrammingParactical Solutions for Multicore Programming
Paractical Solutions for Multicore ProgrammingGuy Korland
 
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesWe Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesUnity Technologies
 
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...David Walker
 
Меняем javascript с помощью javascript
Меняем javascript с помощью javascriptМеняем javascript с помощью javascript
Меняем javascript с помощью javascriptPavel Volokitin
 
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton -  CompilationsISCA Final Presentaiton -  Compilations
ISCA Final Presentaiton - CompilationsHSA Foundation
 
Дмитрий Вовк: Векторизация кода под мобильные платформы
Дмитрий Вовк: Векторизация кода под мобильные платформыДмитрий Вовк: Векторизация кода под мобильные платформы
Дмитрий Вовк: Векторизация кода под мобильные платформыDevGAMM Conference
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23DefconRussia
 

Was ist angesagt? (20)

Introduction to CUDA C: NVIDIA : Notes
Introduction to CUDA C: NVIDIA : NotesIntroduction to CUDA C: NVIDIA : Notes
Introduction to CUDA C: NVIDIA : Notes
 
YaST Debugging
YaST DebuggingYaST Debugging
YaST Debugging
 
Open CL For Speedup Workshop
Open CL For Speedup WorkshopOpen CL For Speedup Workshop
Open CL For Speedup Workshop
 
Technical Deep Dive into the New Prefab System
Technical Deep Dive into the New Prefab SystemTechnical Deep Dive into the New Prefab System
Technical Deep Dive into the New Prefab System
 
DLL Design with Building Blocks
DLL Design with Building BlocksDLL Design with Building Blocks
DLL Design with Building Blocks
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
 
PVS-Studio, a solution for resource intensive applications development
PVS-Studio, a solution for resource intensive applications developmentPVS-Studio, a solution for resource intensive applications development
PVS-Studio, a solution for resource intensive applications development
 
Converting Scene Data to DOTS – Unite Copenhagen 2019
Converting Scene Data to DOTS – Unite Copenhagen 2019Converting Scene Data to DOTS – Unite Copenhagen 2019
Converting Scene Data to DOTS – Unite Copenhagen 2019
 
Paractical Solutions for Multicore Programming
Paractical Solutions for Multicore ProgrammingParactical Solutions for Multicore Programming
Paractical Solutions for Multicore Programming
 
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesWe Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
 
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
 
Меняем javascript с помощью javascript
Меняем javascript с помощью javascriptМеняем javascript с помощью javascript
Меняем javascript с помощью javascript
 
Open gl basics
Open gl basicsOpen gl basics
Open gl basics
 
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton -  CompilationsISCA Final Presentaiton -  Compilations
ISCA Final Presentaiton - Compilations
 
Vulkan 1.1 Reference Guide
Vulkan 1.1 Reference GuideVulkan 1.1 Reference Guide
Vulkan 1.1 Reference Guide
 
Дмитрий Вовк: Векторизация кода под мобильные платформы
Дмитрий Вовк: Векторизация кода под мобильные платформыДмитрий Вовк: Векторизация кода под мобильные платформы
Дмитрий Вовк: Векторизация кода под мобильные платформы
 
The walking 0xDEAD
The walking 0xDEADThe walking 0xDEAD
The walking 0xDEAD
 
Lec02 03 opencl_intro
Lec02 03 opencl_introLec02 03 opencl_intro
Lec02 03 opencl_intro
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23
 
OpenXR 1.0 Reference Guide
OpenXR 1.0 Reference GuideOpenXR 1.0 Reference Guide
OpenXR 1.0 Reference Guide
 

Andere mochten auch (20)

Getting started with YUI3 and AlloyUI
Getting started with YUI3 and AlloyUIGetting started with YUI3 and AlloyUI
Getting started with YUI3 and AlloyUI
 
Accelerometer 1
Accelerometer 1Accelerometer 1
Accelerometer 1
 
Android accelerometer sensor tutorial
Android accelerometer sensor tutorialAndroid accelerometer sensor tutorial
Android accelerometer sensor tutorial
 
Android 1.8 sensor
Android 1.8 sensorAndroid 1.8 sensor
Android 1.8 sensor
 
From sensor data_to_android_and_back
From sensor data_to_android_and_backFrom sensor data_to_android_and_back
From sensor data_to_android_and_back
 
Sensor-driven indoor localization with android #bcs2
Sensor-driven indoor localization with android #bcs2Sensor-driven indoor localization with android #bcs2
Sensor-driven indoor localization with android #bcs2
 
Fusion_Class
Fusion_ClassFusion_Class
Fusion_Class
 
Android Training (Sensors)
Android Training (Sensors)Android Training (Sensors)
Android Training (Sensors)
 
Internet Week Yahoo! Academy: How Direct Can You Be?
Internet Week Yahoo! Academy: How Direct Can You Be?Internet Week Yahoo! Academy: How Direct Can You Be?
Internet Week Yahoo! Academy: How Direct Can You Be?
 
пдд азербайджана
пдд азербайджанапдд азербайджана
пдд азербайджана
 
Gresco catalog
Gresco catalogGresco catalog
Gresco catalog
 
The perng mha ngan box1
The perng mha ngan box1The perng mha ngan box1
The perng mha ngan box1
 
Quotationsanddialogue 2014
Quotationsanddialogue 2014Quotationsanddialogue 2014
Quotationsanddialogue 2014
 
The perng mha ngan box
The perng mha ngan boxThe perng mha ngan box
The perng mha ngan box
 
видеокамера сони
видеокамера сонивидеокамера сони
видеокамера сони
 
Bosh
BoshBosh
Bosh
 
Showdonttell
ShowdonttellShowdonttell
Showdonttell
 
Wallander - Becka
Wallander - BeckaWallander - Becka
Wallander - Becka
 
Gallus2002 usermanual
Gallus2002 usermanualGallus2002 usermanual
Gallus2002 usermanual
 
The perng mha ngan box
The perng mha ngan boxThe perng mha ngan box
The perng mha ngan box
 

Ähnlich wie Introduction to Android G-sensor

Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
 
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...Paris Open Source Summit
 
Advantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processingAdvantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processingGabor Paller
 
SensorStudio deep dive (IDC 2016)
SensorStudio deep dive (IDC 2016)SensorStudio deep dive (IDC 2016)
SensorStudio deep dive (IDC 2016)Herve Blanc
 
Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013Opersys inc.
 
Fluentd - CNCF Paris
Fluentd - CNCF ParisFluentd - CNCF Paris
Fluentd - CNCF ParisHorgix
 
Introducing the Sun SPOTs
Introducing the Sun SPOTsIntroducing the Sun SPOTs
Introducing the Sun SPOTsStefano Sanna
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Opersys inc.
 
Designate Install and Operate Workshop
Designate Install and Operate WorkshopDesignate Install and Operate Workshop
Designate Install and Operate WorkshopGraham Hayes
 
Node in Real Time - The Beginning
Node in Real Time - The BeginningNode in Real Time - The Beginning
Node in Real Time - The BeginningAxilis
 
Jollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-levelJollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-levelJollen Chen
 
UA Mobile 2012 (English)
UA Mobile 2012 (English)UA Mobile 2012 (English)
UA Mobile 2012 (English)dmalykhanov
 
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling ToolsTIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling ToolsXiaozhe Wang
 
ELC North America 2021 Introduction to pin muxing and gpio control under linux
ELC  North America 2021 Introduction to pin muxing and gpio control under linuxELC  North America 2021 Introduction to pin muxing and gpio control under linux
ELC North America 2021 Introduction to pin muxing and gpio control under linuxNeil Armstrong
 
Ultracode Berlin #2 : Introduction to Perceptual Computing by Sulamita Garcia
Ultracode Berlin #2 : Introduction to Perceptual Computing by Sulamita GarciaUltracode Berlin #2 : Introduction to Perceptual Computing by Sulamita Garcia
Ultracode Berlin #2 : Introduction to Perceptual Computing by Sulamita GarciaBeMyApp
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debuggingAshish Agrawal
 
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco Slot
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco SlotDistributed Computing on PostgreSQL | PGConf EU 2017 | Marco Slot
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco SlotCitus Data
 

Ähnlich wie Introduction to Android G-sensor (20)

Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Advantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processingAdvantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processing
 
SensorStudio deep dive (IDC 2016)
SensorStudio deep dive (IDC 2016)SensorStudio deep dive (IDC 2016)
SensorStudio deep dive (IDC 2016)
 
Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013
 
Fluentd - CNCF Paris
Fluentd - CNCF ParisFluentd - CNCF Paris
Fluentd - CNCF Paris
 
Introducing the Sun SPOTs
Introducing the Sun SPOTsIntroducing the Sun SPOTs
Introducing the Sun SPOTs
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
 
Designate Install and Operate Workshop
Designate Install and Operate WorkshopDesignate Install and Operate Workshop
Designate Install and Operate Workshop
 
Node in Real Time - The Beginning
Node in Real Time - The BeginningNode in Real Time - The Beginning
Node in Real Time - The Beginning
 
Jollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-levelJollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-level
 
Nodejs
NodejsNodejs
Nodejs
 
UA Mobile 2012 (English)
UA Mobile 2012 (English)UA Mobile 2012 (English)
UA Mobile 2012 (English)
 
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling ToolsTIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
 
ELC North America 2021 Introduction to pin muxing and gpio control under linux
ELC  North America 2021 Introduction to pin muxing and gpio control under linuxELC  North America 2021 Introduction to pin muxing and gpio control under linux
ELC North America 2021 Introduction to pin muxing and gpio control under linux
 
Ultracode Berlin #2 : Introduction to Perceptual Computing by Sulamita Garcia
Ultracode Berlin #2 : Introduction to Perceptual Computing by Sulamita GarciaUltracode Berlin #2 : Introduction to Perceptual Computing by Sulamita Garcia
Ultracode Berlin #2 : Introduction to Perceptual Computing by Sulamita Garcia
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debugging
 
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco Slot
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco SlotDistributed Computing on PostgreSQL | PGConf EU 2017 | Marco Slot
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco Slot
 

Mehr von Johnson Chou

Introduction to omap4 pad configuration
Introduction to omap4 pad configurationIntroduction to omap4 pad configuration
Introduction to omap4 pad configurationJohnson Chou
 
Introduction of unit test on android kernel
Introduction of unit test on android kernelIntroduction of unit test on android kernel
Introduction of unit test on android kernelJohnson Chou
 
Introduction of omap4 booting sequence
Introduction of omap4 booting sequence Introduction of omap4 booting sequence
Introduction of omap4 booting sequence Johnson Chou
 
Integrate gitolite with mantis
Integrate gitolite with mantisIntegrate gitolite with mantis
Integrate gitolite with mantisJohnson Chou
 
Algorithm Final Presentation
Algorithm Final PresentationAlgorithm Final Presentation
Algorithm Final PresentationJohnson Chou
 

Mehr von Johnson Chou (6)

JavaScript OOPs
JavaScript OOPsJavaScript OOPs
JavaScript OOPs
 
Introduction to omap4 pad configuration
Introduction to omap4 pad configurationIntroduction to omap4 pad configuration
Introduction to omap4 pad configuration
 
Introduction of unit test on android kernel
Introduction of unit test on android kernelIntroduction of unit test on android kernel
Introduction of unit test on android kernel
 
Introduction of omap4 booting sequence
Introduction of omap4 booting sequence Introduction of omap4 booting sequence
Introduction of omap4 booting sequence
 
Integrate gitolite with mantis
Integrate gitolite with mantisIntegrate gitolite with mantis
Integrate gitolite with mantis
 
Algorithm Final Presentation
Algorithm Final PresentationAlgorithm Final Presentation
Algorithm Final Presentation
 

Kürzlich hochgeladen

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 

Kürzlich hochgeladen (20)

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 

Introduction to Android G-sensor

  • 1. Introduction to G-Sesnsor and E-Compass Jiahe Jou 2, Dec., 2011
  • 2. Outlines ● Introduction ○ Sensor System ● G-Sensor System ○ Java Application Layer ○ Java Framework Layer ○ JNI ○ Hardware Abstraction Layer ○ Linux Kernel ○ Setup G-Sensor Driver ● Conclusion
  • 3. Introduction Sensor System
  • 4. Sensor System ● Detect the environment to provide better user experience ○ Accelerometer ○ Magnetometer ○ Light Sensor ○ Temperature Meter ● Application ○ Game feature ○ Rotate screen ○ E-compass
  • 5. Sensor System ● General architecture of sensor system
  • 6. Sensor System ● API ○ Provide a interface to get system sensor manager ● Framework ○ Sensor manager service ○ Definitions of sensor, sensor event, event listener ● JNI ○ Link the framework layer and HAL ● HAL ○ The hardware foundation of Android
  • 7. Sensor System ● In more detail
  • 8. G-Sensor System Java Application Layer Java Framework Layer JNI HAL Linux Kernel Setup the G-Sensor driver
  • 9. Java Application Layer ● Implement a sensor application ○ Get sensor manager ○ Get a specific sensor ○ Register sensor event listener ... mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mAccerlerometer = mSensorManager.getDefautSensor( Sensor.TYPE_ACCELEROMETER); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); ...
  • 10. Java Application Layer ● Implement event listener ... // Called when the sensor accuracy changed public void onAccuracyChanged(int sensor, int accuracy){ // You can leave this function empty } ... // Called when the sensor value changed public void onSensorChanged(SensorEvent event{ ... Log.d(TAG, "onSensorChanged==> sensor: " + sensor + ", x: " + event.values[0] + ", y: " + event.values[1] + ", z: " + event.values[2]); … } ...
  • 11. G-Sensor System Java Application Layer Java Framework Layer JNI HAL Linux Kernel Setup the G-Sensor driver
  • 12. Java Framework Layer ● Sensor Manager ○ getDefautSensor(int type) ... public Sensor getDefaultSensor( int type){ // just return the 1st sensor List<Sensor> l = getSensorList(type); return l.isEmpty() ? null : l.get(0); } … ○ registerListener(SensorEventListener listener, Sensor sensor, int rate) ... public boolean registerListener( (SensorEventListener listener, Sensor sensor, int rate){ // Another function was return return registerListener(listener, sensor, rate, null); } …
  • 13. Java Framework Layer ○ registerListener( (SensorEventListener listener, Sensor sensor, int rate, Handler handler) ■ Delegate a listener on a sensor ■ Lock the listening thread before sensor enabled ■ Enable the sensor ■ Unlock the listening thread ■ Start polling PS. Please refer to the Figure 7 in document
  • 14. G-Sensor System Java Application Layer Java Framework Layer JNI HAL Linux Kernel Setup the G-Sensor driver
  • 15. JNI ● Sensor Manager ○ Mapped to the sensor manager in framework layer ■ nativeClassInit() ○ Provide the native function interface, e.g.: ■ sensors_enable_sensor() ■ sensors_data_poll() PS. Please refer to the Figure 8 and Figure 9 in document
  • 16. G-Sensor System Java Application Layer Java Framework Layer JNI HAL Linux Kernel Setup the G-Sensor driver
  • 17. Hardware Abstraction Layer ● Located in /hardware/STSensors/* ● Built on SensorBase.cpp ○ openInput(const char* inpuName) ○ Open input device for a given name when construction P.S. Please refer to the Figure 10 in document
  • 18. Hardware Abstraction Layer ● AccSensor ○ #define INPUT_SYSFS_PATH_ACC "/sys/class/i2c- adapter/i2c-4/4-0019/" ○ readEvents() ■ Get data from sensor event ■ Calibrate for real world P.S. Please refer to the Figure 12 in document
  • 19. G-Sensor System Java Application Layer Java Framework Layer JNI HAL Linux Kernel Setup the G-Sensor driver
  • 20. Linux Kernel ● User space communicate with kernel space by system call ● Hardware drivers ● i2c protocol used
  • 21. Linux Kernel ● General architecture from user space to hardware
  • 22. Linux Kernel ● i2c driver need implement four methods: ○ probe ■ Check the i2c functionality ■ Initialize the input status ■ Register the poll function ■ Create the sysfs interface ○ remove ■ Unregister the poll device ■ Shutdown the power ■ Remove sysfs interface ■ Free the memory ○ resume ○ suspend P.S. Please refer the Figure 16 and Figure 17 in document
  • 23. Linux Kernel ● lsm303dlh_acc_report_values() static void lsm303dlh_acc_report_values(struct lsm303dlh_acc_data *acc, int *xyz) { struct input_dev *input = acc->input_poll_dev->input; input_report_abs(input, ABS_X, xyz[0]); input_report_abs(input, ABS_Y, xyz[1]); input_report_abs(input, ABS_Z, xyz[2]); input_sync(input); } P.S. Please refer to the Figure 18 and Figure 19 in document
  • 24. G-Sensor System Java Application Layer Java Framework Layer JNI HAL Linux Kernel Setup the G-Sensor driver
  • 25. Setup G-Sensor Driver ● Let Linux kernel load the driver ○ innocomm_oracle_deconfig ○ KConfig ○ Makefile P.S. Please refer to Figure 21 in document ● Setup regulator comsumer ○ board-oracle.c P.S. Please refer to Figure 22 in document ● Setup the i2c between oracle board and chip ○ board-oracle-i2c.c P.S. Please refer to Figure 23 in document
  • 26. Conclusion Conclusion
  • 27. Conclusion ● A top-down view: ○ Java application layer ○ Java framework layer ○ HAL ○ Linux kernel ● E-Compass system is as same as the G- Sensor system