Commit 79581cba authored by Henrique Nakashima's avatar Henrique Nakashima Committed by Commit Bot

Stop clearing KEY_PERSISTED_NOTIFICATION_ID SharedPref.

Move it to deprecated keys, which reserves to name to prevent reuse.

Bug: 1022108

Change-Id: Iff335c71208327c0960592ab058cfc3b83344265
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1993495Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735566}
parent 349114a1
...@@ -32,8 +32,6 @@ import java.lang.annotation.RetentionPolicy; ...@@ -32,8 +32,6 @@ import java.lang.annotation.RetentionPolicy;
*/ */
public class DownloadForegroundService extends Service { public class DownloadForegroundService extends Service {
private static final String TAG = "DownloadFg"; private static final String TAG = "DownloadFg";
// Deprecated, remove this after M75.
private static final String KEY_PERSISTED_NOTIFICATION_ID = "PersistedNotificationId";
private final IBinder mBinder = new LocalBinder(); private final IBinder mBinder = new LocalBinder();
private NotificationManager mNotificationManager; private NotificationManager mNotificationManager;
...@@ -52,7 +50,6 @@ public class DownloadForegroundService extends Service { ...@@ -52,7 +50,6 @@ public class DownloadForegroundService extends Service {
mNotificationManager = mNotificationManager =
(NotificationManager) ContextUtils.getApplicationContext().getSystemService( (NotificationManager) ContextUtils.getApplicationContext().getSystemService(
Context.NOTIFICATION_SERVICE); Context.NOTIFICATION_SERVICE);
clearPersistedNotificationId();
} }
/** /**
...@@ -224,15 +221,6 @@ public class DownloadForegroundService extends Service { ...@@ -224,15 +221,6 @@ public class DownloadForegroundService extends Service {
} }
} }
/**
* Clear stored value for the id of the notification pinned to the service.
*/
@VisibleForTesting
static void clearPersistedNotificationId() {
ContextUtils.getAppSharedPreferences().edit().remove(KEY_PERSISTED_NOTIFICATION_ID).apply();
}
/** Methods for testing. */ /** Methods for testing. */
@VisibleForTesting @VisibleForTesting
......
...@@ -9,7 +9,6 @@ import static android.app.Service.STOP_FOREGROUND_REMOVE; ...@@ -9,7 +9,6 @@ import static android.app.Service.STOP_FOREGROUND_REMOVE;
import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertEquals;
import static org.chromium.chrome.browser.download.DownloadForegroundService.clearPersistedNotificationId;
import static org.chromium.chrome.browser.download.DownloadSnackbarController.INVALID_NOTIFICATION_ID; import static org.chromium.chrome.browser.download.DownloadSnackbarController.INVALID_NOTIFICATION_ID;
import android.app.Notification; import android.app.Notification;
...@@ -18,7 +17,6 @@ import android.support.v4.app.ServiceCompat; ...@@ -18,7 +17,6 @@ import android.support.v4.app.ServiceCompat;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -106,7 +104,6 @@ public class DownloadForegroundServiceTest { ...@@ -106,7 +104,6 @@ public class DownloadForegroundServiceTest {
@Before @Before
public void setUp() { public void setUp() {
mForegroundService = new MockDownloadForegroundService(); mForegroundService = new MockDownloadForegroundService();
clearPersistedNotificationId();
mNotification = mNotification =
NotificationBuilderFactory NotificationBuilderFactory
.createChromeNotificationBuilder( .createChromeNotificationBuilder(
...@@ -117,11 +114,6 @@ public class DownloadForegroundServiceTest { ...@@ -117,11 +114,6 @@ public class DownloadForegroundServiceTest {
.build(); .build();
} }
@After
public void tearDown() {
clearPersistedNotificationId();
}
/** /**
* The expected behavior for start foreground when the API >= 24 is that the old notification is * The expected behavior for start foreground when the API >= 24 is that the old notification is
* able to be detached and the new notification pinned without any need for relaunching or * able to be detached and the new notification pinned without any need for relaunching or
......
...@@ -670,6 +670,7 @@ public final class ChromePreferenceKeys { ...@@ -670,6 +670,7 @@ public final class ChromePreferenceKeys {
static List<String> createDeprecatedKeysForTesting() { static List<String> createDeprecatedKeysForTesting() {
// clang-format off // clang-format off
return Arrays.asList( return Arrays.asList(
"PersistedNotificationId",
"PhysicalWeb.ActivityReferral", "PhysicalWeb.ActivityReferral",
"PhysicalWeb.HasDeferredMetrics", "PhysicalWeb.HasDeferredMetrics",
"PhysicalWeb.OptIn.DeclineButtonPressed", "PhysicalWeb.OptIn.DeclineButtonPressed",
......
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