terminaladblogcatdumpsys

Finding all available activities/fragments for an app that's not yours


When decompiling an app, I find lately, that a few apps' manifests do not seem to have designated activities for the view I want. For example, if com.example.app is on the view I want and I run the following command:

dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

the resultant output will be something like:

mCurrentFocus=Window{9280f2a u0 com.example.app/com.example.app.MainSubMenu}
mFocusedApp=AppWindowToken{da37759 token=Token{9d56fa0 ActivityRecord{5c490a3 u0 com.example.app/.MainSubMenu t98}}}

This is fine, but when the screen I am on is obviously a subactivity/subview/fragment, dumpsys nor logcat will show me the full path to this view. In short, I would like to find the name of the fragment/view and launch directly to it. This syntax looks promising for achieving a fragment view launch (perhaps with some variation):

am start -n com.example.app/.MainSubMenu -e :android:show_fragment com.example.app.somefragmentview

but I am unsure of how to find all fragment names for each activity of the app.


Solution

  • I ended up using AutoInput in combination with MacroDroid to select specific elements of the app's main (launch) screen, based on text. This gets me to any screen of an app without having to rely on touch event coordinates, since developers of these apps typically switch up menu item locations with subsequent updates.

    Here is the AutoInput process in detail (which I imagine can be integrated with Tasker as well):

    1. Install both aforementioned apps.
    2. When selecting an Action for MacroDroid, choose the 'Locale/Tasker Plugin' option. This will list AutoInput's options, and any other options for different plugins you've downloaded, I suppose.
    3. Choose the 'AutoInput Action' option from the list.
    4. Select 'Action' from the next screen, then 'Click'.
    5. For 'Field Type' choose 'Text', or any other piece of information you know about the menu/button/element that you would ordinarily select to get to the screen you want. We are talking about a menu/button/element that exists on the main (launch) screen of your app.
    6. Fill in 'Field Text' with the menu/button/element's text.
    7. Hit the checkmark at the top right when you are finished, and it will return you to MacroDroid.

    A few notes:

    This is all a bit obtuse, I realize, but without knowing how to extract the (has extras) information from Logcat, this was the only available solution that didn't force me to rely on coordinates for touch events. Hopefully this offers a viable alternative until someone finds/offers a way to pull raw extra data from activities.