Merge "Persist pending notification history on shutdown" into rvc-dev am: f460a9cd1f
Change-Id: I0eca0f1485a59c39f8a804550d44db56155cdfa5
This commit is contained in:
@@ -87,4 +87,6 @@ public interface NotificationDelegate {
|
||||
*/
|
||||
void onNotificationSmartReplySent(String key, int clickedIndex, CharSequence reply,
|
||||
int notificationLocation, boolean modifiedBeforeSending);
|
||||
|
||||
void prepareForPossibleShutdown();
|
||||
}
|
||||
|
||||
@@ -157,9 +157,7 @@ public class NotificationHistoryDatabase {
|
||||
}
|
||||
|
||||
public void forceWriteToDisk() {
|
||||
if (!mFileWriteHandler.hasCallbacks(mWriteBufferRunnable)) {
|
||||
mFileWriteHandler.post(mWriteBufferRunnable);
|
||||
}
|
||||
mFileWriteHandler.post(mWriteBufferRunnable);
|
||||
}
|
||||
|
||||
public void onPackageRemoved(String packageName) {
|
||||
|
||||
@@ -181,7 +181,6 @@ public class NotificationHistoryManager {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: wire this up to AMS when power button is long pressed
|
||||
public void triggerWriteToDisk() {
|
||||
synchronized (mLock) {
|
||||
final int userCount = mUserState.size();
|
||||
|
||||
@@ -875,6 +875,11 @@ public class NotificationManagerService extends SystemService {
|
||||
@VisibleForTesting
|
||||
final NotificationDelegate mNotificationDelegate = new NotificationDelegate() {
|
||||
|
||||
@Override
|
||||
public void prepareForPossibleShutdown() {
|
||||
mHistoryManager.triggerWriteToDisk();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetDisabled(int status) {
|
||||
synchronized (mNotificationLock) {
|
||||
|
||||
@@ -1169,6 +1169,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
||||
enforceStatusBarService();
|
||||
long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
mNotificationDelegate.prepareForPossibleShutdown();
|
||||
// ShutdownThread displays UI, so give it a UI context.
|
||||
mHandler.post(() ->
|
||||
ShutdownThread.shutdown(getUiContext(),
|
||||
@@ -1186,6 +1187,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
||||
enforceStatusBarService();
|
||||
long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
mNotificationDelegate.prepareForPossibleShutdown();
|
||||
mHandler.post(() -> {
|
||||
// ShutdownThread displays UI, so give it a UI context.
|
||||
if (safeMode) {
|
||||
|
||||
@@ -162,10 +162,10 @@ public class NotificationHistoryDatabaseTest extends UiServiceTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnlyOneWriteRunnableInQueue() {
|
||||
public void testForceWriteToDisk_bypassesExistingWrites() {
|
||||
when(mFileWriteHandler.hasCallbacks(any())).thenReturn(true);
|
||||
mDataBase.forceWriteToDisk();
|
||||
verify(mFileWriteHandler, never()).post(any());
|
||||
verify(mFileWriteHandler, times(1)).post(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user