Loading core/java/android/app/backup/NotificationLoggingConstants.java 0 → 100644 +33 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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. */ package android.app.backup; /** * @hide */ public class NotificationLoggingConstants { // Key under which the payload blob is stored public static final String KEY_NOTIFICATIONS = "notifications"; @BackupRestoreEventLogger.BackupRestoreDataType public static final String DATA_TYPE_ZEN_CONFIG = KEY_NOTIFICATIONS + ":zen_config"; @BackupRestoreEventLogger.BackupRestoreDataType public static final String DATA_TYPE_ZEN_RULES = KEY_NOTIFICATIONS + ":zen_rules"; @BackupRestoreEventLogger.BackupRestoreError public static final String ERROR_XML_PARSING = KEY_NOTIFICATIONS + ":invalid_xml_parsing"; } core/java/android/service/notification/ZenModeConfig.java +25 −5 Original line number Diff line number Diff line Loading @@ -24,12 +24,12 @@ import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCRE import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_OFF; import static android.app.backup.NotificationLoggingConstants.DATA_TYPE_ZEN_RULES; import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; import static android.service.notification.SystemZenRules.PACKAGE_ANDROID; import static android.service.notification.ZenAdapters.peopleTypeToPrioritySenders; import static android.service.notification.ZenAdapters.prioritySendersToPeopleType; import static android.service.notification.ZenAdapters.zenPolicyConversationSendersToNotificationPolicy; import static android.service.notification.ZenModeConfig.EventInfo.REPLY_YES_OR_MAYBE; import static android.service.notification.ZenPolicy.PEOPLE_TYPE_STARRED; import static android.service.notification.ZenPolicy.PRIORITY_CATEGORY_ALARMS; import static android.service.notification.ZenPolicy.PRIORITY_CATEGORY_CALLS; Loading @@ -56,6 +56,7 @@ import android.app.AutomaticZenRule; import android.app.Flags; import android.app.NotificationManager; import android.app.NotificationManager.Policy; import android.app.backup.BackupRestoreEventLogger; import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; import android.content.Context; Loading Loading @@ -957,8 +958,9 @@ public class ZenModeConfig implements Parcelable { } } public static ZenModeConfig readXml(TypedXmlPullParser parser) throws XmlPullParserException, IOException { public static ZenModeConfig readXml(TypedXmlPullParser parser, @Nullable BackupRestoreEventLogger logger) throws XmlPullParserException, IOException { int readRuleCount = 0; int type = parser.getEventType(); if (type != XmlPullParser.START_TAG) return null; String tag = parser.getName(); Loading Loading @@ -1048,6 +1050,8 @@ public class ZenModeConfig implements Parcelable { readManualRule = true; if (rt.manualRule.zenPolicy == null) { readManualRuleWithoutPolicy = true; } else { readRuleCount++; } } else if (AUTOMATIC_TAG.equals(tag) || (Flags.modesApi() && AUTOMATIC_DELETED_TAG.equals(tag))) { Loading @@ -1062,6 +1066,7 @@ public class ZenModeConfig implements Parcelable { } } else if (AUTOMATIC_TAG.equals(tag)) { rt.automaticRules.put(id, automaticRule); readRuleCount++; } } } else if (STATE_TAG.equals(tag)) { Loading @@ -1085,7 +1090,16 @@ public class ZenModeConfig implements Parcelable { } rt.manualRule.condition = new Condition(rt.manualRule.conditionId, "", Condition.STATE_TRUE); readRuleCount++; } } if (!Flags.modesUi()){ readRuleCount++; } if (logger != null) { logger.logItemsRestored(DATA_TYPE_ZEN_RULES, readRuleCount); } return rt; } Loading @@ -1110,8 +1124,9 @@ public class ZenModeConfig implements Parcelable { * @throws IOException */ public void writeXml(TypedXmlSerializer out, Integer version, boolean forBackup) throws IOException { public void writeXml(TypedXmlSerializer out, Integer version, boolean forBackup, @Nullable BackupRestoreEventLogger logger) throws IOException { int writtenRuleCount = 0; int xmlVersion = getCurrentXmlVersion(); out.startTag(null, ZEN_TAG); out.attribute(null, ZEN_ATT_VERSION, version == null Loading Loading @@ -1147,6 +1162,7 @@ public class ZenModeConfig implements Parcelable { writeRuleXml(manualRule, out, forBackup); out.endTag(null, MANUAL_TAG); } writtenRuleCount++; final int N = automaticRules.size(); for (int i = 0; i < N; i++) { final String id = automaticRules.keyAt(i); Loading @@ -1155,6 +1171,7 @@ public class ZenModeConfig implements Parcelable { out.attribute(null, RULE_ATT_ID, id); writeRuleXml(automaticRule, out, forBackup); out.endTag(null, AUTOMATIC_TAG); writtenRuleCount++; } if (Flags.modesApi() && !forBackup) { for (int i = 0; i < deletedRules.size(); i++) { Loading @@ -1171,6 +1188,9 @@ public class ZenModeConfig implements Parcelable { out.endTag(null, STATE_TAG); out.endTag(null, ZEN_TAG); if (logger != null) { logger.logItemsBackedUp(DATA_TYPE_ZEN_RULES, writtenRuleCount); } } @NonNull Loading services/core/java/com/android/server/notification/NotificationBackupHelper.java +2 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.notification; import static android.app.backup.NotificationLoggingConstants.KEY_NOTIFICATIONS; import android.app.INotificationManager; import android.app.backup.BlobBackupHelper; import android.os.ServiceManager; Loading @@ -31,9 +33,6 @@ public class NotificationBackupHelper extends BlobBackupHelper { // Current version of the blob schema static final int BLOB_VERSION = 1; // Key under which the payload blob is stored static final String KEY_NOTIFICATIONS = "notifications"; private final int mUserId; private final NotificationManagerInternal mNm; Loading services/core/java/com/android/server/notification/NotificationManagerService.java +26 −4 Original line number Diff line number Diff line Loading @@ -161,6 +161,8 @@ import static com.android.internal.util.Preconditions.checkNotNull; import static com.android.server.am.PendingIntentRecord.FLAG_ACTIVITY_SENDER; import static com.android.server.am.PendingIntentRecord.FLAG_BROADCAST_SENDER; import static com.android.server.am.PendingIntentRecord.FLAG_SERVICE_SENDER; import static android.app.backup.NotificationLoggingConstants.DATA_TYPE_ZEN_CONFIG; import static android.app.backup.NotificationLoggingConstants.ERROR_XML_PARSING; import static com.android.server.notification.Flags.expireBitmaps; import static com.android.server.policy.PhoneWindowManager.TOAST_WINDOW_ANIM_BUFFER; import static com.android.server.policy.PhoneWindowManager.TOAST_WINDOW_TIMEOUT; Loading Loading @@ -1098,7 +1100,7 @@ public class NotificationManagerService extends SystemService { } void readPolicyXml(InputStream stream, boolean forRestore, int userId, BackupRestoreEventLogger logger) @Nullable BackupRestoreEventLogger logger) throws XmlPullParserException, NumberFormatException, IOException { final TypedXmlPullParser parser; if (forRestore) { Loading @@ -1114,7 +1116,27 @@ public class NotificationManagerService extends SystemService { int outerDepth = parser.getDepth(); while (XmlUtils.nextElementWithin(parser, outerDepth)) { if (ZenModeConfig.ZEN_TAG.equals(parser.getName())) { mZenModeHelper.readXml(parser, forRestore, userId); int successfulReads = 0; int unsuccessfulReads = 0; try { boolean loadedCorrectly = mZenModeHelper.readXml(parser, forRestore, userId, logger); if (loadedCorrectly) successfulReads++; else unsuccessfulReads++; } catch (Exception e) { Slog.wtf(TAG, "failed to read config", e); unsuccessfulReads++; } if (logger != null) { logger.logItemsRestored(DATA_TYPE_ZEN_CONFIG, successfulReads); if (unsuccessfulReads > 0) { logger.logItemsRestoreFailed( DATA_TYPE_ZEN_CONFIG, unsuccessfulReads, ERROR_XML_PARSING); } } } else if (PreferencesHelper.TAG_RANKING.equals(parser.getName())){ mPreferencesHelper.readXml(parser, forRestore, userId); } Loading Loading @@ -1246,7 +1268,7 @@ public class NotificationManagerService extends SystemService { } } private void writePolicyXml(OutputStream stream, boolean forBackup, int userId, void writePolicyXml(OutputStream stream, boolean forBackup, int userId, BackupRestoreEventLogger logger) throws IOException { final TypedXmlSerializer out; if (forBackup) { Loading @@ -1258,7 +1280,7 @@ public class NotificationManagerService extends SystemService { out.startDocument(null, true); out.startTag(null, TAG_NOTIFICATION_POLICY); out.attributeInt(null, ATTR_VERSION, DB_VERSION); mZenModeHelper.writeXml(out, forBackup, null, userId); mZenModeHelper.writeXml(out, forBackup, null, userId, logger); mPreferencesHelper.writeXml(out, forBackup, userId); mListeners.writeXml(out, forBackup, userId); mAssistants.writeXml(out, forBackup, userId); Loading services/core/java/com/android/server/notification/ZenModeHelper.java +28 −9 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ import static android.service.notification.ZenModeConfig.implicitRuleId; import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE; import static com.android.internal.util.Preconditions.checkArgument; import static android.app.backup.NotificationLoggingConstants.DATA_TYPE_ZEN_CONFIG; import static android.app.backup.NotificationLoggingConstants.ERROR_XML_PARSING; import static java.util.Objects.requireNonNull; Loading @@ -56,6 +58,7 @@ import android.app.AutomaticZenRule; import android.app.Flags; import android.app.NotificationManager; import android.app.NotificationManager.Policy; import android.app.backup.BackupRestoreEventLogger; import android.app.compat.CompatChanges; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; Loading Loading @@ -1759,11 +1762,10 @@ public class ZenModeHelper { pw.println(config); } public void readXml(TypedXmlPullParser parser, boolean forRestore, int userId) throws XmlPullParserException, IOException { ZenModeConfig config = ZenModeConfig.readXml(parser); public boolean readXml(TypedXmlPullParser parser, boolean forRestore, int userId, @Nullable BackupRestoreEventLogger logger) throws XmlPullParserException, IOException { ZenModeConfig config = ZenModeConfig.readXml(parser, logger); String reason = "readXml"; if (config != null) { if (forRestore) { config.user = userId; Loading Loading @@ -1855,22 +1857,38 @@ public class ZenModeHelper { if (DEBUG) Log.d(TAG, reason); synchronized (mConfigLock) { setConfigLocked(config, null, return setConfigLocked(config, null, forRestore ? ORIGIN_RESTORE_BACKUP : ORIGIN_INIT, reason, Process.SYSTEM_UID); } } return false; } public void writeXml(TypedXmlSerializer out, boolean forBackup, Integer version, int userId) throws IOException { public void writeXml(TypedXmlSerializer out, boolean forBackup, Integer version, int userId, @Nullable BackupRestoreEventLogger logger) throws IOException { synchronized (mConfigLock) { int successfulWrites = 0; int unsuccessfulWrites = 0; final int n = mConfigs.size(); for (int i = 0; i < n; i++) { if (forBackup && mConfigs.keyAt(i) != userId) { continue; } mConfigs.valueAt(i).writeXml(out, version, forBackup); try { mConfigs.valueAt(i).writeXml(out, version, forBackup, logger); successfulWrites++; } catch (Exception e) { Slog.e(TAG, "failed to write config", e); unsuccessfulWrites++; } } if (logger != null) { logger.logItemsBackedUp(DATA_TYPE_ZEN_CONFIG, successfulWrites); if (unsuccessfulWrites > 0) { logger.logItemsBackupFailed(DATA_TYPE_ZEN_CONFIG, unsuccessfulWrites, ERROR_XML_PARSING); } } } } Loading Loading @@ -2501,7 +2519,8 @@ public class ZenModeHelper { try { parser = resources.getXml(R.xml.default_zen_mode_config); while (parser.next() != XmlPullParser.END_DOCUMENT) { final ZenModeConfig config = ZenModeConfig.readXml(XmlUtils.makeTyped(parser)); final ZenModeConfig config = ZenModeConfig.readXml(XmlUtils.makeTyped(parser), null); if (config != null) return config; } } catch (Exception e) { Loading Loading
core/java/android/app/backup/NotificationLoggingConstants.java 0 → 100644 +33 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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. */ package android.app.backup; /** * @hide */ public class NotificationLoggingConstants { // Key under which the payload blob is stored public static final String KEY_NOTIFICATIONS = "notifications"; @BackupRestoreEventLogger.BackupRestoreDataType public static final String DATA_TYPE_ZEN_CONFIG = KEY_NOTIFICATIONS + ":zen_config"; @BackupRestoreEventLogger.BackupRestoreDataType public static final String DATA_TYPE_ZEN_RULES = KEY_NOTIFICATIONS + ":zen_rules"; @BackupRestoreEventLogger.BackupRestoreError public static final String ERROR_XML_PARSING = KEY_NOTIFICATIONS + ":invalid_xml_parsing"; }
core/java/android/service/notification/ZenModeConfig.java +25 −5 Original line number Diff line number Diff line Loading @@ -24,12 +24,12 @@ import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCRE import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_OFF; import static android.app.backup.NotificationLoggingConstants.DATA_TYPE_ZEN_RULES; import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; import static android.service.notification.SystemZenRules.PACKAGE_ANDROID; import static android.service.notification.ZenAdapters.peopleTypeToPrioritySenders; import static android.service.notification.ZenAdapters.prioritySendersToPeopleType; import static android.service.notification.ZenAdapters.zenPolicyConversationSendersToNotificationPolicy; import static android.service.notification.ZenModeConfig.EventInfo.REPLY_YES_OR_MAYBE; import static android.service.notification.ZenPolicy.PEOPLE_TYPE_STARRED; import static android.service.notification.ZenPolicy.PRIORITY_CATEGORY_ALARMS; import static android.service.notification.ZenPolicy.PRIORITY_CATEGORY_CALLS; Loading @@ -56,6 +56,7 @@ import android.app.AutomaticZenRule; import android.app.Flags; import android.app.NotificationManager; import android.app.NotificationManager.Policy; import android.app.backup.BackupRestoreEventLogger; import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; import android.content.Context; Loading Loading @@ -957,8 +958,9 @@ public class ZenModeConfig implements Parcelable { } } public static ZenModeConfig readXml(TypedXmlPullParser parser) throws XmlPullParserException, IOException { public static ZenModeConfig readXml(TypedXmlPullParser parser, @Nullable BackupRestoreEventLogger logger) throws XmlPullParserException, IOException { int readRuleCount = 0; int type = parser.getEventType(); if (type != XmlPullParser.START_TAG) return null; String tag = parser.getName(); Loading Loading @@ -1048,6 +1050,8 @@ public class ZenModeConfig implements Parcelable { readManualRule = true; if (rt.manualRule.zenPolicy == null) { readManualRuleWithoutPolicy = true; } else { readRuleCount++; } } else if (AUTOMATIC_TAG.equals(tag) || (Flags.modesApi() && AUTOMATIC_DELETED_TAG.equals(tag))) { Loading @@ -1062,6 +1066,7 @@ public class ZenModeConfig implements Parcelable { } } else if (AUTOMATIC_TAG.equals(tag)) { rt.automaticRules.put(id, automaticRule); readRuleCount++; } } } else if (STATE_TAG.equals(tag)) { Loading @@ -1085,7 +1090,16 @@ public class ZenModeConfig implements Parcelable { } rt.manualRule.condition = new Condition(rt.manualRule.conditionId, "", Condition.STATE_TRUE); readRuleCount++; } } if (!Flags.modesUi()){ readRuleCount++; } if (logger != null) { logger.logItemsRestored(DATA_TYPE_ZEN_RULES, readRuleCount); } return rt; } Loading @@ -1110,8 +1124,9 @@ public class ZenModeConfig implements Parcelable { * @throws IOException */ public void writeXml(TypedXmlSerializer out, Integer version, boolean forBackup) throws IOException { public void writeXml(TypedXmlSerializer out, Integer version, boolean forBackup, @Nullable BackupRestoreEventLogger logger) throws IOException { int writtenRuleCount = 0; int xmlVersion = getCurrentXmlVersion(); out.startTag(null, ZEN_TAG); out.attribute(null, ZEN_ATT_VERSION, version == null Loading Loading @@ -1147,6 +1162,7 @@ public class ZenModeConfig implements Parcelable { writeRuleXml(manualRule, out, forBackup); out.endTag(null, MANUAL_TAG); } writtenRuleCount++; final int N = automaticRules.size(); for (int i = 0; i < N; i++) { final String id = automaticRules.keyAt(i); Loading @@ -1155,6 +1171,7 @@ public class ZenModeConfig implements Parcelable { out.attribute(null, RULE_ATT_ID, id); writeRuleXml(automaticRule, out, forBackup); out.endTag(null, AUTOMATIC_TAG); writtenRuleCount++; } if (Flags.modesApi() && !forBackup) { for (int i = 0; i < deletedRules.size(); i++) { Loading @@ -1171,6 +1188,9 @@ public class ZenModeConfig implements Parcelable { out.endTag(null, STATE_TAG); out.endTag(null, ZEN_TAG); if (logger != null) { logger.logItemsBackedUp(DATA_TYPE_ZEN_RULES, writtenRuleCount); } } @NonNull Loading
services/core/java/com/android/server/notification/NotificationBackupHelper.java +2 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.notification; import static android.app.backup.NotificationLoggingConstants.KEY_NOTIFICATIONS; import android.app.INotificationManager; import android.app.backup.BlobBackupHelper; import android.os.ServiceManager; Loading @@ -31,9 +33,6 @@ public class NotificationBackupHelper extends BlobBackupHelper { // Current version of the blob schema static final int BLOB_VERSION = 1; // Key under which the payload blob is stored static final String KEY_NOTIFICATIONS = "notifications"; private final int mUserId; private final NotificationManagerInternal mNm; Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +26 −4 Original line number Diff line number Diff line Loading @@ -161,6 +161,8 @@ import static com.android.internal.util.Preconditions.checkNotNull; import static com.android.server.am.PendingIntentRecord.FLAG_ACTIVITY_SENDER; import static com.android.server.am.PendingIntentRecord.FLAG_BROADCAST_SENDER; import static com.android.server.am.PendingIntentRecord.FLAG_SERVICE_SENDER; import static android.app.backup.NotificationLoggingConstants.DATA_TYPE_ZEN_CONFIG; import static android.app.backup.NotificationLoggingConstants.ERROR_XML_PARSING; import static com.android.server.notification.Flags.expireBitmaps; import static com.android.server.policy.PhoneWindowManager.TOAST_WINDOW_ANIM_BUFFER; import static com.android.server.policy.PhoneWindowManager.TOAST_WINDOW_TIMEOUT; Loading Loading @@ -1098,7 +1100,7 @@ public class NotificationManagerService extends SystemService { } void readPolicyXml(InputStream stream, boolean forRestore, int userId, BackupRestoreEventLogger logger) @Nullable BackupRestoreEventLogger logger) throws XmlPullParserException, NumberFormatException, IOException { final TypedXmlPullParser parser; if (forRestore) { Loading @@ -1114,7 +1116,27 @@ public class NotificationManagerService extends SystemService { int outerDepth = parser.getDepth(); while (XmlUtils.nextElementWithin(parser, outerDepth)) { if (ZenModeConfig.ZEN_TAG.equals(parser.getName())) { mZenModeHelper.readXml(parser, forRestore, userId); int successfulReads = 0; int unsuccessfulReads = 0; try { boolean loadedCorrectly = mZenModeHelper.readXml(parser, forRestore, userId, logger); if (loadedCorrectly) successfulReads++; else unsuccessfulReads++; } catch (Exception e) { Slog.wtf(TAG, "failed to read config", e); unsuccessfulReads++; } if (logger != null) { logger.logItemsRestored(DATA_TYPE_ZEN_CONFIG, successfulReads); if (unsuccessfulReads > 0) { logger.logItemsRestoreFailed( DATA_TYPE_ZEN_CONFIG, unsuccessfulReads, ERROR_XML_PARSING); } } } else if (PreferencesHelper.TAG_RANKING.equals(parser.getName())){ mPreferencesHelper.readXml(parser, forRestore, userId); } Loading Loading @@ -1246,7 +1268,7 @@ public class NotificationManagerService extends SystemService { } } private void writePolicyXml(OutputStream stream, boolean forBackup, int userId, void writePolicyXml(OutputStream stream, boolean forBackup, int userId, BackupRestoreEventLogger logger) throws IOException { final TypedXmlSerializer out; if (forBackup) { Loading @@ -1258,7 +1280,7 @@ public class NotificationManagerService extends SystemService { out.startDocument(null, true); out.startTag(null, TAG_NOTIFICATION_POLICY); out.attributeInt(null, ATTR_VERSION, DB_VERSION); mZenModeHelper.writeXml(out, forBackup, null, userId); mZenModeHelper.writeXml(out, forBackup, null, userId, logger); mPreferencesHelper.writeXml(out, forBackup, userId); mListeners.writeXml(out, forBackup, userId); mAssistants.writeXml(out, forBackup, userId); Loading
services/core/java/com/android/server/notification/ZenModeHelper.java +28 −9 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ import static android.service.notification.ZenModeConfig.implicitRuleId; import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE; import static com.android.internal.util.Preconditions.checkArgument; import static android.app.backup.NotificationLoggingConstants.DATA_TYPE_ZEN_CONFIG; import static android.app.backup.NotificationLoggingConstants.ERROR_XML_PARSING; import static java.util.Objects.requireNonNull; Loading @@ -56,6 +58,7 @@ import android.app.AutomaticZenRule; import android.app.Flags; import android.app.NotificationManager; import android.app.NotificationManager.Policy; import android.app.backup.BackupRestoreEventLogger; import android.app.compat.CompatChanges; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; Loading Loading @@ -1759,11 +1762,10 @@ public class ZenModeHelper { pw.println(config); } public void readXml(TypedXmlPullParser parser, boolean forRestore, int userId) throws XmlPullParserException, IOException { ZenModeConfig config = ZenModeConfig.readXml(parser); public boolean readXml(TypedXmlPullParser parser, boolean forRestore, int userId, @Nullable BackupRestoreEventLogger logger) throws XmlPullParserException, IOException { ZenModeConfig config = ZenModeConfig.readXml(parser, logger); String reason = "readXml"; if (config != null) { if (forRestore) { config.user = userId; Loading Loading @@ -1855,22 +1857,38 @@ public class ZenModeHelper { if (DEBUG) Log.d(TAG, reason); synchronized (mConfigLock) { setConfigLocked(config, null, return setConfigLocked(config, null, forRestore ? ORIGIN_RESTORE_BACKUP : ORIGIN_INIT, reason, Process.SYSTEM_UID); } } return false; } public void writeXml(TypedXmlSerializer out, boolean forBackup, Integer version, int userId) throws IOException { public void writeXml(TypedXmlSerializer out, boolean forBackup, Integer version, int userId, @Nullable BackupRestoreEventLogger logger) throws IOException { synchronized (mConfigLock) { int successfulWrites = 0; int unsuccessfulWrites = 0; final int n = mConfigs.size(); for (int i = 0; i < n; i++) { if (forBackup && mConfigs.keyAt(i) != userId) { continue; } mConfigs.valueAt(i).writeXml(out, version, forBackup); try { mConfigs.valueAt(i).writeXml(out, version, forBackup, logger); successfulWrites++; } catch (Exception e) { Slog.e(TAG, "failed to write config", e); unsuccessfulWrites++; } } if (logger != null) { logger.logItemsBackedUp(DATA_TYPE_ZEN_CONFIG, successfulWrites); if (unsuccessfulWrites > 0) { logger.logItemsBackupFailed(DATA_TYPE_ZEN_CONFIG, unsuccessfulWrites, ERROR_XML_PARSING); } } } } Loading Loading @@ -2501,7 +2519,8 @@ public class ZenModeHelper { try { parser = resources.getXml(R.xml.default_zen_mode_config); while (parser.next() != XmlPullParser.END_DOCUMENT) { final ZenModeConfig config = ZenModeConfig.readXml(XmlUtils.makeTyped(parser)); final ZenModeConfig config = ZenModeConfig.readXml(XmlUtils.makeTyped(parser), null); if (config != null) return config; } } catch (Exception e) { Loading