Introduction à Android by Jean Collas, Ghislain Deffrasne, Reda Sebbaniis licensed under a Creative Commons Attribution 2.0 France License. Original at http://www.jean-collas.fr/android
Ouverture Jean Collas, Réda Sebbani, Ghislain Deffrasnes
Contexte Contexte 3 Téléphonie Mobile : Smart Phone Développement logiciel pour mobiles Chiffre d’affaire énorme Windows Mobile RIM 40 millions de smartphones / trimestre (2008) Symbian iPhone OS
Contexte Concurrentiel 4 Systèmes d’exploitation pour Mobiles : Marché en constante augmentation Possibilités d’évolution énormes avec un bon produit
Contexte Concurrentiel 5 Systèmes d’exploitation pour Smart phone : Marché en constante augmentation (+28% en 1 an, 31M -> 40M) Possibilités d’évolution énormes avec un bon produit
Internet & Google 6 Fondé en 98, croissance constante Multiples domaines de l’informatique : Recherche, cartographie, vidéo, conception 3D, suite bureautique, publicité, navigateur, … Politique de financement par la publicité Attaque du monde mobile par la source : le système d’exploitation Android
Points forts d’Android Points fort d’Android 7 Point de vue constructeur Point de vue utilisateur Point de vue développeur Point de vue bidouilleur Système Linux + Java Système fonctionnel, intuitif, évolutif Application développées en syntaxe Java SDK complet fourni Projet Open Source C++ / Java
Historique Historique 8 T-Mobile G1 Novembre 2008 Android 1.0 et SDK release 2 Android : Open Source Octobre 2008 Android 1.0 et SDK release 1 Septembre 2008 AndroidMarket Août 2008 Avril 2008 Développement d’Android Developer Challenge Open Handset Alliance Annonce d’Android SDK pour Android Novembre 2007 Start-up Android Août 2005
Open Handset Alliance 9
Consortium créé fin 2007
47 compagnies
Fabricants de semi-conducteurs Opérateurs de téléphonie mobile Entreprises de commercialisation Fabricants d'appareils mobiles Fabricants de logiciels
But : développer des normes ouvertes pour les appareils de téléphonie mobile
T-Mobile G1 T-Mobile G1 (HTC) 10
1ertéléphone avec Android
De 180 à 400 $
Wi-fi et Bluetooth
GPS
Accéléromètres
Caméra
Écran tactile
De nouveaux mobiles 11 LG L’agora par Kogan http://www.businessmobile.fr/solutions-mobiles/guides-mobilite/0,39044672,39220692,00.htm
Matériel Recommandé 12
RAM : 128 Mo (minimum requis)
Mémoire Flash : 256 Mo (minimum requis)
Wifi : 802.11 b/g
USB : interface USB 2.0
Bluetooth 2.0 EDR
Caméra
Périphérique de stockage externe
Écran :
Résolution HVGA (480 × 320 pixels)
Couleurs 16 bits
Preuve de sa portabilité – Futur d’Android 13 Et si Android n’était pas seulement conçu pour les smartphone? Android sur un NetBook
Développementd’Applications 14 Possibilité de créer ses propres applications Environnement de développement Android SDK Plugin Eclipse Émulateur, outils de débuggage, etc… Langage Java ?
Intégration des applications Google 15 Barre de recherche « Google Search » Gmail Google Talk (IM) Navigateur Web Gmaps Google StreetView
Exemples d’applications : Android Market 16 Géolocalisation Orientation Tourisme Géolocalisation Travail Voisinage Google Maps Voyage Achats Covoiturage
Points d’accès d’Android 17 Point de vue constructeur Point de vue utilisateur Point de vue développeur Point de vue bidouilleur Système Linux + Java Système fonctionnel, intuitif, évolutif Application développées en syntaxe Java SDK complet fourni Projet Open Source C++ / Java
Architecture 18 APPLICATIONS Home Contacts Phone Browser … APPLICATION FRAMEWORK Activity Manager Window Manager Content Providers View System Package Manager Telephony Manager Resource Manager Location Manager Notification Manager ANDROID RUNTIME JNI LIBRARIES CoreLibraries Surface Manager Media Framework SQL Lite Dalvik Virtual Machine OpenGL Audio Manager WebKit SGL SSL Libc LINUX KERNEL Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver Keypad Driver WiFi Driver Audio Driver Power Management
Noyau d’Android 19 Architecture ARM Basé sur Linux 2.6.24 Système de fichiers supporté : FAT32 Support de TCP/IP, UDP,… HARDWARE ABSTRACTION LAYER Graphics Audio Camera Bluetooth GPS WiFi … LINUX KERNEL Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver Keypad Driver WiFi Driver Audio Driver Power Management
Adaptation aux besoins du mobile 20
Alarm : timers pour « réveiller » des périphériques
Ashmem : partage de mémoire entre processus
Binder : driver IPC pour la communication inter-processus
Power Management
Low Memory Killer
Kernel Debugger
Logger
HARDWARE ABSTRACTION LAYER Graphics Audio Camera Bluetooth GPS WiFi … LINUX KERNEL Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver Keypad Driver WiFi Driver Audio Driver Power Management
Librairies 21 LIBRARIES Surface Manager Media Framework SQL Lite OpenGL Audio Manager WebKit SGL SSL Libc LINUX KERNEL Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver Keypad Driver WiFi Driver Audio Driver Power Management
Machine Virtuelle Dalvik 24 ANDROID RUNTIME LIBRARIES CoreLibraries Surface Manager Media Framework SQL Lite Dalvik Virtual Machine OpenGL Audio Manager WebKit SGL SSL Libc LINUX KERNEL Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver Keypad Driver WiFi Driver Audio Driver Power Management
Machine Virtuelle Dalvik 25 Nouvelle instance pour chaque processus : Applications indépendantes Exécute des fichiers .dex (Dalvik Executable) Dalvik core class library fournit une base de développement proche de java SE, adapté au mobile
29 Intent Filter Objectif : Description du handler Publication d’IntentFilters par les activités IntentFilter décrivent les capacités de l’application. <intent-filter> <actionandroid:value="android.intent.action.VIEW"/> <actionandroid:value="android.intent.action.EDIT"/> <actionandroid:value="android.intent.action.PICK"/> <category android:value="android.intent.category.DEFAULT" /> <type android:value="vnd.android.cursor.dir/vnd.google.contact" /> </intent-filter>
Les URIs - Utilisation 30 Exemples d’URI: Intent EDIT_ACTION Ouvre l’application de géo-localisation à la position donnée (latitude, longitude). VIEW_ACTION geo: tel: 125 people/ content: google.streetview: //contacts/ 25,32 123 cbll=25,32 Appelle le numéro 123 CALL_ACTION VIEW_ACTION &cbp=1,yaw,,pitch,zoom void startActivity(Intent intent) ; void sendBroadcast(Intent intent)boolean bindService(Intent service, int flags) ComponentName startService(Intent service)
Notification Manager 31 Applications peuvent s’exécuter simultanément Barre de notifications Notificationsd’événements du background Mise en place facilité par le Notification Manager Différentes formes de notifications :
LED
Son
Vibreur
Barre de notification (icône)
Composants d’une application 32 Activity Broadcast Receiver Service Content Provider
ContentProvider 33 SYSTEM APK APK service Activity service Activity Activity SQLite Data XML Remote data
ContentProvider 34 SYSTEM APK APK service Activity service Activity Activity ContentProvider SQLite Data XML Remote data
Les URIs 35 Exemples d’URI d’un content provider: Activity IntentReceiver Service Content Provider 125 people/ content: 53 users/ content: //contacts/ //com.maCompanie.monApp/ A Préfixe d’accès aux données, type d’URI B Identifiant ou type du content provider à consulter C 0 ou plusieurs segments, permettent de déterminer le type de données D Enregistrement spécifique éventuellement demandé (identifiant, référence) <providerclass=".NotePadProvider"android:authorities="com.google.provider.NotePad"/>
Activity 37 Objet qui possède un cycle de vie Code qui réalise un traitement Activity IntentReceiver Point d’entrée d’une application Service Content Provider Généralement, uneActivityafficheune UI <activityclass=".NoteEditor"android:label="@string/title_note"> <intent-filterandroid:label="@string/resolve_edit"> <actionandroid:value="android.intent.action.VIEW"/> <actionandroid:value="android.intent.action.EDIT"/> <categoryandroid:value="android.intent.category.DEFAULT"/> <typeandroid:value="vnd.android.cursor.item/vnd.google.note"/> </intent-filter> </activity>
Broadcast receiver 38 Broadcast receiver permet de réagir à des évènements extérieurs à l’application Activity BroadcastReceiver Service Content Provider . Permet de réveiller une application Un Intent peut être boadcasté; on peut utiliser un broadcast receiver pour gérer ce type d’evt Permet également de réagir à des notification du système (évènements extérieurs/matériels). <receiverandroid:name=".app.OneShotAlarm"android:process=":remote"/>
Service 39 Activity IntentReceiver Composante sans GUI Activité de longue durée Service Content Provider Service interne : Context.startService() Service externe : Context.bindService() Communication via une interface Ex Media Player : pause, lecture, stop, etc
Service : AndroidManifest 40 Activity IntentReceiver <serviceandroid:name=".app.RemoteService"android:process=":remote"> <intent-filter> <!-- These are the interfaces supported by the service, which you can bind to. --> <actionandroid:name="com.example.android.apis.app.IRemoteService"/> <!-- This is an action code you can use to select the service without explicitly supplying the implementation class. --> <actionandroid:name="com.example.android.apis.app.REMOTE_SERVICE"/> </intent-filter> </service> Service Content Provider
Cycle de vie d’une Activité 42 OnCreate() Allocation des ressources Activity IntentReceiver OnStart() Affichage à l’écran Service Content Provider Running OnResume() Passage au premier plan Paused 4 états :
active/running
paused
stopped
killed/shut down
OnPause() Passage en arrière plan Stopped OnStop() Arrêt de l’exécution Killed OnDestroy() Libération des ressources
Cycle de vie d’une Activité 43 Retour à l’application New Activity 1. OnCreate() 2. OnStart() 3. OnResume() Application Killed Running (Foreground) OnFreeze() OnPause() OnResume() Besoin de mémoire 3. OnResume() 2. OnStart() 1. OnRestart() Paused (Background) Application plus visible OnStop() Stopped (Plus visible) L’utilisateur quitte OnDestroy() Destroyed
Hiérarchie des processus 44 Hiérarchie des processus ForegroundProcess Activité Importance Visible Process Activité en arrière plan Processus des composants « Service » disponibles en arrière plan Service Process Background Process Processus en arrière plan, non visible. EmptyProcess Cache pour les processus
Les applications 45 APPLICATIONS Home Contacts Phone Browser … APPLICATION FRAMEWORK Activity Manager Window Manager Content Providers View System Package Manager Telephony Manager Resource Manager Location Manager Notification Manager ANDROID RUNTIME JNI LIBRARIES CoreLibraries Surface Manager Media Framework SQL Lite Dalvik Virtual Machine OpenGL Audio Manager WebKit SGL SSL Libc LINUX KERNEL Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver Keypad Driver WiFi Driver Audio Driver Power Management
Développement en Java : Méthode classique 46 packagecom.android.hello;
57 Symbian's chief technical advantage today is the platform's maturity, and more recently, its real-time kernel. ?
Annexe 1 : Les partenaires de l’OpenHanset Alliance 58
Cycle de vie d’une Activité 59 OnCreate() Retour à l’application Activity IntentReceiver OnStart() Service Content Provider Application killed OnResume() OnRestart() A refaire (diag d’états) Autre activité lancée Activité plus visible Passage au premier plan Passage au premier plan OnPause() Besoin de mémoire pour une application plus prioritaire OnStop() OnDestroy()
IPC 60 IPC, Binder, AIDL Lightweigth, powerful mean Binder : driver for IPC Appelssynchones entre processus Passage de paramètres
AIDL : Android Interface Definition Language
IDL pour réaliser une communication interprocessus (IPC)
When a “Service” isusing IPC, an AIDL description of itsfeaturesisalsoneeded. • Android Interface DefinitionLanguage (AIDL) isused to generate code to allow communication betweentwoprocessesthrough IPC • This mechanismis interface-based, similar to Corba (Unix) or COM (windows) but Iighterweight • Withthisspecific mode, the ‘Service” isstartedthrough the binder and not with“startService()” ? A refaire ?
0 comments
Post a comment