summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author songjinshi <songjinshi@xiaomi.com> 2017-02-14 14:34:13 +0000
committer android-build-merger <android-build-merger@google.com> 2017-02-14 14:34:13 +0000
commitd0e81464bd3f89ccc917a38ffc894331d55bc2bc (patch)
tree4906d8a3231762aefec405232796cd2cd54b0ef0
parent8055dafb08c53bc23d4bdf9d43b35e3d89c28c3d (diff)
parentf69a73793ddb04a858c4ec05bebff9a8f37b29c6 (diff)
Merge "[NotificationManagerService]: Fixes the thread-safe issue." am: d530d1bf18
am: f69a73793d Change-Id: Ifcce0699f9434cf490f9b4b596ba7604208275c6
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java28
1 files changed, 16 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index d31c7b54cee5..22c5e853819f 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -2078,12 +2078,14 @@ public class NotificationManagerService extends SystemService {
Slog.w(TAG, "getBackupPayload: cannot backup policy for user " + user);
return null;
}
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- writePolicyXml(baos, true /*forBackup*/);
- return baos.toByteArray();
- } catch (IOException e) {
- Slog.w(TAG, "getBackupPayload: error writing payload for user " + user, e);
+ synchronized(mPolicyFile) {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ writePolicyXml(baos, true /*forBackup*/);
+ return baos.toByteArray();
+ } catch (IOException e) {
+ Slog.w(TAG, "getBackupPayload: error writing payload for user " + user, e);
+ }
}
return null;
}
@@ -2101,12 +2103,14 @@ public class NotificationManagerService extends SystemService {
Slog.w(TAG, "applyRestore: cannot restore policy for user " + user);
return;
}
- final ByteArrayInputStream bais = new ByteArrayInputStream(payload);
- try {
- readPolicyXml(bais, true /*forRestore*/);
- savePolicyFile();
- } catch (NumberFormatException | XmlPullParserException | IOException e) {
- Slog.w(TAG, "applyRestore: error reading payload", e);
+ synchronized(mPolicyFile) {
+ final ByteArrayInputStream bais = new ByteArrayInputStream(payload);
+ try {
+ readPolicyXml(bais, true /*forRestore*/);
+ savePolicyFile();
+ } catch (NumberFormatException | XmlPullParserException | IOException e) {
+ Slog.w(TAG, "applyRestore: error reading payload", e);
+ }
}
}