21
April
2023
Script for Android smartphone against spam calls: "Airplane mode if the screen is off"
12:06

Script for Android smartphone against spam calls: "Airplane mode if the screen is off"

21 April 2023 12:06

After my wife’s death, no one calls me on my old number, but silent long-distance calls have become more frequent. I wrote a script for a smartphone that disconnects the phone from the mobile network when the screen turns off.

Description

When the screen turns off, the connection to the network is lost. When you turn on the smartphone screen, the connection is restored.

Requirements

To make the script work, I installed the designer program Automate, which allows you to control your smartphone based on events - the start of a call, the screen going dark, the screen turning on, etc.

Details

The block diagram is shown below. To work, you need the "Automate" program, root rights (root in Android), the "act as voice assistant" and "Get phone status data", "ignore app hybernation", "ignore battery optimizations" rights.

Scenario flowchart

Scenario flowchart

1. The first block is the beginning of the scenario

2. The second block "Is Call state Idle?" analyzes the call status (so as not to interrupt an ongoing call when the screen is turned off). Check - immediately, i.e. immediately.
1callstate

3. The third block "When display on" checks whether the screen backlight is turned on

screen_lights_on?

4. The fourth block "Disable airplane mode" disables airplane mode

set airplane mode off

5. The fifth block (top right) "Is call state Idle" checks whether the call is in progress no different from block No. 1.
callstate#2

6. Sixth block - bottom right turns on flight mode

set arplane mode on

Script archive with flo file for Automate 1.36.3

airplane.zip(108 KB)

What to do with missed calls?

The phone receptionist answers calls when I'm not online.



Related publications