Commit 318c5ae5 authored by dfalcantara's avatar dfalcantara Committed by Commit bot

Group Downloads notifications, and separate Incognito

* Download notifications are grouped together, and Incognito
  is put into its own group.  Summary notifications will come
  in a later patch; Android N doesn't seem to bundle these
  together once they're in their own group, making it hard
  to debug without Android Wear.

* New and existing group name constants are moved into
  NotificationConstants.java.

* Cleans up DownloadNotificationService's constant naming
  schemes to make it clearer what each field does.

BUG=678694,674015

Review-Url: https://codereview.chromium.org/2619433003
Cr-Commit-Position: refs/heads/master@{#442017}
parent ca86c9e8
...@@ -37,6 +37,7 @@ import org.chromium.chrome.browser.ChromeApplication; ...@@ -37,6 +37,7 @@ import org.chromium.chrome.browser.ChromeApplication;
import org.chromium.chrome.browser.init.BrowserParts; import org.chromium.chrome.browser.init.BrowserParts;
import org.chromium.chrome.browser.init.ChromeBrowserInitializer; import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
import org.chromium.chrome.browser.init.EmptyBrowserParts; import org.chromium.chrome.browser.init.EmptyBrowserParts;
import org.chromium.chrome.browser.notifications.NotificationConstants;
import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadBridge; import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadBridge;
import org.chromium.chrome.browser.util.IntentUtils; import org.chromium.chrome.browser.util.IntentUtils;
...@@ -45,6 +46,7 @@ import java.util.HashSet; ...@@ -45,6 +46,7 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit;
/** /**
* Service responsible for creating and updating download notifications even after * Service responsible for creating and updating download notifications even after
...@@ -73,21 +75,25 @@ public class DownloadNotificationService extends Service { ...@@ -73,21 +75,25 @@ public class DownloadNotificationService extends Service {
public static final int INVALID_DOWNLOAD_PERCENTAGE = -1; public static final int INVALID_DOWNLOAD_PERCENTAGE = -1;
@VisibleForTesting @VisibleForTesting
static final String PENDING_DOWNLOAD_NOTIFICATIONS = "PendingDownloadNotifications";
static final String NOTIFICATION_NAMESPACE = "DownloadNotificationService"; static final String NOTIFICATION_NAMESPACE = "DownloadNotificationService";
private static final String TAG = "DownloadNotification"; private static final String TAG = "DownloadNotification";
private static final String NEXT_DOWNLOAD_NOTIFICATION_ID = "NextDownloadNotificationId";
// Notification Id starting value, to avoid conflicts from IDs used in prior versions. /** Notification Id starting value, to avoid conflicts from IDs used in prior versions. */
private static final int STARTING_NOTIFICATION_ID = 1000000; private static final int STARTING_NOTIFICATION_ID = 1000000;
private static final String AUTO_RESUMPTION_ATTEMPT_LEFT = "ResumptionAttemptLeft";
private static final int MAX_RESUMPTION_ATTEMPT_LEFT = 5; private static final int MAX_RESUMPTION_ATTEMPT_LEFT = 5;
@VisibleForTesting static final int SECONDS_PER_MINUTE = 60; @VisibleForTesting static final long SECONDS_PER_MINUTE = TimeUnit.MINUTES.toSeconds(1);
@VisibleForTesting static final int SECONDS_PER_HOUR = 60 * 60; @VisibleForTesting static final long SECONDS_PER_HOUR = TimeUnit.HOURS.toSeconds(1);
@VisibleForTesting static final int SECONDS_PER_DAY = 24 * 60 * 60; @VisibleForTesting static final long SECONDS_PER_DAY = TimeUnit.DAYS.toSeconds(1);
private static final String KEY_AUTO_RESUMPTION_ATTEMPT_LEFT = "ResumptionAttemptLeft";
private static final String KEY_NEXT_DOWNLOAD_NOTIFICATION_ID = "NextDownloadNotificationId";
static final String KEY_PENDING_DOWNLOAD_NOTIFICATIONS = "PendingDownloadNotifications";
private final IBinder mBinder = new LocalBinder(); private final IBinder mBinder = new LocalBinder();
private final List<DownloadSharedPreferenceEntry> mDownloadSharedPreferenceEntries = private final List<DownloadSharedPreferenceEntry> mDownloadSharedPreferenceEntries =
new ArrayList<DownloadSharedPreferenceEntry>(); new ArrayList<DownloadSharedPreferenceEntry>();
private final List<String> mDownloadsInProgress = new ArrayList<String>(); private final List<String> mDownloadsInProgress = new ArrayList<String>();
private NotificationManager mNotificationManager; private NotificationManager mNotificationManager;
private SharedPreferences mSharedPrefs; private SharedPreferences mSharedPrefs;
private Context mContext; private Context mContext;
...@@ -141,7 +147,7 @@ public class DownloadNotificationService extends Service { ...@@ -141,7 +147,7 @@ public class DownloadNotificationService extends Service {
onBrowserKilled(); onBrowserKilled();
} }
mNextNotificationId = mSharedPrefs.getInt( mNextNotificationId = mSharedPrefs.getInt(
NEXT_DOWNLOAD_NOTIFICATION_ID, STARTING_NOTIFICATION_ID); KEY_NEXT_DOWNLOAD_NOTIFICATION_ID, STARTING_NOTIFICATION_ID);
} }
...@@ -207,7 +213,7 @@ public class DownloadNotificationService extends Service { ...@@ -207,7 +213,7 @@ public class DownloadNotificationService extends Service {
*/ */
private void updateResumptionAttemptLeft() { private void updateResumptionAttemptLeft() {
SharedPreferences.Editor editor = mSharedPrefs.edit(); SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putInt(AUTO_RESUMPTION_ATTEMPT_LEFT, mNumAutoResumptionAttemptLeft); editor.putInt(KEY_AUTO_RESUMPTION_ATTEMPT_LEFT, mNumAutoResumptionAttemptLeft);
editor.apply(); editor.apply();
} }
...@@ -217,7 +223,7 @@ public class DownloadNotificationService extends Service { ...@@ -217,7 +223,7 @@ public class DownloadNotificationService extends Service {
static void clearResumptionAttemptLeft() { static void clearResumptionAttemptLeft() {
SharedPreferences SharedPrefs = ContextUtils.getAppSharedPreferences(); SharedPreferences SharedPrefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = SharedPrefs.edit(); SharedPreferences.Editor editor = SharedPrefs.edit();
editor.remove(AUTO_RESUMPTION_ATTEMPT_LEFT); editor.remove(KEY_AUTO_RESUMPTION_ATTEMPT_LEFT);
editor.apply(); editor.apply();
} }
...@@ -546,7 +552,8 @@ public class DownloadNotificationService extends Service { ...@@ -546,7 +552,8 @@ public class DownloadNotificationService extends Service {
.setSmallIcon(iconId) .setSmallIcon(iconId)
.setLocalOnly(true) .setLocalOnly(true)
.setAutoCancel(true) .setAutoCancel(true)
.setContentText(contentText); .setContentText(contentText)
.setGroup(NotificationConstants.GROUP_DOWNLOADS);
return builder; return builder;
} }
...@@ -746,7 +753,7 @@ public class DownloadNotificationService extends Service { ...@@ -746,7 +753,7 @@ public class DownloadNotificationService extends Service {
*/ */
@VisibleForTesting @VisibleForTesting
void updateNotification(int id, Notification notification) { void updateNotification(int id, Notification notification) {
mNotificationManager.notify(NOTIFICATION_NAMESPACE, id, notification); mNotificationManager.notify(id, notification);
} }
/** /**
...@@ -835,11 +842,11 @@ public class DownloadNotificationService extends Service { ...@@ -835,11 +842,11 @@ public class DownloadNotificationService extends Service {
* left from the shared preference. * left from the shared preference.
*/ */
void parseDownloadSharedPrefs() { void parseDownloadSharedPrefs() {
mNumAutoResumptionAttemptLeft = mSharedPrefs.getInt(AUTO_RESUMPTION_ATTEMPT_LEFT, mNumAutoResumptionAttemptLeft = mSharedPrefs.getInt(KEY_AUTO_RESUMPTION_ATTEMPT_LEFT,
MAX_RESUMPTION_ATTEMPT_LEFT); MAX_RESUMPTION_ATTEMPT_LEFT);
if (!mSharedPrefs.contains(PENDING_DOWNLOAD_NOTIFICATIONS)) return; if (!mSharedPrefs.contains(KEY_PENDING_DOWNLOAD_NOTIFICATIONS)) return;
Set<String> entries = DownloadManagerService.getStoredDownloadInfo( Set<String> entries = DownloadManagerService.getStoredDownloadInfo(
mSharedPrefs, PENDING_DOWNLOAD_NOTIFICATIONS); mSharedPrefs, KEY_PENDING_DOWNLOAD_NOTIFICATIONS);
for (String entryString : entries) { for (String entryString : entries) {
DownloadSharedPreferenceEntry entry = DownloadSharedPreferenceEntry entry =
DownloadSharedPreferenceEntry.parseFromString(entryString); DownloadSharedPreferenceEntry.parseFromString(entryString);
...@@ -873,7 +880,7 @@ public class DownloadNotificationService extends Service { ...@@ -873,7 +880,7 @@ public class DownloadNotificationService extends Service {
entries.add(mDownloadSharedPreferenceEntries.get(i).getSharedPreferenceString()); entries.add(mDownloadSharedPreferenceEntries.get(i).getSharedPreferenceString());
} }
DownloadManagerService.storeDownloadInfo( DownloadManagerService.storeDownloadInfo(
mSharedPrefs, PENDING_DOWNLOAD_NOTIFICATIONS, entries); mSharedPrefs, KEY_PENDING_DOWNLOAD_NOTIFICATIONS, entries);
} }
/** /**
...@@ -887,7 +894,7 @@ public class DownloadNotificationService extends Service { ...@@ -887,7 +894,7 @@ public class DownloadNotificationService extends Service {
mNextNotificationId = mNextNotificationId == Integer.MAX_VALUE mNextNotificationId = mNextNotificationId == Integer.MAX_VALUE
? STARTING_NOTIFICATION_ID : mNextNotificationId + 1; ? STARTING_NOTIFICATION_ID : mNextNotificationId + 1;
SharedPreferences.Editor editor = mSharedPrefs.edit(); SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putInt(NEXT_DOWNLOAD_NOTIFICATION_ID, mNextNotificationId); editor.putInt(KEY_NEXT_DOWNLOAD_NOTIFICATION_ID, mNextNotificationId);
editor.apply(); editor.apply();
return notificationId; return notificationId;
} }
...@@ -910,15 +917,15 @@ public class DownloadNotificationService extends Service { ...@@ -910,15 +917,15 @@ public class DownloadNotificationService extends Service {
int minutes = 0; int minutes = 0;
if (secondsLong >= SECONDS_PER_DAY) { if (secondsLong >= SECONDS_PER_DAY) {
days = (int) (secondsLong / SECONDS_PER_DAY); days = (int) (secondsLong / SECONDS_PER_DAY);
secondsLong -= (long) days * SECONDS_PER_DAY; secondsLong -= days * SECONDS_PER_DAY;
} }
if (secondsLong >= SECONDS_PER_HOUR) { if (secondsLong >= SECONDS_PER_HOUR) {
hours = (int) (secondsLong / SECONDS_PER_HOUR); hours = (int) (secondsLong / SECONDS_PER_HOUR);
secondsLong -= (long) hours * SECONDS_PER_HOUR; secondsLong -= hours * SECONDS_PER_HOUR;
} }
if (secondsLong >= SECONDS_PER_MINUTE) { if (secondsLong >= SECONDS_PER_MINUTE) {
minutes = (int) (secondsLong / SECONDS_PER_MINUTE); minutes = (int) (secondsLong / SECONDS_PER_MINUTE);
secondsLong -= (long) minutes * SECONDS_PER_MINUTE; secondsLong -= minutes * SECONDS_PER_MINUTE;
} }
int seconds = (int) secondsLong; int seconds = (int) secondsLong;
......
...@@ -11,6 +11,7 @@ import android.support.v4.app.NotificationCompat; ...@@ -11,6 +11,7 @@ import android.support.v4.app.NotificationCompat;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.notifications.NotificationConstants;
/** /**
* Manages the notification indicating that there are incognito tabs opened in Document mode. * Manages the notification indicating that there are incognito tabs opened in Document mode.
...@@ -37,7 +38,8 @@ public class IncognitoNotificationManager { ...@@ -37,7 +38,8 @@ public class IncognitoNotificationManager {
.setVisibility(Notification.VISIBILITY_SECRET) .setVisibility(Notification.VISIBILITY_SECRET)
.setSmallIcon(R.drawable.incognito_statusbar) .setSmallIcon(R.drawable.incognito_statusbar)
.setShowWhen(false) .setShowWhen(false)
.setLocalOnly(true); .setLocalOnly(true)
.setGroup(NotificationConstants.GROUP_INCOGNITO);
NotificationManager nm = NotificationManager nm =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(INCOGNITO_TABS_OPEN_TAG, INCOGNITO_TABS_OPEN_ID, builder.build()); nm.notify(INCOGNITO_TABS_OPEN_TAG, INCOGNITO_TABS_OPEN_ID, builder.build());
......
...@@ -37,6 +37,7 @@ import org.chromium.base.ContextUtils; ...@@ -37,6 +37,7 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.blink.mojom.MediaSessionAction; import org.chromium.blink.mojom.MediaSessionAction;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.notifications.NotificationConstants;
import org.chromium.content_public.common.MediaMetadata; import org.chromium.content_public.common.MediaMetadata;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -270,7 +271,6 @@ public class MediaNotificationManager { ...@@ -270,7 +271,6 @@ public class MediaNotificationManager {
*/ */
public static final class PlaybackListenerService extends ListenerService { public static final class PlaybackListenerService extends ListenerService {
private static final int NOTIFICATION_ID = R.id.media_playback_notification; private static final int NOTIFICATION_ID = R.id.media_playback_notification;
private static final String NOTIFICATION_GROUP_NAME = "MediaPlayback";
@Override @Override
public void onCreate() { public void onCreate() {
...@@ -310,7 +310,6 @@ public class MediaNotificationManager { ...@@ -310,7 +310,6 @@ public class MediaNotificationManager {
*/ */
public static final class PresentationListenerService extends ListenerService { public static final class PresentationListenerService extends ListenerService {
private static final int NOTIFICATION_ID = R.id.presentation_notification; private static final int NOTIFICATION_ID = R.id.presentation_notification;
private static final String NOTIFICATION_GROUP_NAME = "MediaPresentation";
@Override @Override
@Nullable @Nullable
...@@ -324,7 +323,6 @@ public class MediaNotificationManager { ...@@ -324,7 +323,6 @@ public class MediaNotificationManager {
*/ */
public static final class CastListenerService extends ListenerService { public static final class CastListenerService extends ListenerService {
private static final int NOTIFICATION_ID = R.id.remote_notification; private static final int NOTIFICATION_ID = R.id.remote_notification;
private static final String NOTIFICATION_GROUP_NAME = "MediaRemote";
@Override @Override
@Nullable @Nullable
...@@ -399,11 +397,11 @@ public class MediaNotificationManager { ...@@ -399,11 +397,11 @@ public class MediaNotificationManager {
// Returns the notification group name used to prevent automatic grouping. // Returns the notification group name used to prevent automatic grouping.
private String getNotificationGroupName() { private String getNotificationGroupName() {
if (mMediaNotificationInfo.id == PlaybackListenerService.NOTIFICATION_ID) { if (mMediaNotificationInfo.id == PlaybackListenerService.NOTIFICATION_ID) {
return PlaybackListenerService.NOTIFICATION_GROUP_NAME; return NotificationConstants.GROUP_MEDIA_PLAYBACK;
} else if (mMediaNotificationInfo.id == PresentationListenerService.NOTIFICATION_ID) { } else if (mMediaNotificationInfo.id == PresentationListenerService.NOTIFICATION_ID) {
return PresentationListenerService.NOTIFICATION_GROUP_NAME; return NotificationConstants.GROUP_MEDIA_PRESENTATION;
} else if (mMediaNotificationInfo.id == CastListenerService.NOTIFICATION_ID) { } else if (mMediaNotificationInfo.id == CastListenerService.NOTIFICATION_ID) {
return CastListenerService.NOTIFICATION_GROUP_NAME; return NotificationConstants.GROUP_MEDIA_REMOTE;
} }
assert false; assert false;
......
...@@ -59,4 +59,11 @@ public class NotificationConstants { ...@@ -59,4 +59,11 @@ public class NotificationConstants {
* Key for retrieving the results of user input from notification text action intents. * Key for retrieving the results of user input from notification text action intents.
*/ */
static final String KEY_TEXT_REPLY = "key_text_reply"; static final String KEY_TEXT_REPLY = "key_text_reply";
// Notification groups for features that show notifications to the user.
public static final String GROUP_DOWNLOADS = "Downloads";
public static final String GROUP_INCOGNITO = "Incognito";
public static final String GROUP_MEDIA_PLAYBACK = "MediaPlayback";
public static final String GROUP_MEDIA_PRESENTATION = "MediaPresentation";
public static final String GROUP_MEDIA_REMOTE = "MediaRemote";
} }
...@@ -80,7 +80,7 @@ public class DownloadNotificationServiceTest extends ...@@ -80,7 +80,7 @@ public class DownloadNotificationServiceTest extends
super.setupService(); super.setupService();
SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences(); SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = sharedPrefs.edit(); SharedPreferences.Editor editor = sharedPrefs.edit();
editor.remove(DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS); editor.remove(DownloadNotificationService.KEY_PENDING_DOWNLOAD_NOTIFICATIONS);
editor.apply(); editor.apply();
super.tearDown(); super.tearDown();
} }
...@@ -148,7 +148,7 @@ public class DownloadNotificationServiceTest extends ...@@ -148,7 +148,7 @@ public class DownloadNotificationServiceTest extends
SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences(); SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = sharedPrefs.edit(); SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putStringSet( editor.putStringSet(
DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS, notifications); DownloadNotificationService.KEY_PENDING_DOWNLOAD_NOTIFICATIONS, notifications);
editor.apply(); editor.apply();
startNotificationService(); startNotificationService();
assertTrue(scheduler.mScheduled); assertTrue(scheduler.mScheduled);
...@@ -195,7 +195,7 @@ public class DownloadNotificationServiceTest extends ...@@ -195,7 +195,7 @@ public class DownloadNotificationServiceTest extends
SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences(); SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = sharedPrefs.edit(); SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putStringSet( editor.putStringSet(
DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS, notifications); DownloadNotificationService.KEY_PENDING_DOWNLOAD_NOTIFICATIONS, notifications);
editor.apply(); editor.apply();
startNotificationService(); startNotificationService();
assertFalse(scheduler.mScheduled); assertFalse(scheduler.mScheduled);
...@@ -223,15 +223,15 @@ public class DownloadNotificationServiceTest extends ...@@ -223,15 +223,15 @@ public class DownloadNotificationServiceTest extends
ContextUtils.getAppSharedPreferences(); ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = sharedPrefs.edit(); SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putStringSet( editor.putStringSet(
DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS, notifications); DownloadNotificationService.KEY_PENDING_DOWNLOAD_NOTIFICATIONS, notifications);
editor.apply(); editor.apply();
startNotificationService(); startNotificationService();
assertTrue(getService().isPaused()); assertTrue(getService().isPaused());
assertEquals(2, getService().getNotificationIds().size()); assertEquals(2, getService().getNotificationIds().size());
assertTrue(getService().getNotificationIds().contains(1)); assertTrue(getService().getNotificationIds().contains(1));
assertTrue(getService().getNotificationIds().contains(2)); assertTrue(getService().getNotificationIds().contains(2));
assertTrue( assertTrue(sharedPrefs.contains(
sharedPrefs.contains(DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS)); DownloadNotificationService.KEY_PENDING_DOWNLOAD_NOTIFICATIONS));
} }
/** /**
...@@ -255,7 +255,7 @@ public class DownloadNotificationServiceTest extends ...@@ -255,7 +255,7 @@ public class DownloadNotificationServiceTest extends
SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences(); SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = sharedPrefs.edit(); SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putStringSet( editor.putStringSet(
DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS, notifications); DownloadNotificationService.KEY_PENDING_DOWNLOAD_NOTIFICATIONS, notifications);
editor.apply(); editor.apply();
startNotificationService(); startNotificationService();
assertEquals(2, getService().getNotificationIds().size()); assertEquals(2, getService().getNotificationIds().size());
...@@ -268,17 +268,17 @@ public class DownloadNotificationServiceTest extends ...@@ -268,17 +268,17 @@ public class DownloadNotificationServiceTest extends
assertEquals(3, getService().getNotificationIds().size()); assertEquals(3, getService().getNotificationIds().size());
int lastNotificationId = getService().getLastAddedNotificationId(); int lastNotificationId = getService().getLastAddedNotificationId();
Set<String> entries = DownloadManagerService.getStoredDownloadInfo( Set<String> entries = DownloadManagerService.getStoredDownloadInfo(
sharedPrefs, DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS); sharedPrefs, DownloadNotificationService.KEY_PENDING_DOWNLOAD_NOTIFICATIONS);
assertEquals(3, entries.size()); assertEquals(3, entries.size());
service.notifyDownloadSuccessful(guid1, "/path/to/success", "success", 100L, false, false); service.notifyDownloadSuccessful(guid1, "/path/to/success", "success", 100L, false, false);
entries = DownloadManagerService.getStoredDownloadInfo( entries = DownloadManagerService.getStoredDownloadInfo(
sharedPrefs, DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS); sharedPrefs, DownloadNotificationService.KEY_PENDING_DOWNLOAD_NOTIFICATIONS);
assertEquals(2, entries.size()); assertEquals(2, entries.size());
service.notifyDownloadFailed(guid2, "failed"); service.notifyDownloadFailed(guid2, "failed");
entries = DownloadManagerService.getStoredDownloadInfo( entries = DownloadManagerService.getStoredDownloadInfo(
sharedPrefs, DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS); sharedPrefs, DownloadNotificationService.KEY_PENDING_DOWNLOAD_NOTIFICATIONS);
assertEquals(1, entries.size()); assertEquals(1, entries.size());
service.notifyDownloadCanceled(guid3); service.notifyDownloadCanceled(guid3);
...@@ -326,7 +326,7 @@ public class DownloadNotificationServiceTest extends ...@@ -326,7 +326,7 @@ public class DownloadNotificationServiceTest extends
SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences(); SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = sharedPrefs.edit(); SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putStringSet( editor.putStringSet(
DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS, notifications); DownloadNotificationService.KEY_PENDING_DOWNLOAD_NOTIFICATIONS, notifications);
editor.apply(); editor.apply();
startNotificationService(); startNotificationService();
DownloadNotificationService service = bindNotificationService(); DownloadNotificationService service = bindNotificationService();
...@@ -370,12 +370,12 @@ public class DownloadNotificationServiceTest extends ...@@ -370,12 +370,12 @@ public class DownloadNotificationServiceTest extends
ContextUtils.getAppSharedPreferences(); ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = sharedPrefs.edit(); SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putStringSet( editor.putStringSet(
DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS, notifications); DownloadNotificationService.KEY_PENDING_DOWNLOAD_NOTIFICATIONS, notifications);
editor.apply(); editor.apply();
startNotificationService(); startNotificationService();
assertTrue(getService().isPaused()); assertTrue(getService().isPaused());
assertFalse(sharedPrefs.contains( assertFalse(sharedPrefs.contains(
DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS)); DownloadNotificationService.KEY_PENDING_DOWNLOAD_NOTIFICATIONS));
} }
@SmallTest @SmallTest
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment