Languages

Menu
Sites
Language
Gear Fit 2 - can't read files inside service native app

Hi, I try to read folders from /opt/usr/media on Gear Fit 2 from service app. It is hybrid app. Web App starts service and then

I need to read all folders from media folder (like documents, downloads and any folder there).

The code stops at getting folder attributes - line: if(stat(path,$st) == -1).

I don't know what is wrong. The code read files without problem when it is inside UI app but

doesn't want to work in hybrid service.  Are there any constraints about readig files from service app on Gear Fit 2?

 

I added privilages to tizen-manifes.xml.

  <privilege>http://tizen.org/privilege/mediastorage</privilege>
  <privilege>http://tizen.org/privilege/externalstorage</privilege>

 

    char *path;
    storage_get_root_directory(STORAGE_TYPE_INTERNAL, &path); // works OK

// path contains now: /opt/usr/media

    struct stat st;
    if (stat(path, &st) == -1) { // STOP HERE, stat() returns -1
        return; // code enter here and ending
    }

    if (S_ISDIR(st.st_mode)) {

... // not enter here

}

...

Edited by: Slawek Kowalski on 02 Dec, 2017

Responses

7 Replies
Shaswati Saha

Would you please try with only service app instead of Hybrid app to check whether the problem is with service app or not? According to API documentation, Files saved on the internal/external storage are readable or writeable by all applications. So it should work in service app also.

Slawek Kowalski

after calling

stat(path, &st);  // it sets errno if fail

strerror(errno) returns message: Permission denied.


 

Shaswati Saha

According to this link, the problem is with Gear Fit2. I would like to suggest you to try the same thing in Gear S2 device.

Slawek Kowalski

I saw this post before. There is no answer on stackoverflow.

Shaswati Saha

My intension of sharing that link was to refer you to the reason of the problem which seems to me as that problem is with Gear Fit2 device. My suggestion towards you is to try the same experiment you did previously on a Gear S2 device to ensure whether it's a device specific problem or not.

Slawek Kowalski

I checked it before. Native service works without problems on Gear S2/S3.

Shaswati Saha

I tried to read a text file from filepath /opt/usr/media/Downloads/ and didn't face any problem similar to yours. I've tried to create a hybrid app (a web UI app packaged with a native service app) and launched service app using App Control launch request. I've written code to read file in service_app_control function.

N.B:  Software Version of my gear fit2 is R360XXU1DQJ3.