mirror of
https://github.com/mvt-project/mvt.git
synced 2026-09-17 23:22:20 +02:00
Peel tag and restore flags off settings rows
A dumpsys settings row can end in `tag:` and, on some vendor builds, in `isValuePreservedInRestore:` or a bare `notPreservedInRestore` token. The parser only peeled `default:` and `defaultSystemSet:` off the end of a record, so on a row without a default those tokens stayed inside the value, and on a row with one they landed in `defaultSystemSet`. A value of `0 tag:null` is not the safe value `0`, so a setting at its safe value was reported as dangerous; these are the false positives measured in #912. The metadata keys are ordered fields like the rest of the record, so `_split_fields` reads them now, which also replaces the separate handling of the default. The bare token has no `key:` shape and is printed last, so it is stripped first and recorded as `isValuePreservedInRestore: false`. The bugreport fixture gains the three row shapes from #912: a restore flag after `defaultSystemSet:`, and a `tag:` or a bare token directly after the value. Two of them sit on dangerous settings at their safe value, so the unchanged alert count of one is the false-positive check.
This commit is contained in:
@@ -25,7 +25,7 @@ class TestSettingsArtifact:
|
||||
def test_parsing(self):
|
||||
settings = parse_bugreport_settings()
|
||||
|
||||
assert len(settings.results) == 11
|
||||
assert len(settings.results) == 12
|
||||
assert {result["namespace"] for result in settings.results} == {
|
||||
"config",
|
||||
"global",
|
||||
@@ -69,6 +69,24 @@ class TestSettingsArtifact:
|
||||
assert record["value"] == "com.example.dialer,com.example.camera"
|
||||
assert record["default"] == "com.android.settings,\n com.android.vending"
|
||||
|
||||
def test_trailing_metadata_is_not_part_of_the_value(self):
|
||||
settings = parse_bugreport_settings()
|
||||
|
||||
record = find(settings, "lock_screen_show_notifications")[0]
|
||||
assert record["value"] == "1"
|
||||
assert record["defaultSystemSet"] == "true"
|
||||
assert record["isValuePreservedInRestore"] == "true"
|
||||
|
||||
# Without a default, the tag or the restore token follows the value.
|
||||
record = find(settings, "accessibility_enabled")[1]
|
||||
assert record["value"] == "0"
|
||||
assert record["tag"] == "null"
|
||||
assert "default" not in record
|
||||
|
||||
record = find(settings, "send_action_app_error")[0]
|
||||
assert record["value"] == "1"
|
||||
assert record["isValuePreservedInRestore"] == "false"
|
||||
|
||||
def test_repeated_names_are_kept_as_separate_records(self):
|
||||
settings = parse_bugreport_settings()
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ class TestBugreportAnalysis:
|
||||
|
||||
def test_settings_module(self):
|
||||
m = self.launch_bug_report_module(Settings)
|
||||
assert len(m.results) == 11
|
||||
assert len(m.results) == 12
|
||||
|
||||
assert len(m.alertstore.alerts) == 1
|
||||
assert "accessibility_enabled = 1" in m.alertstore.alerts[0].message
|
||||
|
||||
@@ -280,6 +280,7 @@ com.example.chat
|
||||
GLOBAL SETTINGS (user 0)
|
||||
_id:2070 name:adb_wifi_enabled pkg:android value:0 default:0 defaultSystemSet:true
|
||||
_id:778 name:hidden_api_blacklist_exemptions value:{null}
|
||||
_id:9640 name:send_action_app_error pkg:android value:1 notPreservedInRestore
|
||||
_id:9631 name:development_settings_enabled pkg:com.android.settings value:1 default:1 defaultSystemSet:true
|
||||
History (development_settings_enabled)
|
||||
time:11-02 11:21:22.212 mode:update oldValue:null newValue:1 package:com.android.settings
|
||||
@@ -299,12 +300,12 @@ _id:41654 name:widget_instance_data pkg:com.android.systemui value:{
|
||||
} defaultSystemSet:true
|
||||
|
||||
SECURE SETTINGS (user 0)
|
||||
_id:907 name:lock_screen_show_notifications pkg:com.android.settings value:1 default:1 defaultSystemSet:true
|
||||
_id:907 name:lock_screen_show_notifications pkg:com.android.settings value:1 default:1 defaultSystemSet:true isValuePreservedInRestore:true
|
||||
_id:240 name:accessibility_enabled pkg:android value:1 default:0 defaultSystemSet:true
|
||||
History (accessibility_enabled)
|
||||
time:03-28 22:41:07.980 mode:update oldValue:0 newValue:1 package:com.example.helper
|
||||
|
||||
SECURE SETTINGS (user 10)
|
||||
_id:311 name:accessibility_enabled pkg:android value:0 default:0 defaultSystemSet:true
|
||||
_id:311 name:accessibility_enabled pkg:android value:0 tag:null
|
||||
|
||||
--------- 0.019s was the duration of dumpsys settings, ending at: 2022-03-29 23:14:28
|
||||
|
||||
Reference in New Issue
Block a user