Notification history should always be accessed as uid 1000

So the files can be created and read

Test: manual
Fixes: 154823101
Change-Id: I296ef19463f253daacfb9bdaa81c020c9b8bcfe4
This commit is contained in:
Julia Reynolds
2020-04-23 12:53:35 -04:00
parent eab14fca5d
commit 037653b7d3
2 changed files with 16 additions and 10 deletions

View File

@@ -108,7 +108,9 @@ public class NotificationHistoryDatabase {
public void init() {
synchronized (mLock) {
try {
mHistoryDir.mkdir();
if (!mHistoryDir.mkdir()) {
throw new IllegalStateException("could not create history directory");
}
mVersionFile.createNewFile();
} catch (Exception e) {
Slog.e(TAG, "could not create needed files", e);

View File

@@ -26,6 +26,7 @@ import android.content.Context;
import android.content.pm.UserInfo;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Binder;
import android.os.Environment;
import android.os.Handler;
import android.os.UserHandle;
@@ -37,6 +38,7 @@ import android.util.SparseBooleanArray;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.FunctionalUtils;
import com.android.server.IoThread;
import java.io.File;
@@ -198,16 +200,18 @@ public class NotificationHistoryManager {
}
public void addNotification(@NonNull final HistoricalNotification notification) {
synchronized (mLock) {
final NotificationHistoryDatabase userHistory =
getUserHistoryAndInitializeIfNeededLocked(notification.getUserId());
if (userHistory == null) {
Slog.w(TAG, "Attempted to add notif for locked/gone/disabled user "
+ notification.getUserId());
return;
Binder.withCleanCallingIdentity(() -> {
synchronized (mLock) {
final NotificationHistoryDatabase userHistory =
getUserHistoryAndInitializeIfNeededLocked(notification.getUserId());
if (userHistory == null) {
Slog.w(TAG, "Attempted to add notif for locked/gone/disabled user "
+ notification.getUserId());
return;
}
userHistory.addNotification(notification);
}
userHistory.addNotification(notification);
}
});
}
public @NonNull NotificationHistory readNotificationHistory(@UserIdInt int[] userIds) {