Search code examples
androidandroid-intentandroid-source

Android capture data from intent


I have an app that sends intent to an exact app. I have root shell access and could possibly modify AOSP, but I don't really know where to look at.

Got this in logcat:

START u0 {act=com.app.Action.OPEN cmp=com.app/.SomeActivity (has extras)} from uid 10052

How to capture this (has extras)? Or at least keys (not values) used in intent, cause my main goal is to start external app activity with parameters (with root access), but it is closed source and I don't know how extra string key is named.

To clarify the question I should say that intent is called from an app to itself and I don't have sources of this app.


Solution

  • one possible way to get hold of the intent data is the create a package with exactly the same package name and intent filters set up, and then replace the original package with the fake package, as the new intent receiver. only then the solution provided in this answer could be used - because unless an intent is being received, there is nothing to list.


    while being able to build AOSP from source, you still could edit class Intent and add further logging. Uri mData appears to be the data you'd be looking for; where the one constructor in line 6130 seems to be the one most commonly used:

    Intent(String action, Uri uri, Context packageContext, Class<?> cls)
    

    therefore it should be possible to log from within that constructor (the if condition is optional):

    public Intent(String action, Uri uri, Context packageContext, Class<?> cls) {
    
        setAction(action);
        mData = uri;
        mComponent = new ComponentName(packageContext, cls);
    
        if(cls.getSimpleName().equals("SomeActivity")) {
            Log.d("Intent", "has leaked: " + action + ": " + uri.toString());
        }
    }