Airplane mode not disabling/enabling consistently

chaoscreater

Active member
I have 2 macros configured and each macro has an action that either turns on or turns off airplane mode. All the other actions in the same 2 macros run fine, except for the airplane mode action. Sometimes, the airplane mode turns on/off, sometimes they don't.

The macro itself fires correctly. All other actions run correctly. Macrodroid has the correct permissions, is locked in memory, autostart enabled, battery optimization disabled, etc. Everything works except the airplane mode action. Sometimes it'll turn on/off, sometimes it won't. If I manually run a "test actions", it'll work fine.

Any ideas why this is happening? The same 2 macros run fine on another phone.
 

chaoscreater

Active member
no errors in system log. It showed that it executed airplane mode on/off, along with the other actions.

I'll try the loop method, it looks quite promising.
 

chaoscreater

Active member
Hmm, still not working. I can see in the logs that the disable airplane mode action ran 10 times and there were no errors. However, the fact that it ran 10 times means that it never actually disabled airplane mode.

It seems that when I'm actually actively using my phone, there's no problem with enabling or disabling airplane mode. I tried to add a screen on action and a launch homescreen action, but it didn't make a difference.

I'm now testing UI interaction to tap the airplane mode button and see if that works.
 

chaoscreater

Active member
Do the original macros work reliably if the MacroDroid app is in the foreground?
Yup, it works fine if it is in foreground.

I got it working atm, by using a screen on first and then use UI interaction to toggle airplane mode from the notification shade.

Also, my phone is set to run in Battery Saver mode during specific times and that might have caused the issue. It's weird though, because Macrodroid is set to run in background at all times, battery optimization is off, app is locked in memory and all other permissions granted. It shouldn't be blocked even if the entire phone is in battery saver mode. Also, the actions did register in the system log, even while the phone was in battery saver, just that the action didn't actually do anything.

The dontkillmyapp.com site doesn't mention battery saver mode for Xiaomi devices anyway, so I don't think there was anything I missed....

Anyway, issue resolved, thanks for the help.
 

Pseudocyclic

Well-known member
Check this setting (Android settings - Apps - MacroDroid) is enabled:
 

Attachments

  • Screenshot_20210509-224635_Settings.jpg
    Screenshot_20210509-224635_Settings.jpg
    245.8 KB · Views: 12

Pseudocyclic

Well-known member
Try this:

A: MacroDroid Drawer - open
A: Airplane Mode Off
A: Wait Before Next Action - 5ms
A: MacroDroid Drawer - close
 

MacroDroidDev

Administrator
Staff member
I think it's highly likely that if the phone is in battery saver mode there will still be impacts on background apps even if you have configured them fully to run in the background. These settings only help keep the app alive under normal operation. The battery saving mode will work by killing pretty much anything that isn't essential to the phone's operation so I suspect (especially on Xiaomi) this setting overrides anything else configured.
 

chaoscreater

Active member
I think it's highly likely that if the phone is in battery saver mode there will still be impacts on background apps even if you have configured them fully to run in the background. These settings only help keep the app alive under normal operation. The battery saving mode will work by killing pretty much anything that isn't essential to the phone's operation so I suspect (especially on Xiaomi) this setting overrides anything else configured.
nope, that's not the case, as MacroDroid was able to perform all other actions EXCEPT for airplane mode on/off. If battery saver was an issue, then I would think the macro wouldn't even trigger at all, nor any of the actions in the macros.

I also did a test by disabling battery saver mode and it was still the same issue. I mentioned in a previous post, the workaround is to use UI interaction to toggle the airplane mode button in the notification shade menu. This works fine, compared to using MacroDroid as default voice assist to toggle airplane mode. This has nothing to do with battery saver.

Anyway, I figured out what the problem is and it seems to be a bug with MacroDroid. If you manually adjust the default voice assist setting OUTSIDE of MacroDroid's context, then MacroDroid will not recognize this setting change. Instead, what you need to do is change the default voice assist to something else (e.g. Google Assistant). You will get a popup notification from MacroDroid that permission setting is missing. Click on the notification, it will take you to the same default voice assist setting page. Change it to MacroDroid and this time the setting will get recognized and MacroDroid will be able to toggle airplane mode on/off without issues. Alternatively, you can ignore the notification popup and just go into your macro. You should find a purple highlight warning for the airplane mode action (or whatever action that requires MacroDroid running as default voice assist). It will prompt you to change the default voice assist and just change it there.

Basically, you are taken to the same setting page, but you have to go through MacroDroid to get to that setting, rather than get to the setting OUTSIDE of the MacroDroid context.

I think the same is true for when you adjust other permission settings, such as Accessibility. I've seen this for other apps like Greenify, where if you change it outside of the app context, it doesn't recognize that the Acessibility setting is turned on.
 

dhj49er

Well-known member
nope, that's not the case, as MacroDroid was able to perform all other actions EXCEPT for airplane mode on/off. If battery saver was an issue, then I would think the macro wouldn't even trigger at all, nor any of the actions in the macros.

I also did a test by disabling battery saver mode and it was still the same issue. I mentioned in a previous post, the workaround is to use UI interaction to toggle the airplane mode button in the notification shade menu. This works fine, compared to using MacroDroid as default voice assist to toggle airplane mode. This has nothing to do with battery saver.

Anyway, I figured out what the problem is and it seems to be a bug with MacroDroid. If you manually adjust the default voice assist setting OUTSIDE of MacroDroid's context, then MacroDroid will not recognize this setting change. Instead, what you need to do is change the default voice assist to something else (e.g. Google Assistant). You will get a popup notification from MacroDroid that permission setting is missing. Click on the notification, it will take you to the same default voice assist setting page. Change it to MacroDroid and this time the setting will get recognized and MacroDroid will be able to toggle airplane mode on/off without issues. Alternatively, you can ignore the notification popup and just go into your macro. You should find a purple highlight warning for the airplane mode action (or whatever action that requires MacroDroid running as default voice assist). It will prompt you to change the default voice assist and just change it there.

Basically, you are taken to the same setting page, but you have to go through MacroDroid to get to that setting, rather than get to the setting OUTSIDE of the MacroDroid context.

I think the same is true for when you adjust other permission settings, such as Accessibility. I've seen this for other apps like Greenify, where if you change it outside of the app context, it doesn't recognize that the Acessibility setting is turned on.
I have a macro that uses UI integration to change the voice assist app using the phone system settings.
I can confirm that if I use this macro to change to Google, Macrodroid knows and alerts the user it needs to be changed to control airplane setting.
Changing the setting back to Macrodroid via the macro and Macrodroid is aware, no warnings and can control airplane setting.
So I don't see a bug.
 
Last edited:

chaoscreater

Active member
I have a macro that uses UI integration to change the voice assist app using the phone system settings.
I can confirm that if I use this macro to change to Google, Macrodroid knows and alerts the user it needs to be changed to control airplane setting.
Changing the setting back to Macrodroid via the macro and Macrodroid is aware, no warnings and can control airplane setting.
So I don't see a bug.

There's a better way than using UI interaction.

- Create a Secure setting with setting key set to "assistant" and value set to "com.arlosoft.macrodroid/.voiceservice.MacroDroidVoiceService".
- Create a Secure setting with setting key to "voice_interaction_service" and value set to "com.arlosoft.macrodroid/.voiceservice.MacroDroidVoiceService".

That should automatically set MacroDroid as the default voice assist and from there, you can toggle airplane mode without root, as it'll be using MacroDroid as default voice assist to perform that action.

Now, if instead of using the above, you use this:
- Create a Secure setting with setting key set to "assistant" and value set to "com.arlosoft.macrodroid/.triggers.activities.HomeLongPressTriggerActivity".
- Create a Secure setting with setting key to "voice_interaction_service" and value set to "com.arlosoft.macrodroid/.triggers.activities.HomeLongPressTriggerActivity".

Then this will ALSO set MacroDroid as default voice assist. However, you won't be able to toggle airplane mode at all. So I think the issue that I had previously is that MacroDroid did not 100% get set as default voice assist, due to the different values as per example above. Anyway, I got this working now and all without using UI interaction. For reference, you can refer to the above values in the macro id=9532 in the store.
 

dhj49er

Well-known member
I'm struggling to find the macro store.
Does the macro include system settings to change back to Google?
 

Dm114

Well-known member
I'm struggling to find the macro store.
Does the macro include system settings to change back to Google?
To get a macro in the macro store, type id=nnnn (where nnnn is the macro number) in the search field on the top of the screen
 

chaoscreater

Active member
I'm struggling to find the macro store.
Does the macro include system settings to change back to Google?
yes, it does. If you can't find the ID of the macro in the store, you can also try searching for "airplane mode on" by chaoscreater. You will need to enable the actions related to SECURE settings, specifically the "assistant" and "voice_interaction_service" ones (as per my previous post) for MacroDroid (before airplane mode turns on) and Google Assistant (at the very bottom).
 

Dm114

Well-known member
Do these secure system settings work on all phones?
They are supposed to but some of them cannot be changed (the value change has no effect). I don't know whether it depends on Android version, device brand or some other trick... Try yours and good luck! 😉😀
 
Top