Don't do the SAW perm check if there's an invalid UID
Bug: 157451684 Test: atest PreferencesHelperTest Change-Id: I1b9eb9dd60ad91b60a059bdee56af67ad53706ea
This commit is contained in:
@@ -85,7 +85,8 @@ public class PreferencesHelper implements RankingConfig {
|
||||
private static final int XML_VERSION = 2;
|
||||
/** What version to check to do the upgrade for bubbles. */
|
||||
private static final int XML_VERSION_BUBBLES_UPGRADE = 1;
|
||||
private static final int UNKNOWN_UID = UserHandle.USER_NULL;
|
||||
@VisibleForTesting
|
||||
static final int UNKNOWN_UID = UserHandle.USER_NULL;
|
||||
private static final String NON_BLOCKABLE_CHANNEL_DELIM = ":";
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -224,7 +225,7 @@ public class PreferencesHelper implements RankingConfig {
|
||||
}
|
||||
boolean skipWarningLogged = false;
|
||||
boolean hasSAWPermission = false;
|
||||
if (upgradeForBubbles) {
|
||||
if (upgradeForBubbles && uid != UNKNOWN_UID) {
|
||||
hasSAWPermission = mAppOps.noteOpNoThrow(
|
||||
OP_SYSTEM_ALERT_WINDOW, uid, name, null,
|
||||
"check-notif-bubble") == AppOpsManager.MODE_ALLOWED;
|
||||
|
||||
@@ -31,6 +31,7 @@ import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
|
||||
|
||||
import static com.android.server.notification.PreferencesHelper.DEFAULT_BUBBLE_PREFERENCE;
|
||||
import static com.android.server.notification.PreferencesHelper.NOTIFICATION_CHANNEL_COUNT_LIMIT;
|
||||
import static com.android.server.notification.PreferencesHelper.UNKNOWN_UID;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -2510,6 +2511,26 @@ public class PreferencesHelperTest extends UiServiceTestCase {
|
||||
mHelper.getAppLockedFields(PKG_O, UID_O));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBubblePrefence_noSAWCheckForUnknownUid() throws Exception {
|
||||
final String xml = "<ranking version=\"1\">\n"
|
||||
+ "<package name=\"" + PKG_O + "\" uid=\"" + UNKNOWN_UID + "\">\n"
|
||||
+ "<channel id=\"someId\" name=\"hi\""
|
||||
+ " importance=\"3\"/>"
|
||||
+ "</package>"
|
||||
+ "</ranking>";
|
||||
XmlPullParser parser = Xml.newPullParser();
|
||||
parser.setInput(new BufferedInputStream(new ByteArrayInputStream(xml.getBytes())),
|
||||
null);
|
||||
parser.nextTag();
|
||||
mHelper.readXml(parser, false, UserHandle.USER_ALL);
|
||||
|
||||
assertEquals(DEFAULT_BUBBLE_PREFERENCE, mHelper.getBubblePreference(PKG_O, UID_O));
|
||||
assertEquals(0, mHelper.getAppLockedFields(PKG_O, UID_O));
|
||||
verify(mAppOpsManager, never()).noteOpNoThrow(eq(OP_SYSTEM_ALERT_WINDOW), anyInt(),
|
||||
anyString(), eq(null), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBubblePreference_xml() throws Exception {
|
||||
mHelper.setBubblesAllowed(PKG_O, UID_O, BUBBLE_PREFERENCE_NONE);
|
||||
|
||||
Reference in New Issue
Block a user