Loading core/java/android/app/Notification.java +19 −5 Original line number Diff line number Diff line Loading @@ -11815,28 +11815,42 @@ public class Notification implements Parcelable sanitizeProgressColor(indeterminateColor, backgroundColor, defaultProgressColor)); } else { // Ensure segment color contrasts. final List<Segment> segments = new ArrayList<>(); int totalLength = 0; for (Segment segment : mProgressSegments) { final int length = segment.getLength(); if (length <= 0) continue; try { totalLength += Math.addExact(totalLength, length); segments.add(sanitizeSegment(segment, backgroundColor, defaultProgressColor)); } catch (ArithmeticException e) { totalLength = DEFAULT_PROGRESS_MAX; segments.clear(); break; } } // Create default segment when no segments are provided. if (segments.isEmpty()) { segments.add(sanitizeSegment(new Segment(100), backgroundColor, totalLength = DEFAULT_PROGRESS_MAX; segments.add(sanitizeSegment(new Segment(totalLength), backgroundColor, defaultProgressColor)); } // Ensure point color contrasts. final List<Point> points = new ArrayList<>(); for (Point point : mProgressPoints) { final int position = point.getPosition(); if (position < 0 || position > totalLength) continue; points.add(sanitizePoint(point, backgroundColor, defaultProgressColor)); } model = new NotificationProgressModel(segments, points, mProgress, mIsStyledByProgress); Math.clamp(mProgress, 0, totalLength), mIsStyledByProgress); } return model; } Loading core/java/com/android/internal/widget/NotificationProgressBar.java +1 −1 Original line number Diff line number Diff line Loading @@ -453,7 +453,7 @@ public final class NotificationProgressBar extends ProgressBar { } for (ProgressStyle.Point point : points) { final int pos = point.getPosition(); if (pos <= 0 || pos >= progressMax) { if (pos < 0 || pos > progressMax) { throw new IllegalArgumentException("Invalid Point position : " + pos); } } Loading core/tests/coretests/src/com/android/internal/widget/NotificationProgressBarTest.java +0 −30 Original line number Diff line number Diff line Loading @@ -171,36 +171,6 @@ public class NotificationProgressBarTest { isStyledByProgress); } @Test(expected = IllegalArgumentException.class) public void processAndConvertToDrawableParts_pointPositionIsZero() { List<ProgressStyle.Segment> segments = new ArrayList<>(); segments.add(new ProgressStyle.Segment(100)); List<ProgressStyle.Point> points = new ArrayList<>(); points.add(new ProgressStyle.Point(0).setColor(Color.RED)); int progress = 50; int progressMax = 100; boolean isStyledByProgress = true; NotificationProgressBar.processAndConvertToDrawableParts(segments, points, progress, progressMax, isStyledByProgress); } @Test(expected = IllegalArgumentException.class) public void processAndConvertToDrawableParts_pointPositionAtMax() { List<ProgressStyle.Segment> segments = new ArrayList<>(); segments.add(new ProgressStyle.Segment(100)); List<ProgressStyle.Point> points = new ArrayList<>(); points.add(new ProgressStyle.Point(100).setColor(Color.RED)); int progress = 50; int progressMax = 100; boolean isStyledByProgress = true; NotificationProgressBar.processAndConvertToDrawableParts(segments, points, progress, progressMax, isStyledByProgress); } @Test(expected = IllegalArgumentException.class) public void processAndConvertToDrawableParts_pointPositionAboveMax() { List<ProgressStyle.Segment> segments = new ArrayList<>(); Loading Loading
core/java/android/app/Notification.java +19 −5 Original line number Diff line number Diff line Loading @@ -11815,28 +11815,42 @@ public class Notification implements Parcelable sanitizeProgressColor(indeterminateColor, backgroundColor, defaultProgressColor)); } else { // Ensure segment color contrasts. final List<Segment> segments = new ArrayList<>(); int totalLength = 0; for (Segment segment : mProgressSegments) { final int length = segment.getLength(); if (length <= 0) continue; try { totalLength += Math.addExact(totalLength, length); segments.add(sanitizeSegment(segment, backgroundColor, defaultProgressColor)); } catch (ArithmeticException e) { totalLength = DEFAULT_PROGRESS_MAX; segments.clear(); break; } } // Create default segment when no segments are provided. if (segments.isEmpty()) { segments.add(sanitizeSegment(new Segment(100), backgroundColor, totalLength = DEFAULT_PROGRESS_MAX; segments.add(sanitizeSegment(new Segment(totalLength), backgroundColor, defaultProgressColor)); } // Ensure point color contrasts. final List<Point> points = new ArrayList<>(); for (Point point : mProgressPoints) { final int position = point.getPosition(); if (position < 0 || position > totalLength) continue; points.add(sanitizePoint(point, backgroundColor, defaultProgressColor)); } model = new NotificationProgressModel(segments, points, mProgress, mIsStyledByProgress); Math.clamp(mProgress, 0, totalLength), mIsStyledByProgress); } return model; } Loading
core/java/com/android/internal/widget/NotificationProgressBar.java +1 −1 Original line number Diff line number Diff line Loading @@ -453,7 +453,7 @@ public final class NotificationProgressBar extends ProgressBar { } for (ProgressStyle.Point point : points) { final int pos = point.getPosition(); if (pos <= 0 || pos >= progressMax) { if (pos < 0 || pos > progressMax) { throw new IllegalArgumentException("Invalid Point position : " + pos); } } Loading
core/tests/coretests/src/com/android/internal/widget/NotificationProgressBarTest.java +0 −30 Original line number Diff line number Diff line Loading @@ -171,36 +171,6 @@ public class NotificationProgressBarTest { isStyledByProgress); } @Test(expected = IllegalArgumentException.class) public void processAndConvertToDrawableParts_pointPositionIsZero() { List<ProgressStyle.Segment> segments = new ArrayList<>(); segments.add(new ProgressStyle.Segment(100)); List<ProgressStyle.Point> points = new ArrayList<>(); points.add(new ProgressStyle.Point(0).setColor(Color.RED)); int progress = 50; int progressMax = 100; boolean isStyledByProgress = true; NotificationProgressBar.processAndConvertToDrawableParts(segments, points, progress, progressMax, isStyledByProgress); } @Test(expected = IllegalArgumentException.class) public void processAndConvertToDrawableParts_pointPositionAtMax() { List<ProgressStyle.Segment> segments = new ArrayList<>(); segments.add(new ProgressStyle.Segment(100)); List<ProgressStyle.Point> points = new ArrayList<>(); points.add(new ProgressStyle.Point(100).setColor(Color.RED)); int progress = 50; int progressMax = 100; boolean isStyledByProgress = true; NotificationProgressBar.processAndConvertToDrawableParts(segments, points, progress, progressMax, isStyledByProgress); } @Test(expected = IllegalArgumentException.class) public void processAndConvertToDrawableParts_pointPositionAboveMax() { List<ProgressStyle.Segment> segments = new ArrayList<>(); Loading