Android

De Guifi.net - Wiki Català

Revisió de 00:51, 14 nov 2010; Al (Discussió | contribucions)

(dif) ←Versió més antiga | Versió actual (dif) | Versió més nova→ (dif)

Android és una distribució de GNU/Linux inicialment dissenyada per a smartphones amb un frontend en Java propietat inicial d'Android Inc, venuda a Google Inc al 2005, la qual va alliberar la primera versió junt amb altres membres de la Open Handset Alliance el 5 de novembre del 2007. Algunes parts de la plataforma Android són de codi obert disponibles sota la llicència d'Apache.

Una branca millorada d'Android és la distribució CyanogenMod.

Mòbils configurables i oberts:

http://synapse-phones.com/order.php

FAQ

Versions

Android Dev Phone (ADP)

El ADP o Android Dev Phone és un mòbil especial amb un SIM desbloquejada i un hardware desbloquejat que esta pensat per al desenvolupadors avançats. És una versió del HTC Dream. També hi ha un ADP 2 basat en HTC Magic... El Nexus One és lliure i és l'utilitzar actualment? (--acacha 08:40, 19 ago 2010 (UTC))

Hacking

Codi font

Que no és Open Source?

Q: Is all of the firmware opensourced? If not, what isn't?

A: No. Currently, the kernel is fully opensourced. However there are still some some proprietary userspace bits, which include:

* htc RIL (radio interface) library and data files

(this is glue between the telephony layer in android and the AT/QMI control channels provided via GPL kernel drivers)

* libhgl.so - qualcomm/ati opengl ES library * libqcamera.so - qualcomm camera library * akmd - software to process and adjust compass/accelerometer events * qualcomm h264 codec frontend (does some processing the dsp cannot do)

Sistemes de fitxers suportats

Els Sistemes de fitxers suportat són:

Instal·lar Debian a Android

Android SDK

Configurar un dispositiu per a depurar-lo

Traduït de http://developer.android.com/guide/developing/device.html

Els passos a seguir són:

  • Declarar al manifest de la nostra aplicació que l'aplicació es depurable. Al fitxer XML AndroidManifest.xml afegiu:
android:debuggable="true"

A l'element <application>.

  • Al mòbil activar la depuració USB:
Des de la Home Screen --> Boto MENU, select Applications > Development, then enable USB debugging.
  • Configurar el sistema per detectar el dispositiu:

A Ubuntu Linux:

Cal configurar udev creant el fitxer:

/etc/udev/rules.d/51-android.rules.

I afegir:

SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"

L'exemple és per un dispositiu HTC. La llista de venedors:

Manufacturer	USB Vendor ID
Acer 	0502
Dell 	413c
Foxconn 	0489
Garmin-Asus 	091E
HTC 	0bb4
Huawei 	12d1
Kyocera 	0482
LG 	1004
Motorola 	22b8
Nvidia 	0955
Pantech 	10A9
Samsung 	04e8
Sharp 	04dd
Sony Ericsson 	0fce
ZTE 	19D2
  • Canvieu els permisos del fitxer:
$ sudo chmod a+r /etc/udev/rules.d/51-android.rules

Amb adb cal utilitzar -d flag per depurar. Amb Eclipse es fa normal i corrent.

adb

Adb són les sigles de:

Android Debug Bridge

Es tracta d'una eina de línia d'ordres que es part del Android SDK (la trobareu a la carpeta tools). Les opcions són:

$ ./adb 
Android Debug Bridge version 1.0.26

 -d                            - directs command to the only connected USB device
                                 returns an error if more than one USB device is present.
 -e                            - directs command to the only running emulator.
                                 returns an error if more than one emulator is running.
 -s <serial number>            - directs command to the USB device or emulator with
                                 the given serial number. Overrides ANDROID_SERIAL
                                 environment variable.
 -p <product name or path>     - simple product name like 'sooner', or
                                  a relative/absolute path to a product
                                 out directory like 'out/target/product/sooner'.
                                 If -p is not specified, the ANDROID_PRODUCT_OUT
                                 environment variable is used, which must
                                 be an absolute path.
 devices                       - list all connected devices
 connect <host>:<port>         - connect to a device via TCP/IP
 disconnect <host>:<port>      - disconnect from a TCP/IP device

device commands:
  adb push <local> <remote>    - copy file/dir to device
  adb pull <remote> [<local>]  - copy file/dir from device
  adb sync [ <directory> ]     - copy host->device only if changed
                                 (see 'adb help all')
  adb shell                    - run remote shell interactively
  adb shell <command>          - run remote shell command
  adb emu <command>            - run emulator console command
  adb logcat [ <filter-spec> ] - View device log
  adb forward <local> <remote> - forward socket connections
                                 forward specs are one of: 
                                   tcp:<port>
                                   localabstract:<unix domain socket name>
                                   localreserved:<unix domain socket name>
                                   localfilesystem:<unix domain socket name>
                                   dev:<character device name>
                                   jdwp:<process pid> (remote only)
  adb jdwp                     - list PIDs of processes hosting a JDWP transport
  adb install [-l] [-r] [-s] <file> - push this package file to the device and install it
                                 ('-l' means forward-lock the app)
                                 ('-r' means reinstall the app, keeping its data)
                                 ('-s' means install on SD card instead of internal storage)
  adb uninstall [-k] <package> - remove this app package from the device
                                 ('-k' means keep the data and cache directories)
  adb bugreport                - return all information from the device
                                 that should be included in a bug report.

  adb help                     - show this help message
  adb version                  - show version num  

DATAOPTS:
 (no option)                   - don't touch the data partition
  -w                           - wipe the data partition
  -d                           - flash the data partition 
 
scripting:
  adb wait-for-device          - block until device is online
  adb start-server             - ensure that there is a server running
  adb kill-server              - kill the server if it is running
  adb get-state                - prints: offline | bootloader | device
  adb get-serialno             - prints: <serial-number>
  adb status-window            - continuously print device status for a specified device
  adb remount                  - remounts the /system partition on the device read-write
  adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
  adb reboot-bootloader        - reboots the device into the bootloader
  adb root                     - restarts the adbd daemon with root permissions
  adb usb                      - restarts the adbd daemon listening on USB
  adb tcpip <port>             - restarts the adbd daemon listening on TCP on the specified port
networking:
  adb ppp <tty> [parameters]   - Run PPP over USB.
 Note: you should not automatically start a PPP connection.
 <tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
 [parameters] - Eg. defaultroute debug dump local notty usepeerdns

adb sync notes: adb sync [ <directory> ]
  <localdir> can be interpreted in several ways: 

  - If <directory> is not specified, both /system and /data partitions will be updated.

  - If it is "system" or "data", only the corresponding partition
    is updated.
  

Obtenir una shell amb adb

Des de la carpeta tool del SDK d'Android:

$ ./adb shell

Consultar els dispositius detectats

$ ./adb devices
List of devices attached 
HT97WL902677	recovery

Troubleshooting

error: device not found

Si teniu l'error:

$ ./adb shell
* daemon not running. starting it now *
* daemon started successfully *
error: device not found

A altres ordres us donarà l'error:

- waiting for device -

Cal seguir les passes de:

Android#Configurar_udev_per_tal_que_reconegui_el_dispositiu_HTC

Tampoc cal oblidar activar la depuració USB des del mòbil a la configuració --> Aplicaciones --> Desarrollo. De fet millor seguir la guia completa:

Android#Configurar_un_dispositiu_per_a_depurar-lo

Configurar udev per tal que reconegui el dispositiu HTC

$ sudo joe /etc/udev/rules.d/51-android.rules

Afegiu les següents línies:

SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"

Premeu Ctrl+K+x. Canvieu els permisos del fitxer:

$ chmod a+rx /etc/udev/rules.d/70-android.rules

I ara feu:

$ sudo /etc/init.d/udev restart

A les noves versions d'Ubuntu cal posar:

$ sudo restart udev

lsusb i HTC Hero

Escriviu:

$ watch lsusb

Connecteu el dispositiu HTC amb el cable USB (el dispositiu HTC ha d'estar encès). Apareixerà una línia com la següent:

Bus 002 Device 007: ID 0bb4:0c01 High Tech Computer Corp.

On:

  • 0bb4: és el vendor ID (HTC)
  • 0c01: és el dispositiu (HTC Hero)

Si l'encenem en mode FastBoot les dades són diferents:

Bus 002 Device 010: ID 0bb4:0fff High Tech Computer Corp.

Afegir fasboot a adb

El fitxer binari el podeu obtenir amb wget:

$ wget http://android-dls.com/files/linux/fastboot

El feu executable:

$ sudo chmod +x fastboot

Ara el copieu a la carpeta tools del Android SDK i ja el teniu.

Fitxers de log

$ ./adb logcat

També hi ha una aplicació per consultar el fitxer de log des del mòbil:

http://code.google.com/p/android-random/

Rootear

Consulteu HTC Hero


Aplicacions

Per activar el Android Market amb aplicacions de pagaments (s'activen segons el proveïdor i el pais):

De pagament:

Instal·lació amb Eclipse

--acacha 11:50, 12 febr 2009 (CET)

Seguiu els passos de l'article Eclipse pas a pas a Ubuntu per tal d'instal·lar Eclipse.

Ara aneu a la web de Android:

http://code.google.com/android/download.html

I descarregueu l'Android. Abans heu d'acceptar la llicència.

Entreu a la carpeta eclipse i creeu una carpeta per Android:

$ cd eclipse
$ wget http://dl.google.com/android/android-sdk-linux_x86-1.0_r2.zip

Podeu comprovar que la descarrega és correcta amb:

$  md5sum android-sdk-linux_x86-1.0_r2.zip 

a1f3b6d854596f850f5008856d0f380e android-sdk-linux_x86-1.0_r2.zip

Com podeu veure coincideix amb el número que apareix a la web de Android:

a1f3b6d854596f850f5008856d0f380e

Ara descomprimiu el SDK:

$ unzip android-sdk-linux_x86-1.0_r2.zip

Ara afegiu al PATH del vostre sistema Android:

$ joe ~/.bashrc

Afegiu la línia

export PATH=${PATH}:/home/sergi/eclipse/android-sdk-linux_x86-1.0_r2/tools

Plugin d'Eclipse

Ara anem a instal·lar el Plugin d'Eclipse. Entreu al menú Help/Software Updates i aneu a la pestanya Available Software, feu clic a Add Site i afegiu la URL:

https://dl-ssl.google.com/android/eclipse/

Seleccioneu el lloc que acabeu d'afegir i feu clic a Install. Feu clic a Next i accepteu la llicència.

Un cop hagi acabat us demanarà reiniciar Eclipse. Feu-ho. Ara procedim a configurar-lo. Aneu a Window/Preferences i seleccioneu Android i indiqueu on teniu Android. En el meu cas:

/home/sergi/eclipse/android-sdk-linux_x86-1.0_r2

Primer programa. Hola mon!

Consulteu:

Alliberar HTC Magic

Skin HTC magic

cd android-sdk-linux_86/
cd platforms/android-2.0.1/skins
wget http://teavuihuang.com/android/HVGA-P-HTCMagic.zip
cd 
cd android-sdk-linux_86/
./mksdcard -l SDCARD 512M ./SD1G.img
./android create avd --name HTCMagic --target 2 --sdcard SD1G.img --skin HVGA-P-HTCMagic
./emulator @HTCMagic


Línia de comandes

BusyBox

sysctl i Nucli Linux

Android, iperf, ConnectBoot i Proxy

Accés a root

Bateria

Aplicacions

Android Market

wpToGo

Wordpress des del Android. Postejar...

Vegeu també

Wordpress

Enllaços externs

Eines de l'usuari