From b94610b00ff7573e1f16c8f08cc92d11d88d080a Mon Sep 17 00:00:00 2001 From: Sangjin Kim Date: Wed, 9 Nov 2016 04:04:07 -0800 Subject: [PATCH] Revert "modify default plugin's behavior by emulator" This reverts commit a430ea553950d5a9910cc051c3171da852607c03. Change-Id: I23c07c65ac71009a9e48a60b3e6e9f1f4586fe96 --- src/default_plugin_basic.c | 8 +++++-- src/default_plugin_event.c | 53 ++++++++++++++++++++++++---------------------- src/plugin.c | 16 +------------- 3 files changed, 35 insertions(+), 42 deletions(-) diff --git a/src/default_plugin_basic.c b/src/default_plugin_basic.c index 2072824..f8ceba0 100644 --- a/src/default_plugin_basic.c +++ b/src/default_plugin_basic.c @@ -57,7 +57,11 @@ int get_plugin_capability ( parameters* in, parameters* out ) } else if ( capability == CAPABILITY_FILESYNC ) { make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_PUSHPULL ); } else if ( capability == CAPABILITY_USB_PROTOCOL ) { - make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED ); + if ( is_emulator() ) { + make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_DISABLED ); + } else { + make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED ); + } } else if ( capability == CAPABILITY_SOCK_PROTOCOL ) { make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED ); } else if ( capability == CAPABILITY_ROOT_ONOFF ) { @@ -73,7 +77,7 @@ int get_plugin_capability ( parameters* in, parameters* out ) } else if ( capability == CAPABILITY_PRODUCT_VER ) { make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_UNKNOWN ); } else if ( capability == CAPABILITY_LOG_ENABLE ) { - make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED ); + make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_DISABLED ); } else if ( capability == CAPABILITY_LOG_PATH ) { make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", LOG_DIRECTORY ); } else if ( capability == CAPABILITY_APPCMD ) { diff --git a/src/default_plugin_event.c b/src/default_plugin_event.c index 6731746..2f7d745 100644 --- a/src/default_plugin_event.c +++ b/src/default_plugin_event.c @@ -17,10 +17,36 @@ #include #include +#define TRACE_TAG TRACE_SDB +#include "log.h" + #include "sysdeps.h" #include "sdbd_plugin.h" #include "default_plugin.h" +int get_lock_state ( parameters* in, parameters* out ) +{ + if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL + || in->array_of_parameter[0].type != type_int32 ) { + D ( "Invalid argument\n" ); + return PLUGIN_CMD_FAIL; + } + + if ( out == NULL ) { + D ( "Invalid argument\n" ); + return PLUGIN_CMD_FAIL; + } + + D ( "lock type: %d\n", in->array_of_parameter[0].v_int32); + + out->number_of_parameter = 1; + out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) ); + out->array_of_parameter[0].type = type_int32; + out->array_of_parameter[0].v_int32 = ( plugin_pwlocked() == 1 ) ? PLUGIN_RET_ON : PLUGIN_RET_OFF; + + return PLUGIN_CMD_SUCCESS; +} + int plugin_pwlocked ( void ) { int pwlock_status = 0; @@ -56,29 +82,6 @@ int plugin_pwlocked ( void ) return 0; // unlocked! } -int get_lock_state ( parameters* in, parameters* out ) -{ - if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL - || in->array_of_parameter[0].type != type_int32 ) { - PLUGIN_LOG ( "Invalid argument\n" ); - return PLUGIN_CMD_FAIL; - } - - if ( out == NULL ) { - PLUGIN_LOG ( "Invalid argument\n" ); - return PLUGIN_CMD_FAIL; - } - - PLUGIN_LOG ( "lock type: %d\n", in->array_of_parameter[0].v_int32); - - out->number_of_parameter = 1; - out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) ); - out->array_of_parameter[0].type = type_int32; - out->array_of_parameter[0].v_int32 = ( plugin_pwlocked() == 1 ) ? PLUGIN_RET_ON : PLUGIN_RET_OFF; - - return PLUGIN_CMD_SUCCESS; -} - static void pwlock_cb ( keynode_t *key, void* data ) { PLUGIN_LOG ( "pwlock callback is issued\n" ); @@ -128,8 +131,8 @@ void create_pwlock_thread() { sdb_thread_t t; if ( sdb_thread_create ( &t, pwlock_thread, NULL ) ) { - PLUGIN_LOG ( "default plugin : cannot create_pwlock_thread.\n" ); + PLUGIN_LOG ( "cannot create_pwlock_thread.\n" ); return; } - PLUGIN_LOG ( "default plugin : created pwlock_thread\n" ); + PLUGIN_LOG ( "created pwlock_thread\n" ); } diff --git a/src/plugin.c b/src/plugin.c index ff9f19c..1cf11f7 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -73,10 +73,7 @@ int plugin_event_handler ( int event_type, parameters* data ) static int plugin_register_command ( int command, priority cmd_priority ) { if ( plugin_cmd_hashtable ) { - int ret = hashtable_put ( plugin_cmd_hashtable, command, cmd_priority ); - D ("register plugin command : cmd(%d), result(%d)\n", command, ret); - } else { - D ("hashtable is not created\n"); + hashtable_put ( plugin_cmd_hashtable, command, cmd_priority ); } return 0; } @@ -164,9 +161,6 @@ int is_supported_by_plugin ( int cmd ) if ( plugin_cmd_hashtable ) { int value; ret = hashtable_get ( plugin_cmd_hashtable, cmd, &value ); - D ("get from hashtable : cmd(%d), result(%d)\n", cmd, ret); - } else { - D ("hashtable is not created\n"); } return ret; @@ -269,16 +263,12 @@ int request_capability_to_plugin ( int cap, char* out_buf, unsigned int out_len in.array_of_parameter[0].type = type_int32; in.array_of_parameter[0].v_int32 = cap; - D ("requested capability : %d\n", cap); - ret = request_sync_cmd ( PLUGIN_SYNC_CMD_CAPABILITY, &in, &out ); if ( ret == PLUGIN_CMD_SUCCESS ) { strncpy ( out_buf, out.array_of_parameter[0].v_string.data, out_len - 1 ); out_buf[out_len - 1] = '\0'; success = 1; release_parameters ( &out ); - - D ("request capability success : %s\n", out_buf); } release_parameters ( &in ); @@ -304,14 +294,10 @@ int request_validity_to_plugin ( int cmd, const char* in_buf ) in.array_of_parameter = NULL; } - D ("requested validity : %d, %s\n", cmd, in_buf); - ret = request_sync_cmd ( cmd, &in, &out ); if ( ret == PLUGIN_CMD_SUCCESS ) { success = ( out.array_of_parameter[0].v_int32 == PLUGIN_RET_VALID ) ? 1 : 0; release_parameters ( &out ); - - D ("request validity success : %d\n", out.array_of_parameter[0].v_int32); } release_parameters ( &in ); -- 2.7.4