Traditionally Mali Graphics Debugger(MGD) works on a rooted device, in this mode an interceptor layer sits between your application and the driver. Your application then calls into this interceptor layer and the interceptor then sends a copy of this data back to the MGD application and passes the call on to the driver.
However, this isn't the only way that MGD can be used. The second option has all of the functionality of the first option with the added benefit that it will also work on a standard Android device with no modification. The trade-off is that you need access to the full source code of the application that you want to profile. This blog explores the second option so you can debug your applications on non-rooted devices.
Prerequisites
- Your computer should be setup for Android development, in particular:
- The Android SDK and NDK should be installed
- Your system path should include the adb binary.
- You should have access to the full source code of your application
- Your device must be running at least Android 4.2
Installation
Copy the folder called android-non-root from the target directory in your MGD installation to your application's root folder.
In your target application's Android.mk add the following code.
include $(LOCAL_PATH)/../android-non-root/MGD.mk
- In your projects main activity class you need to add the following:
static { try { System.loadLibrary("MGD"); } catch( UnsatisfiedLinkError e ) { // Feel free to remove this log message. Log.i("[ MGD ]", "libMGD.so not loaded."); } }
- Recompile the application and install it on your Android device
Running your application
The first thing we need to do is to install the MGDDaemon application on the target. The MGDDaemon application is responsible for sending the information from the interceptor library to the host. Without it the host won't receive any data.
- cd into the android-non-root directory and run adb install -r MGDDaemon.apk
- Then run adb forward from a command prompt adb forward tcp:5002 tcp:5002
- Then launch the MGD Application. This should take you to a list of applications that it has detected have the MGD interceptor library correctly inserted. Before you click on one you need to press the Mali Graphics Debugger daemon switch to on.
Once pressing the switch you should be able to connect to the process in the MGD host and a new tab for your current trace should be created. At this point you just need to click on your application in the MGD daemon application and the trace should work.
Following these steps you should be able to use MGD on any Mali based platform. If you have any issues please raise them on the community and someone will be more than happy to assist you through the process.