Merge "Allow updates to importance of default apps" into qt-dev

This commit is contained in:
TreeHugger Robot
2019-05-18 09:25:23 +00:00
committed by Android (Google) Code Review
2 changed files with 11 additions and 7 deletions

View File

@@ -736,7 +736,8 @@ public class PreferencesHelper implements RankingConfig {
} }
updatedChannel.setImportanceLockedByCriticalDeviceFunction( updatedChannel.setImportanceLockedByCriticalDeviceFunction(
r.defaultAppLockedImportance); r.defaultAppLockedImportance);
if (updatedChannel.isImportanceLockedByCriticalDeviceFunction()) { if (updatedChannel.isImportanceLockedByCriticalDeviceFunction()
&& updatedChannel.getImportance() == IMPORTANCE_NONE) {
updatedChannel.setImportance(channel.getImportance()); updatedChannel.setImportance(channel.getImportance());
} }

View File

@@ -66,6 +66,9 @@ import android.util.ArraySet;
import android.util.Pair; import android.util.Pair;
import android.util.Xml; import android.util.Xml;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import com.android.internal.util.FastXmlSerializer; import com.android.internal.util.FastXmlSerializer;
import com.android.server.UiServiceTestCase; import com.android.server.UiServiceTestCase;
@@ -90,9 +93,6 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
@SmallTest @SmallTest
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class PreferencesHelperTest extends UiServiceTestCase { public class PreferencesHelperTest extends UiServiceTestCase {
@@ -2520,7 +2520,6 @@ public class PreferencesHelperTest extends UiServiceTestCase {
toAdd.add(new Pair(PKG_O, UID_O)); toAdd.add(new Pair(PKG_O, UID_O));
mHelper.updateDefaultApps(UserHandle.getUserId(UID_O), null, toAdd); mHelper.updateDefaultApps(UserHandle.getUserId(UID_O), null, toAdd);
assertTrue(mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false) assertTrue(mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false)
.isImportanceLockedByCriticalDeviceFunction()); .isImportanceLockedByCriticalDeviceFunction());
assertFalse(mHelper.getNotificationChannel(PKG_N_MR1, UID_N_MR1, b.getId(), false) assertFalse(mHelper.getNotificationChannel(PKG_N_MR1, UID_N_MR1, b.getId(), false)
@@ -2623,16 +2622,20 @@ public class PreferencesHelperTest extends UiServiceTestCase {
update.setAllowBubbles(false); update.setAllowBubbles(false);
mHelper.updateNotificationChannel(PKG_O, UID_O, update, true); mHelper.updateNotificationChannel(PKG_O, UID_O, update, true);
assertEquals(IMPORTANCE_HIGH, assertEquals(IMPORTANCE_HIGH,
mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).getImportance()); mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).getImportance());
assertEquals(false, assertEquals(false,
mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).canBubble()); mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).canBubble());
mHelper.updateNotificationChannel(PKG_O, UID_O, update, false); mHelper.updateNotificationChannel(PKG_O, UID_O, update, false);
assertEquals(IMPORTANCE_HIGH, assertEquals(IMPORTANCE_HIGH,
mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).getImportance()); mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).getImportance());
NotificationChannel updateImportanceLow = new NotificationChannel("a", "a",
IMPORTANCE_LOW);
mHelper.updateNotificationChannel(PKG_O, UID_O, updateImportanceLow, true);
assertEquals(IMPORTANCE_LOW,
mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).getImportance());
} }
@Test @Test