Merge "Don't do the SAW perm check if there's an invalid UID" into rvc-dev am: 67be1e7ae7 am: 391f175c1c
Change-Id: If0439a09516d0fe16130dd79a81e9a643cc4ad0a
This commit is contained in:
@@ -85,7 +85,8 @@ public class PreferencesHelper implements RankingConfig {
|
|||||||
private static final int XML_VERSION = 2;
|
private static final int XML_VERSION = 2;
|
||||||
/** What version to check to do the upgrade for bubbles. */
|
/** What version to check to do the upgrade for bubbles. */
|
||||||
private static final int XML_VERSION_BUBBLES_UPGRADE = 1;
|
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 = ":";
|
private static final String NON_BLOCKABLE_CHANNEL_DELIM = ":";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -224,7 +225,7 @@ public class PreferencesHelper implements RankingConfig {
|
|||||||
}
|
}
|
||||||
boolean skipWarningLogged = false;
|
boolean skipWarningLogged = false;
|
||||||
boolean hasSAWPermission = false;
|
boolean hasSAWPermission = false;
|
||||||
if (upgradeForBubbles) {
|
if (upgradeForBubbles && uid != UNKNOWN_UID) {
|
||||||
hasSAWPermission = mAppOps.noteOpNoThrow(
|
hasSAWPermission = mAppOps.noteOpNoThrow(
|
||||||
OP_SYSTEM_ALERT_WINDOW, uid, name, null,
|
OP_SYSTEM_ALERT_WINDOW, uid, name, null,
|
||||||
"check-notif-bubble") == AppOpsManager.MODE_ALLOWED;
|
"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.DEFAULT_BUBBLE_PREFERENCE;
|
||||||
import static com.android.server.notification.PreferencesHelper.NOTIFICATION_CHANNEL_COUNT_LIMIT;
|
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;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@@ -2510,6 +2511,26 @@ public class PreferencesHelperTest extends UiServiceTestCase {
|
|||||||
mHelper.getAppLockedFields(PKG_O, UID_O));
|
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
|
@Test
|
||||||
public void testBubblePreference_xml() throws Exception {
|
public void testBubblePreference_xml() throws Exception {
|
||||||
mHelper.setBubblesAllowed(PKG_O, UID_O, BUBBLE_PREFERENCE_NONE);
|
mHelper.setBubblesAllowed(PKG_O, UID_O, BUBBLE_PREFERENCE_NONE);
|
||||||
|
|||||||
Reference in New Issue
Block a user