From 4d2c3a80a66c822c1c13fecd4f369bc21e33e644 Mon Sep 17 00:00:00 2001 From: Abhishek Vijay Date: Thu, 20 Feb 2020 15:07:08 +0530 Subject: [PATCH] [ITC/UTC][accounts-svc][Non-ACR][Change rpm installation path] Change-Id: Ide2162b37287b34e6e55790d39c6366424568066 Signed-off-by: Abhishek Vijay --- .../accounts-svc/ITs-accounts-svc-common.h | 36 +++++++---- src/itc/accounts-svc/ITs-accounts-svc.c | 61 ++++++++++++++++++ src/utc/accounts-svc/utc-accounts-svc.c | 62 +++++++++++++++++++ 3 files changed, 147 insertions(+), 12 deletions(-) diff --git a/src/itc/accounts-svc/ITs-accounts-svc-common.h b/src/itc/accounts-svc/ITs-accounts-svc-common.h index 26cf3f79b..63c706c4f 100755 --- a/src/itc/accounts-svc/ITs-accounts-svc-common.h +++ b/src/itc/accounts-svc/ITs-accounts-svc-common.h @@ -22,30 +22,39 @@ #include #include #include +#include /************************************************************************/ /** @addtogroup itc-accounts-svc * @ingroup itc * @{ */ +typedef enum { + _PROFILE_UNKNOWN = 0, + _PROFILE_MOBILE = 0x1, + _PROFILE_WEARABLE = 0x2, + _PROFILE_TV = 0x4, + _PROFILE_IVI = 0x8, + _PROFILE_COMMON = 0x10, +} tizen_profile_t; #define API_NAMESPACE "ACCOUNTS_SVC_ITC" -#define ICONPATH "icontexto_256.png" -#define SERVICEPROID "http://tizen.org/account/capability/contact" -#define TIMEOUT_CB 10000 -#define ACCESSTOKEN "access-token" -#define APPID "native.accounts-svc-itc" -#define EMAILID "TCTSampleAccount@tizen.org" -#define USERNAME "TizenLite Test" -#define PATH_LEN 1024 -#define BUFFERSIZE 256 -#define BUFFER 20 +#define ICONPATH "icontexto_256.png" +#define SERVICEPROID "http://tizen.org/account/capability/contact" +#define TIMEOUT_CB 10000 +#define ACCESSTOKEN "access-token" +#define APPID "native.accounts-svc-itc" +#define EMAILID "TCTSampleAccount@tizen.org" +#define USERNAME "TizenLite Test" +#define PATH_LEN 1024 +#define BUFFERSIZE 256 +#define BUFFER 20 #define CALENDAR_CAPABILITY "http://tizen.org/account/capability/calendar" #define CONTACT_CAPABILITY "http://tizen.org/account/capability/contact" -#define ACCOUNT_ICON_PATH "/shared/res/account.png" +#define ACCOUNT_ICON_PATH "/shared/res/account.png" #define ACCOUNT_SMALL_ICON_PATH "/shared/res/account_small.png" #define SERVICE_PROVIDER_ID "http://www.tizen.org/" -#define MULTIPLE_ACCOUNT_SUPPORT 1 +#define MULTIPLE_ACCOUNT_SUPPORT 1 #define RPM_INSTALL_LOCATION "/usr/apps/native-accounts-svc-itc" #define TPK_APP_PREFIX "org.tizen." #define ACCOUNT_FEATURE "http://tizen.org/feature/account" @@ -85,6 +94,9 @@ }\ } +/* Accessing system info */ +int system_info_get_platform_string(const char *key, char **value); + /*********************** Global Variables *******************************/ bool g_bAccountLabelCB; diff --git a/src/itc/accounts-svc/ITs-accounts-svc.c b/src/itc/accounts-svc/ITs-accounts-svc.c index e68a151fb..e7e1dc8dc 100755 --- a/src/itc/accounts-svc/ITs-accounts-svc.c +++ b/src/itc/accounts-svc/ITs-accounts-svc.c @@ -43,6 +43,47 @@ static int g_nProviderCount = 0; static GMainLoop *mainloop; char g_eProviderFeature[10][BUFFERSIZE] = {CALENDAR_CAPABILITY, CONTACT_CAPABILITY}; +tizen_profile_t profile; + +static inline tizen_profile_t get_tizen_profile() +{ + char *profileName = NULL; + + if (__builtin_expect(profile != _PROFILE_UNKNOWN, 1)) + return profile; + + system_info_get_platform_string("http://tizen.org/feature/profile", &profileName); + + /* To pass the checking of g_ir */ + if (!profileName) + return _PROFILE_UNKNOWN; + + switch (*profileName) { + case 'm': + case 'M': + profile = _PROFILE_MOBILE; + break; + case 'w': + case 'W': + profile = _PROFILE_WEARABLE; + break; + case 't': + case 'T': + profile = _PROFILE_TV; + break; + case 'i': + case 'I': + profile = _PROFILE_IVI; + break; + default: // common or unknown ==> ALL ARE COMMON. + profile = _PROFILE_COMMON; + } + + free(profileName); + return profile; +} + + /** * @function ITs_accounts_svc_startup * @description Called before each test. creates a account handle @@ -1804,7 +1845,17 @@ int ITc_account_type_get_icon_path_p(void) return 1; } } + + /*if profile is TV then change the icon path*/ + if (get_tizen_profile() == _PROFILE_TV) { + int str_len = strlen("/opt/usr/apps"); + memset(pszValue, 0, PATH_LEN); + strncpy(pszValue, "/opt/usr/apps", str_len); + pszValue[str_len+1] = '\0'; + } + FPRINTF("[Line : %d][%s] Values Received = %s\\n", __LINE__, API_NAMESPACE, pszValue); + int path_size = strlen(pszValue) + strlen(psz_pkg_id) + strlen(ACCOUNT_ICON_PATH) + 2; pszACTUAL_FILE_PATH = (char*)calloc(path_size, sizeof(char)); if (pszACTUAL_FILE_PATH == NULL) @@ -1981,7 +2032,17 @@ int ITc_account_type_get_small_icon_path_p(void) return 1; } } + + /*if profile is TV then change the icon path*/ + if (get_tizen_profile() == _PROFILE_TV) { + int str_len = strlen("/opt/usr/apps"); + memset(pszValue, 0, PATH_LEN); + strncpy(pszValue, "/opt/usr/apps", str_len); + pszValue[str_len+1] = '\0'; + } + FPRINTF("[Line : %d][%s] Values Received = %s\\n", __LINE__, API_NAMESPACE, pszValue); + int path_size = strlen(pszValue) + strlen(psz_pkg_id) + strlen(ACCOUNT_SMALL_ICON_PATH) + 2; pszACTUAL_FILE_PATH = (char*)calloc(path_size, sizeof(char)); if (pszACTUAL_FILE_PATH == NULL) diff --git a/src/utc/accounts-svc/utc-accounts-svc.c b/src/utc/accounts-svc/utc-accounts-svc.c index 01794d813..571bfde93 100755 --- a/src/utc/accounts-svc/utc-accounts-svc.c +++ b/src/utc/accounts-svc/utc-accounts-svc.c @@ -85,6 +85,18 @@ enum ICON_PATH_TYPE { SMALL_ICON }; +typedef enum { + _PROFILE_UNKNOWN = 0, + _PROFILE_MOBILE = 0x1, + _PROFILE_WEARABLE = 0x2, + _PROFILE_TV = 0x4, + _PROFILE_IVI = 0x8, + _PROFILE_COMMON = 0x10, +} tizen_profile_t; + +/* Accessing system info */ +int system_info_get_platform_string(const char *key, char **value); + //& set: AccountsSvc static bool created = false; static account_h account = NULL; @@ -99,6 +111,47 @@ static const char* user_name = USER_NAME; static const account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED; static const int test_multi_account_support = 1; +tizen_profile_t profile; + +static inline tizen_profile_t get_tizen_profile() +{ + char *profileName = NULL; + + if (__builtin_expect(profile != _PROFILE_UNKNOWN, 1)) + return profile; + + system_info_get_platform_string("http://tizen.org/feature/profile", &profileName); + + /* To pass the checking of g_ir */ + if (!profileName) + return _PROFILE_UNKNOWN; + + switch (*profileName) { + case 'm': + case 'M': + profile = _PROFILE_MOBILE; + break; + case 'w': + case 'W': + profile = _PROFILE_WEARABLE; + break; + case 't': + case 'T': + profile = _PROFILE_TV; + break; + case 'i': + case 'I': + profile = _PROFILE_IVI; + break; + default: // common or unknown ==> ALL ARE COMMON. + profile = _PROFILE_COMMON; + } + + free(profileName); + return profile; +} + + static gboolean timeout_cb(gpointer data) { printf("timeout!\n"); _is_fail = true; @@ -205,6 +258,15 @@ char *_account_get_path(int type) return NULL; } } + + /*if profile is TV then change the icon path*/ + if (get_tizen_profile() == _PROFILE_TV) { + int str_len = strlen("/opt/usr/apps"); + memset(pszValue, 0, BUFFERSIZE); + strncpy(pszValue, "/opt/usr/apps", str_len); + pszValue[str_len+1] = '\0'; + } + PRINT_UTC_LOG("[Line : %d][%s] Values Received = %s\\n", __LINE__, API_NAMESPACE, pszValue); if (type == ICON) { -- 2.34.1