Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +10 −0 Original line number Diff line number Diff line Loading @@ -222,11 +222,21 @@ public class NotificationData { for (AsyncTask task : mRunningTasks) { task.cancel(true /* mayInterruptIfRunning */); } mRunningTasks.clear(); } public void addInflationTask(AsyncTask asyncInflationTask) { mRunningTasks.add(asyncInflationTask); } public void onInflationTaskFinished(AsyncTask asyncInflationTask) { mRunningTasks.remove(asyncInflationTask); } @VisibleForTesting public ArraySet<AsyncTask> getRunningTasks() { return mRunningTasks; } } private final ArrayMap<String, Entry> mEntries = new ArrayMap<>(); Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java +1 −0 Original line number Diff line number Diff line Loading @@ -325,6 +325,7 @@ public class NotificationInflater { @Override protected void onPostExecute(Notification.Builder builder) { mRow.getEntry().onInflationTaskFinished(this); if (mError == null) { finishInflation(mReInflateFlags, builder, mPackageContext); } else { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java +9 −1 Original line number Diff line number Diff line Loading @@ -115,13 +115,21 @@ public class NotificationInflaterTest { public void testInflationThrowsErrorDoesntCallUpdated() throws Exception { mRow.getPrivateLayout().removeAllViews(); mRow.getStatusBarNotification().getNotification().contentView = new RemoteViews(mContext.getPackageName(), R.layout.status_bar);; = new RemoteViews(mContext.getPackageName(), R.layout.status_bar); runThenWaitForInflation(() -> mNotificationInflater.inflateNotificationViews(), true /* expectingException */, mNotificationInflater); Assert.assertTrue(mRow.getPrivateLayout().getChildCount() == 0); verify(mRow, times(0)).onNotificationUpdated(); } @Test public void testAsyncTaskRemoved() throws Exception { mRow.getEntry().abortInflation(); runThenWaitForInflation(() -> mNotificationInflater.inflateNotificationViews(), mNotificationInflater); Assert.assertTrue(mRow.getEntry().getRunningTasks().size() == 0); } public static void runThenWaitForInflation(Runnable block, NotificationInflater inflater) throws Exception { runThenWaitForInflation(block, false /* expectingException */, inflater); Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +10 −0 Original line number Diff line number Diff line Loading @@ -222,11 +222,21 @@ public class NotificationData { for (AsyncTask task : mRunningTasks) { task.cancel(true /* mayInterruptIfRunning */); } mRunningTasks.clear(); } public void addInflationTask(AsyncTask asyncInflationTask) { mRunningTasks.add(asyncInflationTask); } public void onInflationTaskFinished(AsyncTask asyncInflationTask) { mRunningTasks.remove(asyncInflationTask); } @VisibleForTesting public ArraySet<AsyncTask> getRunningTasks() { return mRunningTasks; } } private final ArrayMap<String, Entry> mEntries = new ArrayMap<>(); Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java +1 −0 Original line number Diff line number Diff line Loading @@ -325,6 +325,7 @@ public class NotificationInflater { @Override protected void onPostExecute(Notification.Builder builder) { mRow.getEntry().onInflationTaskFinished(this); if (mError == null) { finishInflation(mReInflateFlags, builder, mPackageContext); } else { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java +9 −1 Original line number Diff line number Diff line Loading @@ -115,13 +115,21 @@ public class NotificationInflaterTest { public void testInflationThrowsErrorDoesntCallUpdated() throws Exception { mRow.getPrivateLayout().removeAllViews(); mRow.getStatusBarNotification().getNotification().contentView = new RemoteViews(mContext.getPackageName(), R.layout.status_bar);; = new RemoteViews(mContext.getPackageName(), R.layout.status_bar); runThenWaitForInflation(() -> mNotificationInflater.inflateNotificationViews(), true /* expectingException */, mNotificationInflater); Assert.assertTrue(mRow.getPrivateLayout().getChildCount() == 0); verify(mRow, times(0)).onNotificationUpdated(); } @Test public void testAsyncTaskRemoved() throws Exception { mRow.getEntry().abortInflation(); runThenWaitForInflation(() -> mNotificationInflater.inflateNotificationViews(), mNotificationInflater); Assert.assertTrue(mRow.getEntry().getRunningTasks().size() == 0); } public static void runThenWaitForInflation(Runnable block, NotificationInflater inflater) throws Exception { runThenWaitForInflation(block, false /* expectingException */, inflater); Loading