[ITC/UTC][accounts-svc][Non-ACR][Change rpm installation path] 05/225505/4
authorAbhishek Vijay <abhishek.v@samsung.com>
Thu, 20 Feb 2020 09:37:08 +0000 (15:07 +0530)
committershobhit verma <shobhit.v@samsung.com>
Mon, 24 Feb 2020 05:49:22 +0000 (05:49 +0000)
Change-Id: Ide2162b37287b34e6e55790d39c6366424568066
Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
src/itc/accounts-svc/ITs-accounts-svc-common.h
src/itc/accounts-svc/ITs-accounts-svc.c
src/utc/accounts-svc/utc-accounts-svc.c

index 26cf3f79b9cd333569936ebe41449bd5f2aea712..63c706c4ff761e572e3b2ff7ac87dd196b6e42f0 100755 (executable)
 #include <account.h>
 #include <glib.h>
 #include <app.h>
+#include <system_info.h>
 
 /************************************************************************/
 /** @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;
index e68a151fb68ee9aec0f7775808b20af9be7adaaa..e7e1dc8dc4659e3cf69183635cb26ca76d1adece 100755 (executable)
@@ -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)
index 01794d8134771d752da4d86d189bf3da2b2a379f..571bfde93f186728e8157b5aefe1a7f6efe2ae76 100755 (executable)
@@ -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)
                        {