| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.wm.shell.bubbles; |
| 18 |
|
| 19 |
import static android.app.Notification.FLAG_BUBBLE; |
| 20 |
|
| 21 |
import android.app.Notification; |
| 22 |
import android.app.Notification.BubbleMetadata; |
| 23 |
import android.app.NotificationManager.Policy; |
| 24 |
import android.content.LocusId; |
| 25 |
import android.service.notification.NotificationListenerService.Ranking; |
| 26 |
import android.service.notification.StatusBarNotification; |
| 27 |
|
| 28 |
import androidx.annotation.NonNull; |
| 29 |
import androidx.annotation.Nullable; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public class BubbleEntry { |
| 37 |
|
| 38 |
private StatusBarNotification mSbn; |
| 39 |
private Ranking mRanking; |
| 40 |
|
| 41 |
private boolean mIsClearable; |
| 42 |
private boolean mShouldSuppressNotificationDot; |
| 43 |
private boolean mShouldSuppressNotificationList; |
| 44 |
private boolean mShouldSuppressPeek; |
| 45 |
|
| 46 |
public BubbleEntry(@NonNull StatusBarNotification sbn, |
| 47 |
Ranking ranking, boolean isClearable, boolean shouldSuppressNotificationDot, |
| 48 |
boolean shouldSuppressNotificationList, boolean shouldSuppressPeek) { |
| 49 |
mSbn = sbn; |
| 50 |
mRanking = ranking; |
| 51 |
|
| 52 |
mIsClearable = isClearable; |
| 53 |
mShouldSuppressNotificationDot = shouldSuppressNotificationDot; |
| 54 |
mShouldSuppressNotificationList = shouldSuppressNotificationList; |
| 55 |
mShouldSuppressPeek = shouldSuppressPeek; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
@NonNull |
| 60 |
public StatusBarNotification getStatusBarNotification() { |
| 61 |
return mSbn; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
public Ranking getRanking() { |
| 66 |
return mRanking; |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
public String getKey() { |
| 71 |
return mSbn.getKey(); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
public String getGroupKey() { |
| 76 |
return mSbn.getGroupKey(); |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
public LocusId getLocusId() { |
| 81 |
return mSbn.getNotification().getLocusId(); |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
@Nullable |
| 86 |
public BubbleMetadata getBubbleMetadata() { |
| 87 |
return getStatusBarNotification().getNotification().getBubbleMetadata(); |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
public boolean setFlagBubble(boolean shouldBubble) { |
| 99 |
boolean wasBubble = isBubble(); |
| 100 |
if (!shouldBubble) { |
| 101 |
mSbn.getNotification().flags &= ~FLAG_BUBBLE; |
| 102 |
} else if (getBubbleMetadata() != null && canBubble()) { |
| 103 |
|
| 104 |
mSbn.getNotification().flags |= FLAG_BUBBLE; |
| 105 |
} |
| 106 |
return wasBubble != isBubble(); |
| 107 |
} |
| 108 |
|
| 109 |
public boolean isBubble() { |
| 110 |
return (mSbn.getNotification().flags & FLAG_BUBBLE) != 0; |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
public boolean canBubble() { |
| 115 |
return mRanking.canBubble(); |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
public boolean isClearable() { |
| 120 |
return mIsClearable; |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
public boolean shouldSuppressNotificationDot() { |
| 125 |
return mShouldSuppressNotificationDot; |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
public boolean shouldSuppressNotificationList() { |
| 133 |
return mShouldSuppressNotificationList; |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
public boolean shouldSuppressPeek() { |
| 138 |
return mShouldSuppressPeek; |
| 139 |
} |
| 140 |
} |