Relationship of bada 2.0 and Tizen 2.1

Gabor Paller's picture

Tizen 2.0 was based entirely on the web application model. While the web application model is attractive for developers who know the web technologies, it is not easy for newcomers and leads to resource consumption (battery, memory) problems in certain classes of applications. Here is a presentation about these problems. My advice then was to look for platforms that have native application model too in case the developer runs into the restrictions of the web model. The recently released Tizen 2.1 platform did just that and adopted a native application model.

Compared to the Tizen 2.0 SDK, the installation of the Tizen 2.1 SDK was relatively problem-free on my 64-bit Ubuntu system. Somehow the identification of the Java Runtime Environment is still a problem, I had to create soft links manually so that the jre subdirectory is mapped to my JRE_HOME/bin directory, otherwise the IDE, the resource editor and the signing tool was not able to launch. After I installed the SDK and created my first HelloWorld project, a very familiar directory structure appeared.

This layout is highly reminiscent to the layout of a bada application. In order to figure out, how much bada and Tizen native apps have in common, I decided to port to Tizen one of the example applications from Sfonge's bada training. This app is the first of the Interesting Words series and is very simple. It displays an interesting word and its meaning. When pressing a button, it jumps to a new word.

The Tizen project is attached to this post. You have to be logged into the Sfonge site to access it.

The first obvious change is that all the Osp namespaces are renamed now to Tizen. So instead of e.g. Osp::App, you would have Tizen::App. Osp (Open Services Platform) was bada's maiden name. All the class name and namespace references have to be renamed accordingly. The class Osp::App::Application changed more dramatically, it is now called Tizen::App::UiApp. The significance of this change is that Tizen has an application class called service application which doesn't have UI.

After these changes the project can be compiled which is a good indication how close Tizen native and bada native application models are to each other. It won't run, however, as Tizen made another, more subtle change which is related again to the fact that some Tizen apps don't have UI. In bada, the app could assume that the top-level Frame has already been created by the application framework when its OnAppInitializing method is called and could just obtain a pointer to this Frame in that method:

bool
words1::OnAppInitializing(AppRegistry& appRegistry) {
...
       Frame *pFrame = GetAppFrame()->GetFrame();
...
}

In Tizen, the top-level Frame needs to be created by the application. A new Frame descendant class needs to be created and all the top-level Frame initialization needs to be moved into the OnInitializing method of that descendant class.

bool
words1::OnAppInitializing(AppRegistry& appRegistry) {
...
    words1Frame* pwords1Frame = new words1Frame(db);
    pwords1Frame->Construct();
    pwords1Frame->SetName(L"words1");
    AddFrame(*pwords1Frame);

    return true;
}

...

result
words1Frame::OnInitializing(void)
{
    // Create the main form
    WordsForm *pWordsForm = new WordsForm( db );
    pWordsForm->Initialize();

    AddControl(*pWordsForm);
    SetCurrentForm(*pWordsForm);
    return E_SUCCESS;
}

There is one more hiccup to handle. Tizen SDK offers the same resource editor that bada had. It does not open the XML file, however, that is used to describe the form and is located in the res/ directory. Fortunately the solution is simple. In the bada XML file there is a tag like this:

<Scene Bversion="1.2.1.v20101224" Dversion="20100701">

The version codes need update like this:

<Scene Bversion="3.0.0.v20120410" Dversion="20120315">

And then it is done! The words1 example application executes nicely after these modifications.

Bada programmers will find the Tizen native application model very familiar and bada applications can be ported into the new platform with relatively few and mostly automatic modifications. In addition, Tizen offers some new feature that were made possible as bada's underlying real-time kernel was swapped to Tizen's Linux. But more about that later.

Taxonomy upgrade extras: