back to article Meet the BlackBerry wizardry that created its 'better Android than Android'

Some remarkable technical wizardry lies behind BlackBerry’s Android coup. When it was launched in January, BlackBerry’s new OS was brand new BlackBerry 10 and largely app-less. But today it can execute Android apps at impressive speed. How did they do it? Thanks to some helpful inside knowledge, The Register will reveal it all …

COMMENTS

This topic is closed for new posts.
  1. Anonymous Coward
    Anonymous Coward

    If it uses QNX rather than Linux, of course it is going to be better than Android...

    1. Anonymous Coward
      Anonymous Coward

      "If it uses QNX rather than Linux"

      I don't see why the downvote. QNX is not Unix, it is a POSIX-compliant OS designed from the bottom up for reliability and efficient multitasking in machines that are relatively light on resources. As such, it should be a better fit for a mobile phone than Android, which is based on Linux, originally conceived as a Unix-like substitute in larger machines.

      Personally I use a Q10 and so have no interest in running anything Android on it, but it's an impressive engineering achievement to get Android apps working properly on the Z10/Z30.

      1. sorry, what?
        Unhappy

        Re: "If it uses QNX rather than Linux"

        I feel compelled to say that, whilst what you say may be essentially correct, Linux started life long enough ago that many of the phones we have in our pockets are actually of a better spec in processor and memory terms than the devices on which Linux was run back in the day. The issue is efficiency and therefore reduced power usage and, I suspect, there won't be a huge amount of difference between the two (said in an uninformed and glib manner).

        I have been an Android user for several years now. The thing that I have come to dislike is the way I feel spied on by Google and its continuous slurping of data. For third party apps I never accept certain permission combinations but for those core Googly ones (like gmail and maps) you're basically stuffed because Google can do whatever it wants. On the device or 'in the cloud'. Same applies to the Play Store itself.

        Not to say that I'd switch to BB. Mainly because I can't see them surviving. And I hate the Apple premium, so that's a no. Windows Phone? Not a chance; I seriously dislike the UX. So I'm left wondering if there are any decent Android branches that improve the privacy side of things...

        1. eszklar

          Re: "If it uses QNX rather than Linux"

          Replicant (if your phone supports it) or CyanogenMod (again if your phone support it) and F-Droid.

        2. John Smith 19 Gold badge
          Gimp

          Re: "If it uses QNX rather than Linux"

          "The thing that I have come to dislike is the way I feel spied on by Google and its continuous slurping of data."

          Well you are being spied upon by Google.

          What happened to the "Iron" build of Chrome without most of the spying?

        3. David Simpson 1

          Re: "If it uses QNX rather than Linux"

          What about CyanogenMod or KANG?

      2. Richard Plinston

        Re: "If it uses QNX rather than Linux"

        > Linux, originally conceived as a Unix-like substitute in larger machines.

        Linux originally ran on 80386 machines, which were considerably less powerful than even the most modest ARM phone.

        It happens that Linux can scale from very small machines to supercomputers.

        1. Matthew 25

          Re: "If it uses QNX rather than Linux"

          "Linux originally ran on 80386 machines, which were considerably less powerful than even the most modest ARM phone."

          QNX didn't even need that much processing power and was supported on 8088

        2. david 12 Silver badge

          Re: "If it uses QNX rather than Linux"

          >Linux originally ran on 80386 machines, which were considerably less powerful than

          >even the most modest ARM phone.

          QNX originally ran on 8088 machines, which were considerably less powerful than even the most modest 80386 machines.

      3. David 14

        Re: "If it uses QNX rather than Linux"

        "... Linux, originally conceived as a Unix-like substitute in larger machines"

        Hmm, not sure what you reference as "larger machines". Larger than a cell phone, sure... but back in the 1992 timeframe, when I first started using Linux (and was forever grateful to the 1993 "slackware" release of the O/S making it as easy as downloading and writing only 55 x 1.44 MB floppy disks)... it was designed for "386" processors running in the 12 to 40MHz rating... something that is dwarfed by modern cell phones.

        Linux has become a system used in larger server, for sure.... but it did not start that way!

    2. DrXym

      Every major phone OS uses a different kernel yet they all manage to provide a good user experience. The kernel is largely an irrelevance. There is absolutely nothing inherently better about QNX vs Linux as far as the end user is concerned, or the apps for that matter.

      1. Anonymous Coward
        Anonymous Coward

        A microkernel has less surface for ring 0 exploits, and thus is more easily made secure than a monolithic kernel. It doesn't mean that QNX is necessarily more secure, but the potential is there.

        1. Anonymous Coward
          Anonymous Coward

          "It doesn't mean that QNX is necessarily more secure"

          No, not necessarily, but given that RIM (as it was) put a lot of effort into security, and also made the decision to go with QNX, we might speculate that they knew what they were doing.

          1. DrXym

            Re: "It doesn't mean that QNX is necessarily more secure"

            "No, not necessarily, but given that RIM (as it was) put a lot of effort into security, and also made the decision to go with QNX, we might speculate that they knew what they were doing."

            Of course they put a lot of effort into it. They OWN QNX and it's called eating their own dogfood. One must assume if they had used another kernel they would have put an equal amount of effort into that.

            Second, being a microkernel isn't any more secure or safe than a monolithic kernel. Those things are orthogonal to the general architecture. There are security enhanced versions of Linux with EAL4+ certification for example. The kernel isn't even half the story either since it could be the most secure kernel in the world but if the application layer does stupid things then it doesn't really matter.

            1. h3

              Re: "It doesn't mean that QNX is necessarily more secure"

              You can run Linux on top of a microkernel that has been done loads of times you can work out the abi.

              All the formally verified systems are Microkernels.

              1. Charles 9

                Re: "It doesn't mean that QNX is necessarily more secure"

                Only because formal verification is very complicated, and even then the formal verification only applies to specific compilations/implementations like that for SEL4.

    3. Euan 1
      Paris Hilton

      Re:

      Sexonded!

  2. Phil Atkin

    I second that motion

    The QNX engineering team is awesome.

    1. asdf

      Re: I second that motion

      Yeah but at this point we have to trust inept BB management to have not laid off the good engineering talent. Considering how middle management in any company prefers the own horn tooters and butt kissers to the good people good luck with that.

  3. Bronek Kozicki

    +1 to El Reg

    ... for using the correct meaning of the word "hack".

  4. Alan Bourke

    To quote Ian Dury ...

    ... there ain't half been some clever bastards.

    1. wolfetone Silver badge

      Re: To quote Ian Dury ...

      Lucky bleeders, lucky bleeders

  5. KjetilS

    "Android runs Java applications on a JVM called Dalvik"

    No it doesn't. It runs Android applications on a VM called Dalvik. The language is quite similar to Java, but it isn't Java, and Dalvik isn't a JVM.

  6. Mr Spigot

    Well done guys, plenty of overtime coming up

    I won't pretend to understand what they've achieved in any depth, but often the problem with hacks like this is that they are built on platform idiosyncrasies and have no resilience to future change. So at best they have a maintenance headache and at worst the house of cards comes tumbling down.

    Why invest in the BB ecosystem on the hope it'll run android apps for the foreseeable future - just buy android!.

    1. ElNumbre
      Thumb Up

      Re: Well done guys, plenty of overtime coming up

      Those were might thoughts exactly. Id imagine that every time Google update the Android API's, and particularly when they do a major release (Android 5 anyone) that the foundation of the House of Cards will be undermined extensively.

      Id rather see them invest in porting their technology to Android or (shudder) Windows Phone. A 'powered by Android, secured by Blackberry' device could be a big seller in the corporate world.

      1. Anonymous Coward
        Anonymous Coward

        Re: Well done guys, plenty of overtime coming up

        Based on current form; given that Google have taken baby steps into phone production and that they have all those partners to keep sweet, I'd say that they'll make a point of breaking things for Blackberry on the next release.

        1. Anonymous Coward
          Anonymous Coward

          Re: Well done guys, plenty of overtime coming up

          Google undoubtedly makes more $$ per BB user than per Android user, because the average Android user is so stinkin' cheap.

          In fact, I'll bet Google is giving BB a hand on this project, and that the Chocolate factory is more than happy to see their own Android apps like Chrome, the Gmail app, Maps - work natively on the BB platform.

          Google already has massive market share with Android - 2/3 of tablets and 4/5 of phones worldwide. They don't need much more market share, they need access to more eyeballs for their ads. BB can give them a few more eyeballs, and a few more lucrative ones at that.

        2. John Smith 19 Gold badge
          Unhappy

          Re: Well done guys, plenty of overtime coming up

          "Based on current form; given that Google have taken baby steps into phone production and that they have all those partners to keep sweet, I'd say that they'll make a point of breaking things for Blackberry on the next release."

          The old MS strategy of "Windows ain't done will Lotus won't run?"

          Surely not.

        3. jonathanb Silver badge

          Re: Well done guys, plenty of overtime coming up

          If they do break things for Blackberry, they also break things for earlier versions of Android, and people don't upgrade that quickly.

          1. Anonymous Coward
            Anonymous Coward

            Re: Well done guys, plenty of overtime coming up

            The hack is at the syscall and POSIX layers, well below all the stuff that makes Android Android. These low-level interfaces don't churn much.

            That said, outside the native extensions hack, the Android player needs to thunk a lot of Android services to BB10 equivalents, and this can be labour intensive to maintain through future gyrations of Android.

      2. Charles 9

        Re: Well done guys, plenty of overtime coming up

        I would think it will start happening sooner than that. Android 4.4 KitKat introduces the new Android Runtime (ART). The big feature of ART is precompiling Dalvik apps upon installation. Seems a bit rough around the edges, but it definitely shows where they're going.

      3. Metrognome

        @ ElNumbre

        'powered by Android, secured by [insert_any_name]' ...

        Isn't this a contradiction in terms?

    2. Anonymous Coward
      Anonymous Coward

      Re: Well done guys, plenty of overtime coming up

      Because most android devices are cheap feeling pieces of plastic. I've owned 3 of them, and they all felt like a kid's toy. I'd rather use an iphone instead of an android these days. I settled for the best though and decided on Blackberry 10 - and now I have a plethora of apps available. Awesome time to own a Blackberry!

    3. Luke McCarthy

      Re: Well done guys, plenty of overtime coming up

      I don't think that is a real problem, since this works at the Linux system call level.

  7. Anonymous Coward
    Anonymous Coward

    Does anybody actually know of anyone that actually uses blackberry ?

    I knew one guy who loved them right up to the point they gave up their records after the riots. Hearing him scream about police state for weeks afterwards was very funny.

    1. AJ MacLeod

      Yeah, what an idiot. He should have trusted all his personal information to Google, they never pry...

    2. Captain Scarlet
      Coffee/keyboard

      Erm yes

      and be careful with your phone, it sounds like your "friends" would very likely just stea your ifad/milky way (Other forms of communication available) whilst you arent looking

    3. Anonymous Coward
      Anonymous Coward

      Yes. I use one. I'm tired of android being a buggy piece of crap, crashing, constantly seeing "com.(whatever) has stopped responding - Force Close or Wait". I switched to iphone, which was a bigger mistake. I'm completely happy and satisfied now with Blackberry.

    4. Victor Cooper

      I will soon

      Use BB10 as an Android app launcher or Android as an Android app launcher? Hmm easy choice. I had a Q10 and loved the wonderful HUB and multitasker. Loved the phone but lost it. Replaced it with a Nexus 4 because I wanted a few Android apps that the Q10 was missing. But Android itself does not compare to the BB10 messaging experience with the HUB. Now that I can launch most Android apps from BB10, I ordered the Z30. So I am one who will own a BlackBerry. Can't wait to get it.

  8. Tom 7

    Actually thats Blackberry doomed

    MS will employ the whizz kids to get VBA running on RT.

    Poor buggers.

  9. Philippe

    Apple and Google will love these guys.

    Whilst I was reading about this impressive piece of wizardry, I had images of Apple and Google head-hunters circling around Waterloo, Ontario like vultures around a dead horse.

  10. Anonymous Coward
    Thumb Up

    Not surprising

    *BSD has been doing this for years. Linux/MIPS was also able to do this with some SGI IRIX binaries, although from what I heard, it could only emulate a subset of IRIX 5.x syscalls.

    WINE also does similar things to get Windows code to run on Linux and BSD… a PECOFF loader pulls the application into memory from the .exe file and any .dll's (since Linux only natively understands ELF and a.out) then the linker goes hunting for the Linux-native implementations of bits that are missing.

    Still, good on them for giving it a go, hopefully it works out for them.

    1. Kevin Johnston

      Re: Not surprising

      To be fair to the guys, saying that another OS/Kernel/whatever already does it does them down. Writing the code to get in working in your specific situation is a different order from asking if it can be done

    2. naw

      Re: Not surprising

      And IBMs AIX (Power Unix) did it for Linux with Lx86, and SCO Unix did it for AT&T Unix, I'm sure there's others - I'm not putting down BB's technical capability here, certainly it's beyond me to do the same, but I do wonder if they put a lot of effort into the wrong area. They now have to maintain compatibility with the Android Appstore, App Developers won't care about BB compatibility, so BB will have to make ALL of th effort and as Android develops that will become more and more difficult. IMO, they should have bit the bullet and gone down the Android (or Cyanogen or Replicant or some other Android Fork) and produce their own Android fork, but Hardened and Optimised for Business users with all the sort of back end services and integration that business users might want.

  11. DrXym

    The next step

    Blackberry should just make an Android handset. It doesn't stop them from adding value add to their solution in terms of secure storage, remote wipe, a UI optimized for email, an app store with secure audited apps etc. But just running Android would do a lot to improve its chances in the market place.

    1. Dave 126 Silver badge

      Re: The next step

      A bit like Samsung's KNOX efforts, then?

      1. DrXym

        Re: The next step

        Well yes, but of course Blackberry has been at this game a lot longer and has a reputation for it. They could trade off that reputation while still producing a device that benefits from being a true android handset.

        Perhaps Google, Samsung and Blackberry should all part of the same initiative and differentiate at the UI level.

    2. John Sanders

      Re: The next step

      Producing an Android handset running their customized BBRY platform should have been priority from day one.

      I do appreciate the technical mastery of the QNX guys, but at the same time it is a colossal waste of time when you think they could have just tweaked Android to make their own BBRY Android and they wouldn't have had to resort to hacking tricks.

      Like someone said in the thread, I bet this doesn't work to RIMs advantage and plays more like it did for OS/2 to run Windows apps.

      1. naw

        Re: The next step

        Yep - I think that they have invested so much into BB/QNX, they can't bring themselves to about-turn and admit it's a cul-de-sac. The Windows/OS2 scenario is a good observation

    3. Victor Cooper

      Re: The next step

      But I don't like the Android experience and absolutely love the Blackberry one. I can handle running some apps written for Android on the Blackberry platform but that is it. No there has to be others who prefer the superior user experience of the BB10 and would not want BB to be just another Android knock off. No thanks. I like the exclusivity of the brand no matter how small it is.

  12. Michael C.

    More of this, please

    This is the sort of tech news I need to read about on a daily basis. Interesting stuff, more of this please!

  13. sabroni Silver badge

    Security?

    So how secure is the supposedly locked down business side of BB10 now android apps can call into blobs of code that no one at BB understands?

    1. Paul Shirley

      Re: Security?

      In also struggling to see how an essentially brute force hack is "clever". Hard work but clever?

      A clever solution would have isolated all app components in their own pseudo VM and shimmed emulation under it, allowing some amount of security to be enforced.

      1. Anonymous Coward
        Anonymous Coward

        Re: Security?

        An alternative would be to run Linux in a VM and then Android on top of that. This would be in some ways cleaner, but would greatly increase the RAM requirements, since there'd be two separate full OSes running at the same time. Cleaving at the POSIX layer reduces duplication of OS resources.

        As for security, the Android binary blob is no different from any other binary blob QNX runs in user space. (A 3rd party BB10 native app is as "blobby" to the company as an Android binary.) It doesn't increase the surface area for attack.

    2. Bigboy1

      Re: Security?

      The android apps can be housed in a Secure container using blackberry "Balance". There is no inherent danger to using android apps. It is no different than accepting any other form of unsecured data, or any blackberry native app because they is don't have access to root.

      This is coup pure and simple. There really is no reason to consider the Blackberry anything less than a "better android than android". Still the average consumer is going to just grab whatever phone he last saw on a tv commercial. That's why Blackberry is best to focus on Enterprise or a couple years and look for another chance to crack the wider consumer market.

  14. CAPS LOCK

    Hmmm, this reminds me of "A better Windows than Windows"

    Being better at running your competitors applications is not a road you should go down.

  15. hamoboy

    This might be a lifeline, but nothing more

    So in effect, the message Blackberry is giving to app vendors everywhere is "Write for Android, and you'll target us too". Thus removing any motivation for these developers to try and write native QNX apps. Even in Apple's darkest days before the iPhone, they never bundled Parallels or any such emulation software with their machines, they knew that that might have provided a short term gain, but long term it would have been a sign of surrender. Vendors don't want to targer a platform whose makers have surrendered.

    1. Victor Cooper

      Re: This might be a lifeline, but nothing more

      I have owned a series of Macs since 2007. I would not own one for work today if it did not have VMware , Virtualbox or Parallels support. There are still many native apps that the Mac platform does not support. As big as apple is today, the Mac native app support is still pretty poor at least in the workplace. I don't agree with your argument.

      1. hamoboy

        Re: This might be a lifeline, but nothing more

        But Apple never BUNDLED emulators with their machines. It was always an aftermarket purchase. In the same way, Blackberry should have made this something users could add on later, not something that comes with the phone. App now have negative incentive to make a native QNX port.

    2. david 12 Silver badge

      Re: This might be a lifeline, but nothing more

      >Thus removing any motivation for these developers to try and write native QNX apps

      dunno. Blackbetty has native support for QT: Android doesn't. It convinces us.

  16. Anonymous Coward
    Anonymous Coward

    All worthless thou.

    1. Blackberry is dead.

    2. There are still compatibility issues.

    3. There will never be Google Play store.

    Go get a Nexus5 and save yourself the grief that will surely accompany BB10 ownership.

    1. Anonymous Coward
      Anonymous Coward

      Re: All worthless thou.

      I have followed your advice and am still trying to work out where to insert my SD card. Also, I can no longer go two days between battery charges. How do I fix this?

      1. Dave 126 Silver badge

        Re: All worthless thou.

        >Go get a Nexus5 and save yourself the grief that will surely accompany BB10 ownership.

        >>I have followed your advice and am still trying to work out where to insert my SD card. Also, I can no longer go two days between battery charges. How do I fix this?

        Er, trade it in for an LG G2?

      2. jonathanb Silver badge

        Re: All worthless thou.

        Apparently you can use a USB2go cable to attach a USB mass storage device, so a SD card adapter at the other end of that cable should do it. Not as good as an internal slot, but it can be done.

    2. Victor Cooper

      Re: All worthless thou.

      Have a Nexus 4. No thanks to the Nexus 5. With the news that it can run apks directly I just ordered the Z30. Pinch gesture in the HUB to close out / open read mails, custom quick menu and the native Blackberry Express on the fly presentation tool are just 3 of many great features I am looking forward to. So no thanks again to the Nexus 5. My nexus 4 will be a more than adequate backup to my Z30 upgrade.

  17. Mage Silver badge
    Flame

    It won't save RIM/Blackberry

    But it may make QNX more valuable in the eventual firesale.

    A great trick/hack though.

  18. David Kelly 2

    Blackberry has Android-envy

    If Blackberry is going to expose themselves to all the faults and flaws in Android then they might as well ditch the excellent QNX and go Android-native.

    1. Anonymous Coward
      Anonymous Coward

      Re: Blackberry has Android-envy

      No, they gained access to Android apps *without* exposing their entire system to all the risks and flaws (perceived or otherwise) of Android. The Android player is in its own app container and can be walled off from other apps and system resources.

  19. Anonymous Coward
    FAIL

    But apparantly they couldn't get BB10 running on the Playbook! Hmm...

    1. Bronek Kozicki

      Yes, that got me peeved too. However, PlayBook only has 1GB RAM and all BB10 handsets have 2GB , I understand this extra 1GB requirement is actually there for a reason.

      Here is a thought: could this hack possible reduce some memory weight of Android runtime, thus making PlayBook viable again?

  20. John Sanders

    Ok if QNX could do it why not linux?

    When are we going to get an Android runtime for Desktop Linux?

    Come on, It should be possible to run .apks on Linux by now!!!!

    1. larokus

      Re: Ok if QNX could do it why not linux?

      Run an emulator to run an emulator!! Bluestacks for windows is android on your desktop. :D

    2. Anonymous Coward
      Anonymous Coward

      Re: Ok if QNX could do it why not linux?

      You mean like this?

      1. Anonymous Coward
        Anonymous Coward

        Re: Ok if QNX could do it why not linux?

        Android players for PCs won't run ARM native extensions directly on the CPU like BB10 does, given that PCs are x86.

  21. Nathan 6
    FAIL

    So after Management has hit the Iceberge ...

    So after management ran the ship headlong into an iceberg, and fled into their golden life rafts, its up to the engineers to save the company with "this cool hack"? At this point, the ship is halfway to the bottom, and no amount of hackery can save it.

    Only thing that would have save them would be if they had build a Java API on top of QNX from the start, or just rolled their own Andriod OS 3-4 years ago. However, that would have required competent management.

    Kinda reminds me of the whole JCPenny mess, in which a new CEO and his management team were given ~80 million in one year to save the company, and guess what, company is now way worse off. The JCP board would have been better of just setting 80 million dollars on fire or just given it to their employees.

  22. John Smith 19 Gold badge
    Thumb Up

    "one of Skype or Instagram even had self-modifying code"

    Wow.

    That would make one of them the third legitimate use for this technique I've heard of (I gather it's popular with malware writers, but apart from them it's not really clear who else). The othere 2 were the AT&T "Blit" bitmapped graphics terminal and the Apollo Guidance Computer.

    The article does not give enough tech detail to understand what they've done. I'm getting (having nosed through Wikipedia)

    1)Dalvik is a special JVM. It reads its own file format that is more compact than Java .class files.

    2)RIM engineers have ported it.

    3)But QNX <> Chrome <>Linux (IIRC Chrome has been formerly forked from Linux)

    4)Their hack operates below the kernel function call level and operates right at the software interupt (SWI) instruction level (actual ARM op code) AFAIK a OS kernel call can have multiple SWI calls inside it.

    5) But I'm b**gered if I know how.

    So thumbs up for the hack, whatever it is.

    Only time will tell however if the management manage to snatch defeat from the jaws of victory. :(

    1. Michael Wojcik Silver badge

      Re: "one of Skype or Instagram even had self-modifying code"

      That would make one of them the third legitimate use for this technique I've heard of (I gather it's popular with malware writers, but apart from them it's not really clear who else).

      Self-modifying code was quite common in mainframe applications at least into the mid-1980s. It was often used in assembly-language apps for things like patching, on-demand loading, memoization, etc. Some higher-level languages supported it directly, such as COBOL with its ALTER statement.

      I've also seen it used in some performance-critical code, again back in the '80s. As CPU caches became more complex, there was a lot of discussion about their effects on self-modifying code.

      Depending on what you consider "self-modifying code", you might also include some techniques that involve dynamically-generated code, such as GCC trampolines (which build code at runtime on the stack). That's not usually considered self-modification, though.

      As for how the QNX technique works: it's really not that complex (or new - Andrew oversells it in the article). The interrupt handler looks at the parameters to determine whether it's a QNX syscall or a Linux syscall. In the latter case it probably jumps to a thunk that does the conversion. (The conversion could be done in the handler, but that'd be messy.) QNX and Linux syscalls are mostly equivalent, thanks to POSIX, so it's mostly a matter of massaging parameters.

  23. David Simpson 1

    Considering that 4.4 KitKat has the option to replace Dalvik with ART, by way of a test it stand to reason that by 4.5 or 5.0 ART will be default and all Blackberry's effort will seem rather pointless.

    1. Richard Plinston

      > it stand to reason that by 4.5 or 5.0 ART will be default and all Blackberry's effort will seem rather pointless.

      ART is open source too. BB can build their own version.

      In any case ART does run Dalvik apps, it just starts them faster by running the 'JIT' compiler on installation rather than at app startup (plus other optimizations). The apps aren't any different so they will still run under Android Dalvik* and BB Dalvik.

      * NOTE: there is no plan to obsolete every app** in the play store nor all pre-4.5 Andoid phones** and tablets just to make BB unhappy.

      ** cf Windows Mobile 6.x and Windows Phone 7 where they _did_ do that to their own developers, OEMs and customers.

  24. Anonymous Coward
    Anonymous Coward

    A Better Android?

    Take Android, remove the underlying Linux OS, slide in the QNX OS in its place and maybe, just maybe, you have a more reliable Android platform. Maybe BlackBerry is on to something here...

This topic is closed for new posts.

Other stories you might like