17

I'm sure this would have been asked before. But I couldn't find out yet.

I recently updated to Lollipop in my Sony Xperia Z phone. The notification bar and pull down settings are great.

But on lock screen, I don't want to turn on/off any WiFi, Bluetooth or any settings. Simply pull down settings should not be allowed on lock screen. How can I do that? Is there any option?

I have pattern lock already.

Coder
  • 271
  • 1
  • 2
  • 5

2 Answers2

14

I'm using CyanogenOS 12 (derived from CM12), so the following solution may not work on an stock Lollipop, but regardless, it is a very useful solution.


The tiles that you can toggle in the Quick Settings are assigned particular names like Bluetooth → bt, Wi-Fi -> wifi, Landscape/Portrait → rotation, and many others, and these names are stored as a value for the key sysui_qs_tiles under the table secure of settings.db (Settings Storage).

While those tiles can be removed/re-arranged from the Settings UI, the command line can also be considered to achieve the task.

The relevant command is settings and its usage is mentioned as:

usage:  settings [--user NUM] get namespace key
        settings [--user NUM] put namespace key value
        settings [--user NUM] delete namespace key

'namespace' is one of {system, secure, global}, case-insensitive
If '--user NUM' is not given, the operations are performed on the owner user.

You would need ADB setup in your machine before you proceed any further. Alternatively, if the device is rooted, you can use a terminal app like Terminal Emulator for Android.

Note: ADB in wireless mode may prove dangerous if the device doesn't support authenticating a client before giving access. Proceed at your own risk!

We first have to find out the value stored in the key sysui_qs_tiles, and to do that, enter in a terminal the command:

adb shell settings get secure sysui_qs_tiles

For rooted devices using terminal app:

su
settings get secure sysui_qs_tiles

The output would be like:

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

Now, if I want to remove Airplane Mode from the Quick Settings or want Wi-Fi tile to be shown after Hotspot, then the commands in a respective order would be:

adb shell settings put secure sysui_qs_tiles wifi,bt,cell,rotation,flashlight,hotspot,location
adb shell settings put secure sysui_qs_tiles bt,cell,rotation,flashlight,hotspot,wifi,location

For rooted devices using terminal app:

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

Now, coming back to the requirement, that is, "hide quick settings on Lock screen". You can use an tool like Tasker to remove the tiles from Quick Settings when the screen is locked, and add them back when the screen is unlocked.

Before we proceed with Tasker's usage, I should mention that settings command can only be used with ADB in non-rooted devices because of higher privileges required than what is granted to an ordinary user, and hence, for automation in Tasker the device would have to have ADB running in wireless mode. To do so, see:

Instructions for Tasker

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

    Command: adb connect localhost:<PORT>; adb shell settings put secure sysui_qs_tiles wifi,bt,cell,rotation,flashlight,hotspot,location

    For rooted devices, the details would be:

    • Command: settings put secure sysui_qs_tiles wifi,bt,cell,rotation,flashlight,hotspot,location
    • Check Use Root

    For cases where it matters:

    1. Use <PORT> as the port number on which ADB wireless is running like 5555
    2. In place of wifi,bt,cell,rotation,flashlight,hotspot,location use the names of the tiles you want or have in Quick Settings
  3. Create an another task named "Tiles s-locked".

  4. Note: If you configured settings such that the screen doesn't lock right after the device gets to sleep, but after XY seconds (like 30 seconds), then create an action as Task → Wait and set those XY Seconds. Alternatively, sleep XY can be used in the next step under the Command. Arielle suggested the idea.

  5. Add an another action as Code → Run Shell, and add these details:

    Command: adb connect localhost:<PORT>; adb shell settings put secure sysui_qs_tiles ' '

    For rooted devices, the details would be:

    • Command: settings put secure sysui_qs_tiles ' '
    • Check Use Root
  6. Create a profile named "S-unlocked" under Event → Display → Display Unlocked, choose Highest Priority, and link the task "Tiles s-unlocked".
  7. Create an another profile named "S-locked" under Event → Display → Display Off, choose Highest Priority, and link the task "Tiles s-locked".
  8. Have the Tasker enabled, and behold the desired action by locking/unlocking the screen.

    (Click image to enlarge)

    Order of images as "No tiles when screen is locked" → "Tiles when screen is unlocked"

(Click image to enlarge)

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

Let me know if my solution works in a device running Stock Lollipop.

Firelord
  • 25,084
  • 20
  • 124
  • 286
  • Hi I'm not interested to root my mobile. I thought there will be a way with just in mobile settings which I couldn't find. Thanks :) – Coder Jul 29 '15 at 04:46
  • 1
    For Readers: settings put secure qs_show_brightness_slider 0 would remove the brightness slider. Change 0 to 1 and it would come back. Unfortunately, my device behaves oddly when I run that command using Tasker. The effect takes place if only I try it manually via ADB or terminal but not via Tasker! If it works for you, let me know. – Firelord Aug 14 '15 at 12:03
  • 1
    Thanks a lot for this, it works great on CM12.1 but I want to add a small thing: I noticed that if you also want to set some specific quick settings on your lock screen (for example only flashlight and ambient display) they do not work if the command is executed while the phone is locked. The solution is to configure your phone not to lock the screen until 5 seconds after the displays is turned of (in this way that the command can be run before it locks and everything works correctly). – user138784 Aug 15 '15 at 15:55
  • @user138784 Thanks for the input. Have you tried the solution with brightness slider (second comment) as well? – Firelord Aug 16 '15 at 07:09
  • @Firelord I just did and it works. For soms reason disabling and re-enabling Tasker is necessary for it to work properly. I also encountered this strange behaviour when changing which tiles I wanted in the Shell command. – user138784 Aug 16 '15 at 12:14
  • Isn't running ADB wireless a security risk itself? I mean, is it firewalled or does it have localhost access only? If not, the whole world can access your phone. – Martin Oct 21 '15 at 09:15
  • @Martin, yes, you got it right. The whole world has access to your phone, provided that they come to know that ADB is running in wireless mode on your device. – Firelord Oct 21 '15 at 09:20
  • @Firelord, a simple portscan on the most basic port 5555 would do just fine. So much for security. Also, I have a stock Nexus 5 with Android 6 and i don't seem to have ADB on it. Do you need to install it separately? – Martin Oct 21 '15 at 09:37
  • @Martin, I've only tested my method on Lollipop and the adb binary comes with the system. Also, I've not verified the hypothesis but in order to connect to Android via wireless ADB you still would have to authenticate the fingerprint the very first time at least. – Firelord Oct 21 '15 at 09:42
  • @Firelord any idea what the name of the usb tethering tile is? – user138784 Jan 16 '16 at 13:17
  • @user138784: not sure about CM but in Vanir, it is usb_tether. // I heard that Tasker added support for CM tiles. – Firelord Jan 16 '16 at 13:53
  • 1
    @Firelord as far as I found, the support is for custom tiles and BT tethering can't be toggled by tasker on my device (but I think it can by the pro version of secure settings). I didn't find support for setting the available tiles. – user138784 Jan 19 '16 at 09:36
  • @Firelord Is there a list of all available tiles online? Your solution worked perfectly with Tasker. I'd like to add other tiles besides the ones you mentioned. Thanks – winchendonsprings Jul 14 '16 at 21:41
  • @winchendonsprings : As such, I'm not aware of any list. However, you can consider trying GravityBox xposed module for your Android version. It is a better solution than the current one and provides a good range of quick tiles. – Firelord Jul 15 '16 at 15:44
1

There is no way to disable the quick settings on the lockscreen.

However, it may be possible by flashing a custom ROM on your phone. I know you can rearrange/remove tiles in CyanogenMod.

Note: by flashing a custom ROM your data will be wiped and your warranty is void.

Edit: On XDA-Developers I found this:

The Quick settings menu can be edited - when the phone is unlocked open quick settings panel and tap and hold any of its icons, you will be allowed to remove or add some functionalities. Just remove airplane mode and mobile data. This way when the phone is locked no one can disable its connectivity. The drawback is that you can't switch the airplane mode easily even when the phone is unlocked.

Source: http://forum.xda-developers.com/showpost.php?p=60243490&postcount=13

Thomas Vos
  • 4,000
  • 5
  • 35
  • 46