Tizen Data Controls vs. Android content providers

Gabor Paller's picture

Bada used to have a mechanism called AppControls. AppControls are very similar to Android's Intent-based application invocation. With the 2.1 version, Tizen received another sharing mechanism reminiscent of the Android platform. It is called Data Control and is very similar to the Content Provider mechanism in Android. Using Data Controls, the service application can expose persistent, read/write or read-only data to other applications. While in Android, the access of the exposed data follows SQL semantics and therefore it is not trivial to implement the content provider if the data is not actually stored in an SQLite database, in Tizen there are two options. The data control (as it is known in Tizen) may implement SQL access or it may implement Map access. In the latter case the user of the data control accesses the data with keys and the data abstraction is key-value pair. It is obviously easier to implement if you don't need the power of SQL access. In this example application a Map-type data control will be presented.

The example application is attached to the end of the post. You have to be logged into the Sfonge site in order to access it.

The application itself is the familiar Words2 which present interesting words in a list then opens an explanation page when a list item is clicked. This time the data is provided by a data control (implemented in the wordsdatacontrolservice service application) while the UI is provided by the wordsdatacontrolui application.

The API is asynchronous on the side of the data control user. This makes the API much harder to use than the Android content provider API with its synchronous invocation syntax. For example in Listform.cpp, first we register a listener for result callbacks:

       pDC = AppManager::GetMapDataControlN(words2withsceneApp::PROVIDER_ID);

then the query is issued:

        r = pDC->GetValue(dataId, key, reqId);

finally the result comes back in the callback function:


Fortunately, it is possible to update the UI in the callback.

There is another interesting restriction. Unlike in Android, it is not possible to define permission to restrict access to the data control. In order to protect the data control from unwanted access, the platform enforces that the user of the data control and the data control service application must be signed with keys belonging to the same certificate. This pretty much kills all the use cases of system-wide data sharing - you can share data only with your own applications.

All in all, sharing map-type data is a useful feature which complements well the SQL-type content provider - it would be also handy to have a similar feature in Android. The same-certificate restriction between the data control user and the data control service application is a serious restriction, however, and can be justified only by the fact that application packages cannot introduce new permissions in Tizen.

And at last, an interesting observation. The example program I shared does not function properly. Compile and run wordsdatacontrolservice then compile and run wordsdatacontrolui. Observe that wordsdatacontrolservice crashes when the first explanation page is opened. Wordsdatacontrolui keeps running, however, and you can return to the list and select another word. Then the app starts to work perfectly because wordsdatacontrolservice is restarted in the background the next time the data control is accessed.

I spent hours chasing this bug and I ended up with the conclusion that somehow the service application's memory space gets corrupted. The ArrayList implementing the word "database" is created in the OnAppInitializing method but by the time the list is accessed, it contains garbage. This happens only when the service application is started first. Curiously, Tizen's own sample applications create data structures only transiently and only in the request method. If anyone knows the reason of this strange behaviour, I would be grateful for a comment.

Attached file: 
Taxonomy upgrade extras: