Extension with Rush. Keep the app running. Doze mode. Service. Notification. Source code

And again: I doubt that this is responsible for preventing Doze mode, but only the Foreground service of the notification.

In other words, IGNORE_BATTERY_OPTIMIZATION has no permanent effect on Doze (especially not on certain devices, like Galaxy Note8, S8, ...). I've tested this extensively (using @Taifun's extension).

Not on my test devices (Galaxy ...).

@Anke

Battery optimization is Doze mode.
Battery optimization (Doze mode) - Taming The Droid.

I have only tried this extension installed on Xiaomi Android 9, it would be interesting for other users to try it on other versions of Android (26+)

This extension does not use FOREGROUND_SERVICE

Ok, but why doesn't Taifun's extension work then?

See e.g. here:

@Anke

An app that is whitelisted can use the network (in my extension Web.Url) and hold partial wake locks during Doze (MediaPlayer.setLooping running).

the weird thing is that s = s + 1 doesn't work for you

From this link:

I would like to understand if it is really possible to prevent Doze (completely) without a (Foreground) Service.

It works for some time (which cannot be precisely predicted) and then slows down and then stops completely. I had the same behavior with streaming (radio) apps. After a while, ignoring the battery optimization will no longer be effective and the network connection, CPU, timer etc. will be throttled or terminated. I tested this on my Galaxy Note8, S8 (Android 9).

This problem does not appear on some other test devices. But Samsung devices are still very common, so I needed a general solution. And I found this (as I said) with the Foreground service.

I'd really like to understand how it works.

So which service of the following do your extension use?

grafik

@Anke
It is not a Foreground service because it does not use startForeground, nor does it use "android.permission.FOREGROUND_SERVICE".

It also needs the help of the MediaPlayer, the old idea, to continue working, this should not be needed by a "normal" Service, so the code indicated on the web of tutoril is more of a service workaround.

Here's an example from Foreground, although I'm afraid it doesn't work the way we want it either.

2 Likes

9.- Testing with Bluetooth HC-06.

ServicioBluetooth.aia (106.1 KB)

  • I have only tested it on a Xiaomi with Android 9. It works, that is, it maintains the connection even with the screen turned off.
  • Arduino sends by Bluetooth 1 2 3 4 5 6 7 8...
  • App receives those numbers and shows them on the screen (and in Notification every 10)

bluetooth_Ser

#include <SoftwareSerial.h>
SoftwareSerial BT(2,3);

int k = 0;
String kString = "0";

void setup(){
 BT.begin(9600);
 Serial.begin(9600);
}
 
void loop(){
  k = k + 1;
  Serial.println(k);
  kString = (String) k + '\n';
  BT.write(kString.c_str());
  delay(1000);
}

(TODO, check battery consumption in hours.)

3 Likes

Thanks for the explanation.
I checked whether a streaming app was also running in the background (idle mode). And it works.

I will check later whether the ExoPlayer also works in Kodular with it. If so, it would be great. See here:

The question that remains is whether it will also work without notification?

10.- A mobile sends information to another that is with the black screen.

ServicioCuenta.aia (109.0 KB)

  • We install the application on a mobile, I'll call it BLACK DEVICE.

  • Click on "Start", then on "TurnOffDozemode", then on "Check if is Ignoring Battery Optimization" and on "Minimize this Screen".

  • We will observe that approximately every second counts one unit.

  • Now we close the screen, that is, we press the button of the mobile to put it with a black screen, in the sleeping state. So we leave it for 5 ... 10 ... 20 minutes.

  • In another mobile, I will call it WHITE DEVICE, we load the same application, in this we can do it with the MIT COMPANION or installed.

  • In this mobile we only press the last button "Send random number", every so often we press this button.

  • By pressing this button a random number will be sent to CloudDB, this same mobile will receive it and also the BLACK DEVICE, this will speak the number.

  • If the system works, we can leave the BLACK DEVICE mobile for a long time with a black screen and you will always receive the number sent by the WHITE DEVICE.

  • I have only tested it on a Xiaomi with Android 9. (Battery consumption with this app: 2.5 % / hour)

3 Likes

file "servicio.aia" è Free?

File servicio.aia is free.

This extension is free : com.kio4.servicio.aix

Extension com.kio4.servicio.aix is free.

1 Like

Hi Sorry, I would like to inform you that I have tried your .aia file, of this excellent extension, but everything works fine until I put the phone in the dark in suspension.

In fact, when I send a number randomly, the first time it is read remotely, regularly even with the app minimized and the mobile phone suspended, but the second time the number is no longer read remotely.

While, if I don't minimize the App, and put it on hold, everything is going well.

To me, it would be useful for it not only to be able to receive all the numbers that I send randomly but also for the summary to read them, even when the app is minimized, and the mobile phone in suspension.
It's possible? Because currently as I wrote it does not.

I am using two "Huawey p8 lite" phones

Hello @Angelo_D, I only tried this extension on Android 9, I put the source code in case someone wants to improve it. Thanks for trying it out.
Other extensions of this type:
Backgroung Task extension by @Kumaraswamy
or Ullis Roboter Seite/AI2 Keep Alive

1 Like