Add DeviceConfig flags to incident reports.
Test: generated reports on local devices Bug: 136268432 Change-Id: If9b6d8704ee000e466ac221cf96a1c6becd33d9e
This commit is contained in:
@@ -20,6 +20,7 @@ package android.providers.settings;
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "SettingsServiceProto";
|
||||
|
||||
import "frameworks/base/core/proto/android/providers/settings/config.proto";
|
||||
import "frameworks/base/core/proto/android/providers/settings/global.proto";
|
||||
import "frameworks/base/core/proto/android/providers/settings/secure.proto";
|
||||
import "frameworks/base/core/proto/android/providers/settings/system.proto";
|
||||
@@ -33,6 +34,9 @@ message SettingsServiceDumpProto {
|
||||
|
||||
// Global settings
|
||||
optional GlobalSettingsProto global_settings = 2;
|
||||
|
||||
// Config settings
|
||||
optional ConfigSettingsProto config_settings = 3;
|
||||
}
|
||||
|
||||
message UserSettingsProto {
|
||||
|
||||
55
core/proto/android/providers/settings/config.proto
Normal file
55
core/proto/android/providers/settings/config.proto
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
syntax = "proto2";
|
||||
package android.providers.settings;
|
||||
|
||||
option java_multiple_files = true;
|
||||
|
||||
import "frameworks/base/core/proto/android/providers/settings/common.proto";
|
||||
import "frameworks/base/core/proto/android/privacy.proto";
|
||||
|
||||
message ConfigSettingsProto {
|
||||
option (android.msg_privacy).dest = DEST_EXPLICIT;
|
||||
|
||||
repeated SettingsOperationProto historical_operations = 1;
|
||||
repeated NamespaceProto extra_namespaces = 2;
|
||||
repeated SettingProto activity_manager_native_boot_settings = 3;
|
||||
repeated SettingProto activity_manager_settings = 4;
|
||||
repeated SettingProto app_compat_settings = 5;
|
||||
repeated SettingProto autofill_settings = 6;
|
||||
repeated SettingProto connectivity_settings = 7;
|
||||
repeated SettingProto content_capture_settings = 8;
|
||||
repeated SettingProto dex_boot_settings = 9;
|
||||
repeated SettingProto game_driver_settings = 10;
|
||||
repeated SettingProto input_native_boot_settings = 11;
|
||||
repeated SettingProto netd_native_settings = 12;
|
||||
repeated SettingProto privacy_settings = 13;
|
||||
repeated SettingProto rollback_boot_settings = 14;
|
||||
repeated SettingProto rollback_settings = 15;
|
||||
repeated SettingProto runtime_native_boot_settings = 16;
|
||||
repeated SettingProto runtime_native_settings = 17;
|
||||
repeated SettingProto runtime_settings = 18;
|
||||
repeated SettingProto storage_settings = 19;
|
||||
repeated SettingProto systemui_settings = 20;
|
||||
repeated SettingProto telephony_settings = 21;
|
||||
repeated SettingProto textclassifier_settings = 22;
|
||||
|
||||
message NamespaceProto {
|
||||
optional string namespace = 1;
|
||||
repeated SettingProto settings = 2;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,9 @@ package com.android.providers.settings;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.provider.Settings;
|
||||
import android.providers.settings.ConfigSettingsProto;
|
||||
import android.providers.settings.GlobalSettingsProto;
|
||||
import android.providers.settings.SecureSettingsProto;
|
||||
import android.providers.settings.SettingProto;
|
||||
@@ -28,24 +30,79 @@ import android.providers.settings.UserSettingsProto;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** @hide */
|
||||
class SettingsProtoDumpUtil {
|
||||
private static final Map<String, Long> NAMESPACE_TO_FIELD_MAP = createNamespaceMap();
|
||||
|
||||
private SettingsProtoDumpUtil() {}
|
||||
|
||||
private static Map<String, Long> createNamespaceMap() {
|
||||
Map<String, Long> namespaceToFieldMap = new HashMap<>();
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
|
||||
ConfigSettingsProto.ACTIVITY_MANAGER_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_ACTIVITY_MANAGER_NATIVE_BOOT,
|
||||
ConfigSettingsProto.ACTIVITY_MANAGER_NATIVE_BOOT_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_APP_COMPAT,
|
||||
ConfigSettingsProto.APP_COMPAT_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_AUTOFILL,
|
||||
ConfigSettingsProto.AUTOFILL_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_CONNECTIVITY,
|
||||
ConfigSettingsProto.CONNECTIVITY_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_CONTENT_CAPTURE,
|
||||
ConfigSettingsProto.CONTENT_CAPTURE_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_DEX_BOOT,
|
||||
ConfigSettingsProto.DEX_BOOT_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_GAME_DRIVER,
|
||||
ConfigSettingsProto.GAME_DRIVER_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_INPUT_NATIVE_BOOT,
|
||||
ConfigSettingsProto.INPUT_NATIVE_BOOT_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_NETD_NATIVE,
|
||||
ConfigSettingsProto.NETD_NATIVE_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_PRIVACY,
|
||||
ConfigSettingsProto.PRIVACY_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_ROLLBACK,
|
||||
ConfigSettingsProto.ROLLBACK_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_ROLLBACK_BOOT,
|
||||
ConfigSettingsProto.ROLLBACK_BOOT_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_RUNTIME,
|
||||
ConfigSettingsProto.RUNTIME_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_RUNTIME_NATIVE,
|
||||
ConfigSettingsProto.RUNTIME_NATIVE_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_RUNTIME_NATIVE_BOOT,
|
||||
ConfigSettingsProto.RUNTIME_NATIVE_BOOT_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_STORAGE,
|
||||
ConfigSettingsProto.STORAGE_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||
ConfigSettingsProto.SYSTEMUI_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_TELEPHONY,
|
||||
ConfigSettingsProto.TELEPHONY_SETTINGS);
|
||||
namespaceToFieldMap.put(DeviceConfig.NAMESPACE_TEXTCLASSIFIER,
|
||||
ConfigSettingsProto.TEXTCLASSIFIER_SETTINGS);
|
||||
return Collections.unmodifiableMap(namespaceToFieldMap);
|
||||
}
|
||||
|
||||
static void dumpProtoLocked(SettingsProvider.SettingsRegistry settingsRegistry,
|
||||
ProtoOutputStream proto) {
|
||||
// Config settings
|
||||
SettingsState configSettings = settingsRegistry.getSettingsLocked(
|
||||
SettingsProvider.SETTINGS_TYPE_CONFIG, UserHandle.USER_SYSTEM);
|
||||
if (configSettings != null) {
|
||||
// TODO(b/113100523): dump configuration settings after they are added
|
||||
dumpProtoConfigSettingsLocked(
|
||||
proto, SettingsServiceDumpProto.CONFIG_SETTINGS, configSettings);
|
||||
}
|
||||
|
||||
// Global settings
|
||||
SettingsState globalSettings = settingsRegistry.getSettingsLocked(
|
||||
SettingsProvider.SETTINGS_TYPE_GLOBAL, UserHandle.USER_SYSTEM);
|
||||
if (globalSettings != null) {
|
||||
dumpProtoGlobalSettingsLocked(proto, SettingsServiceDumpProto.GLOBAL_SETTINGS, globalSettings);
|
||||
dumpProtoGlobalSettingsLocked(
|
||||
proto, SettingsServiceDumpProto.GLOBAL_SETTINGS, globalSettings);
|
||||
}
|
||||
|
||||
// Per-user settings
|
||||
@@ -1599,6 +1656,33 @@ class SettingsProtoDumpUtil {
|
||||
// Settings.Global.INSTALL_NON_MARKET_APPS intentionally excluded since it's deprecated.
|
||||
}
|
||||
|
||||
private static void dumpProtoConfigSettingsLocked(
|
||||
@NonNull ProtoOutputStream p, long fieldId, @NonNull SettingsState s) {
|
||||
Map<String, List<String>> namespaceMap = new HashMap<>();
|
||||
final long token = p.start(fieldId);
|
||||
s.dumpHistoricalOperations(p, ConfigSettingsProto.HISTORICAL_OPERATIONS);
|
||||
for (String name : s.getSettingNamesLocked()) {
|
||||
String namespace = name.substring(0, name.indexOf('/'));
|
||||
if (NAMESPACE_TO_FIELD_MAP.containsKey(namespace)) {
|
||||
dumpSetting(s, p, name, NAMESPACE_TO_FIELD_MAP.get(namespace));
|
||||
} else {
|
||||
if (!namespaceMap.containsKey(namespace)) {
|
||||
namespaceMap.put(namespace, new ArrayList<>());
|
||||
}
|
||||
namespaceMap.get(namespace).add(name);
|
||||
}
|
||||
}
|
||||
for (String namespace : namespaceMap.keySet()) {
|
||||
final long namespacesToken = p.start(ConfigSettingsProto.EXTRA_NAMESPACES);
|
||||
p.write(ConfigSettingsProto.NamespaceProto.NAMESPACE, namespace);
|
||||
for (String name : namespaceMap.get(namespace)) {
|
||||
dumpSetting(s, p, name, ConfigSettingsProto.NamespaceProto.SETTINGS);
|
||||
}
|
||||
p.end(namespacesToken);
|
||||
}
|
||||
p.end(token);
|
||||
}
|
||||
|
||||
/** Dumps settings that use a common prefix into a repeated field. */
|
||||
private static void dumpRepeatedSetting(@NonNull SettingsState settings,
|
||||
@NonNull ProtoOutputStream proto, String settingPrefix, long fieldId) {
|
||||
|
||||
Reference in New Issue
Block a user