#include "FApp_AppImpl.h"
#include "FApp_ServiceAppImpl.h"
#include "FAppPkg_PackageManagerImpl.h"
+#include "FAppPkg_PackageInfoImpl.h"
#include "FApp_AppManagerImpl.h"
#include "FApp_TemplateUtil.h"
#include "FApp_IAppEventListener.h"
const wchar_t USE_UI_VAL_TRUE[] = L"True";
const wchar_t LIFE_DURATION_KEY[] = L"LifeDuration";
const int LIFE_DURATION_MSEC_MAX = 30000;
+const int LIFE_DURATION_MSEC_MAX_PLATFORM = 60000*3;
static const RequestId HANDLER_REQUEST_ALARMID = 2;
SysLog(NID_APP, "Service requested.");
char* pOperation = NULL;
int errVal = service_get_operation(service, &pOperation);
- result r = E_SUCCESS;
if ( (errVal == SERVICE_ERROR_NONE) && (!strcmp(pOperation, "osp.appsvc.operation.ALARM")) )
{
- char* pAlarmId = NULL;
+ OnAlarmOperation(service);
+ }
- errVal = service_get_extra_data(service, SERVICE_DATA_ALARM_ID, &pAlarmId);
- if (errVal == SERVICE_ERROR_NONE)
- {
- int alarmId = atoi(pAlarmId);
+ if (pOperation)
+ {
+ free(pOperation);
+ }
+
+ if( __lifeDuration > 0 && __pauseLifeDurationTimer == false)
+ {
+ SetLifeDurationTimer(__lifeDuration);
+ }
+}
+
+void
+_ServiceAppImpl::OnAlarmOperation(service_s* service)
+{
+ char* pAlarmId = NULL;
- SysLog(NID_SYS, "Start to load external lib");
- Library lib;
- OnAlarmForLaunch pOnAlarmForLaunch = null;
- r = lib.Construct(ALARM_PLUGIN_LIBRARY_PATH);
+ int errVal = service_get_extra_data(service, SERVICE_DATA_ALARM_ID, &pAlarmId);
+ if (errVal == SERVICE_ERROR_NONE)
+ {
+ int alarmId = atoi(pAlarmId);
+
+ SysLog(NID_SYS, "Start to load external lib");
+ Library lib;
+ OnAlarmForLaunch pOnAlarmForLaunch = null;
+ result r = lib.Construct(ALARM_PLUGIN_LIBRARY_PATH);
- if(r == E_SUCCESS)
+ if(r == E_SUCCESS)
+ {
+ SysLog(NID_SYS, "Open alarm condition library");
+ pOnAlarmForLaunch = (OnAlarmForLaunch)lib.GetProcAddress(L"OnAlarmForLaunch");
+ if(pOnAlarmForLaunch != null)
{
- SysLog(NID_SYS, "Open alarm condition library");
- pOnAlarmForLaunch = (OnAlarmForLaunch)lib.GetProcAddress(L"OnAlarmForLaunch");
- if(pOnAlarmForLaunch != null)
- {
- SysLog(NID_SYS, "Function is found");
- pOnAlarmForLaunch(alarmId);
- SysLog(NID_SYS, "Requested to check current alarm id to AlarmConditionHandler %d", alarmId);
- }
- else
- {
- SysLog(NID_SYS, "Fail to find alarm function");
- }
+ SysLog(NID_SYS, "Function is found");
+ pOnAlarmForLaunch(alarmId);
+ SysLog(NID_SYS, "Requested to check current alarm id to AlarmConditionHandler %d", alarmId);
}
else
{
- SysLog(NID_SYS, "Fail to open alarm condition library");
+ SysLog(NID_SYS, "Fail to find alarm function");
}
}
-
- if (pAlarmId)
+ else
{
- free(pAlarmId);
+ SysLog(NID_SYS, "Fail to open alarm condition library");
}
}
- if (pOperation)
- {
- free(pOperation);
- }
-
- if( __lifeDuration > 0 && __pauseLifeDurationTimer == false)
+ if (pAlarmId)
{
- SetLifeDurationTimer(__lifeDuration);
+ free(pAlarmId);
}
}
if( __pauseLifeDurationTimer == false)
{
- int timeout = ( __lifeDuration > LIFE_DURATION_MSEC_MAX ) ? LIFE_DURATION_MSEC_MAX : __lifeDuration;
+ bool isPlatformPrivilege = (GetPrivilegeLevel() == _API_VISIBILITY_PARTNER_MANUFACTURER)? true : false;
+ const int maxTimeOut = (isPlatformPrivilege == true)? LIFE_DURATION_MSEC_MAX_PLATFORM : LIFE_DURATION_MSEC_MAX;
+
+ const int timeout = (__lifeDuration > maxTimeOut) ? maxTimeOut : __lifeDuration;
__pLifeDurationTimer->Start(timeout);
SysLog(NID_APP, "Life duration timer is started (%d millis)", timeout );
}
SetLifeDurationTimer(__lifeDuration);
}
+int
+_ServiceAppImpl::GetPrivilegeLevel(void)
+{
+ const AppId appId = _AppInfo::GetApplicationId();
+
+ _PackageManagerImpl* pPkg = _PackageManagerImpl::GetInstance();
+ SysTryReturn(NID_APP, pPkg != null, _API_VISIBILITY_PUBLIC, E_INVALID_STATE, "Invalid PackageManager instance.");
+
+ String pkgId = _PackageManagerImpl::GetPackageIdByAppId(appId);
+ SysTryReturn(NID_APP, !pkgId.IsEmpty(), _API_VISIBILITY_PUBLIC, E_INVALID_STATE, "Invalid appId(%ls).", appId.GetPointer() );
+
+ PackageInfo* pInfo = pPkg->GetPackageInfoN(pkgId);
+ SysTryReturn(NID_APP, pInfo != null, _API_VISIBILITY_PUBLIC, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ const _PackageInfoImpl* pPkgInfo = _PackageInfoImpl::GetInstance(pInfo);
+ SysTryReturn(NID_APP, pPkgInfo != null, _API_VISIBILITY_PUBLIC, E_INVALID_STATE, "Invalid PackageInfo instance.");
+
+ return pPkgInfo->GetApiVisibility();
+}
+
} } //Tizen::App