import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
import org.tizen.dynamicanalyzer.project.AppInfo;
+import org.tizen.dynamicanalyzer.project.Project;
import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
public class LifecycleLogParser {
private static LifecycleLogParser instance = null;
-
-// 2 void _AppImpl::OnTerminate(void* user_data)
-// 3 void _AppInfo::SetAppState(AppState appState)
-// 4 void _UiAppImpl::OnBackground(void)
-// 5 void _UiAppImpl::OnForeground(void)
-//
-// 83 _dalc_app_create
-// 84 _dalc_app_terminate
-// 85 _dalc_app_pause
-// 86 _dalc_app_resume
-// 87 _dalc_app_service
-
- /*
- * for OSP
- */
- private static final int API_ID_INITIALIZING_OSP = 3;
- private static final int API_ID_RUNNING_OSP = 5;
- private static final int API_ID_PAUSING_OSP = 4;
- private static final int API_ID_TERMINATING_OSP = 2;
-
- /*
- * for EFL
- */
- private static final int API_ID_INITIALIZING_EFL = 83;
- private static final int API_ID_SERVICE_EFL = 87;
- private static final int API_ID_RESUME_EFL = 86;
- private static final int API_ID_PAUSING_EFL = 85;
- private static final int API_ID_TERMINATING_EFL = 84;
-
+
+ // life-cycle API names for OSP
+ private static final String API_NAME_INITIALIZING_OSP = "_AppInfo::SetAppState(AppState appState)";
+ private static final String API_NAME_RUNNING_OSP = "_UiAppImpl::OnForeground(void)";
+ private static final String API_NAME_PAUSING_OSP = "_UiAppImpl::OnBackground(void)";
+ private static final String API_NAME_TERMINATING_OSP = "_AppImpl::OnTerminate(void* user_data)";
+
+ // life-cycle API names for EFL
+ private static final String API_NAME_INITIALIZING_EFL = "_dalc_app_create";
+ private static final String API_NAME_SERVICE_EFL = "_dalc_app_service";
+ private static final String API_NAME_RESUME_EFL = "_dalc_app_resume";
+ private static final String API_NAME_PAUSING_EFL = "_dalc_app_pause";
+ private static final String API_NAME_TERMINATING_EFL = "_dalc_app_terminate";
+
+ // life-cycle API ID for OSP
+ private int API_ID_INITIALIZING_OSP = 0;
+ private int API_ID_RUNNING_OSP = 0;
+ private int API_ID_PAUSING_OSP = 0;
+ private int API_ID_TERMINATING_OSP = 0;
+
+ // life-cycle API ID for EFL
+ private int API_ID_INITIALIZING_EFL = 0;
+ private int API_ID_SERVICE_EFL = 0;
+ private int API_ID_RESUME_EFL = 0;
+ private int API_ID_PAUSING_EFL = 0;
+ private int API_ID_TERMINATING_EFL = 0;
+
// Use HashSet because prevent duplicated insertion
- private Set<LifecycleBar> lifecycleBarList = new HashSet<LifecycleBar>();
+ private Set<LifecycleBar> lifecycleBarList = new HashSet<LifecycleBar>();
private List<DATimeline> timelineList = new ArrayList<DATimeline>();
public static LifecycleLogParser getInstance() {
private LifecycleLogParser() {
}
+ public void initialize(Project project) {
+ API_ID_INITIALIZING_OSP = project.getFunctionID(API_NAME_INITIALIZING_OSP);
+ API_ID_RUNNING_OSP = project.getFunctionID(API_NAME_RUNNING_OSP);
+ API_ID_PAUSING_OSP = project.getFunctionID(API_NAME_PAUSING_OSP);
+ API_ID_TERMINATING_OSP = project.getFunctionID(API_NAME_TERMINATING_OSP);
+
+ API_ID_INITIALIZING_EFL = project.getFunctionID(API_NAME_INITIALIZING_EFL);
+ API_ID_SERVICE_EFL = project.getFunctionID(API_NAME_SERVICE_EFL);
+ API_ID_RESUME_EFL = project.getFunctionID(API_NAME_RESUME_EFL);
+ API_ID_PAUSING_EFL = project.getFunctionID(API_NAME_PAUSING_EFL);
+ API_ID_TERMINATING_EFL = project.getFunctionID(API_NAME_TERMINATING_EFL);
+ }
+
public void parseLogPackage(LogPackage logPack) {
Logs logs = logPack.getLogs(ProtocolConstants.MSG_PROBE_LIFECYCLE);
if (null == logs) {
return;
}
-
+
List<LogData> logDataList = logs.getRawLogs();
for (LogData logData : logDataList) {
- parseLog(logData.getTime(), ((LifeCycleLogData)logData).getApiId());
+ parseLog(logData.getTime(), ((LifeCycleLogData) logData).getApiId());
}
}
public void parseLog(long lifeChangeTime, int lifeStatus) {
Color color;
String text;
-
- if(Global.getProject() == null) {
+
+ if (Global.getProject() == null) {
return;
}
/*
* TODO need to check detail application type
*/
// EFL
- if (Global.getProject().getApplicationInfo().getAppType().
- contains(AppInfo.APPTYPE_CAPP)) {
+ if (Global.getProject().getApplicationInfo().getAppType().contains(AppInfo.APPTYPE_CAPP)) {
if (lifeStatus == API_ID_INITIALIZING_EFL) {
color = ColorResources.LIFECYCLE_INITIALIZING;
text = TimelineChartLabels.LIFECYCLE_INITIALIZING;
color = ColorResources.LIFECYCLE_TERMINATING;
text = TimelineChartLabels.LIFECYCLE_TERMINATING;
} else {
- Logger.error("lifecycle log error"); //$NON-NLS-1$
+ Logger.error("lifecycle log error (%d)", lifeStatus); //$NON-NLS-1$
return;
}
- }
+ }
// OSP
- else if (Global.getProject().getApplicationInfo().getAppType().
- contains(AppInfo.APPTYPE_CPP)) {
+ else if (Global.getProject().getApplicationInfo().getAppType()
+ .contains(AppInfo.APPTYPE_CPP)) {
if (lifeStatus == API_ID_INITIALIZING_OSP) {
color = ColorResources.LIFECYCLE_INITIALIZING;
text = TimelineChartLabels.LIFECYCLE_INITIALIZING;
color = ColorResources.LIFECYCLE_TERMINATING;
text = TimelineChartLabels.LIFECYCLE_TERMINATING;
} else {
- Logger.error("lifecycle log error"); //$NON-NLS-1$
+ Logger.error("lifecycle log error (%d)", lifeStatus); //$NON-NLS-1$
return;
}
} else {
Logger.error("It doesn't support lifecycle application type.");
return;
}
-
+
double startTime = Double.parseDouble(Long.toString(lifeChangeTime))
/ TimelineConstants.MEGA_DOUBLE;