Merge "[NotificationManagerService]: Fixes the thread-safe issue."

This commit is contained in:
Treehugger Robot
2017-02-14 14:23:18 +00:00
committed by Gerrit Code Review

View File

@@ -2078,6 +2078,7 @@ public class NotificationManagerService extends SystemService {
Slog.w(TAG, "getBackupPayload: cannot backup policy for user " + user); Slog.w(TAG, "getBackupPayload: cannot backup policy for user " + user);
return null; return null;
} }
synchronized(mPolicyFile) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try { try {
writePolicyXml(baos, true /*forBackup*/); writePolicyXml(baos, true /*forBackup*/);
@@ -2085,6 +2086,7 @@ public class NotificationManagerService extends SystemService {
} catch (IOException e) { } catch (IOException e) {
Slog.w(TAG, "getBackupPayload: error writing payload for user " + user, e); Slog.w(TAG, "getBackupPayload: error writing payload for user " + user, e);
} }
}
return null; return null;
} }
@@ -2101,6 +2103,7 @@ public class NotificationManagerService extends SystemService {
Slog.w(TAG, "applyRestore: cannot restore policy for user " + user); Slog.w(TAG, "applyRestore: cannot restore policy for user " + user);
return; return;
} }
synchronized(mPolicyFile) {
final ByteArrayInputStream bais = new ByteArrayInputStream(payload); final ByteArrayInputStream bais = new ByteArrayInputStream(payload);
try { try {
readPolicyXml(bais, true /*forRestore*/); readPolicyXml(bais, true /*forRestore*/);
@@ -2109,6 +2112,7 @@ public class NotificationManagerService extends SystemService {
Slog.w(TAG, "applyRestore: error reading payload", e); Slog.w(TAG, "applyRestore: error reading payload", e);
} }
} }
}
@Override @Override
public boolean isNotificationPolicyAccessGranted(String pkg) { public boolean isNotificationPolicyAccessGranted(String pkg) {