Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50ebccb2 authored by Felipe Leme's avatar Felipe Leme
Browse files

Added overrideableByRestore option to `settings put`.

Here's how to test it...

First create some aliases...

$ alias get_sec='adb shell settings get secure --user cur'
$ alias put_sec='adb shell settings pu secure --user cur'
$ alias del_sec='adb shell settings delete secure --user cur'
$ alias bmgr='adb shell bmgr --user cur'

...prepare the backup manager...

$ bmgr transport com.android.localtransport/.LocalTransport
$ bmgr init com.android.localtransport/.LocalTransport
$ bmgr activate true
$ bmgr enable true

...and remove a setting, as the new option only works if it's not
already saved with isValuePreservedInRestore:

$ del_sec lock_screen_show_notifications
Deleted 1 rows
$ get_sec lock_screen_show_notifications
null

Now set it:

$ set_sec lock_screen_show_notifications 1
$ get_sec lock_screen_show_notifications
1

Since the setting didn't exist yet (it was deleted), it will be
stored with isValuePreservedInRestore = false (which shows as
notPreservedInRestore on dumpsys):

$ adb shell dumpsys settings | grep name:lock_screen_show_notifications
_id:157 name:lock_screen_show_notifications pkg:root value:1

Use the command below to create backup (with value 1)

$ bmgr backupnow com.android.providers.settings --monitor-verbose > /dev/null

Now set it again, with a different value:

$ set_sec lock_screen_show_notifications 0
$ get_sec lock_screen_show_notifications
0

Notice the the notPreservedInRestore is gone, as the value existed before:

$ adb shell dumpsys settings | grep name:lock_screen_show_notifications
_id:158 name:lock_screen_show_notifications pkg:root value:0

So if you try to restore it, it doesn't work:

$ bmgr restore 1 com.android.providers.settings --monitor-verbose > /dev/null
$ get_sec lock_screen_show_notifications
0

Now let's repeat the previous steps, but using overrideableByRestore

$ del_sec lock_screen_show_notifications
$ get_sec lock_screen_show_notifications
null
$ set_sec lock_screen_show_notifications 1
$ get_sec lock_screen_show_notifications
1
$ set_sec lock_screen_show_notifications 0 overrideableByRestore
$ get_sec lock_screen_show_notifications
0

Notice the notPreservedInRestore is set this time:

$ adb shell dumpsys settings | grep name:lock_screen_show_notifications
_id:159 name:lock_screen_show_notifications pkg:root value:0 notPreservedInRestore

So now restore works:

$ bmgr restore 1 com.android.providers.settings --monitor-verbose > /dev/null
$ get_sec lock_screen_show_notifications
1

Test: manual verification using steps above
Fixes: 396734809
Flag: EXEMPT changes on debugging components only

Change-Id: I11d239f9b2a70de8f94ff7f9f6df0be79fc69142
parent 583b8f25
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment