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

am: d530d1bf18

Change-Id: I661207bb52d84b1928d7ff3ad262cfe89e71e60b
This commit is contained in:
songjinshi
2017-02-14 14:29:36 +00:00
committed by android-build-merger

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) {