Tizen OS Local Upgrade Client Guide

From Tizen Wiki
Jump to: navigation, search
  1. Setup tizen-manifest
    1. Add metaday key
      • Without metadata, upgrade daemon cannot send event to client
      • Metadata key : tizen-fota-manager, value : client
    2. Add priviliege
    3. Example tizen-manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns="http://tizen.org/ns/packages" api-version="5.5" package="org.example.update-manager-client" version="1.0.0">
    <profile name="iot-headed" />
    <service-application appid="org.example.update-manager-client" exec="update-manager-client" type="capp" multiple="false" taskmanage="false" nodisplay="true">
        <icon>update-manager-client.png</icon>
        <label>update-manager-client</label>
        <metadata key="tizen-fota-manager" value="client"/>
    </service-application>
    <privileges>
        <privilege>http://tizen.org/privilege/appdir.shareddata</privilege>
        <privilege>http://tizen.org/privilege/datasharing</privilege>
        <privilege>http://tizen.org/privilege/d2d.datasharing</privilege>
        <privilege>http://tizen.org/privilege/externalstorage</privilege>
        <privilege>http://tizen.org/privilege/externalstorage.appdata</privilege>
        <privilege>http://tizen.org/privilege/updatecontrol.admin</privilege>
    </privileges>
</manifest>
2. Setup src
  1. Client app should process plug event after receive plug app control
    • Plugged event key : fota-plug, value : (delta path)
  2. Client app should process user's download event
    • Download event should only worked when usb plugged
    • Download path : client app's shared path
  3. Client app should process unplug event after receive unplug app control
    • Unplugged event key : fota-unplug, value : (usb home path)
  4. Client app should process user's upgrade trigger event
    • By using update control API : update_control_do_update
  5. Client app should process reboot event when first reboot after upgrade
    • Reboot event key : fota-reboot, value : value : 00(success), 0(ro only success), other(fail)
    • Or you can fetch upgrade result with update control API : update_control_get_property(...)
  6. Example source code
void service_app_control(app_control_h app_control, void *data)
{
    int ret = 0;
    int *result = NULL;
    char *value = NULL;

    ret = app_control_get_extra_data(app_control, "fota-plug", &value);
    if (ret == APP_CONTROL_ERROR_NONE) {
        /* Process plug event */
        LOGI("App-control fota-plug : %s", value);

        delta_path = value;
    }

    ret = app_control_get_extra_data(app_control, "fota-download", &value);
    if (ret == APP_CONTROL_ERROR_NONE) {
        /* Process user's download event */
        LOGI("App-control fota-download : %s", value);

        if (delta_path != NULL) {
            system(
                g_strjoin(" ", 
                    "cp", delta_path, app_get_shared_data_path(), NULL
                )
            );
        }
    }

    ret = app_control_get_extra_data(app_control, "fota-unplug", &value);
    if (ret == APP_CONTROL_ERROR_NONE) {
        /* Process unplug event */
        LOGI("App-control fota-unplug : %s", value);

        delta_path = NULL;
    }

    ret = app_control_get_extra_data(app_control, "fota-update", &value);
    if (ret == APP_CONTROL_ERROR_NONE) {
        /* Process user's upgrade trigger event */
        LOGI("App-control fota-update : %s", value);

        ret = update_control_initialize();
        LOGI("update_control_initialize return : %d", ret);

        ret = update_control_do_update();
        LOGI("update_control_do_update return : %d", ret);

        ret = update_control_deinitialize();
        LOGI("update_control_deinitialize return : %d", ret);
    }

    ret = app_control_get_extra_data(app_control, "fota-reboot", &value);
    if (ret == APP_CONTROL_ERROR_NONE) {
        /* Process reboot event */
        LOGI("App-control fota-reboot : %s", value);
    }
}