/*
* system-popup
*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "popup-common.h"
#include <aul.h>
+#include <appsvc.h>
+#include <app_control.h>
#define SETTING_MMC_ENCRYPTION_UG "setting-mmc-encryption-efl"
+#define EXTENDED_SD_APPNAME "org.tizen.extended-sd"
+#define ODE_APPNAME "org.tizen.ode"
+#define SDCARD_KEY "_SDCARD_NUM_"
+#define VIEWTYPE_KEY "viewtype"
+#define DEVPATH_KEY "dev_path"
+#define MAPPINGNODE_KEY "mapping_node"
#define DD_BUS_NAME "org.tizen.system.deviced"
#define DD_OBJECT_PATH_ODE "/Org/Tizen/System/DeviceD/Ode"
#define DD_SIGNAL_ODE_MOUNT "RequestOdeMount"
#define DD_SIGNAL_REMOVE_MMC "RemoveMmc"
+enum ext_app {
+ EXT_SETTING_MMC_UG,
+ EXT_SD_SETTING,
+ EXT_ODE
+};
+
static const struct popup_ops mount_error_ops;
+static const struct popup_ops unmount_error_ops;
static const struct popup_ops mount_read_only_ops;
static const struct popup_ops check_smack_ops;
static const struct popup_ops ode_encrypt_ops;
static const struct popup_ops ode_decrypt_ops;
+static const struct popup_ops sdcard_setup_ops;
+static const struct popup_ops unlock_extendedsd_ops;
+
+static char *Sdcard_ID = NULL;
+static char *View_Type = NULL;
+static char *Dev_Path = NULL;
+static char *Mapping_Node = NULL;
static void remove_other_mmc_popups(const struct popup_ops *ops)
{
+ if (ops != &sdcard_setup_ops)
+ unload_simple_popup(&sdcard_setup_ops);
+
if (ops != &mount_error_ops)
unload_simple_popup(&mount_error_ops);
+ if (ops != &unmount_error_ops)
+ unload_simple_popup(&unmount_error_ops);
+
if (ops != &mount_read_only_ops)
unload_simple_popup(&mount_read_only_ops);
return true;
}
+static bool mmc_unmounted(void)
+{
+ int val;
+
+ if (vconf_get_int(VCONFKEY_SYSMAN_MMC_UNMOUNT, &val) == 0
+ && val == VCONFKEY_SYSMAN_MMC_UNMOUNT_FAILED)
+ return false;
+ return true;
+}
+
static void send_mount_signal(char *signal)
{
int ret;
_E("FAIL: broadcast_dbus_signal(%s:%d)", signal, ret);
}
-static void launch_app(char *appname)
+static void launch_app(int type)
{
- bundle *b;
- int ret;
+ app_control_h app_control = NULL;
+ int ret = -1;
- if (!appname)
+ ret = app_control_create(&app_control);
+ if (ret != APP_CONTROL_ERROR_NONE)
return;
- b = bundle_create();
- if (b) {
- ret = aul_launch_app(appname, b);
- if (ret < 0)
- _E("FAIL: aul_launch_app(%d)", ret);
- if (bundle_free(b) != 0)
- _E("FAIL: bundle_free(b);");
+ if (type == EXT_SETTING_MMC_UG)
+ ret = app_control_set_app_id(app_control, SETTING_MMC_ENCRYPTION_UG);
+ else if (type == EXT_SD_SETTING) {
+ app_control_add_extra_data(app_control, SDCARD_KEY, Sdcard_ID);
+ ret = app_control_set_app_id(app_control, EXTENDED_SD_APPNAME);
+ } else if (type == EXT_ODE) {
+ app_control_add_extra_data(app_control, VIEWTYPE_KEY, View_Type);
+ app_control_add_extra_data(app_control, DEVPATH_KEY, Dev_Path);
+ app_control_add_extra_data(app_control, MAPPINGNODE_KEY, Mapping_Node);
+ ret = app_control_set_app_id(app_control, ODE_APPNAME);
} else {
- _E("Failed to create bundle");
+ _E("No matched type(%d)", type);
+ goto out;
+ }
+
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ _E("Fail to set app id");
+ goto out;
+ }
+
+ ret = app_control_send_launch_request(app_control, NULL, NULL);
+ if (ret != APP_CONTROL_ERROR_NONE)
+ _E("Fail to send launch request");
+
+out:
+ if (app_control) {
+ (void)app_control_destroy(app_control);
+ app_control = NULL;
}
}
static void ode_launch_settings(const struct popup_ops *ops)
{
unload_simple_popup(ops);
- launch_app(SETTING_MMC_ENCRYPTION_UG);
+ launch_app(EXT_SETTING_MMC_UG);
terminate_if_no_popup();
}
return mmc_mounted();
}
+static bool skip_unmount_error_popup(bundle *b, const struct popup_ops *ops)
+{
+ return mmc_unmounted();
+}
+
static bool skip_ode_popup(bundle *b, const struct popup_ops *ops)
{
return !mmc_inserted();
}
-static E_DBus_Signal_Handler *mmc_removed_handler= NULL;
+static E_DBus_Signal_Handler *mmc_removed_handler = NULL;
static void unregister_ode_handler(const struct popup_ops *ops)
{
terminate_if_no_popup();
}
+static void mmc_unmount_status_changed(keynode_t *in_key, void *data)
+{
+ const struct popup_ops *ops = data;
+
+ if (vconf_keynode_get_int(in_key) == VCONFKEY_SYSMAN_MMC_UNMOUNT_FAILED)
+ return;
+
+ unload_simple_popup(ops);
+ terminate_if_no_popup();
+}
+
static void register_mmc_mount_handler(const struct popup_ops *ops)
{
if (vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_MOUNT,
mmc_mount_status_changed);
}
+static void register_mmc_unmount_handler(const struct popup_ops *ops)
+{
+ if (vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_UNMOUNT,
+ mmc_unmount_status_changed, (void *)ops) != 0)
+ _E("Failed to register mmc mount handler");
+}
+
+static void unregister_mmc_unmount_handler(const struct popup_ops *ops)
+{
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_UNMOUNT,
+ mmc_unmount_status_changed);
+}
+
static int launch_mmc_popup(bundle *b, const struct popup_ops *ops)
{
remove_other_mmc_popups(ops);
if (ops == &mount_error_ops)
register_mmc_mount_handler(ops);
+ if (ops == &unmount_error_ops)
+ register_mmc_unmount_handler(ops);
+
if (ops == &ode_encrypt_ops ||
ops == &ode_decrypt_ops)
register_ode_handler(ops);
static void terminate_mmc_popup(const struct popup_ops *ops)
{
unregister_mmc_mount_handler(ops);
+ unregister_mmc_unmount_handler(ops);
unregister_ode_handler(ops);
}
+static void launch_sdcard_setup(const struct popup_ops *ops)
+{
+ unload_simple_popup(ops);
+ launch_app(EXT_SD_SETTING);
+ terminate_if_no_popup();
+}
+
+static int launch_ode(bundle *b, const struct popup_ops *ops)
+{
+ if (!b || !ops)
+ return -EINVAL;
+
+ View_Type = (char *)bundle_get_val(b, VIEWTYPE_KEY);
+ Dev_Path = (char *)bundle_get_val(b, DEVPATH_KEY);
+ Mapping_Node = (char *)bundle_get_val(b, MAPPINGNODE_KEY);
+
+ if (!View_Type || !Dev_Path || !Mapping_Node) {
+ _E("Failed to get data for ode");
+ return -ENOENT;
+ }
+
+ launch_app(EXT_ODE);
+ return 0;
+}
+
+static int sdcard_setup_get_content(const struct popup_ops *ops, char *content, unsigned int len)
+{
+ int ret;
+ char *text;
+ struct object_ops *obj;
+
+ if (!ops || !content)
+ return -EINVAL;
+
+ ret = get_object_by_ops(ops, &obj);
+ if (ret < 0) {
+ _E("Failed to get object (%d)", ret);
+ return -ENOENT;
+ }
+
+ Sdcard_ID = (char *)bundle_get_val(obj->b, SDCARD_KEY);
+ if (!Sdcard_ID) {
+ _E("Failed to get SDCARD ID");
+ return -ENOENT;
+ }
+
+ text = _("IDS_ST_BODY_THERE_IS_ALREADY_DATA_FROM_ANOTHER_PHONE_STORED_ON_THIS_SD_CARD_TO_USE_THIS_SD_CARD_ON_THIS_PHONE_TAP_SET_UP_TO_FORMAT_MSG");
+ snprintf(content, len, "%s", text);
+
+ return 0;
+}
+
static const struct popup_ops mount_error_ops = {
.name = "mounterr",//"mmc_mount_error",
+ .pattern = FEEDBACK_PATTERN_LOWBATT,
.show = load_simple_popup,
- .content = "IDS_DN_POP_FAILED_TO_MOUNT_SD_CARD_REINSERT_OR_FORMAT_SD_CARD",
+ .title = "IDS_IDLE_HEADER_COULDNT_MOUNT_SD_CARD_ABB",
+ .content = "IDS_IDLE_POP_REMOVE_AND_REINSERT_YOUR_SD_CARD_OR_FORMAT_IT_THEN_TRY_AGAIN",
.left_text = "IDS_COM_SK_OK",
.skip = skip_mount_error_popup,
.pre = launch_mmc_popup,
};
+static const struct popup_ops unmount_error_ops = {
+ .name = "unmounterr",//"mmc_unmount_error",
+ .pattern = FEEDBACK_PATTERN_LOWBATT,
+ .show = load_simple_popup,
+ .title = "IDS_IDLE_HEADER_COULDNT_UNMOUNT_SD_CARD_ABB",
+ .content = "IDS_IDLE_POP_THE_SD_CARD_MAY_BE_IN_USE_TRY_AGAIN_LATER",
+ .left_text = "IDS_COM_SK_OK",
+ .skip = skip_unmount_error_popup,
+ .pre = launch_mmc_popup,
+};
+
static const struct popup_ops mount_read_only_ops = {
.name = "mountrdonly",//"mmc_mount_read_only",
+ .pattern = FEEDBACK_PATTERN_LOWBATT,
.show = load_simple_popup,
.content = "IDS_ST_BODY_SD_CARD_MOUNTED_READ_ONLY",
.left_text = "IDS_COM_SK_OK",
static const struct popup_ops check_smack_ops = {
.name = "checksmack",//"mmc_check_smack",
+ .pattern = FEEDBACK_PATTERN_LOWBATT,
.show = load_simple_popup,
.content = "IDS_MF_BODY_MMC_DATA_IS_INITIALIZING_ING",
.left_text = "IDS_COM_SK_OK",
static const struct popup_ops ode_encrypt_ops = {
.name = "odeencrypt",//"mmc_ode_encrypt",
+ .pattern = FEEDBACK_PATTERN_LOWBATT,
.show = load_simple_popup,
.title = "IDS_DN_BODY_ENCRYPT_SD_CARD",
.content = "IDS_ST_POP_TO_USE_YOUR_SD_CARD_IT_MUST_BE_ENCRYPTED_ENCRYPT_SD_CARD_OR_DISABLE_DEVICE_ENCRYPTION_Q",
static const struct popup_ops ode_decrypt_ops = {
.name = "odedecrypt",//"mmc_ode_decrypt",
+ .pattern = FEEDBACK_PATTERN_LOWBATT,
.show = load_simple_popup,
.title = "IDS_DN_BODY_DECRYPT_SD_CARD",
.content = "IDS_ST_POP_TO_USE_YOUR_SD_CARD_IT_MUST_BE_DECRYPTED_DECRYPT_SD_CARD_OR_ENABLE_DEVICE_ENCRYPTION_Q",
.terminate = terminate_mmc_popup,
};
+static const struct popup_ops sdcard_setup_ops = {
+ .name = "sdcardsetup",
+ .pattern = FEEDBACK_PATTERN_LOWBATT,
+ .show = load_simple_popup,
+ .title = "IDS_ST_HEADER_COULDNT_USE_SD_CARD",
+ .get_content = sdcard_setup_get_content,
+ .left_text = "IDS_COM_SK_CANCEL",
+ .right_text = "IDS_TPLATFORM_BUTTON_SET_UP_ABB",
+ .right = launch_sdcard_setup,
+ .pre = launch_mmc_popup,
+};
+
+static const struct popup_ops unlock_extendedsd_ops = {
+ .name = "unlockextendedsd",
+ .show = launch_ode,
+};
+
/* Constructor to register mmc popup */
static __attribute__ ((constructor)) void register_mmc_popup(void)
{
register_popup(&mount_error_ops);
+ register_popup(&unmount_error_ops);
register_popup(&mount_read_only_ops);
register_popup(&check_smack_ops);
register_popup(&ode_encrypt_ops);
register_popup(&ode_decrypt_ops);
+ register_popup(&sdcard_setup_ops);
+ register_popup(&unlock_extendedsd_ops);
}