Add SilentAuthReceiver for Doze network-block reproduction, Fixes AB#3612535#2516
Add SilentAuthReceiver for Doze network-block reproduction, Fixes AB#3612535#2516rpdome wants to merge 7 commits into
Conversation
Add a BroadcastReceiver to MsalTestApp that triggers acquireTokenSilent
from a background process context (PROCESS_STATE_RECEIVER). This enables
reliable reproduction of the Doze network-block issue that affects
background broker auth triggered by FCM notifications.
Key findings from investigation:
- When a foreground app binds to Broker via IPC, Android's
NetworkPolicyManagerService adds a dozable-allow firewall rule for the
Broker's UID. This masks the Doze network block during UI testing.
- When the caller is in a background context (BroadcastReceiver/Service),
the IPC binding does NOT elevate the Broker enough for dozable-allow.
The Broker's network call fails with UnknownHostException.
- This matches the production scenario: Outlook receives FCM push in
background -> calls OneAuth -> OneAuth calls Broker -> Broker's network
to eSTS is blocked by Doze firewall.
Usage:
adb shell dumpsys battery unplug
adb shell dumpsys deviceidle force-idle
adb shell am broadcast \
-a com.microsoft.identity.client.testapp.SILENT_AUTH \
-n com.msft.identity.client.sample.local/com.microsoft.identity.client.testapp.SilentAuthReceiver
adb logcat -s SilentAuthReceiver:*
|
❌ Work item link check failed. Description does not contain AB#{ID}. Click here to Learn more. |
There was a problem hiding this comment.
Pull request overview
Adds a new testing hook in MsalTestApp to reproduce the Doze network-block scenario by triggering acquireTokenSilent from a BroadcastReceiver (background/receiver process state), along with manifest registration to invoke it via adb.
Changes:
- Introduces
SilentAuthReceiverto create a PCA instance and runacquireTokenSilentAsync(forceRefresh=true)from a receiver context. - Registers the receiver in
AndroidManifest.xmlwith an intent-filter action for adb triggering.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/SilentAuthReceiver.java | Adds a BroadcastReceiver to run silent token acquisition from a background receiver context for Doze repro. |
| testapps/testapp/src/main/AndroidManifest.xml | Registers the new receiver/action used to trigger the Doze repro flow. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
8cf2f3c to
bca228f
Compare
|
❌ Invalid work item number: AB#3612535 ##. Work item number must be a valid integer. Click here to learn more. |
|
✅ Work item link check complete. Description contains link AB#3612535 to an Azure Boards work item. |
9a67d3b to
a6d2373
Compare
|
Overall LGTM, just minor comments. |
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-for-android/sessions/8666a879-5695-4eb3-bed2-71862e059d5f Co-authored-by: rpdome <19558668+rpdome@users.noreply.github.com>
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-for-android/sessions/8666a879-5695-4eb3-bed2-71862e059d5f Co-authored-by: rpdome <19558668+rpdome@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-for-android/sessions/cbdbc7c2-0ac5-48a5-9349-50239c795309 Co-authored-by: rpdome <19558668+rpdome@users.noreply.github.com>
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-for-android/sessions/0e8621a1-0a3e-4157-b8ac-c8436b3d2a33 Co-authored-by: rpdome <19558668+rpdome@users.noreply.github.com>
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-for-android/sessions/cbdbc7c2-0ac5-48a5-9349-50239c795309 Co-authored-by: rpdome <19558668+rpdome@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
AB#3612535
Summary
Add a BroadcastReceiver to MsalTestApp that triggers acquireTokenSilent from a background process context (PROCESS_STATE_RECEIVER). This enables reliable reproduction of the Doze network-block issue that affects background broker auth triggered by FCM notifications.
Root Cause (from investigation)
When a foreground app binds to Broker via IPC, Android's NetworkPolicyManagerService adds a \dozable-allow\ firewall rule for the Broker's UID — masking the Doze network block during UI testing.
When the caller is in a background context (BroadcastReceiver/Service handling FCM), the IPC binding does NOT elevate the Broker enough for \dozable-allow. The Broker's network call to eSTS fails with \UnknownHostException.
Evidence
Files
Usage
\\�ash
Prerequisites: broker + MsalTestApp installed, account signed in
adb shell dumpsys battery unplug
adb shell dumpsys deviceidle force-idle
adb shell am broadcast -a com.microsoft.identity.client.testapp.SILENT_AUTH -n com.msft.identity.client.sample.local/com.microsoft.identity.client.testapp.SilentAuthReceiver
adb logcat -s SilentAuthReceiver:*
Cleanup:
adb shell dumpsys deviceidle unforce && adb shell dumpsys battery reset
\\
Test script
A companion script \scripts/doze-repro-test.sh\ in android-complete automates the full sequence.