This commit does not perform actual device encryption.
Product should provide encryption backend to complete the operation
Change-Id: I2dcbab861dba817960013dcef26c413ca5de40f2
Signed-off-by: yeji01kim <yeji01.kim@samsung.com>
}
}
-int SecurityPolicy::setInternalStorageEncryption(const bool encrypt)
+int SecurityPolicy::setInternalStorageEncryption(bool encrypt)
{
try {
return context->methodCall<int>("SecurityPolicy::setInternalStorageEncryption", encrypt);
}
}
-bool SecurityPolicy::isInternalStorageEncrypted()
+int SecurityPolicy::isInternalStorageEncrypted()
{
try {
- return context->methodCall<bool>("SecurityPolicy::isInternalStorageEncrypted");
+ return context->methodCall<int>("SecurityPolicy::isInternalStorageEncrypted");
} catch (runtime::Exception& e) {
- return false;
+ return -1;
}
}
-int SecurityPolicy::setExternalStorageEncryption(const bool encrypt)
+int SecurityPolicy::setExternalStorageEncryption(bool encrypt)
{
try {
return context->methodCall<int>("SecurityPolicy::setExternalStorageEncryption", encrypt);
}
}
-bool SecurityPolicy::isExternalStorageEncrypted()
+int SecurityPolicy::isExternalStorageEncrypted()
{
try {
- return context->methodCall<bool>("SecurityPolicy::isExternalStorageEncrypted");
+ return context->methodCall<int>("SecurityPolicy::isExternalStorageEncrypted");
} catch (runtime::Exception& e) {
- return false;
+ return -1;
}
}
int wipeData(const int id);
int reboot();
int powerOffDevice();
- int setInternalStorageEncryption(const bool encrypt);
- bool isInternalStorageEncrypted();
- int setExternalStorageEncryption(const bool encrypt);
- bool isExternalStorageEncrypted();
+ int setInternalStorageEncryption(bool encrypt);
+ int isInternalStorageEncrypted();
+ int setExternalStorageEncryption(bool encrypt);
+ int isExternalStorageEncrypted();
std::vector<std::string> getFileNamesOnDevice(const std::string& path);
std::vector<std::string> getFileNamesWithAttributes(const std::string& path);
<policy name="password-forbidden-strings">\n</policy>
</policy-group>
<policy-group name="security">
- <policy name="internal-storage-encryption">allowed</policy>
- <policy name="external-storage-encryption">allowed</policy>
+ <policy name="internal-storage-encryption"></policy>
+ <policy name="external-storage-encryption"></policy>
<policy name="internet-sharing">allowed</policy>
- <policy name="require-device-encryption">allowed</policy>
- <policy name="require-sdcard-encryption">allowed</policy>
</policy-group>
<policy-group name="wifi">
<policy name="wifi-profile-change">allowed</policy>
ctxt.registerNonparametricMethod(this, (int)(SecurityPolicy::lockoutScreen));
ctxt.registerNonparametricMethod(this, (int)(SecurityPolicy::reboot));
ctxt.registerNonparametricMethod(this, (int)(SecurityPolicy::powerOffDevice));
- ctxt.registerNonparametricMethod(this, (bool)(SecurityPolicy::isInternalStorageEncrypted));
- ctxt.registerNonparametricMethod(this, (bool)(SecurityPolicy::isExternalStorageEncrypted));
+ ctxt.registerNonparametricMethod(this, (int)(SecurityPolicy::isInternalStorageEncrypted));
+ ctxt.registerNonparametricMethod(this, (int)(SecurityPolicy::isExternalStorageEncrypted));
ctxt.registerParametricMethod(this, (int)(SecurityPolicy::setInternalStorageEncryption)(bool));
ctxt.registerParametricMethod(this, (int)(SecurityPolicy::setExternalStorageEncryption)(bool));
ctxt.registerParametricMethod(this, (std::vector<std::string>)(SecurityPolicy::getFileNamesOnDevice)(std::string));
return ret;
}
-int SecurityPolicy::setInternalStorageEncryption(const bool encrypt)
+int SecurityPolicy::setInternalStorageEncryption(bool encrypt)
{
+ std::string policy = context.getPolicy("internal-storage-encryption");
+ if ((encrypt == true) && (policy == "encrypted")) {
+ return 0;
+ } else if ((encrypt == false) && (policy == "decrypted")) {
+ return 0;
+ }
+
try {
Bundle bundle;
- bundle.add("viewtype", encrypt ? "encryption" : "decryption");
+ bundle.add("viewtype", encrypt ? "ENCRYPT_DEVICE" : "DECRYPT_DEVICE");
Launchpad launchpad(context.getPeerUid());
launchpad.launch(APPID_DEVICE_ENCRYPTION, bundle);
return 0;
}
-bool SecurityPolicy::isInternalStorageEncrypted()
+int SecurityPolicy::isInternalStorageEncrypted()
{
- INFO("Not implemented yet");
+ std::string policy = context.getPolicy("internal-storage-encryption");
+ if (policy == "encrypted") {
+ return true;
+ }
+
return false;
}
-int SecurityPolicy::setExternalStorageEncryption(const bool encrypt)
+int SecurityPolicy::setExternalStorageEncryption(bool encrypt)
{
- int status;
-
- if (::vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &status) != 0) {
- ERROR("Failed to read VCONFKEY_SYSMAN_MMC_STATUS");
- return -1;
- }
-
- if (status != VCONFKEY_SYSMAN_MMC_MOUNTED) {
- WARN("MMC was not mounted");
- return -1;
- }
-
- int wasEncrypted;
- if (::vconf_get_bool(VCONFKEY_SETAPPL_MMC_ENCRYPTION_STATUS_BOOL, &wasEncrypted) != 0) {
- ERROR("Failed to read VCONFKEY_SETAPPL_MMC_ENCRYPTION_STATUS_BOOL");
- return -1;
+ std::string policy = context.getPolicy("external-storage-encryption");
+ if ((encrypt == true) && (policy == "encrypted")) {
+ return 0;
+ } else if ((encrypt == false) && (policy == "decrypted")) {
+ return 0;
}
try {
Bundle bundle;
- bundle.add("_SYSPOPUP_CONTENT_", encrypt ? "odeencrypt" : "odedecrypt");
+ bundle.add("viewtype", encrypt ? "ENCRYPT_SD_CARD" : "DECRYPT_SD_CARD");
- Syspopup syspopup("mmc-syspopup");
- if (syspopup.launch(bundle) < 0) {
- ERROR("Failed to launch mmc-syspopup");
- return -1;
- }
+ Launchpad launchpad(context.getPeerUid());
+ launchpad.launch(APPID_DEVICE_ENCRYPTION, bundle);
} catch (runtime::Exception& e) {
+ ERROR("Failed to start sd card encryption");
return -1;
}
return 0;
}
-bool SecurityPolicy::isExternalStorageEncrypted()
+int SecurityPolicy::isExternalStorageEncrypted()
{
+ std::string policy = context.getPolicy("external-storage-encryption");
+ if (policy == "encrypted") {
+ return true;
+ }
+
return false;
}
std::string old = policy.getContent();
policy.setContent(value);
if (old != value) {
- service->notify(event, info);
+ if (event != "") {
+ service->notify(event, info);
+ }
+
policyStorage->flush();
}
} catch (runtime::Exception& e) {
DECRYPT_SD_CARD,
} dpm_encryption_viewtype;
-typedef struct odedata {
+typedef struct appdata {
Evas_Object *win;
Evas_Object *conform;
Evas_Object *nf;
int view_type;
} appdata_s;
-appdata_s global_ad;
-
#define MSG_TEXT_STYLE "DEFAULT='font=Tizen:style=Regular font_size=30 color=#000000 wrap=mixed align=left'"
#define NEEDED_BATTERY_PERCENT 80
group { name: "Encrypt_device_layout";
images {
- image: "../images/icon.png" COMP;
- image: "../images/warning.png" COMP;
+ image: "../images/icon_encrypt_check.png" COMP;
+ image: "../images/icon_encrypt_bar.png" COMP;
}
parts {
part { name: "base";
scale: 1;
description { state: "default" 0.0;
rel1 { relative: 0.0 1.0; to: "top_padding"; }
- rel2 { relative: 0.0 1.0; to: "top_padding"; offset: 100 100;}
+ rel2 { relative: 0.0 1.0; to: "top_padding"; offset: 100 100; }
}
}
part { name: "battery_icon";
rel2 { relative: 1.0 1.0; to: "battery_icon_base"; }
align: 0.5 0.5;
max: 95 95;
- image.normal: "../images/icon.png";
+ image.normal: "../images/icon_encrypt_check.png";
+ color: 153 153 153 255;
}
description { state: "default_warning" 0.0;
inherit: "default" 0.0;
- image.normal: "../images/warning.png";
+ image.normal: "../images/icon_encrypt_bar.png";
+ color: 0 0 0 255;
}
description { state: "default_hidden" 0.0;
inherit: "default" 0.0;
type: SWALLOW;
scale: 1;
description { state: "default" 0.0;
- rel1 { relative: 1.0 0.3; to: "battery_icon_base"; offset: 15 0;}
+ rel1 { relative: 1.0 0.3; to: "battery_icon_base"; }
rel2 { relative: 1.0 1.0; to_x: "top_padding"; to_y: "battery_icon_base";}
align: 0.0 0.5;
}
type: SPACER;
scale: 1;
description { state: "default" 0.0;
- rel1 { relative: 0.0 1.0; to: "battery_icon_base"; offset: 0 15; }
- rel2 { relative: 1.0 1.0; to: "battery_icon_base"; offset: 0 115; }
+ rel1 { relative: 0.0 1.0; to: "battery_icon_base"; }
+ rel2 { relative: 1.0 1.0; to: "battery_icon_base"; offset: 0 100; }
}
}
part { name: "charge_icon";
rel2 { relative: 1.0 1.0; to: "charge_icon_base"; }
align: 0.5 0.5;
max: 95 95;
- image.normal: "../images/icon.png";
+ image.normal: "../images/icon_encrypt_check.png";
+ color: 153 153 153 255;
}
description { state: "default_warning" 0.0;
inherit: "default" 0.0;
- image.normal: "../images/warning.png";
+ image.normal: "../images/icon_encrypt_bar.png";
+ color: 0 0 0 255;
}
description { state: "default_hidden" 0.0;
inherit: "default" 0.0;
type: SWALLOW;
scale: 1;
description { state: "default" 0.0;
- rel1 { relative: 1.0 0.3; to: "charge_icon_base"; offset: 15 0;}
+ rel1 { relative: 1.0 0.3; to: "charge_icon_base"; }
rel2 { relative: 1.0 1.0; to_x: "top_padding"; to_y: "charge_icon_base";}
}
}
type: SPACER;
scale: 1;
description { state: "default" 0.0;
- rel1 { relative: 0.0 1.0; to: "charge_icon_base"; offset: 0 15; }
- rel2 { relative: 1.0 1.0; to: "charge_icon_base"; offset: 0 115; }
+ rel1 { relative: 0.0 1.0; to: "charge_icon_base"; }
+ rel2 { relative: 1.0 1.0; to: "charge_icon_base"; offset: 0 100; }
}
}
part { name: "locktype_icon";
rel2 { relative: 1.0 1.0; to: "locktype_icon_base"; }
align: 0.5 0.5;
max: 95 95;
- image.normal: "../images/icon.png";
+ image.normal: "../images/icon_encrypt_check.png";
+ color: 153 153 153 255;
}
description { state: "default_warning" 0.0;
inherit: "default" 0.0;
- image.normal: "../images/warning.png";
+ image.normal: "../images/icon_encrypt_bar.png";
+ color: 0 0 0 255;
}
description { state: "default_hidden" 0.0;
inherit: "default" 0.0;
type: SWALLOW;
scale: 1;
description { state: "default" 0.0;
- rel1 { relative: 1.0 0.0; to: "locktype_icon_base"; offset: 15 0;}
+ rel1 { relative: 1.0 0.2; to: "locktype_icon_base"; }
rel2 { relative: 1.0 1.0; to_x: "top_padding"; to_y: "locktype_icon_base";}
align: 0.0 0.5;
}
group { name: "Decrypt_device_layout";
images {
- image: "../images/icon.png" COMP;
- image: "../images/warning.png" COMP;
+ image: "../images/icon_encrypt_check.png" COMP;
+ image: "../images/icon_encrypt_bar.png" COMP;
}
parts {
part { name: "base";
rel2 { relative: 1.0 1.0; to: "battery_icon_base"; }
align: 0.5 0.5;
max: 95 95;
- image.normal: "../images/icon.png";
+ image.normal: "../images/icon_encrypt_check.png";
+ color: 153 153 153 255;
}
description { state: "default_warning" 0.0;
inherit: "default" 0.0;
- image.normal: "../images/warning.png";
+ image.normal: "../images/icon_encrypt_bar.png";
+ color: 0 0 0 255;
}
description { state: "default_hidden" 0.0;
inherit: "default" 0.0;
type: SWALLOW;
scale: 1;
description { state: "default" 0.0;
- rel1 { relative: 1.0 0.3; to: "battery_icon_base"; offset: 15 0;}
+ rel1 { relative: 1.0 0.3; to: "battery_icon_base"; }
rel2 { relative: 1.0 1.0; to_x: "top_padding"; to_y: "battery_icon_base";}
align: 0.0 1.0;
}
type: SPACER;
scale: 1;
description { state: "default" 0.0;
- rel1 { relative: 0.0 1.0; to: "battery_icon_base"; offset: 0 15; }
- rel2 { relative: 1.0 1.0; to: "battery_icon_base"; offset: 0 115; }
+ rel1 { relative: 0.0 1.0; to: "battery_icon_base"; }
+ rel2 { relative: 1.0 1.0; to: "battery_icon_base"; offset: 0 100; }
}
}
part { name: "charge_icon";
rel2 { relative: 1.0 1.0; to: "charge_icon_base"; }
align: 0.5 0.5;
max: 95 95;
- image.normal: "../images/icon.png";
+ image.normal: "../images/icon_encrypt_check.png";
+ color: 153 153 153 255;
}
description { state: "default_warning" 0.0;
inherit: "default" 0.0;
- image.normal: "../images/warning.png";
+ image.normal: "../images/icon_encrypt_bar.png";
+ color: 0 0 0 255;
}
description { state: "default_hidden" 0.0;
inherit: "default" 0.0;
type: SWALLOW;
scale: 1;
description { state: "default" 0.0;
- rel1 { relative: 1.0 0.3; to: "charge_icon_base"; offset: 15 0;}
+ rel1 { relative: 1.0 0.3; to: "charge_icon_base"; }
rel2 { relative: 1.0 1.0; to_x: "top_padding"; to_y: "charge_icon_base"; }
align: 0.0 1.0;
}
group { name: "Encrypt_sd_card_layout";
images {
- image: "../images/icon.png" COMP;
- image: "../images/warning.png" COMP;
+ image: "../images/icon_encrypt_check.png" COMP;
+ image: "../images/icon_encrypt_bar.png" COMP;
}
parts {
part { name: "base";
rel2 { relative: 1.0 1.0; to: "sd_card_icon_base"; }
align: 0.5 0.5;
max: 95 95;
- image.normal: "../images/icon.png";
+ image.normal: "../images/icon_encrypt_check.png";
+ color: 153 153 153 255;
}
description { state: "default_warning" 0.0;
inherit: "default" 0.0;
- image.normal: "../images/warning.png";
+ image.normal: "../images/icon_encrypt_bar.png";
+ color: 0 0 0 255;
}
description { state: "default_hidden" 0.0;
inherit: "default" 0.0;
type: SWALLOW;
scale: 1;
description { state: "default" 0.0;
- rel1 { relative: 1.0 0.3; to: "sd_card_icon_base"; offset: 15 0; }
+ rel1 { relative: 1.0 0.3; to: "sd_card_icon_base"; }
rel2 { relative: 1.0 1.0; to_x: "top_padding"; to_y: "sd_card_icon_base"; }
align: 0.0 0.5;
}
type: SPACER;
scale: 1;
description { state: "default" 0.0;
- rel1 { relative: 0.0 1.0; to: "sd_card_icon_base"; offset: 0 15; }
- rel2 { relative: 1.0 1.0; to: "sd_card_icon_base"; offset: 0 115; }
+ rel1 { relative: 0.0 1.0; to: "sd_card_icon_base"; }
+ rel2 { relative: 1.0 1.0; to: "sd_card_icon_base"; offset: 0 100; }
}
}
part { name: "sd_card_pw_icon";
rel2 { relative: 1.0 1.0; to: "sd_card_pw_icon_base"; }
align: 0.5 0.5;
max: 95 95;
- image.normal: "../images/icon.png";
+ image.normal: "../images/icon_encrypt_check.png";
+ color: 153 153 153 255;
visible: 0;
}
description { state: "default_warning" 0.0;
inherit: "default" 0.0;
- image.normal: "../images/warning.png";
+ image.normal: "../images/icon_encrypt_bar.png";
+ color: 0 0 0 255;
}
description { state: "default_hidden" 0.0;
inherit: "default" 0.0;
type: SWALLOW;
scale: 1;
description { state: "default" 0.0;
- rel1 { relative: 1.0 0.3; to: "sd_card_pw_icon_base"; offset: 15 0; }
+ rel1 { relative: 1.0 0.3; to: "sd_card_pw_icon_base"; }
rel2 { relative: 1.0 1.0; to_x: "top_padding"; to_y: "sd_card_pw_icon_base"; }
align: 0.0 0.5;
}
group { name: "Decrypt_sd_card_layout";
images {
- image: "../images/icon.png" COMP;
- image: "../images/warning.png" COMP;
+ image: "../images/icon_encrypt_check.png" COMP;
+ image: "../images/icon_encrypt_bar.png" COMP;
}
parts {
part { name: "base";
dlog_print(DLOG_DEBUG, LOG_TAG, "decrypt sd card confrim");
break;
}
+
+ ui_app_exit();
}
static void set_confirm_next_btn_layout(Evas_Object* layout, appdata_s* ad, const char* btn_text)
if (ad->view_type == ENCRYPT_DEVICE) {
if (ad->device_info.battery_status && ad->device_info.charger_status && ad->device_info.locktype_status) {
- /* available next button */
elm_object_disabled_set(ad->device_info.next_button, EINA_FALSE);
} else {
- /* disabled next button */
elm_object_disabled_set(ad->device_info.next_button, EINA_TRUE);
}
} else if (ad->view_type == DECRYPT_DEVICE) {
if (ad->device_info.battery_status && ad->device_info.charger_status) {
- /* available next button */
elm_object_disabled_set(ad->device_info.next_button, EINA_FALSE);
} else {
- /* disabled next button */
elm_object_disabled_set(ad->device_info.next_button, EINA_TRUE);
}
} else if (ad->view_type == ENCRYPT_SD_CARD) {
if (ad->device_info.sdcard_status) {
- /* available next button */
elm_object_disabled_set(ad->device_info.next_button, EINA_FALSE);
} else {
- /* disabled next button */
elm_object_disabled_set(ad->device_info.next_button, EINA_TRUE);
}
}
ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
elm_win_conformant_set(ad->win, EINA_TRUE);
elm_win_autodel_set(ad->win, EINA_TRUE);
-
- if (elm_win_wm_rotation_supported_get(ad->win)) {
- int rots[4] = { 0, 90, 180, 270 };
- elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
- }
-
evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
/* Conformant */
static void app_control(app_control_h app_control, void* data)
{
/* Handle the launch request. */
- appdata_s* ad = &global_ad;
+ appdata_s* ad = (appdata_s*)data;
int ret;
char *viewtype = NULL;
int main(int argc, char* argv[])
{
+ appdata_s ad = {0, };
int ret = 0;
ui_app_lifecycle_callback_s event_callback = { 0, };
event_callback.resume = app_resume;
event_callback.app_control = app_control;
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &global_ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &global_ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &global_ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &global_ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &global_ad);
+ ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad);
+ ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad);
+ ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad);
+ ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad);
+ ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad);
ui_app_remove_event_handler(handlers[APP_EVENT_LOW_MEMORY]);
- ret = ui_app_main(argc, argv, &event_callback, &global_ad);
+ ret = ui_app_main(argc, argv, &event_callback, &ad);
if (ret != APP_ERROR_NONE)
dlog_print(DLOG_ERROR, LOG_TAG, "ui_app_main is failed. err = %d", ret);
return ret;