Merge "[SettingsProvider] better debug messages for invalid write arguments" into sc-dev am: 72de027815
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14454046 Change-Id: I93d8f61da83ff2c711e38e59b55ec777d33be02d
This commit is contained in:
@@ -808,28 +808,29 @@ final class SettingsState {
|
|||||||
for (int i = 0; i < settingCount; i++) {
|
for (int i = 0; i < settingCount; i++) {
|
||||||
Setting setting = settings.valueAt(i);
|
Setting setting = settings.valueAt(i);
|
||||||
|
|
||||||
writeSingleSetting(mVersion, serializer, setting.getId(), setting.getName(),
|
if (writeSingleSetting(mVersion, serializer, setting.getId(), setting.getName(),
|
||||||
setting.getValue(), setting.getDefaultValue(), setting.getPackageName(),
|
setting.getValue(), setting.getDefaultValue(), setting.getPackageName(),
|
||||||
setting.getTag(), setting.isDefaultFromSystem(),
|
setting.getTag(), setting.isDefaultFromSystem(),
|
||||||
setting.isValuePreservedInRestore());
|
setting.isValuePreservedInRestore())) {
|
||||||
|
|
||||||
if (DEBUG_PERSISTENCE) {
|
if (DEBUG_PERSISTENCE) {
|
||||||
Slog.i(LOG_TAG, "[PERSISTED]" + setting.getName() + "="
|
Slog.i(LOG_TAG, "[PERSISTED]" + setting.getName() + "="
|
||||||
+ setting.getValue());
|
+ setting.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
serializer.endTag(null, TAG_SETTINGS);
|
serializer.endTag(null, TAG_SETTINGS);
|
||||||
|
|
||||||
serializer.startTag(null, TAG_NAMESPACE_HASHES);
|
serializer.startTag(null, TAG_NAMESPACE_HASHES);
|
||||||
for (int i = 0; i < namespaceBannedHashes.size(); i++) {
|
for (int i = 0; i < namespaceBannedHashes.size(); i++) {
|
||||||
String namespace = namespaceBannedHashes.keyAt(i);
|
String namespace = namespaceBannedHashes.keyAt(i);
|
||||||
String bannedHash = namespaceBannedHashes.get(namespace);
|
String bannedHash = namespaceBannedHashes.get(namespace);
|
||||||
writeSingleNamespaceHash(serializer, namespace, bannedHash);
|
if (writeSingleNamespaceHash(serializer, namespace, bannedHash)) {
|
||||||
if (DEBUG_PERSISTENCE) {
|
if (DEBUG_PERSISTENCE) {
|
||||||
Slog.i(LOG_TAG, "[PERSISTED] namespace=" + namespace
|
Slog.i(LOG_TAG, "[PERSISTED] namespace=" + namespace
|
||||||
+ ", bannedHash=" + bannedHash);
|
+ ", bannedHash=" + bannedHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
serializer.endTag(null, TAG_NAMESPACE_HASHES);
|
serializer.endTag(null, TAG_NAMESPACE_HASHES);
|
||||||
serializer.endDocument();
|
serializer.endDocument();
|
||||||
destination.finishWrite(out);
|
destination.finishWrite(out);
|
||||||
@@ -898,14 +899,20 @@ final class SettingsState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeSingleSetting(int version, TypedXmlSerializer serializer, String id,
|
static boolean writeSingleSetting(int version, TypedXmlSerializer serializer, String id,
|
||||||
String name, String value, String defaultValue, String packageName,
|
String name, String value, String defaultValue, String packageName,
|
||||||
String tag, boolean defaultSysSet, boolean isValuePreservedInRestore)
|
String tag, boolean defaultSysSet, boolean isValuePreservedInRestore)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (id == null || isBinary(id) || name == null || isBinary(name)
|
if (id == null || isBinary(id) || name == null || isBinary(name)
|
||||||
|| packageName == null || isBinary(packageName)) {
|
|| packageName == null || isBinary(packageName)) {
|
||||||
// This shouldn't happen.
|
if (DEBUG_PERSISTENCE) {
|
||||||
return;
|
Slog.w(LOG_TAG, "Invalid arguments for writeSingleSetting: version=" + version
|
||||||
|
+ ", id=" + id + ", name=" + name + ", value=" + value
|
||||||
|
+ ", defaultValue=" + defaultValue + ", packageName=" + packageName
|
||||||
|
+ ", tag=" + tag + ", defaultSysSet=" + defaultSysSet
|
||||||
|
+ ", isValuePreservedInRestore=" + isValuePreservedInRestore);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
serializer.startTag(null, TAG_SETTING);
|
serializer.startTag(null, TAG_SETTING);
|
||||||
serializer.attribute(null, ATTR_ID, id);
|
serializer.attribute(null, ATTR_ID, id);
|
||||||
@@ -924,6 +931,7 @@ final class SettingsState {
|
|||||||
serializer.attributeBoolean(null, ATTR_PRESERVE_IN_RESTORE, true);
|
serializer.attributeBoolean(null, ATTR_PRESERVE_IN_RESTORE, true);
|
||||||
}
|
}
|
||||||
serializer.endTag(null, TAG_SETTING);
|
serializer.endTag(null, TAG_SETTING);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setValueAttribute(String attr, String attrBase64, int version,
|
static void setValueAttribute(String attr, String attrBase64, int version,
|
||||||
@@ -946,15 +954,20 @@ final class SettingsState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeSingleNamespaceHash(TypedXmlSerializer serializer, String namespace,
|
private static boolean writeSingleNamespaceHash(TypedXmlSerializer serializer, String namespace,
|
||||||
String bannedHashCode) throws IOException {
|
String bannedHashCode) throws IOException {
|
||||||
if (namespace == null || bannedHashCode == null) {
|
if (namespace == null || bannedHashCode == null) {
|
||||||
return;
|
if (DEBUG_PERSISTENCE) {
|
||||||
|
Slog.w(LOG_TAG, "Invalid arguments for writeSingleNamespaceHash: namespace="
|
||||||
|
+ namespace + ", bannedHashCode=" + bannedHashCode);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
serializer.startTag(null, TAG_NAMESPACE_HASH);
|
serializer.startTag(null, TAG_NAMESPACE_HASH);
|
||||||
serializer.attribute(null, ATTR_NAMESPACE, namespace);
|
serializer.attribute(null, ATTR_NAMESPACE, namespace);
|
||||||
serializer.attribute(null, ATTR_BANNED_HASH, bannedHashCode);
|
serializer.attribute(null, ATTR_BANNED_HASH, bannedHashCode);
|
||||||
serializer.endTag(null, TAG_NAMESPACE_HASH);
|
serializer.endTag(null, TAG_NAMESPACE_HASH);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String hashCode(Map<String, String> keyValues) {
|
private static String hashCode(Map<String, String> keyValues) {
|
||||||
|
|||||||
Reference in New Issue
Block a user