Apps | Hardware | Setup | Network | Hacking | Wishlist | Top |
This Page Contents:
Other hacking pages:
Web Links:
Cellphone carriers want to maintain control of the product; particularly they want you to use their billable services rather than some competing service for which they do not get paid. Although Android is an open source project, apparently it is legal for the carriers to distribute a not-exactly-open derivative work on their retail phones. However, it is also legal for you to treat their restrictions with the respect they deserve.
This wiki page is the straight poop on how to break into a retail phone. It's arcane. Basically, revert to the original OS image, version 1.0 RC29, which has a gaping security hole, and do the simple 'sploit. (It looks like the developers put in a backdoor at the very beginning of Android development, and forgot to turn it off for the production release.) From there your best move is to turn a retail phone into a developer phone. You will then be able to apply subsequent updates to return to the current version, but you will still have root access.
This looks like a useful collection of howtos. Including jailbreak instructions.
I'm sure the right
way is to create and install a custom image,
which is what the hackers have done.
However, I bought a developer phone, which gives me a (nearly) free
ticket to r00t heaven. See the section on software
development for what to install: the
SDK includes the
program adb
. You connect your G1 via
USB,
run adb, start a shell on the G1, and then su root
without a
password.
Note: Rooting your phone does not break a retail phone's lock to the carrier's SIMs, nor does it relieve you of your obligation to pay under a calling plan contract. These issues can be broken, but it will cost you money.
Now that I have root access, what am I going to hack with it?
The browser refuses to look at any local files, e.g. on the SD card. My first project is to investigate fixes that require root access to do.
There are endless hassles because the distro software does not recognize X.509 certificates signed by my work and home certificate authorities. I need to install my root certs. (Accomplished; see how to add the certificate.)
Install the Dropbear SSH server. A lot of my system administration procedures, particularly backup, involve SSH. (I normally use OpenSSH, but a Dropbear package is already available.)
Figure out a decent way to backup data on the phone. Google is
involved for PIM
stuff like the contact list, at least for normal
people, but
there is a lot of additional data that doesn't seem to be getting
backed up.
The G1 is a phone, not a software development machine.
Thus the UNIX infrastructure is very limited. It doesn't even have
a cp
command. I would like to put a complete UNIX software
suite on it, particularly including bash. This would reside on the
SD card. Most likely the
distro would be Debian. You don't need root access to do that part,
but to actually get the programs on the path takes root access.
First I need to find out what kernel modules the distro gives us, and then I want to supplement them. Areas I particularly want are IPv6, iptables (firewall), and cryptography.
While the unhacked phone is pretty good about not listening on outside ports, I would feel safer with a proper firewall.
A really big missing feature on the G1 is Bluetooth OBEX. A server probably requires root access to install.
On my phone, as delivered, this is what I see in Settings - About Phone:
Firmwareversion: 1.0 (the original one)
After installing the Cupcake upgrade (Android v1.5):
Firmwareversion: 1.5
This news article announces
OTA updates to version RC33
starting approximately 2009-02-06.
It adds Latitude
to Google Maps (share your location with friends
through the Google cloud), and Search by Voice
(I think this is
for Google Search, not the contact list). Plus, of course, bug fixes.
There was a prior update to RC30 during 2009-01-xx.
Look on xda-developers.com for how to install this update on a rooted phone. Kron2 says: (with some instructions merged by jimc from a subsequent post)
Copy it to the root directory of the SD card. Call it update.zip; this name is required for the procedure.
Make sure the battery has plenty of charge; it's going to be really nasty if the phone dies in the middle of the update. Disconnect the charger.
Turn off the G1, then turn on by holding down the Home and End keys. This will start the Android System Recovery Utility. Its control window will pop up.
Open the keyboard and hit Alt-L (turns on logging to the console).
Kron2 didn't mention this, but try Alt-B to make a backup. Now, how will you restore it?
Hit Alt-S to begin the update.
When it finishes, follow onscreen instructions, press Home+Back. The G1 reboots a few times, don't panic.
Check Settings - About Phone - Build Number; it should include the string RC33. There is also a new radio image (phone coprocessor software?) The RC33 update does not include A2DP.
Here are three more threads about updating.
How to update a rooted phone and keep root access. This describes RC30, but probably will work for subsequent updates too.
How to sabotage the OTA update process. Jimc says: you really should apply the updates eventually. My developer phone with a T-Mobile Sidekick calling plan appears to be immune to having OTA updates pushed out: they have no idea that a G1 is talking to them. An alternative is that the developer phone has no daemon process that pulls in updates, since I'm supposed to do that myself as part of the software development process.
Here is the URL for the hacked image for RC33, and the procedure to install it.
The next full version of the OS
is code-named Cupcake
. It is / will be / may be called version 1.5.
It has kernel 2.6.27. It is expected to have complete (?)
Bluetooth A2DP
support (stereo audio at 22kHz for music), plus limited (command line)
support for
HID,
PAN and
DUN.
Rumor has it that Cupcake will be out in 2009-04-xx.
Look for ADP1 firmware
update
, which may be out a little after the retail release; this
is the update for the developer phone. Or install a hacked version.
This posting by Living_Sword (forum administrator) on 2008-12-07 describes the Android System Recovery Utility. It gives a screenshot of how to back up your Android before installing a new image. To make it happen, turn off the phone, then hold down Home+Power and it will boot into recovery mode. The screen shows a list:
The backup is stored in /sdcard/nandroid/* -- so how do you restore it?
This posting by Living_Sword (forum administrator) also on 2008-12-07
describes how to get a developer booter onto a retail phone.
When booting, Power+Camera drops it into the bootloader. When you connect
the
USB
cable it shows FASTBOOT
. When in the booter, to get it to
boot normally you need to remove the battery. It may also work to press
green-menu-red all together (suggestion: in that order) -- try that first.
I have extensive local HTML content on my Nokia N810 and I would like to use it similarly on the G1 whether or not I have a network connection, e.g. on an airplane or when data roaming charges make online use unattractive. In this list of content categories, (*) indicates that I do not do this item personally but, according to forum postings, this category is a major use of the handheld device for other people.
Personal home page, so the browser starts with something reasonable whether or not the net is connected.
Downloaded copies of journal (professional or scientific magazine) articles.
E-books in HTML format.
Music, with my platform-independent web page indexing.
Photo gallery, with my platform-independent web page indexing.
Maintenance manuals, to be consulted in a remote corner of Edwards Air Force Base. (*)
Product catalogs, to be discussed at the customer's site independent of flaky cellular coverage. (*)
So how can the web browser display the local content?
A normal web browser accesses such content using a
URL such as
file:///sdcard/homepage.html
. But not on Android!
In numerous forum postings, users complain endlessly about the absence of
file:/// URLs.
Here is
one complaint about file:/// by Luca Belluccini (2008-08-24).
In that thread Megha Joshi says that file:/// was formerly supported but
was killed for security reasons. I haven't come across exactly what the
threat is, but I assume it has to do with a
hacker's page using Javascript to open a file:///
URL
for a file containing personal information such as the Gmail password
or the contact list, and then sending it as a POST form to the mother ship.
In jimc's opinion the baby has been thrown out with the bathwater: the
file:/// URL
is too useful to just be made illegal in Android. There are extensive
entanglements involving UNIX file permissions that would prevent the
described exploit, although the actual threat may have been something else
entirely. But the response should be to fix the security hole, not to
declare that the file:///
URL
is the hole and fix
that.
Regarding the same origin
policy followed by sane browsers including
Android's, the rule is that scripting languages may refer only to
URLs
having the same protocol
(URI schema),
hostname and port as the script itself.
Clearly the same origin
policy can and should
be applied unmodified to a file:///
URL, which will compare
unequal to the signature of every hacker script. It is certainly true that
Firefox has a seemingly unending stream of violations of the same
origin
policy, and we have to assume that
MSIE
is no better, but in jimc's opinion this is no reason to make file:///
illegal; better is to declare Javascript to be spawn of the Devil
(or all web scripting languages) and suppress them instead.
In theory I could locate the patches by which file:/// was suppressed, revert them, and build my own custom browser and/or compiled infrastructure (libraries). But that would be a lot of work, and would cut me off from future security updates, which are particularly important for a web browser. Also, I have about two weeks to get something working before going on a trip. So let's look at further solutions.
This is a port of the
Jetty
webserver (written in Java) for Android.
It would appear that *.apk is a known mime-type for an Android java-esque
package file. Here is how to install one -- much of this would be taken
care of automatically by the Market app.
Normally the phone is set to only install applications from the
Android Market, which presumably have minimal supervision for
suppressing Trojan horses and other malware. The first time you
install a rogue app, you need to navigate to Settings -
Applications and turn on Unknown Locations
. When it asks,
promise not to sue them. It is possible that this only works on a
developer phone (or a phone on which a developer image has been
installed).
Click on the *.apk link. The browser downloads it and shows the download history.
Click on the file's row in the download history. It asks what app to execute. Tell it package manager.
It checks with you about permissions. Tell it OK. It installs the app. When finished it offers to launch it.
Jetty itself: you get an app called Manage Jetty
. Launch it,
configure (I changed the lameass console password), then hit Start.
It starts the server, and puts up a notification, which is a link to the
Manage Jetty
app. It's OK to clear notifications. Here's what I found
out when trying out Jetty:
You can access it from outside the phone: http://selen:8080/console You can also access it from inside the phone: http://localhost:8080/console
It is not too swift; be patient. It seems to run a little faster from inside the phone.
The demo app called console
can show your contacts, (some)
system settings,
call log, and network address(es). To see anything you need to log
in. The loginID is admin
and the password is whatever you
configured.
There is a button to edit a contact, but when I hit it Jetty
crashed. (To recover, execute Manage Jetty
, stop and
restart the backend.)
But I have not found an app to deliver local content. There are several sample applications on the Jetty website -- hack, hack, hack.
A
URL
of the form data:text/html:(the content) (URL-encoded, limited to 8Kb)
will be shown by the web engine. The Linda
File Manager actually does this when opening
a
HTML file, but
in the one case I tried it didn't work too well; the browser claimed
that the page
did not exist.
If an application has been written to open a local file and send out its contents, it can be invoked by the browser through a URL of the form content://$path/android_asset/$file.html, where $path is the D-bus path of the content provider application. This blog posting shows how to open and send back the local content. It looks fairly simple, but I'll need to learn how to use my copy of Eclipse and the SDK to build an application that can actually be installed and invoked by the browser.
This blog posting describes Gears and why it is important (by David Berlind dated 2008-09-12). To summarize: Gears is a plug-in to a web browser, factory-installed in Google's Chrome and in the Android browser, but also available for Firefox, Safari and MSIE and possibly others. The purpose of Gears is to make a local cache of active content so that the user can interact with it even when there is no network connection. For example, if you edit a document using Google's cloud-based office suite, the content will be cached locally, you can continue to edit minus the net, and it will be synced when feasible. (And I'll bet this saves a lot of load on the server, and also improves the user experience when the net is running but slow.) The author's main point is that things like document editors become platform independent, to the detriment of vendors of platform-specific locally installed software.
It sounds like this may be what I'm looking for, at least for the issue of reading journal articles.
Google Gears
sample application page: their
ResourceStore Demo
looks relevant. I performed the demo, and it
works. The cache is located in /data/data/com.android.browser/gears, i.e.
in the main flash memory, so only a few megabytes of content can be
accomodated -- unless it will not balk at a symbolic link into the
SD card.
There are two addditional major classes (each with a demo): ManagedResourceStore expects to find a list of
URLs
(relative to the list file, per the same origin
rule); all the
content will be cached, and the infrastructure can recognize and download
new versions. The Database class creates a local database file and can
execute SQL
queries on it; the demo lets you type arbitrary queries on the web form.
Both of these look like they could solve different problems of mine.
Testing Gears on the
SD card:
I tried but failed to copy /data/data/com.android.browser/gears
to my laptop using adb pull
, because the adb daemon does not have
read permission for this file. My plan was to then copy it to the
SD card using adb push
.
As a fallback I renamed the directory and newly created an empty one
on the card, with a symlink. The original gears directory has mode 700
owned by app17:app17, but the VFAT filesystem on the
SD card
is not capable of setting either the mode or the owner of individual files.
Nonetheless, the local infrastructure created the same directories on
the card as it did in main flash memory. Unfortunately both the
ResourceStore and ManagedResourceStore demos did not capture and store the
data, but the Database demo did create its database, which persisted
through clearing the browser cache and rebooting.
Whatever the issue was with the demo apps, the underlying plugin library works. I wrote a script that installs the needed infrastructure in an arbitrary web directory, and with that I am able to make and use a local cache of my Science Magazine issues, e-books and reference material, independent of the network connection.
See Android bug 2454 for my report on the file:/// URL issue.
The start point for developers is the
Developing on a Device
page.
That page has a list of steps for configuring your application (software
being developed) and the phone for debugging, including installing Windows
drivers, or a udev rule to make the
USB
device writable.
However, the provided udev rule did not work for me; I had to do something
different.
On OpenSuSE 11.1 I have a group sbox
, of which I am a member, for
the Maemo SDK, which I'm
re-using for Android. I created /etc/udev/rules.d/51-android.rules saying:
ENV{DEVTYPE}=="usb_device", SYSFS{idVendor}=="0bb4", MODE="0660", GROUP="sbox"
When the G1 is connected to the laptop by USB, the relevant USB devices are created: in my case, /dev/bus/usb/005/(whatever). The above rule will cause them to be writable by my group. In my distro there are default rules in 50-udev-default.rules, so I needed my rule to be later in lexical order. I was unable to get SUBSYSTEM=="usb" to work.
The next step is to download and install the SDK (link to download page). (269Mb installed.) They recommend that you also use the Eclipse IDE versions 3.3 or 3.4, Sun Java JDK version 5 or 6 (not 4), and the Android Development Tools plugin. It doesn't work with Gnu Compiler for Java (gcj).
Jimc needed to install:
- Android SDK (from above above URL)
- Eclipse. Apparently it is not on the standard SuSE distro in v11.1, although it was in v10.3. I got it from the OpenSuSE Build Service. The required components were:
- eclipse-3.4-6.2.noarch.rpm (build service)
- eclipse-platform-3.4-6.2.noarch.rpm (build service, 72Mb)
- eclipse-archdep-platform-3.4-6.2.i586.rpm (build service)
- libswt3-gtk2-3.4-6.2.i586.rpm (build service)
- ant-1.7.0-199.15.noarch.rpm (regular distro)
- xerces-j2-xml-resolver-2.8.1-238.15.noarch.rpm (regular distro, for xml-commons-resolver)
- jakarta-commons-logging-1.0.4-265.96.noarch.rpm (regular distro)
- servletapi4-4.0.4-24.146.noarch.rpm (build service)
- regexp-1.3-232.69.noarch.rpm (regular distro)
- java-1_6_0-sun-1.6.0.u13-0.1.1.i586.rpm (distro updates)
- java-1_6_0-sun-devel-1.6.0.u13-0.1.1.i586.rpm (distro updates)
- java-1_6_0-sun-plugin-1.6.0.u13-0.1.1.i586.rpm (distro updates)
- rhino-1.7-6.14.noarch.rpm (regular distro)
- bea-stax-api-1.2.0-5.23.noarch.rpm (regular distro)
- xmlbeans-2.1.0-2.29.noarch.rpm (regular distro)
- Eclipse JDT Plugin (should be included).
- JDK. Nomenclature is not exactly transparent, but having dug around in the docs on the Sun site linked to, I'm installing SuSE's java-1_6_0-openjdk-1.4_b14-24.3.1.i586.rpm (from distro updates).
- Android Development Tools Plugin (for Eclipse). Start eclipse and follow their instructions for how to download and install it from within Eclipse.
Here is a link to
the Android Development Guide. Under Tools
(in the left panel)
you can find specific instructions about adb
, the Android Debug
Bridge.
Now, assuming you have taken the writeup's advice and added the
SDK's tools directory
to your path, you can do adb shell
and get a shell on the
G1. The resources are very limited, for example you can do ls
or ls -l
, but not ls -ld
. This is not a root shell;
the user appears to be shell
. However, you can do su root
and you become root, without a password.
Additional useful adb commands (see the writeup for a complete list):
adb pull /from/G1 /to/local -- Copies from the G1 to the localhost. Files or directories (recursively) can be copied. Not limited to the SD card.
adb push /from/local /to/G1 -- Inversely: copies from the localhost to the G1.
adb shell -- Get a shell on the G1. This is not a root shell; your
loginID appears to be shell
.
Do su root
(no password needed) to become root.
adb remount -- Remounts /system read-write so you can hack on it. Now, how do you remount it readonly when you are finished (for safety)?
This isn't an adb command, but if you are going to write on or
otherwise monkey in /system, it is mounted readonly. First cat
/proc/mounts
to check the device, format, and the real mountpoint,
and then do:
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /systemRemember to put it back to
rowhen finished. (This tip from Nirnimesh dated 2009-01-19.)
File Structure: /data/data/com.android.browser is a directory (read-write) belonging to that package. All (or almost all) packages have such a directory, named after the package in the style of a dbus path. In the browser's case (and likely for all of them), there is a loginID and group assigned; in this case it's app_17:app17. I don't know, but suspect, that the suffix number is created when the package is installed. Most data files are owned by this loginID and group (except, for the browser, an empty directory called lib, owned by system:system). Permissions vary but 775 is the most common, followed by 700 (all are directories in this case).
I'm going to have to look at /system/app/Browser.apk which is probably the biggest app on the device: 1Mb. No, it's second biggest; Launcher.apk is bigger (1.4Mb).
An apk file is a zip archive. To unpack:
mkdir /tmp/dir
cd /tmp/dir
Here are some games I came across in my research:
Game to try: bejeweled. The one I've heard of has a theme of hunting in a fantastic universe. No, the one of this name on the Android Market is about arranging glittering objects in rows.
This game vendor put together 10 games, or is in the process of
writing some of them. There are two airplane games:
Check back here for Mini-Dogfight
when available; also check
out SuperGStunt
which supposedly is already available.
Try to find the PlaysVideo
app. This is not a game, it
plays video, probably requiring it to be transcoded to a reasonable
frame size beforehand. The reference didn't say which codecs it has.
This is a list of files on (someone's) Android installation. Amazing: /system/media/audio/alarms/Alarm_Rooster_02.ogg: all the alarms, notification beeps and ringtones are compressed as Ogg. There is also /system/sounds/test.mid, if one has a Midi app. It would appear that the CPU chip includes a DSP even though not mentioned on the specs page.
Howto move /data/app and /data/app-private to the SD card. You would want to do this if you run out of space in main flash and want to install more apps or expand application storage, i.e. databases. The valuable item here is a link to an ARM version of Busybox, and instructions how to populate your system with symlinks from command names to busybox.
Lameass! /system/lib/modules/wlan.ko exists. That's all. Until we get a module for ext2/ext3, there won't be any reformtting of SD cards.
Here are Pavel Machek's instructions to install Debian on your SD card.
Wallpaper: In this forum post about wallpaper (2008-10-24), mikef1182 asks what is the correct size for a wallpaper image, and PunkZanyj and Emjei respond that 640x480 works for them.
Copy your wallpaper image onto the memory card. With the home screen visible, hit Menu and pick Wallpaper, then Pictures. The picture viewer should find your image; select it. The wallpaper app will show a crop rectangle. You can resize the rectangle by putting your finger on the edge, or move it using your finger in the middle, but if you have specially created a 640x480 image your goal will be to cover the whole thing with the rectangle. Hit save, and the wallpaper will be applied (after scaling to 640x480 if needed).
With the display closed you see the left, central or right 320x480 portion of the image, i.e. half of it horizontally. With the display open you get a horizontal band 320px high minus 80px top and bottom, while from side to side you see the central 480px minus 80px on the sides, shifting left or right according to the icon pane being used.
Home screen and icons: I have 34 apps with icons on my machine, and the
main icon page can be intimidating. Compare to my laptop which has 114
items in the two-level menu, i.e. the main menu has a few key apps and
a bunch of category sub-menus. While I like the two-level menu, I have
also found out how to use the features of the Android menu generator to
make a nice icon collection. A flick gesture (motion with the finger) in any
of the four directions has a different effect: up produces the all icons
page (which can be scrolled, but a down flick on the control tab dismisses it).
Left or right brings into view a separate page of icons.
Down shows the current notifications (if any); you need to start your flick
gesture touching the status bar.
You can populate the left, main or right
icon page with up to 16 icons each. You could also put up a round clock
(the time is shown in the status bar too),
a Google search box, a picture viewer, or a shortcut that launches an app
with a particular argument: URL, folder, hostname, etc.
To do this, do a long touch on the background, and open the appropriate
dropdown list. To move an icon do a long touch on it and it will swell up.
Then drag it where you want; icons are aligned on a grid. To remove an
icon drag it onto the bottom tab, which has morphed into a garbage can.
You cannot drag an icon from one page to another. The icon is still present
in the all icons
page.
Apps | Hardware | Setup | Network | Hacking | Wishlist | Top |