Tutorial
- 1. Quick Start
- 2. Create Your Account
- 3. Use Dashboard
- 4. Create Your First Task
- 5. Publish Task
- 6. Control Permission
- 7. Run MI-LAB Client APP
Create Your First Task: MI-LAB is task-centric
MI-LAB is designed to offer task-centric support for experimentation and analysis. Data is collected for certain research task and will be used for this task. MI-LAB task support the following features:
-
Customized android task app distribution
-
MobileInsight integration API support
-
Experimental data management and analysis
-
Permission management for individual/public to view, execution and data access
How to develop your own customized task
A MI-LAB task should be designed to run along with a MobileInsight plugin.
The idea is to let MobileInsight plugin focus on collecting targeted cellular messages and provide run-time analysis, and MI-LAB task app take responsibility for the rest needs, e.g. manipulate the network environment, generate background data traffic, record application layer performance metrics, and whatever you want.
MobileInsight plugin
MI-LAB has three example [MobileInsight Plugins](plugins/):
-
NetLoggerCFG: it collects all available cellular messages from NAS/RRC layer to physical layer.
-
NetLoggerMMDiag: this plugin is designed to study mobility configurations, it collects signalling messages containing mobility configuration information for multiple RATs including LTE, WCDMA, EVDO, 1xRTT and GSM along with radio signal measurements at physical layer for serving cell and neighbouring cells.
-
App2Go: this plugin collects LTE RRC layer packets and physical layer measurement results.
You can use them directly for your task, or you can also create your own MobileInsight plugin. For tutorials about developing MobileInsight plugin, please refer to here: [MobileInsight Develop Tutorials](http://mobileinsight.net/developer-guide.html)
Android task App development
MI-LAB support several simple interface for task app to co-work with MobileInsight and MI-LAB client App.
To make your own task app, you can start with this [MI-LAB task demo](https://github.com/moonsky219/milab-taskdemo) and use it as a template.
Interface with MI-LAB client app
MI-LAB client app uses AIDL to communicate with task app. To support this feature, you need to make a "net.mobilieinsight.milab" package under the aidl directory and include the following three aidl files. They are all included in the template demo task repo.
// IMILab.aidl
package net.mobileinsight.milab;
// Declare any non-default types here with import statements
interface IMILab {
/**
* Demonstrates some basic types that you can use as parameters
* and return values in AIDL.
*/
void pauseMI();
void resumeMI();
void sendMsg(String strMsg);
void insertMsg(String strMsg);
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
double aDouble, String aString);
}
// ITask.aidl
package net.mobileinsight.milab;
import net.mobileinsight.milab.TaskObject;
import net.mobileinsight.milab.IMILab;
// Declare any non-default types here with import statements
interface ITask {
int getPid();
TaskObject getOutput();
void exit();
/**
* Demonstrates some basic types that you can use as parameters
* and return values in AIDL.
*/
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
double aDouble, String aString);
void register(IMILab interfaceMILab);
void run();
}
// TaskObject.aidl
package net.mobileinsight.milab;
parcelable TaskObject;
MI-LAB client App requires a TaskObject sent from task App, it need to be defined locally within 'net.mobileinsight.milab' package under java directory. This is also included in demo task repo:
package net.mobileinsight.milab;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Created by moonsky219 on 5/6/18.
*/
public class TaskObject implements Parcelable {
private String TaskName;
private String TaskDescription;
private String pathOutputFolder;
private String pluginNameMI;
// ......
}
}
Your own task app will be launched as an Android service. So you need to declare your main service in the AndroidManifest.xml:
<service
android:name=".MainService"
android:enabled="true"
android:exported="true"
android:stopWithTask="false" />
Modification needed
Now comes the most important part, in the MainService, you need to use the interface defined previously and specify the information contained in a TaskObject in the override function public TaskObject getOutput().
The fields are the following 4 items:
-
TaskName: the name of your Task App
-
TaskDescription: a description of your Task App (it will showed on the MI-LAB Client APP task panel)
-
PathOutputFolder: the absolute path of the directory which contains all files generated by your task APP and wish to upload to MI-LAB as task logs
-
MobileInsight Plugin: the name of the MobileInsight Plugin you want to use
@Override
public TaskObject getOutput() throws RemoteException {
Log.i(getString(R.string.tag), "getOutput() is called.");
TaskObject toSend = new TaskObject();
toSend.setTaskName(getString(R.string.app_name));
toSend.setTaskDescription("A demo task using NetLoggerMMDiag");
String strOutput = new File(Environment.getExternalStorageDirectory(), getString(R.string.app_name)).getAbsolutePath();
toSend.setPathOutputFolder(strOutput);
toSend.setPluginNameMI("NetLoggerMMDiag");
return toSend;
}
The entrance is the override function run() which will be called by MI-LAB client app once user click "Run" button. You can launch your own activity from there.
@Override
public void run() throws RemoteException {
getApplicationContext().registerReceiver(brPauseMI, new IntentFilter(getString(R.string.tag) + ".MainService.PauseMI"));
getApplicationContext().registerReceiver(brResumeMI, new IntentFilter(getString(R.string.tag) + ".MainService.ResumeMI"));
Intent dialogIntent = new Intent(getApplicationContext(), MainActivity.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialogIntent);
}
In case you don't need to launch an Activity for any UI, MI-LAB provides an interface: sendMsg(String), which will display task app messages on MI-LAB app console.
MainService.this.interfaceMILab.sendMsg(getString(R.string.tag) + " started.");
MI-LAB also provides another two interfaces: pauseMI() and resumeMI(), which allow you to pause and resume running of MobileInsight plugin.
Note
You don't need to call resumeMI() to start MobileInsight plugin, MI-LAB launch MobileInsight and run the specified plugin once user click the MobileInsight button.
MainService.this.interfaceMILab.pauseMI();
MainService.this.interfaceMILab.resumeMI();