Dalvik "Hello World" on Harmattan (in a chroot)

Here’s a quick and boring tutorial on how to get a Java “Hello World” application running on the Dalvik VM of Nitdroid within Harmattan. This requires the Nitdroid Open Mode Kernel (might or might not work with Inception), all Nitdroid files and a bit of patience. This might brick your device or worse, and require a reflash at best. As you can see from the screenshot below, it’s not that exciting ;)

  1. If you want to avoid the Open Mode Warning on each boot, remove the disclaimer from the cal area (this can only be done while in closed mode, as the cal area becomes read-only when flashing open mode until closed mode is re-flashed. This is also the reason why you can’t set a device lock code in open mode – the lock code is saved in the cal area) – this is an optional step, and just a cosmetic fix.
  2. Flash the Nitdroid Open Mode Kernel (be sure to read the “Known limitations” on that post) – this works both on the N950 and N9.
  3. Boot into Harmattan open mode and replace the preinit script to allow booting into Nitdroid (again, read and understand the warnings on that post)
  4. Then, download a Nitdroid tarball (the latest is alpha 5, but I had better luck with alpha 4) and extract it to /home/nitdroid/ – the post explains the steps in great detail, including the kernel flashing and preinit replacement
  5. Reboot into Nitdroid (this might be optional, but do it just to check if your Nitdroid installation is working)
  6. Reboot into Harmattan again – the following commands are all carried out as root user inside Harmattan (using “devel-su“)
  7. Bind mount /dev/ and /sys/ into Nitdroid:
    mount –bind /dev/ /home/nitdroid/dev/
    mount –bind /sys/ /home/nitdroid/sys/
  8. chroot into the Nitdroid hierarchy:
    /usr/sbin/chroot /home/nitdroid/
  9. Set some environment variables (not all of them might be needed, you can find them in “setup the global environment” of init.rc — save these commands into “setupenv.sh” or something in /home/nitdroid/ and save yourself some typing):
    export PATH=/system/bin:/system/xbin:/usr/sbin:/usr/bin:/sbin:/bin
    export LD_LIBRARY_PATH=/system/lib
    export ANDROID_BOOTLOGO=1
    export ANDROID_ROOT=/system
    export ANDROID_ASSETS=/system/app
    export ANDROID_DATA=/data
    export EXTERNAL_STORAGE=/mnt/sdcard
    export ASEC_MOUNTPOINT=/mnt/asec
    export LOOP_MOUNTPOINT=/mnt/obb
    export BOOTCLASSPATH=/system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/sys
  10. Start the Dalvik VM:
    / # /system/bin/dalvikvm
    Dalvik VM requires a class name

Ok, great – 10 steps to start the Dalvik VM, but I promised a Hello World. For that, you need the Android SDK (and the corresponding Java JDK) and follow the “Basic Dalvik VM Invocation” instructions (steps 1 to 6 on your host computer, from step 6 on your Harmattan device):

  1. With your favorite editor (mine is vim), create a file “Foo.java” with the following content:
    public class Foo {
        public static void main(String [] args) {
            System.out.println(“Hello, world”);
        }
    }
  2. Compile it:
    javac Foo.java
  3. Use the “dx” utility (from the Android SDK) to package the Foo.class (generated by javac) into a .jar
    dx –dex –output=foo.jar Foo.class
  4. Bonus exercise: “less” the foo.jar file to see its contents:
    % less foo.jar
    Archive:  foo.jar
     Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
    ——–  ——  ——- —- ———- —– ——–  —-
          72  Defl:N       70   3% 2012-10-23 15:51 1294a38f  META-INF/MANIFEST.MF
         732  Defl:N      404  45% 2012-10-23 15:51 b6e3654e  classes.dex
    ——–          ——-  —                            ——-
         804              474  41%                            2 files
  5. Copy this over to your Harmattan device (assuming USB Networking + Developer Mode + “user” access, “developer” should also work):
    scp foo.jar user@192.168.2.15:
  6. SSH into your Harmattan device, become root (devel-su) and copy the .jar file into the Nitdroid hierarchy:
    cp /home/user/foo.jar /home/nitdroid/
  7. chroot into Nitdroid again and set up the environment (see above)
  8. Finally, run Dalvik VM, telling it to run the class “Foo” and using a classpath of “foo.jar”:
    / # /system/bin/dalvikvm -cp foo.jar Foo

gPodder 2.20.2 for Maemo 4/5, gPodder 3.3.0 for MeeGo 1.2 Harmattan

gPodder 2.20.2 has been released today, and gPodder 3.3.0 has also been released. Version 2.20.2 is for users of Maemo 4 (N800/N810) and Maemo 5 (N900) and version 3.3.0 is for MeeGo 1.2 Harmattan users (N950/N9).

The reason why another 2.x release comes out at this point in time is because YouTube downloading was broken by another website change recently, and of course we don’t want to leave our good old Maemo users without their daily YouTube video fix. A full list of changes for Maemo 4 and 5 can be found in the 2.20.2 release announcement.

Version 3.3.0 for MeeGo 1.2 Harmattan brings some nice features like download resuming, filters for unfinished files, scroll position improvements and display of the publish date and file size in the shownotes. Of course, 3.3.0 also includes the YouTube download fix. A full list of changes can be found in the 3.3.0 release annoucement.

As a side note, Maemo 5 support has now been completely removed from the master branch as of 3.3.0 (it has never been officially supported, but you could kind of run in on the N900 with some motivation and work). N900 users really wanting to use gPodder 3 should use it on Nemo Mobile, supporting gPodder 3 and its QML UI in Maemo 5 is just too much work, and the time working on gPodder is better spent improving the Harmattan version and making sure that the 2.x branch doesn’t break.

Here’s the run-down of the release status for various versions and targets:

gPodder 2.20.2 is ready for testing in Extras-Testing for Maemo 5 Fremantle.
gPodder 2.20.2 is already in Extras for Maemo 4 Diablo.
gPodder 3.3.0 has been uploaded to Nokia Store QA for MeeGo 1.2 Harmattan.
gPodder 3.3.0 has also been uploaded to the MeeGo Community OBS.

HOWTO: Set up a Maemo 5 Scratchbox SDK VM (and upload packages)

I’ve somehow lost my good old “MaemoSDK” VirtualBox VM, so while I’m setting up the new VM, here are the instructions in case I or somebody else needs to do that again.

The goal: To have a nice VM (more lightweight than the Maemo SDK VMs offered online) that one can SSH into and build packages for Maemo 4 and Maemo 5:

  1. Get the Debian i386 netinst CD image from http://www.debian.org/CD/netinst/
  2. Create a new VirtualBox VM (Name: MaemoSDK, Operating System: Linux, Version: Debian) – the default size (8 GB) should be okay, less is also okay
  3. Go to Settings, Storage, IDE Controller, select the .iso you downloaded in step 1
  4. Power up the VM, select “Install” in the menu
  5. Set the hostname to “maemosdk”
  6. Use an empty root password (you can use “sudo” from your user)
  7. Full name for the new user: Maemo Developer
  8. Username for the new user: user
  9. Password for the new user: maemo
  10. Use the default options for partitioning, and wait until the base system is installed
  11. Select the “SSH Server” option when the Debian Installer offers it
  12. Install GRUB into the MBR of the VM
  13. Go to the Maemo 5 SDK Download Page on Nokia Developer
  14. From the SDK Download page, get the Scratchbox installer script (maemo-scratchbox-install_5.0.sh) and the SDK installer script (maemo-sdk-install_5.0.sh):
    http://repository.maemo.org/stable/5.0/maemo-scratchbox-install_5.0.sh
    http://repository.maemo.org/stable/5.0/maemo-sdk-install_5.0.sh 
  15. Login to your new VM, then wget the two scripts above
  16. sudo sh maemo-scratchbox-install_5.0.sh
  17. sudo sh maemo-scratchbox-install_5.0.sh -u user
  18. Log out and log back in again
  19. sh maemo-sdk-install_5.0.sh
  20. When asked, I chose Full + Development packages, but feel free to chose a more minimal variant (in that case, you might have to install -dev packages later on as build-dependencies)

You can also read up on how to set up SSH agent forwarding in the VM, so that you don’t need to store your SSH key on the SDK VM.

As for building gPodder from source in this SDK, here are the instructions:

  1. scratchbox
  2. vi /etc/apt/sources.list # then add these entries:
    deb http://repository.maemo.org/extras-devel fremantle free non-free
    deb-src http://repository.maemo.org/extras-devel fremantle free
  3. fakeroot apt-get install python2.5 python-feedparser python-mygpoclient python-dev maemo-optify
  4. git clone git://github.com/gpodder/gpodder.git
  5. cd gpodder
  6. git checkout origin/maemo-5
  7. dpkg-buildpackage -rfakeroot -S -sa -I.git -i.git # for the source upload
  8. dpkg-buildpackage -rfakeroot -b # for the binary to test locally

You can also build the Maemo 4 (N800/N810) package by replacing “maemo-5″ with “maemo-4″ in the “git checkout” command.

To get files out of the SDK without setting up fancy SSH stuff, you can also just use netcat (on the target: nc -l 9999 | tar xzv, on the source: tar czv /path/to/files/ | nc a.b.c.d 9999).

To upload files to Maemo Extras, follow the instructions at Uploading to Extras.

Numpty Physics 0.3.3 for Harmattan is here

Another project that has been on the back burner for a while is the new NumptyPhysics port to Harmattan (“new” because Aapo has ported it once before). One of the most important bug fixes (avoiding the multi-touch drawing error) has been committed a month ago, and

So, this weekend, Numpty Physics 0.3.3 has been released. This version includes some basic Harmattan integration work (single-instance, swipe lock integration, pause-in-background, squircle-style icon by flopjoke, …) that will – hopefully – allow the application to also go into Nokia Store as free app (as Apps For MeeGo is still down).

NumptyPhysics is available as download on Github, or you can wait until it gets approved by Nokia Store QA and install it via the client. It’s yet another project that used the shared “harmattan” organization on Github: https://github.com/harmattan/numptyphysics – feel free to improve the code and send pull requests :) Also, please report any integration issues or minor things that could be improved for Harmattan integration on the bug tracker.

Brain Party Git repository, new release 0.5.990

Back in March I’ve been working on Brain Party for the N950/N9, and since then, I’ve uploaded it to Apps For MeeGo in May. With Apps For MeeGo being down more often recently, I thought it might be a good idea to upload it to Nokia Store, so more people can discover this nice game.

Before uploading to Nokia Store, some things have to be fixed – a big icon and screenshots have to be made/taken, single-instance launching and being a good multitasking citizen (pausing gameplay when put into background) is a precondition for QA to not fail, so these things have now been implemented.

In order to properly maintain Brain Party for the N950/N9 in the future, and to track changes, I’ve set up a Git repository in the Collaborative Harmattan Repository on Github (which gets used a lot – as of today, we have 35 repositories and 16 organization members, and you can get yourself added easily).

The Git repository of Brain Party starts off with an initial commit that is just a copy of the 0.5.91-2 source package contents from Fremantle (sans the artwork/music, which got added in a separate commit later), and then has (in a single commit) all Harmattan customizations that I did back in March, May and today. The repository content is quite big, as the images, sounds and music are all included now, but that shouldn’t stop you from cloning it and hacking the code ;)

As written in the announcement on TMO, you can get your .deb from the downloads page or wait until it surfaces on Nokia Store as free app. As with most repositories on Github, we have an issue tracker where you can file pull requests, bugs and other things that you notice while using Brain Party :)

gPodder 3.2.0 (and 3.2.1) released for Harmattan

gPodder 3.2.0 “The Great Radish Famine” has been released this week, and some users (not including me, otherwise I would have caught the bug earlier) had problems with the upgrade (see bug 1627 for details), so that’s why gPodder 3.2.1 is already on its way to AFM and Nokia Store today. Expect the bug fix to appear as an update in the next few days.

Highlights of 3.2.0 are an improved UI (e.g. cover art in the “All episodes” list) and Flattr integration, so you can now support podcast authors via micropayments (you’ll find the Flattr button below the shownotes for podcasts that publish a Flattr URL).

The gory details about what went wrong with packaging this time can be found in the 3.2.1 blog post, and bug 1627 contains – special thanks to Reiner for providing the necessary debugging info needed to get this sorted out (again, I was not experiencing this bug myself).

If your 3.2.0 update worked out fine (the bug didn’t affect all users), this is not for you – just enjoy 3.2.0, and install 3.2.1 when it comes out :)

gPodder 3.1.2 for MeeGo Harmattan

It’s another month, and (given the monthly release schedule of the app) it’s not really a surprise that a new version of gPodder has been released. This is mostly a bugfix release, but brings one very useful feature to gPodder: The ability to hide downloaded podcasts from the Music app. While this is nothing new to command-line fans who edit tracker-miner-fs.cfg by hand, there has not been an end-user friendly way to do it. Now there is: You can just flip a switch in the gPodder Settings and hide the podcasts from the Music app (which does nothing more than adding or removing the gPodder directory to tracker-miner-fs.cfg’s IgnoredDirectories list), which is especially useful in a situation where your downloaded podcast accumulate (this happens to me right now – less time to listen to podcasts) and you play your music in “Shuffle all” mode.

Other improvements include a small fix for the episode list filter button for locales where the text sometimes became longer than the button:

As you can see, in the left screenshot (gPodder 3.1.1) the “Hide deleted” text (in German: “Gelöschte verstecken”) goes over the toolbar button. To “fix” this, the toolbar button has been made wider (right screenshot, gPodder 3.1.2), which (in my opinion) also looks a bit nicer.

The rest of the improvements include some fixes to the CLI, updated and added translations, and some minor build system fixes – read the full changelog if you want the gory details :)

The MeeGo 1.2 Harmattan package for gPodder 3.1.2 has been uploaded to Apps For MeeGo and Nokia Store already, it should hit Apps For MeeGo Staging in a few hours (please do the QA procedure for it then, so it can land in Apps For MeeGo proper) and it should hit Nokia Store in a few days when QA has finished.

Billboard now available in Nokia Store

At the last Hack-A-N9 meetup, I’ve been working on a test app to show the currently-playing song. This has then been extended to a fully-fledged app that is easily configurable for the user, so that non-developers could use it (after all, hacks and scripts existed before that did the same thing).

The app is called “Billboard”, and its goal is to provide useful information on the low-power-mode screen of the N9 in a way that “normal” users can use it. It also tries to be very lightweight on resources, and smart about updates so that updates are only made when needed, which saves battery power.

Billboard website: http://thp.io/2012/billboard/
Nokia Store link: http://store.ovi.com/content/279408

The currently-released version on Nokia Store is version 1.0.0, and an update (version 1.0.1) with some fixes to allow co-operation with MeeCast, fLPMC and other applications has been uploaded today and is currently waiting in the Ovi QA queue.

There’s also a support thread on TMO in case you need help or have suggestions.

Avoiding jet lag using continuous clock change

http://www.developer.nokia.com/Community/Blogs/blog/andrew-fleggs-nokia-developer-blog/2012/02/26/avoiding-jet-lag-using-continuous-clock-change

These days I’m often travelling long distances; whether it’s to Asia or Detroit with work; or San Francisco for the MeeGo and JavaOne Conferences.

Ten hour flights are rarely fun; but when combined with a ten hour time difference? The jet lag can destroy you.

However, I trust a clock when I see it. So if I can convince myself that the time isn’t changing in one big jump, jet lag is less of an issue. I used to do this with my watch: every two hours on a ten hour flight with an eight hour time difference: move my watch forward two hours. By speeding up, or slowing down time, I find it excellent for transitioning gradually to my destination timezone.

My N9′s standby screen provides an opportunity to do this automatically: every time I glance at my phone on the flight, it could show me the right “transient” time.

I prototyped it with a spreadsheet (download), for a recent trip to Korea, to see how effective it would be before writing an app:

 

To try it out, first off, enter the local departure and arrival times; and the timezone difference:

If travelling eastwards, the time difference will be positive. If travelling westwards, it will be negative.

A shell script will then be shown in column E. Copy this column and paste it into a text editor. Copy the resulting script to your UNIX-based mobile device (N9, N950, N900, N8x0, jailbroken iPad).

On a Harmattan device, the script needs to be run in develsh:

~ $ develsh outbound.sh

On everything else it needs to be run as root:

Jaffas-iPad:~ mobile$ su -
Password:
Jaffas-Ipad:~ root# sh outbound.sh

If run with screen or nohup, you shouldn’t even need to keep the terminal open.

NEXT STEPS

Obviously the next step is an app. Is it something you’d be interested in? Is there a nice Qt API for changing the time? Are there Qt APIs for looking up timezones, and setting the device’s timezone?

Thanks to eipi for allowing me to use MaeFlight‘s icon in this post. Also published on Nokia Developer blogs

Microsoft + Nokia Babies: Hate at a Distance, Love Up Close

original source: http://www.pop.com.br/

Apologies to QML fans but I’m going to to extend the interruption of that series by at least one more article.  Blame a cynical friend’s recent conversion to the Dark Side of mobile Microsoft 

As regular readers know I’ve been a dual Microsoft/Linux power user for many years.  While some friends see that as a bad case of cognitive dissonance, I prefer to call it technical agnosticism.  I was never interested though to include Windows Mobile in that scope, mainly due to an observance that it was just Windows scaled (badly) down to a handheld device rather than something specifically designed for the form factor.

Microsoft finally realized that, bit the bullet, and created Windows Phone from scratch.  But the product still carried Windows branding baggage and has been panned by some mobilists and tech pundits– many of whom did so with ten-foot virtual poles.

This has been especially true of Nokia fans (self included), particularly those who saw great things in the Linux-based operating systems Maemo and then MeeGo and had high hopes for the sexy N9.  Nokia’s CEO had brought about the Elopocalypse in accepting Steve Ballmer’s engagement offer, and no one from the Linux side of the family wanted to be part of the post-wedding reception.  Some later snickered at the Spanish meaning for “Lumia” (as tempting as it is to riff on that further, I’ll demur).

So far the MicroNokia nuptials have resulted in two acknowledged offspring: the fraternal Nokia Lumia twins, 710 and 800.  There’s nothing apparently spectacular about the 710, hardware- or appearance-wise.  Its low price is the most attractive feature.  As for the 800, photos don’t quite do it justice.  You have to use this device to realize its true beauty.

The same can be said for Microsoft’s Windows Phone 7 OS.  Yes, videos seem compelling, but jaded smartphone users aren’t easily impressed by moving pictures.  Experience it first-hand, however, and the skepticism melts.  I admit to encountering that at Nokia World when I first got to play with the Lumias.

This sort of mindset conversion is never more dramatic than when a diehard open source devotee is swayed.  Such was the case when my aforementioned friend Johan Paul surprisingly tweeted the following:

I’m highly interested in what he’ll have to say further, the more he uses his Lumia 800.

Now, I can’t quite profess unconditional love for these babies.  Some of the beauty is only skin-deep and there are genetic defects only a mother could overlook.  My personal OS peeves are no tethering, no Bluetooth file transfers and no USB mass storage mode.  HUGE step backwards in my opinion and a MUST fix.  As for the Lumia 800, lack of TV output combined with omission of a front-facing camera have my teeth gritted.  I also have to wonder why support for quickly-trending NFC was left out.

Beyond feature failures, Microsoft and Nokia face distinct but obviously related challenges here.  The former needs to get Windows Phone in general out of the market share basement.  The latter needs to re-establish their specific phones as must-have products.  I have yet to see a clear signal on how evangelical overlap is going to be handled by the two, particularly where software development is concerned.  I also still wonder if the marriage between them will ultimately put off other WP participants (not that I actually care).

Nevertheless, if outreach efforts can get examples into the hands of prospective buyers everywhere, even doubtful ones like my friend Johan, Microsoft and Nokia do indeed have a potentially winning combo.  The 25,000 device-seeding effort won’t hurt!  In addition to my QML explorations, I plan to develop for Windows Phone and can’t wait to start showing off my own Lumia 800.

I just need to get that pretty baby in my hands…

Filed under: Into Outreach, Inviting Change, Mentioning Maemo, Mentioning MeeGo, The Write Stuff, Views and Reviews Tagged: forumnokia, Johan Paul, LinkedIn, Lumia, Maemo, MeeGo, Microsoft, Nokia, Windows Phone