Languages

Menu
Sites
Language
Unable to access a database created in trusted folder

Hello,

I'm trying to open a database created by a Tizen Native Application in "/opt/usr/apps/<app-id>/shared/trusted"  folder from a Tizen Service Application, but when I'm call the  open of the database will always fail in the Service Application with sqlite error code 14(This says -Unable to open database file). Also, my Service application is packaged with my Native application and both the Service and Native Applications are signed with same author certificate.

Can anyone please help me solve this error and also share with me how can we communicate between an service applciation and Native application.

Edited by: Vivek Chandra Amancha on 18 May, 2015
View Selected Answer

Responses

13 Replies
Marco Buettner

For your first problem if have no idea, maybe you have to setup in manifest.xml filesystem.read/write privileg?

At your second question. The communication can be established by MessagePort API

Vivek Chandra Amancha

I already tried with MessagePort,  the message port is working only if the native application is working otherwise it is giving error. Actually I want to communicate a message from Service application to Native application and this communication is asynchronous.

Marco Buettner

Aha... you wanna communicated between a closed app and service? I think it will not work...

Vivek Chandra Amancha

In Tizen, may be it is impossible.!!!

Alex Dem

Hi,
Afaik usually in multi-package applications service app is used to analyze some parameters or conditions in background and raise UI app if necessity. Maybe you should move some logic from UI app to native service.

I think you could use AppControl functionality also:
https://developer.tizen.org/dev-guide/2.3.0/org.tizen.guides/html/native/app/application_n.htm#app_controls

Using AppControl  you could launch UI app from service app, send some additional params from service to UI and extract them on UI app side. In fact you will have another entry point for UI app (you could display any other screen on launch, but not main screen) etc

Alexey.

Mark as answer
Alex Dem

Hi
Fyi: I was able to create database, close it and open again in readonly mode in /opt/usr/apps/<app-id>/data folder without any privileges & permissions in my standalone service app.
I was unable to perform such actions in <app-id>/shared/trusted folder , but I did not tried with multi-package app.
my code snippet is:

     sqlite3 *ppDb;

     char * dataPath = app_get_data_path();
     int siz = strlen(dataPath)+10;

     char * path = malloc(sizeof(char)*siz);

     strcpy(path,dataPath);
     strncat(path, "test.db", siz);

     int ret = sqlite3_open_v2( path , &ppDb, SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE, NULL);
     LOGI("ret: %d",ret);

     ret=sqlite3_close(ppDb) ;

     if (ret == SQLITE_OK)
     {
         ret = sqlite3_open_v2( path , &ppDb, SQLITE_OPEN_READONLY, NULL);
         LOGI("ret: %d",ret);
     }
     free(dataPath);
     free(path);

Alexey.

Alex Dem

Or also you could try to create and use common sql database in /opt/usr/media/ folder (with http://tizen.org/privilege/mediastorage privilege in manifest)
Alexey.

Vivek Chandra Amancha

Thanks Alex, now I can open the database in readonly mode, but still it fails at sqlite3_prepare_v2 with error code 1.

Vivek Chandra Amancha

Sorry Alex, It's working perfectly alright. Made a asmall mistake. Thank You.

Alex Dem

just fyi, link to a tutorial:
https://developer.tizen.org/dev-guide/native/2.3.0/org.tizen.mobile.native.appprogramming/html/tutorials/opensource_tutorial/opensource_encrypted_db_tutorial.htm
Alexey.

Vivek Chandra Amancha

How can we launch a specific view of an application  from service application???

Alex Dem

Hi,
I have provided link above, you could look at this tutorial.But simplest way could be next:

1) Try to launch your UI app from service app this way

    app_control_h app_control;

    app_control_create(&app_control);
    app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
    app_control_set_app_id(app_control, "org.tizen.UIAppId");

    app_control_send_launch_request(app_control, NULL, NULL);
    app_control_destroy(app_control);

with http://tizen.org/privilege/appmanager.launch 

2) changes in UI app:

static void
app_control(app_control_h app_control, void *data)
{
    /* Handle the launch request. */
    char *callerApp;
    char *operation;
    int ret =app_control_get_caller(app_control,&callerApp);

    if (ret == 0)
    {
        if(strcmp(callerApp,"org.tizen.ServiceAppId")==0)
        {
               //perform some actions, show any other screen
               //also you could analyze operation
               app_control_get_operation(app_control, &operation);

               if (strcmp(operation, APP_CONTROL_OPERATION_DEFAULT)==0)
               {
                   //1st entry point
               }
               else if (strcmp(operation, APP_CONTROL_OPERATION_MAIN)==0)
               {
                   //2nd entry point
               }
        }

    }
}

Alexey.

Alex Dem

just fyi (since you are submitter of  topic about 'lock screen' also),
I guess you could separate your app on 3 parts/apps in one multipckage (main UI app/appBlocker/service app). All communication between apps could be performed with Message Port (service app could manage requests/ perform commands ). Service app could analyze some conditions and raise appBlocker (for example).
Alexey.