# Call Flow Analysis Techniques for tracing execution flows in decompiled Android applications, from entry points down to network calls. ## 1. Start from AndroidManifest.xml The manifest declares all entry points. After decompilation, find it at: ``` /resources/AndroidManifest.xml ``` Key elements to look for: ```bash # Activities (UI screens) grep -n 'android:name=.*Activity' resources/AndroidManifest.xml # Services (background work) grep -n 'android:name=.*Service' resources/AndroidManifest.xml # BroadcastReceivers grep -n '` impl. To find the binding for an interface `Foo`, look for files that contain both a Koin import / module DSL marker and a reference to `Foo`: ```bash grep -rln 'org\.koin\.core\.module' sources/ | xargs grep -l 'Foo' ``` ### Trace through DI 1. Find where an interface is used (e.g. `ApiService` injected into a repository). 2. Find the `@Provides` / `@Binds` method (Hilt) **or** the `single { ... }` / `factory { ... }` block (Koin) that creates the implementation. 3. Follow the implementation to the actual HTTP call. ## 6. Find Constants and Configuration Hardcoded values are rarely obfuscated: ```bash # Base URLs grep -rni 'BASE_URL\|API_URL\|SERVER_URL\|HOST' sources/ # API keys grep -rni 'API_KEY\|CLIENT_ID\|APP_KEY\|SECRET' sources/ # BuildConfig values grep -rn 'BuildConfig\.' sources/ # SharedPreferences keys (runtime config) grep -rn 'getSharedPreferences\|getString(\|putString(' sources/ ``` ## 7. Navigating Obfuscated Code When code is obfuscated (ProGuard/R8): ### What gets obfuscated - Class names → `a`, `b`, `c` - Method names → `a()`, `b()`, `c()` - Field names → `f1234a`, `f1235b` ### What does NOT get obfuscated - **String literals** — URLs, keys, error messages remain readable - **Android framework classes** — `Activity`, `Fragment`, `Intent` keep their names - **Library public APIs** — Retrofit annotations, OkHttp builders retain names - **AndroidManifest entries** — Activity/Service names must be real ### Strategy for obfuscated code 1. **Start from strings**: Search for URLs, error messages, and known constants 2. **Start from framework classes**: Activities and Fragments are named in the manifest 3. **Follow library calls**: Retrofit `@GET`/`@POST` annotations are readable even when the interface class name is obfuscated 4. **Recover original Kotlin names from metadata**: `@DebugMetadata` and `@Metadata.d2` strings preserve the original FQNs even after R8 obfuscation. Run `scripts/recover-kotlin-names.sh` to build an `obf -> real` map (typically recovers 30-50% of classes — and almost 100% of `*Repository` / `*ViewModel` / `*Impl`). See [`kotlin-name-recovery.md`](./kotlin-name-recovery.md). This is the single highest-leverage step on any Kotlin app. 5. **Cross-reference**: If `class a` calls `Retrofit.create(b.class)`, then `b` is a Retrofit service interface 6. **`--deobf` is rarely enough on its own**: jadx's `--deobf` renames obfuscated symbols with synthetic placeholders (`p001a`, `C0123Foo`) — useful for disambiguation but it does **not** recover original names. Pair it with the metadata recovery above. ## 8. Tracing a Complete Call Flow: Example Goal: Find how login works in an obfuscated app. ``` 1. grep for "login" in strings → find "auth/login" URL in class `c.a.b.d` 2. Class `c.a.b.d` has @POST("auth/login") → it's a Retrofit interface 3. grep for `c.a.b.d` usage → class `c.a.b.f` calls it (the repository) 4. grep for `c.a.b.f` usage → class `c.a.a.g` calls it (the ViewModel) 5. grep for `c.a.a.g` usage → `LoginActivity` has a field of this type 6. Read LoginActivity.onCreate() → sets click listener → calls ViewModel method ``` Result: `LoginActivity → ViewModel → Repository → Retrofit @POST("auth/login")` ## 9. Tools and Commands Summary | Goal | Command | |---|---| | Find entry points | `grep 'android:name' resources/AndroidManifest.xml` | | Find lifecycle methods | `grep -rn 'onCreate\|onResume' sources/` | | Find click handlers | `grep -rn 'setOnClickListener\|onClick' sources/` | | Find DI bindings | `grep -rn '@Provides\|@Binds\|@Inject' sources/` | | Find constants | `grep -rni 'BASE_URL\|API_KEY' sources/` | | Find usages of a class | `grep -rn 'ClassName' sources/` | | Follow a string | `grep -rn '"some text"' sources/` |