Android VOIP applications behavior in Doze mode - android

I'm working on legacy VOIP application on Android.
It doesn't use Google Cloud Messaging technology right now, but just keeping its own TCP connection forever.
Recently Google has introduced its Android M preview release with Doze mode
So the question: is there any workaround how the app can receive incoming calls/messages in Doze mode without redesigning the whole system to use GCM?

You may use ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS to ask the user permission to be ignored by battery optimization. However, double check Optimizing for Doze and App Standby, it seems to be allowed only for enterprise VoIP/IM (see questions #33114063 and #31154128)

No, GCM seems to be the only way. See a great analysis of the problems with doze mode including network and GCM here:
https://commonsware.com/blog/2015/06/03/random-musing-m-developer-preview-ugly-part-one.html

Related

Behaviour of Android / iOS when receiving Bluetooth LE communcation during doze

I'm developing an app in Ionic/Capacitor/Vue for both iOS and Android, but now I am in need of some guidance.
The app will communicate with a satellite antenna over Bluetooth LE. I'm using https://github.com/katzer/cordova-plugin-background-mode to keep the app running even when the screen is off. However I'm not in control of the antenna firmware, and so far haven't been able to test what happens if the antenna sends some packet while the screen is off or the app is in the background. What I'm hoping would happen is that the app would act on the incoming communication, even if it's in the background.
Also, the background-mode plugin has this warning on its website:
Infinite background tasks are not official supported on most mobile operation systems and thus not compliant with public store vendors. A successful submssion isn't garanteed.
I need to have this app published on both App Store and Play Store. What other options do I have?
There are two up-to-date plugins which help running background tasks on Android:
Foreground Service: https://github.com/capawesome-team/capacitor-android-foreground-service
Battery Optimization: https://github.com/capawesome-team/capacitor-android-battery-optimization
Please note that I am the project owner.
On iOS you should only need to use the Bluetooth LE plugin without additional plugins.

Wake up android app via push notification while in doze without FCM

Greatings!
We are developing an android app with Xamarin that has to meet the following restrictions:
wifi yes, but no internet connection
no FCM/google play services (app should also work in China)
push messages from a Manager-SW (uses rabbitmq) need to arrive quickly after being send (< 1min) AND also when the device is in doze mode
no pulling mechanism
At the moment we are having a wifilock and a wakelock. The battery optimization for this app is turned off. This way messages always arrive even when the device goes to doze mode.. with some exceptions.
There are devices like the HUAWEI P20 that have their own battery save solution (App launch) --> app is not running although we have all the stuff above
Also this solution is not ideal considering battery usage.
I have looked into alternatvies like Pushy, but for me it seems they have problems with doze mode too.
Do you know any alternatives to FCM?
Is there any easy way to go around the Huawei stuff without the user having to change the settings manually?
Many thanks to all of you in advance!

"Unable to resolve host" error with Google Drive API

I am using Google Drive REST API to download 1.5 GB backup file using a foreground service. I found that after the file is downloaded partially, the following exception is generated by code:
Unable to resolve host "www.googleapis.com": No address associated with hostname
I am testing my application on Android 6.0 device. I have set the targetSdkVersion to 27.
I have following questions:
Is the device WIFI automatically tuned off when the device is kept idle for sometime? As I am using a foreground service, is it possible to have this problem?
If no, what can be the other causes for this issue?
I would appreciate any suggestions and thoughts on this topic. Thank you.
Starting from Android 6.0 (API level 23), App Standby defers background network activity for apps with which the user has not recently interacted. You can read the documentation about Optimize Doze and App Stanby of Android app.
If a user leaves a device unplugged and stationary for a period of time, with the screen off, the device enters Doze mode. In Doze mode, the system attempts to conserve battery by restricting apps' access to network and CPU-intensive services. Doze mode restricts to perform a Wi-Fi scans.
You can prevent the doze mode or standby mode of Android apps using foreground service by GcmTaskService.

Android Doze Mode - Bluetooth

My question is fairly simple. I would like to know what it is the best practice for my app so that it can be "Doze-proof". This is getting even more relevant as Android N will be applying Doze in more case scenario.
While reading Doze Documentation there is a part mentioning network access :
In Doze mode, the system attempts to conserve battery by restricting
apps' access to network and CPU-intensive services. It also prevents
apps from accessing the network and defers their jobs, syncs, and
standard alarms.
I believe Buetooth falls under Network Access, is that correct?
Since I do not own a Marshmallow (or Android N) enabled-device and since Emulator does not allow Bluetooth interaction I cannot really test my app behavior in Doze Mode.
Will Doze Mode kill any ongoing Bluetooth connexion? Does the same apply either for Bluetooth Classic and LE ? What about headsets with Bluetooth A2DP ?
My app must maintain this connection or else the core functionality will be broken.
Surely there is some kind of exceptions for such case where your device needs to be connected to a Bluetooth remote device for as long the user whishes too.
I know there exists a Doze Whitelist but it would seem it might not, in some cases, let the app behave as it would on a device below API 23.
Thank you for your help!
Looks like doze doesn't have any restriction on bluetooth per se but to do anything meaningful, you would need to keep the cpu on and wake locks are ignored in deeper doze.
If it's a core functionality of your app, you can try to ask users to whitelist your app. This can grant partial wake locks and keep the cpu on.
Foreground services are also exempted from any doze restrictions so that's another transparent way.

Android BLE disconnected when screen off (without charger)

It's working well on most Android devices.
Other device's screen gets locked after 1 minutes BLE device gets disconnected,if device without charger.
Thanks for any suggestions!
this might come from the Keep Wi-Fi on during sleep option (which might affect all radios) - as it seems this only exists in 8.0 but not in 8.1 (at least on the Pixel 2 XL, according to this article).
You might be having this problem because your app is not properly configured to handle Doze mode.
While there do not seem to be any restrictions on using BLE itself, doze mode might be messing with the control mechanism for your bluetooth connection (ex: a background service).
To see if this is the issue, you can whitelist your app manually via Settings > Battery > Battery Optimization and disabling optimization for your app.
Furthermore, as of Android 8.0, there are restrictions on background services when your app is not in the foreground. So, you may need to create a foreground service to handle the connection.

Categories

Resources