Need help running a service app on wearable device

Need help running a service app on wearable device

BY 25 Mar 2016 Web Application Development
(Please note that since the forum software doesn’t allow “external links”, I’ve had to modify all the bits to be http:|| with pipes instead of forward slashes. They are correct in the relevant XML/JS code.)
 
I’m trying to get a service app running on a Samsung Gear S2 (SM-R720 with firmware R720XXU2AOJ5) with Tizen Wearable SDK 2.3.1. I have been trying to follow the semi-guide at <developer.tizen.org/dev-guide/wearable/2.3.0/org.tizen.wearable.web.appprogramming/html/tutorials/service_tutorial/service_app_tutorial.htm> without success.
 
I began with an already-working JS-based GUI app. Based on the link above, I did the following:
 
– Added a <feature> element to the config.xml:
 
    <feature name=”http:||tizen.org/feature/web.service”/>
 
– Added two <tizen:privilege> elements to the config.xml:
 
    <tizen:privilege name=”http:||tizen.org/privilege/application.info”/>
    <tizen:privilege name=”http:||tizen.org/privilege/application.launch”/>
 
– Added a <tizen:service> element to the config.xml:
 
    <tizen:service id=”DFXHyIJESe.GearWebService” auto-restart=”true” on-boot=”true”>
        <tizen:content src=”service/service.js”/>
        <tizen:name>GearWebService</tizen:name>
        <tizen:icon src=”service/service_icon.png”/>
        <tizen:description>Web Service Application Template</tizen:description>
    </tizen:service>
 
Note: the <tizen:application> element already looks like this:
 
    <tizen:application id=”DFXHyIJESe.GearClientApp” package=”DFXHyIJESe” required_version=”2.3.1″/>
 
– Added a service/service.js file, essentially the same as the guide. (Excerpts below.)
 
I have been trying to ways to launch the app. The first uses tizen.application.launchAppControl as per the guide:
 
    var onLaunchAppControlSuccess = function() {
        console.log(“launchAppControl succeeded.”);
    };
    var onLaunchAppControlError = function(e) {
        console.log(“launchAppControl error: Name: ” + e.name + “, Message: ” + e.message);
    };
    var SERVICE_APP_ID = “DFXHyIJESe.GearWebService”;
    var appControl = new tizen.ApplicationControl(“http:||tizen.org/appcontrol/operation/service”);
    try {
        console.log(“Launching app control for ID ” + SERVICE_APP_ID);
        tizen.application.launchAppControl(appControl, SERVICE_APP_ID, onLaunchAppControlSuccess, onLaunchAppControlError);
    } catch (e) {
        console.log(“Exception with launchAppControl: Name: ” + e.name + “, Message: ” + e.message);
    }
 
Results in this error message:
 
    launchAppControl error: Name: NotFoundError, Message: given package is not found
 
 
I’ve also tried it a second method, using tizen.application.launch:
 
    var onLaunchSuccess = function () {
        console.log(“Service launched successfully.”);
    };
    var onLaunchError = function (error) {
        console.log(“Failed to launch: ” + JSON.stringify(error));
    };
    var onGetAppsContextSuccess = function (contexts) {
        console.log(“Checking for service…”);
        var serviceAppFound = false;
        console.log(“Looking for service ID ” + SERVICE_APP_ID);
        for (var i = 0; i < contexts.length; i++) {
            try {
                var appInfo = tizen.application.getAppInfo(contexts[i].appId);
                console.log(“AppInfo ” + i + ” ID: ” + appInfo.id);
                if (appInfo.id === SERVICE_APP_ID) {
                    console.log(“Service running.”);
                    serviceAppFound = true;
                    break;
                }
            } catch (e) {
                console.log(“Exception with getAppInfo: ” + e.message);
            }
        }
        if (serviceAppFound) {
            console.log(“Service running.”);
        } else {
            console.log(“Service not running.”);
            try {
                console.log(“Launching [” + SERVICE_APP_ID + “]…”);
                tizen.application.launch(SERVICE_APP_ID, onLaunchSuccess, onLaunchError);
            } catch (e) {
                console.log(“Exception with launch: ” + e.message);
            }
        }
    };
    try {
        tizen.application.getAppsContext(onGetAppsContextSuccess, onGetAppsContextError);
    } catch (e) {
        console.log(“Exception with getAppsContext: ” + e.message);
    }
 
Results in:
 
Checking for service…
Looking for service ID DFXHyIJESe.GearWebService
AppInfo 0 ID: com.samsung.w-home
AppInfo 1 ID: com.samsung.watchface
AppInfo 2 ID: org.tizen.data-provider-slave
AppInfo 3 ID: com.samsung.shealth.widget.pedometer
AppInfo 4 ID: com.samsung.w-calendar2.widget.monthly
AppInfo 5 ID: com.samsung.weather-widget
AppInfo 6 ID: com.samsung.w-music-player.widget
AppInfo 7 ID: com.samsung.w-music-player.music-control-service
AppInfo 8 ID: com.samsung.shealth-service
AppInfo 9 ID: health-data-service
AppInfo 10 ID: com.samsung.wusvc
AppInfo 11 ID: com.samsung.message.consumer
AppInfo 12 ID: com.samsung.watchface-service
AppInfo 13 ID: com.samsung.clocksetting
AppInfo 14 ID: dbox.web-provider
AppInfo 15 ID: com.samsung.w-gallery.consumer
AppInfo 16 ID: DFXHyIJESe.GearClientApp
Service not running.
Launching [DFXHyIJESe.GearWebService]…
Failed to launch: {“code”:0,”name”:”UnknownError”,”type”:”UnknownError”,”message”:”unknown error”} 
 
Can anyone help me get a simple, JS-based service running on this Tizen 2.3 wearable device?
 
Thanks!
Written by