-
Notifications
You must be signed in to change notification settings - Fork 108
Handle Doze and App Standby
Wei Jia edited this page Aug 11, 2017
·
2 revisions
Starting from Android 6.0 (API 23), Android introduced the power optimization feature. When device is in doze mode or app is in standby mode, there is no network access. However apps using ADAL can still run in the background and make silent auth requests. Because of today ADAL's network check is only checking if there is active network, it introduces lots of auth failures with connection timeout. See Android doc (https://developer.android.com/training/monitoring-device-state/doze-standby.html)
ADAL is introducing the new error code NO_NETWORK_CONNECTION_POWER_OPTIMIZATION. The error can be returned in the following cases,
- ADAL embedded silent auth and broker auth: Developer will receive AuthenticationException with error code as NO_NETWORK_CONNECTION_POWER_OPTIMIZATION. For Async call, exception will be returned through callback.
- acquireToken with prompt behavior as auto for both ADAL embedded auth and broker auth: acquireToken call requires an UI element to be passed in, when acquireToken happens that the app should already be in foreground which means app is no longer in standby or device is no longer in doze mode. Since acquireToken with promptBehavior as auto will do token cache lookup first, and it's really depends on the app, NO_NETWORK_CONNECTION_POWER_OPTIMIZATION will still be returned if the silent auth happens in doze and standby mode.
When app receives the error code from ADAL, app should wake up app to finish silent auth.
- Error Handling
- Auth Telemetry
- Logging
- Doze and App Standby
- ProGuard
- Session Cookies in WebView
- Resource Overrides