1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.statusbar; 18 19 import android.service.notification.NotificationListenerService.Ranking; 20 import android.service.notification.StatusBarNotification; 21 22 import com.android.internal.annotations.VisibleForTesting; 23 import com.android.systemui.statusbar.notification.collection.NotificationEntry; 24 25 @VisibleForTesting 26 public class NotificationEntryHelper { modifyRanking(NotificationEntry entry)27 public static ModifiedRankingBuilder modifyRanking(NotificationEntry entry) { 28 return new ModifiedRankingBuilder(entry); 29 } 30 modifySbn(NotificationEntry entry)31 public static ModifiedSbnBuilder modifySbn(NotificationEntry entry) { 32 return new ModifiedSbnBuilder(entry); 33 } 34 35 public static class ModifiedRankingBuilder extends RankingBuilder { 36 private final NotificationEntry mTarget; 37 ModifiedRankingBuilder(NotificationEntry target)38 private ModifiedRankingBuilder(NotificationEntry target) { 39 super(target.getRanking()); 40 mTarget = target; 41 } 42 43 @Override build()44 public Ranking build() { 45 final Ranking ranking = super.build(); 46 mTarget.setRanking(ranking); 47 return ranking; 48 } 49 } 50 51 public static class ModifiedSbnBuilder extends SbnBuilder { 52 private final NotificationEntry mTarget; 53 ModifiedSbnBuilder(NotificationEntry target)54 private ModifiedSbnBuilder(NotificationEntry target) { 55 super(target.getSbn()); 56 mTarget = target; 57 } 58 59 @Override build()60 public StatusBarNotification build() { 61 final StatusBarNotification sbn = super.build(); 62 mTarget.setSbn(sbn); 63 return sbn; 64 } 65 } 66 } 67