Fix text in notification settings for apps that do not send notifications
Added a new string to show for apps apps that target T, but do not declare the POST_NOTIFICATIONS permission in notification settings. Bug: 229108007 Test: `croot` `make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.notification.app.NotificationsOffPreferenceControllerTest"` and manual: open Settings-Notifications-App Settings, check the text for apps that does not post notifications with toggle disabled. Text should be: "This app does not send notifications" when system language is English. Change-Id: I9822b6f983e00c5982522099e339d86fae45aefe
This commit is contained in:
@@ -20,6 +20,7 @@ import static android.app.NotificationManager.IMPORTANCE_NONE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -32,6 +33,7 @@ import android.os.UserManager;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.notification.NotificationBackend;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -157,4 +159,23 @@ public class NotificationsOffPreferenceControllerTest {
|
||||
assertThat(pref.getTitle().toString()).contains("app");
|
||||
assertThat(pref.isSelectable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_whenToggleDisabled() {
|
||||
// Given: the app does not request to post notifications
|
||||
// and it's preference toggle is disabled
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.banned = true;
|
||||
appRow.permissionStateLocked = true;
|
||||
mController.onResume(appRow, null, null, null, null, null, null);
|
||||
Preference pref = new Preference(RuntimeEnvironment.application);
|
||||
|
||||
// When: updateState(Preference preference) is called
|
||||
mController.updateState(pref);
|
||||
|
||||
// Then: title of pref should be app_notifications_not_send_desc
|
||||
assertEquals(
|
||||
RuntimeEnvironment.application.getString(R.string.app_notifications_not_send_desc),
|
||||
pref.getTitle().toString());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user