6

When I display the quick settings panel, there are shortcuts to enable some functions (wifi, data connection ...)

When my phone is locked (pin code), the location switch disappears, (for security reasons AFAIK).

But the airplane mode switch is ever displayed, so a thiefer could easily enable it, and disable location by the same.

Is there a way to disable the airplane mode switch when my phone is locked ?

Locked :

locked

Unlocked :

Unlocked

3

Note:

  • The following solution is tested on COS12 (Android 5.0.2) and Carbon ROM (Android 5.1.1).
  • For this answer, you would need ADB setup in your machine, USB debugging enabled in the device and connected to PC. Alternatively, for rooted devices, terminal app like Terminal Emulator for Android can be used.
  • Root access is required (see exception at the bottom).

The tiles that you can toggle in the Quick Settings are assigned particular names and are stored as a value for the key sysui_qs_tiles under the table secure (both key and the table may differ for your ROM) of settings.db (Settings Storage app).

Note:

  • When using a terminal emulator app, enter su and then follow the commands without the prefix adb shell.
  • For each stage, two commands are mentioned. Both are alternatives to each other here.
  • For the usage of settings and content, enter adb shell settings and adb shell content respectively

To find out the value stored in the key sysui_qs_tiles, enter the command

adb shell settings get secure sysui_qs_tiles
adb shell content --query content://settings/secure --where "name='systeui_qs_tiles'"

The output would be like:

wifi,bt,cell,rotation,flashlight,hotspot,location,airplane

airplane is for Airplane mode. If you remove it from the value, the quick tile would instantaneously vanish.

Example,

adb shell settings put secure sysui_qs_tiles "wifi,bt,cell,rotation,flashlight,hotspot,location"
adb shell content update --url content://settings/secure value:s:"wifi,bt,cell,rotation,flashlight,hotspot,location" --where "name='sysui_qs_tiles'"

It must be noted that you should not use the aforesaid value but only the one which you got from your query.

As for hiding/removing the Airplane mode on the lock-screen and adding it back when the screen is unlocked you can use an tool, such as Tasker or MacroDroid.

Instructions for Tasker

  1. Create a task named "Screen unlocked".
  2. Add an action as Code → Run Shell, and add these details:

    • Command:

      settings put secure sysui_qs_tiles "wifi,bt,cell,rotation,flashlight,hotspot,location,airplane"

      Use the key-value relevant for your device. Also, as an alternative, you can use the content command, if you would like to. This info remains valid for further instructions as well.

    • Check Use Root
  3. Create an another task named "Screen locked".

  4. Note: If you configured lock-screen settings so that the screen doesn't lock right after the device gets to sleep, but after XY seconds (such as, 30 seconds), then create an action as Task → Wait and set those XY Seconds. Alternatively, sleep XY command can also be used.
  5. Add an action as Code → Run Shell, and add these details:

    • Command:

      settings put secure sysui_qs_tiles "wifi,bt,cell,rotation,flashlight,hotspot,location"
    • Check Use Root
  6. Create a profile named "S-unlocked" under Event → Display → Display Unlocked, choose Highest Priority, and link the task "Screen unlocked".
  7. Create an another profile named "S-locked" under Event → Display → Display Off, choose Highest Priority, and link the task "Screen locked".
  8. Have the Tasker enabled and behold the desired action by locking/unlocking the screen.

Should you decide to use MacroDroid, install Secure Settings too because it is needed to run commands in MacroDroid's actions.

Relevant triggers in MacroDroid:

  • Screen On/Off → Screen Off
  • Screen Unlocked

Relevant actions in MacroDroid:

  • Secure Settings → Actions → Run Command

    • Use the commands learned in this solution. Follow instructions for Tasker for any guidance
  • Wait Before Next Action

Screenshots

Order of images as "All tiles available when screen is unlocked" → "No Airplane tile when screen is locked"

(Click image to enlarge)

IMG: No tiles when screen is locked IMG: Tiles when screen is unlocked


It is possible to use this solution without root access. You would need ADB running in wireless and loopback mode for that. It is not very convenient, however, it does work. For any guidance, see my answer for Lollipop hide quick settings on Lock screen.

1

Install XposedInstaller and use GravityBox module. It has a setting for disabling the Power button at lockscreen. Hope it helps.

  • I guess you forgot to mention that both of them needs root access. Also, could you link the apps? – Firelord Nov 23 '15 at 22:16
1

I have not seen any way in which this can be done on stock Android.

If you are willing to root, this can be achieved through a custom ROM like Cataclysm.

Not the answer you're looking for? Browse other questions tagged or ask your own question.