Delete unused code

Test: atest
Bug: 170298503
Change-Id: Icc565b5251a387c9ebd694340a49f45947afaad8
(cherry picked from commit 79b4ccc026d4c9ccb7deff64827c39d77b46d67f)
diff --git a/src/android/ext/services/notification/AgingHelper.java b/src/android/ext/services/notification/AgingHelper.java
deleted file mode 100644
index 9d61710..0000000
--- a/src/android/ext/services/notification/AgingHelper.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.ext.services.notification;
-
-import static android.app.NotificationManager.IMPORTANCE_MIN;
-
-import android.app.AlarmManager;
-import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.ext.services.notification.NotificationCategorizer.Category;
-import android.net.Uri;
-import android.util.ArraySet;
-import android.util.Log;
-
-import java.util.Set;
-
-public class AgingHelper {
-    private final static String TAG = "AgingHelper";
-    private final boolean DEBUG = false;
-
-    private static final String AGING_ACTION = AgingHelper.class.getSimpleName() + ".EVALUATE";
-    private static final int REQUEST_CODE_AGING = 1;
-    private static final String AGING_SCHEME = "aging";
-    private static final String EXTRA_KEY = "key";
-    private static final String EXTRA_CATEGORY = "category";
-
-    private static final int HOUR_MS = 1000 * 60 * 60;
-    private static final int TWO_HOURS_MS = 2 * HOUR_MS;
-
-    private Context mContext;
-    private NotificationCategorizer mNotificationCategorizer;
-    private AlarmManager mAm;
-    private Callback mCallback;
-
-    // The set of keys we've scheduled alarms for
-    private Set<String> mAging = new ArraySet<>();
-
-    public AgingHelper(Context context, NotificationCategorizer categorizer, Callback callback) {
-        mNotificationCategorizer = categorizer;
-        mContext = context;
-        mAm = mContext.getSystemService(AlarmManager.class);
-        mCallback = callback;
-
-        IntentFilter filter = new IntentFilter(AGING_ACTION);
-        filter.addDataScheme(AGING_SCHEME);
-        mContext.registerReceiver(mBroadcastReceiver, filter);
-    }
-
-    // NAS lifecycle methods
-
-    public void onNotificationSeen(NotificationEntry entry) {
-        // user has strong opinions about this notification. we can't down rank it, so don't bother.
-        if (entry.getChannel().hasUserSetImportance()) {
-            return;
-        }
-
-        @Category int category = mNotificationCategorizer.getCategory(entry);
-
-        // already very low
-        if (category == NotificationCategorizer.CATEGORY_MIN) {
-            return;
-        }
-
-        if (entry.hasSeen()) {
-            if (category == NotificationCategorizer.CATEGORY_ONGOING
-                    || category > NotificationCategorizer.CATEGORY_REMINDER) {
-                scheduleAging(entry.getSbn().getKey(), category, TWO_HOURS_MS);
-            } else {
-                scheduleAging(entry.getSbn().getKey(), category, HOUR_MS);
-            }
-
-            mAging.add(entry.getSbn().getKey());
-        }
-    }
-
-    public void onNotificationPosted(NotificationEntry entry) {
-        cancelAging(entry.getSbn().getKey());
-    }
-
-    public void onNotificationRemoved(String key) {
-        cancelAging(key);
-    }
-
-    public void onDestroy() {
-        mContext.unregisterReceiver(mBroadcastReceiver);
-    }
-
-    // Aging
-
-    private void scheduleAging(String key, @Category int category, long duration) {
-        if (mAging.contains(key)) {
-            // already scheduled. Don't reset aging just because the user saw the noti again.
-            return;
-        }
-        final PendingIntent pi = createPendingIntent(key, category);
-        long time = System.currentTimeMillis() + duration;
-        if (DEBUG) Log.d(TAG, "Scheduling evaluate for " + key + " in ms: " + duration);
-        mAm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, time, pi);
-    }
-
-    private void cancelAging(String key) {
-        final PendingIntent pi = createPendingIntent(key);
-        mAm.cancel(pi);
-        mAging.remove(key);
-    }
-
-    private Intent createBaseIntent(String key) {
-        return new Intent(AGING_ACTION)
-                .setData(new Uri.Builder().scheme(AGING_SCHEME).appendPath(key).build());
-    }
-
-    private Intent createAgingIntent(String key, @Category int category) {
-        Intent intent = createBaseIntent(key);
-        intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
-                .putExtra(EXTRA_CATEGORY, category)
-                .putExtra(EXTRA_KEY, key);
-        return intent;
-    }
-
-    private PendingIntent createPendingIntent(String key, @Category int category) {
-        return PendingIntent.getBroadcast(mContext,
-                REQUEST_CODE_AGING,
-                createAgingIntent(key, category),
-                PendingIntent.FLAG_UPDATE_CURRENT);
-    }
-
-    private PendingIntent createPendingIntent(String key) {
-        return PendingIntent.getBroadcast(mContext,
-                REQUEST_CODE_AGING,
-                createBaseIntent(key),
-                PendingIntent.FLAG_UPDATE_CURRENT);
-    }
-
-    private void demote(String key, @Category int category) {
-        int newImportance = IMPORTANCE_MIN;
-        // TODO: Change "aged" importance based on category
-        mCallback.sendAdjustment(key, newImportance);
-    }
-
-    protected interface Callback {
-        void sendAdjustment(String key, int newImportance);
-    }
-
-    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            if (DEBUG) {
-                Log.d(TAG, "Reposting notification");
-            }
-            if (AGING_ACTION.equals(intent.getAction())) {
-                demote(intent.getStringExtra(EXTRA_KEY), intent.getIntExtra(EXTRA_CATEGORY,
-                        NotificationCategorizer.CATEGORY_EVERYTHING_ELSE));
-            }
-        }
-    };
-}
diff --git a/tests/src/android/ext/services/notification/AgingHelperTest.java b/tests/src/android/ext/services/notification/AgingHelperTest.java
deleted file mode 100644
index dfda1d7..0000000
--- a/tests/src/android/ext/services/notification/AgingHelperTest.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.ext.services.notification;
-
-import static android.app.NotificationManager.IMPORTANCE_HIGH;
-import static android.app.NotificationManager.IMPORTANCE_MIN;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyLong;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.AlarmManager;
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.PendingIntent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.os.Build;
-import android.os.Process;
-import android.os.UserHandle;
-import android.service.notification.StatusBarNotification;
-import android.testing.TestableContext;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-@RunWith(AndroidJUnit4.class)
-public class AgingHelperTest {
-    private String mPkg = "pkg";
-    private int mUid = 2018;
-
-    @Rule
-    public final TestableContext mContext =
-            new TestableContext(InstrumentationRegistry.getTargetContext(), null);
-
-    @Mock
-    private NotificationCategorizer mCategorizer;
-    @Mock
-    private AlarmManager mAlarmManager;
-    @Mock
-    private PackageManager mPackageManager;
-    @Mock
-    private AgingHelper.Callback mCallback;
-    @Mock
-    private SmsHelper mSmsHelper;
-
-    private AgingHelper mAgingHelper;
-
-    private StatusBarNotification generateSbn(String channelId) {
-        Notification n = new Notification.Builder(mContext, channelId)
-                .setContentTitle("foo")
-                .build();
-
-        return new StatusBarNotification(mPkg, mPkg, 0, "tag", mUid, mUid, n,
-                UserHandle.SYSTEM, null, 0);
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-        mPkg = mContext.getPackageName();
-        mUid = Process.myUid();
-
-        ApplicationInfo info = mock(ApplicationInfo.class);
-        when(mPackageManager.getApplicationInfoAsUser(anyString(), anyInt(), any()))
-                .thenReturn(info);
-        info.targetSdkVersion = Build.VERSION_CODES.P;
-
-        mContext.addMockSystemService(AlarmManager.class, mAlarmManager);
-
-        mAgingHelper = new AgingHelper(mContext, mCategorizer, mCallback);
-    }
-
-    @Test
-    public void testNoSnoozingOnPost() {
-        NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
-        StatusBarNotification sbn = generateSbn(channel.getId());
-        NotificationEntry entry = new NotificationEntry(
-                mContext, mPackageManager, sbn, channel, mSmsHelper);
-
-
-        mAgingHelper.onNotificationPosted(entry);
-        verify(mAlarmManager, never()).setExactAndAllowWhileIdle(anyInt(), anyLong(), any());
-    }
-
-    @Test
-    public void testPostResetsSnooze() {
-        NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
-        StatusBarNotification sbn = generateSbn(channel.getId());
-        NotificationEntry entry = new NotificationEntry(
-                mContext, mPackageManager, sbn, channel, mSmsHelper);
-
-
-        mAgingHelper.onNotificationPosted(entry);
-        verify(mAlarmManager, times(1)).cancel(any(PendingIntent.class));
-    }
-
-    @Test
-    public void testSnoozingOnSeen() {
-        NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
-        StatusBarNotification sbn = generateSbn(channel.getId());
-        NotificationEntry entry = new NotificationEntry(
-                mContext, mPackageManager, sbn, channel, mSmsHelper);
-        entry.setSeen();
-        when(mCategorizer.getCategory(entry)).thenReturn(NotificationCategorizer.CATEGORY_PEOPLE);
-
-        mAgingHelper.onNotificationSeen(entry);
-        verify(mAlarmManager, times(1)).setExactAndAllowWhileIdle(anyInt(), anyLong(), any());
-    }
-
-    @Test
-    public void testNoSnoozingOnSeenUserLocked() {
-        NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
-        channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
-        StatusBarNotification sbn = generateSbn(channel.getId());
-        NotificationEntry entry = new NotificationEntry(
-                mContext, mPackageManager, sbn, channel, mSmsHelper);
-        when(mCategorizer.getCategory(entry)).thenReturn(NotificationCategorizer.CATEGORY_PEOPLE);
-
-        mAgingHelper.onNotificationSeen(entry);
-        verify(mAlarmManager, never()).setExactAndAllowWhileIdle(anyInt(), anyLong(), any());
-    }
-
-    @Test
-    public void testNoSnoozingOnSeenAlreadyLow() {
-        NotificationEntry entry = mock(NotificationEntry.class);
-        when(entry.getChannel()).thenReturn(new NotificationChannel("", "", IMPORTANCE_HIGH));
-        when(entry.getImportance()).thenReturn(IMPORTANCE_MIN);
-
-        mAgingHelper.onNotificationSeen(entry);
-        verify(mAlarmManager, never()).setExactAndAllowWhileIdle(anyInt(), anyLong(), any());
-    }
-}