Skip to content

Instantly share code, notes, and snippets.

@bgotink
Last active October 17, 2020 03:02
Show Gist options
  • Save bgotink/24a6a9f731fcaba26a5a to your computer and use it in GitHub Desktop.
Save bgotink/24a6a9f731fcaba26a5a to your computer and use it in GitHub Desktop.
unset a setting if it breaks your android OS

This guide tells you how to reset a system setting in case your OS breaks once you change it. In my case, as soon as I enabled the "force RTL layout" setting, I got "System UI stopped working" over and over again, even in safe mode.

Requirements

  • This guide is written for Android 5.1, it should work for older versions (with remarks, cf. below), it might work for newer versions.
  • You'll need a custom recovery, I recomment TWRP.
  • You'll need adb available, google around to know how to install it on your OS. If you're on windows, ensure you have the drivers for your smartphone!
  • USB debugging should be enabled in the developer menu
  • If you already have root access over ADB on your phone, you can skip the entire "reboot into recovery and mount /system and /data" part. You will probably still need the reboot at the end though.

What to do

Connect your smartphone to your computer.

# reboot in recovery
# you may see a pop-up asking whether you want to allow your computer to remotely debug your phone, click "allow"
adb reboot recovery

Once you've booted into recovery, mount /system and /data (how to do this depends on your recovery). Start a shell on your phone by executing

# first, make sure we're root
adb root

# start a shell
adb shell

Next, execute these commands in the ADB shell:

# we need this to get sqlite to work
cd /system/lib

# open the database
# NOTE for older devices: if any of the following commands fail,
# try the files below, until you find one that works:
# - /data/data/com.android.providers.settings/settings.db
# - /dbdata/databases/com.android.providers.settings/settings.db
# NOTE if sqlite3 can't be found: this guide won't work for you, you can use
# the guide here instead: http://forum.xda-developers.com/showthread.php?t=774507&page=4
/system/xbin/sqlite3 /data/data/com.android.providers.settings/databases/settings.db

We're now in the database, tread carefully!

-- take a look at all settings
SELECT * FROM global;

-- you'll see a bunch of output, find the setting that you just changed
-- (if it's the last setting you changed, it should be the last line)
-- the line constist of <number>|<name>|<value>
-- remember the name, and replace <name> in the command below with the name of your setting

-- change the setting
-- values:
-- - checkbox that should be off: 0
-- - checkbox that should be on: 1
-- - other: ???
-- replace <value> with the correct value in the command below.
UPDATE global SET value = '<value>' WHERE name = '<name>';
-- For example: the command I had to enter was:
-- UPDATE global SET value = '0' WHERE name = 'debug.force_rtl';

Close the database and the adb shell by hitting ctrl + D twice. Once you're back in the shell of your computer, run

adb reboot

and you're done.

@oboenikui
Copy link

I found another solution using "content" command. Root access isn't required.
Boot into normal system, and execute

adb shell content delete --uri content://settings/global --where "name='debug.force_rtl'"
adb reboot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment