mobile_insight.element module

Basic abstractions for the trace collector and analyzer. It defines send/receive abstractions of cellular messages, logging functions and interface to other applications (MI-APP, mobile-version only)

Author: Yuanjie Li Update: Yunqi Guo, 2020/06

class mobile_insight.element.Element

Bases: object

The parent class to derive trace collectors and analyzers.

broadcast_info(method, msg_dict)

(Mobile-version only) Broadcast monitor/analyzer information to other Android apps. This method is the interface between MobileInsight and Android apps requiring cellular info. It leverages Android’s intent-based broadcast mechanism.

The intent is per-analyzer/monitor based, and the action is named as follows: MobileInsight.ANALYZER/MONITOR-NAME.method

where ANALYZER/MONITOR-NAME is the class name of the monitor/analyzer, and method is analyzer/monitor-specific method to notify the Android apps

Parameters
  • method (string) – analyzer/monitor-specific methods for broadcast action

  • msg_dict (string->string dictionary) – A dictionary that lists the information to be broadcasted.

log_critical(msg)

CRITICAL_level log printout

Parameters

msg – raw messages to be logged

log_debug(msg)

DEBUG_level log printout

Parameters

msg – raw messages to be logged

log_error(msg)

ERROR_level log printout

Parameters

msg – raw messages to be logged

log_info(msg)

INFO_level log printout

Parameters

msg – raw messages to be logged

log_warning(msg)

WARNING_level log printout

Parameters

msg – raw messages to be logged

logger = None
recv(module, event)

Upon receiving an event from module, trigger associated callbacks

This method should be overwritten by the analyzer and trace collector

Parameters
  • module – the module who raises the event

  • event – the event to be received

send(event)

Raise an event to all Analyzers in from_analyzer_list :param event: the event to be sent

set_log(logpath, loglevel=20)

Set the logging in analyzers. All the analyzers share the same logger.

Parameters
  • logpath – the file path to save the log

  • loglevel – the level of the log. The default value is logging.INFO.

class mobile_insight.element.Event(timestamp, type_id, data)

Bases: object

The event is used to trigger the analyzer and perform some actions.

The event can be raised by a trace collector (a message) or an analyzer. An event is a triple of (timestamp, type, data).