Merge "Make pre-upgrade footer appear more consistently"

This commit is contained in:
TreeHugger Robot
2023-02-01 18:30:13 +00:00
committed by Android (Google) Code Review
2 changed files with 7 additions and 22 deletions

View File

@@ -58,19 +58,15 @@ public class PreUpgradePreferenceController extends BasePreferenceController {
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
if (mNm.isNotificationListenerAccessGranted(mCn)) { mNlf = mNm.getListenerFilter(mCn, mUserId);
mNlf = mNm.getListenerFilter(mCn, mUserId);
if (mTargetSdk > Build.VERSION_CODES.S) { if (mTargetSdk > Build.VERSION_CODES.S) {
return CONDITIONALLY_UNAVAILABLE;
}
if (!mNlf.areAllTypesAllowed() || !mNlf.getDisallowedPackages().isEmpty()) {
return CONDITIONALLY_UNAVAILABLE;
}
return AVAILABLE;
} else {
return CONDITIONALLY_UNAVAILABLE; return CONDITIONALLY_UNAVAILABLE;
} }
if (!mNlf.areAllTypesAllowed() || !mNlf.getDisallowedPackages().isEmpty()) {
return CONDITIONALLY_UNAVAILABLE;
}
return AVAILABLE;
} }
} }

View File

@@ -62,17 +62,8 @@ public class PreUpgradePreferenceControllerTest {
mController.setUserId(0); mController.setUserId(0);
} }
@Test
public void testAvailable_notGranted() {
when(mNm.isNotificationListenerAccessGranted(any())).thenReturn(false);
mController.setTargetSdk(Build.VERSION_CODES.S);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
}
@Test @Test
public void testAvailable_lowTargetSdk_noCustomizations() { public void testAvailable_lowTargetSdk_noCustomizations() {
when(mNm.isNotificationListenerAccessGranted(any())).thenReturn(true);
mController.setTargetSdk(Build.VERSION_CODES.S); mController.setTargetSdk(Build.VERSION_CODES.S);
when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter()); when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter());
@@ -81,7 +72,6 @@ public class PreUpgradePreferenceControllerTest {
@Test @Test
public void testAvailable_lowTargetSdk_customizations() { public void testAvailable_lowTargetSdk_customizations() {
when(mNm.isNotificationListenerAccessGranted(any())).thenReturn(true);
mController.setTargetSdk(Build.VERSION_CODES.S); mController.setTargetSdk(Build.VERSION_CODES.S);
NotificationListenerFilter nlf = new NotificationListenerFilter(); NotificationListenerFilter nlf = new NotificationListenerFilter();
nlf.setTypes(FLAG_FILTER_TYPE_CONVERSATIONS); nlf.setTypes(FLAG_FILTER_TYPE_CONVERSATIONS);
@@ -92,7 +82,6 @@ public class PreUpgradePreferenceControllerTest {
@Test @Test
public void testAvailable_highTargetSdk_noCustomizations() { public void testAvailable_highTargetSdk_noCustomizations() {
when(mNm.isNotificationListenerAccessGranted(any())).thenReturn(true);
mController.setTargetSdk(Build.VERSION_CODES.CUR_DEVELOPMENT + 1); mController.setTargetSdk(Build.VERSION_CODES.CUR_DEVELOPMENT + 1);
when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter()); when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter());