diff --git a/Tizen.web/ImageClassificationOffloading/js/main.js b/Tizen.web/ImageClassificationOffloading/js/main.js index 9f36bec5..b411788f 100644 --- a/Tizen.web/ImageClassificationOffloading/js/main.js +++ b/Tizen.web/ImageClassificationOffloading/js/main.js @@ -13,6 +13,7 @@ import { GetMaxIdx, GetImgPath, loadLabelInfo, + startHybridService, } from "./utils.js"; let fHandle = null; @@ -160,7 +161,7 @@ window.onload = async function () { const networkType = await getNetworkType(); ip = await getIpAddress(networkType); labels = loadLabelInfo(); - + startHybridService(); document.getElementById("start_local").addEventListener("click", function () { runLocal(); }); diff --git a/Tizen.web/ImageClassificationOffloading/js/utils.js b/Tizen.web/ImageClassificationOffloading/js/utils.js index 783a53ca..d7696263 100644 --- a/Tizen.web/ImageClassificationOffloading/js/utils.js +++ b/Tizen.web/ImageClassificationOffloading/js/utils.js @@ -7,6 +7,8 @@ * @author Yelin Jeong */ +let gServiceAppId = "EQmf4iSfpX.imageclassificationoffloadingservice"; + /** * Get currently used network type * @returns the network type @@ -72,3 +74,61 @@ export function loadLabelInfo() { const labelList = fHandle.readString(); return labelList.split("\n"); } + +function launchServiceApp() { + function onSuccess() { + console.log("Service App launched successfully"); + } + + function onError(err) { + console.error("Service App launch failed", err); + } + + try { + console.log("Launching [" + gServiceAppId + "] ..."); + tizen.application.launch(gServiceAppId, onSuccess, onError); + } catch (exc) { + console.error("Exception while launching HybridServiceApp: " + exc.message); + } +} + +function onGetAppsContextSuccess(contexts) { + let i = 0; + let appInfo = null; + + for (i = 0; i < contexts.length; i = i + 1) { + try { + appInfo = tizen.application.getAppInfo(contexts[i].appId); + } catch (exc) { + console.error("Exception while getting application info " + exc.message); + } + + if (appInfo.id === gServiceAppId) { + break; + } + } + + if (i >= contexts.length) { + console.log("Service App not found, Trying to launch service app"); + launchServiceApp(); + } +} + +function onGetAppsContextError(err) { + console.error("getAppsContext exc", err); +} + +/** + * Starts obtaining information about applications + * that are currently running on a device. + */ +export function startHybridService() { + try { + tizen.application.getAppsContext( + onGetAppsContextSuccess, + onGetAppsContextError, + ); + } catch (e) { + console.log("Get AppContext failed, " + e); + } +} diff --git a/Tizen.web/ImageClassificationOffloadingService/.cproject b/Tizen.web/ImageClassificationOffloadingService/.cproject new file mode 100644 index 00000000..8717e36a --- /dev/null +++ b/Tizen.web/ImageClassificationOffloadingService/.cproject @@ -0,0 +1,658 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tizen.web/ImageClassificationOffloadingService/.exportMap b/Tizen.web/ImageClassificationOffloadingService/.exportMap new file mode 100644 index 00000000..de305161 --- /dev/null +++ b/Tizen.web/ImageClassificationOffloadingService/.exportMap @@ -0,0 +1,5 @@ +{ + global: main; + _IO_*; + local: *; +}; diff --git a/Tizen.web/ImageClassificationOffloadingService/.project b/Tizen.web/ImageClassificationOffloadingService/.project new file mode 100644 index 00000000..27036ad4 --- /dev/null +++ b/Tizen.web/ImageClassificationOffloadingService/.project @@ -0,0 +1,46 @@ + + + ImageClassificationOffloadingService + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + 1719816172307 + + 26 + + org.eclipse.ui.ide.multiFilter + 1.0-projectRelativePath-matches-false-false-*/.tpk + + + + 1719816172309 + + 6 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-project_def.prop + + + + diff --git a/Tizen.web/ImageClassificationOffloadingService/.tproject b/Tizen.web/ImageClassificationOffloadingService/.tproject new file mode 100644 index 00000000..3d473b57 --- /dev/null +++ b/Tizen.web/ImageClassificationOffloadingService/.tproject @@ -0,0 +1,12 @@ + + + + + tizen-8.0 + + + + + + + diff --git a/Tizen.web/ImageClassificationOffloadingService/inc/main.h b/Tizen.web/ImageClassificationOffloadingService/inc/main.h new file mode 100644 index 00000000..aaf601e7 --- /dev/null +++ b/Tizen.web/ImageClassificationOffloadingService/inc/main.h @@ -0,0 +1,20 @@ +/** + * @file main.h + * @date 04 Jul 2024 + * @brief Tizen native service for hybrid application + * @author Yelin Jeong + * @bug No known bugs. + */ + +#ifndef __IMAGECLASSIFICATIONOFFLOADINGSERVICE_H__ +#define __IMAGECLASSIFICATIONOFFLOADINGSERVICE_H__ + +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "image_classification_offloading_service" + + +#endif /* __IMAGECLASSIFICATIONOFFLOADINGSERVICE_H__ */ diff --git a/Tizen.web/ImageClassificationOffloadingService/project_def.prop b/Tizen.web/ImageClassificationOffloadingService/project_def.prop new file mode 100644 index 00000000..fbba1d7c --- /dev/null +++ b/Tizen.web/ImageClassificationOffloadingService/project_def.prop @@ -0,0 +1,11 @@ +APPNAME = imageclassificationoffloadingservice + +type = app +profile = tizen-8.0 + +USER_SRCS = src/main.c +USER_DEFS = +USER_INC_DIRS = inc +USER_OBJS = +USER_LIBS = +USER_EDCS = diff --git a/Tizen.web/ImageClassificationOffloadingService/shared/res/imageclassificationoffloadingservice.png b/Tizen.web/ImageClassificationOffloadingService/shared/res/imageclassificationoffloadingservice.png new file mode 100644 index 00000000..9765b1bd Binary files /dev/null and b/Tizen.web/ImageClassificationOffloadingService/shared/res/imageclassificationoffloadingservice.png differ diff --git a/Tizen.web/ImageClassificationOffloadingService/src/main.c b/Tizen.web/ImageClassificationOffloadingService/src/main.c new file mode 100644 index 00000000..1e2ebb24 --- /dev/null +++ b/Tizen.web/ImageClassificationOffloadingService/src/main.c @@ -0,0 +1,48 @@ +/** + * @file main.c + * @date 04 Jul 2024 + * @brief Tizen native service for hybrid application + * @author Yelin Jeong + * @bug No known bugs. + */ + +#include "main.h" +#include +#include + +/** + * @brief Service app create callback + */ +static bool _create_cb(void* user_data){ + dlog_print(DLOG_INFO, LOG_TAG, "Callback create\n"); + return true; +} + +/** + * @brief Service app terminate callback + */ +static void _terminate_cb(void* user_data){ + dlog_print(DLOG_INFO, LOG_TAG, "Callback terminate\n"); +} + +/** + * @brief Service app app control callback + */ +static void _app_control_cb(app_control_h app_control, void* user_data){ + dlog_print(DLOG_INFO, LOG_TAG, "Callback app_control\n"); +} + +/** + * @brief Main function. + */ +int main(int argc, char *argv[]) { + service_app_lifecycle_callback_s event_callback = { + .create = _create_cb, + .terminate = _terminate_cb, + .app_control = _app_control_cb + }; + + dlog_print(DLOG_ERROR, LOG_TAG, + "Image classification offloading service start"); + return service_app_main(argc, argv, &event_callback, NULL); +} diff --git a/Tizen.web/ImageClassificationOffloadingService/tizen-manifest.xml b/Tizen.web/ImageClassificationOffloadingService/tizen-manifest.xml new file mode 100644 index 00000000..a95c8a21 --- /dev/null +++ b/Tizen.web/ImageClassificationOffloadingService/tizen-manifest.xml @@ -0,0 +1,8 @@ + + + + + imageclassificationoffloadingservice.png + + +