Remove unneeded methods
Test: make, make cts, make cts-verifier, runtest systemui-notification
Change-Id: I25b559cfcc30f2d85f468adf840f9124e80f00b0
diff --git a/api/system-current.txt b/api/system-current.txt
index 9b295bf..87fc385 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -40360,7 +40360,6 @@
method public int getUser();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.notification.Adjustment> CREATOR;
- field public static final java.lang.String KEY_CHANNEL_ID = "key_channel_id";
field public static final java.lang.String KEY_PEOPLE = "key_people";
field public static final java.lang.String KEY_SNOOZE_CRITERIA = "key_snooze_criteria";
}
@@ -40415,14 +40414,10 @@
ctor public NotificationAssistantService();
method public final void adjustNotification(android.service.notification.Adjustment);
method public final void adjustNotifications(java.util.List<android.service.notification.Adjustment>);
- method public void createNotificationChannel(java.lang.String, android.app.NotificationChannel);
- method public void deleteNotificationChannel(java.lang.String, java.lang.String);
- method public java.util.List<android.app.NotificationChannel> getNotificationChannels(java.lang.String);
method public final android.os.IBinder onBind(android.content.Intent);
method public abstract android.service.notification.Adjustment onNotificationEnqueued(android.service.notification.StatusBarNotification);
method public abstract void onNotificationSnoozedUntilContext(android.service.notification.StatusBarNotification, java.lang.String);
method public final void unsnoozeNotification(java.lang.String);
- method public void updateNotificationChannel(java.lang.String, android.app.NotificationChannel);
field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService";
}
diff --git a/api/test-current.txt b/api/test-current.txt
index 6db91be..e9f19db 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -37453,7 +37453,6 @@
method public int getUser();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.notification.Adjustment> CREATOR;
- field public static final java.lang.String KEY_CHANNEL_ID = "key_channel_id";
field public static final java.lang.String KEY_PEOPLE = "key_people";
field public static final java.lang.String KEY_SNOOZE_CRITERIA = "key_snooze_criteria";
}
@@ -37508,14 +37507,10 @@
ctor public NotificationAssistantService();
method public final void adjustNotification(android.service.notification.Adjustment);
method public final void adjustNotifications(java.util.List<android.service.notification.Adjustment>);
- method public void createNotificationChannel(java.lang.String, android.app.NotificationChannel);
- method public void deleteNotificationChannel(java.lang.String, java.lang.String);
- method public java.util.List<android.app.NotificationChannel> getNotificationChannels(java.lang.String);
method public final android.os.IBinder onBind(android.content.Intent);
method public abstract android.service.notification.Adjustment onNotificationEnqueued(android.service.notification.StatusBarNotification);
method public abstract void onNotificationSnoozedUntilContext(android.service.notification.StatusBarNotification, java.lang.String);
method public final void unsnoozeNotification(java.lang.String);
- method public void updateNotificationChannel(java.lang.String, android.app.NotificationChannel);
field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService";
}
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index 43cad5b..61dacef 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -104,10 +104,6 @@
void applyEnqueuedAdjustmentFromAssistant(in INotificationListener token, in Adjustment adjustment);
void applyAdjustmentFromAssistant(in INotificationListener token, in Adjustment adjustment);
void applyAdjustmentsFromAssistant(in INotificationListener token, in List<Adjustment> adjustments);
- void createNotificationChannelFromAssistant(in INotificationListener token, String pkg, in NotificationChannel channel);
- void updateNotificationChannelFromAssistant(in INotificationListener token, String pkg, in NotificationChannel channel);
- void deleteNotificationChannelFromAssistant(in INotificationListener token, String pkg, String channelId);
- ParceledListSlice getNotificationChannelsFromAssistant(in INotificationListener token, String pkg);
void unsnoozeNotificationFromAssistant(in INotificationListener token, String key);
ComponentName getEffectsSuppressor();
diff --git a/core/java/android/service/notification/Adjustment.java b/core/java/android/service/notification/Adjustment.java
index e39d53f..137cf57 100644
--- a/core/java/android/service/notification/Adjustment.java
+++ b/core/java/android/service/notification/Adjustment.java
@@ -36,10 +36,6 @@
private final int mUser;
/**
- * Data type: {@code String}. See {@link NotificationChannel#getId()}.
- */
- public static final String KEY_CHANNEL_ID = "key_channel_id";
- /**
* Data type: ArrayList of {@code String}, where each is a representation of a
* {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}.
* See {@link android.app.Notification.Builder#addPerson(String)}.
diff --git a/core/java/android/service/notification/NotificationAssistantService.java b/core/java/android/service/notification/NotificationAssistantService.java
index 46609df..6ec9d69 100644
--- a/core/java/android/service/notification/NotificationAssistantService.java
+++ b/core/java/android/service/notification/NotificationAssistantService.java
@@ -138,69 +138,6 @@
}
}
- /**
- * Creates a notification channel that notifications can be posted to for a given package.
- *
- * @param pkg The package to create a channel for.
- * @param channel the channel to attempt to create.
- */
- public void createNotificationChannel(@NonNull String pkg,
- @NonNull NotificationChannel channel) {
- if (!isBound()) return;
- try {
- getNotificationInterface().createNotificationChannelFromAssistant(
- mWrapper, pkg, channel);
- } catch (RemoteException e) {
- Log.v(TAG, "Unable to contact notification manager", e);
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Updates a notification channel for a given package.
- *
- * @param pkg The package to the channel belongs to.
- * @param channel the channel to attempt to update.
- */
- public void updateNotificationChannel(@NonNull String pkg,
- @NonNull NotificationChannel channel) {
- if (!isBound()) return;
- try {
- getNotificationInterface().updateNotificationChannelFromAssistant(
- mWrapper, pkg, channel);
- } catch (RemoteException e) {
- Log.v(TAG, "Unable to contact notification manager", e);
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Returns all notification channels belonging to the given package.
- */
- public List<NotificationChannel> getNotificationChannels(@NonNull String pkg) {
- if (!isBound()) return null;
- try {
- return getNotificationInterface().getNotificationChannelsFromAssistant(
- mWrapper, pkg).getList();
- } catch (RemoteException e) {
- Log.v(TAG, "Unable to contact notification manager", e);
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Deletes the given notification channel.
- */
- public void deleteNotificationChannel(@NonNull String pkg, @NonNull String channelId) {
- if (!isBound()) return;
- try {
- getNotificationInterface().deleteNotificationChannelFromAssistant(
- mWrapper, pkg, channelId);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
private class NotificationAssistantServiceWrapper extends NotificationListenerWrapper {
@Override
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 44c715b..64ee1e9 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1294,19 +1294,14 @@
sendRegisteredOnlyBroadcast(NotificationManager.ACTION_EFFECTS_SUPPRESSOR_CHANGED);
}
- private void updateNotificationChannelInt(String pkg, int uid, NotificationChannel channel,
- boolean fromAssistant) {
+ private void updateNotificationChannelInt(String pkg, int uid, NotificationChannel channel) {
if (channel.getImportance() == NotificationManager.IMPORTANCE_NONE) {
// cancel
cancelAllNotificationsInt(MY_UID, MY_PID, pkg, channel.getId(), 0, 0, true,
UserHandle.getUserId(Binder.getCallingUid()), REASON_CHANNEL_BANNED,
null);
}
- if (fromAssistant) {
- mRankingHelper.updateNotificationChannelFromAssistant(pkg, uid, channel);
- } else {
- mRankingHelper.updateNotificationChannel(pkg, uid, channel);
- }
+ mRankingHelper.updateNotificationChannel(pkg, uid, channel);
synchronized (mNotificationLock) {
final int N = mNotificationList.size();
@@ -1709,7 +1704,7 @@
NotificationChannel channel) {
enforceSystemOrSystemUI("Caller not system or systemui");
Preconditions.checkNotNull(channel);
- updateNotificationChannelInt(pkg, uid, channel, false);
+ updateNotificationChannelInt(pkg, uid, channel);
}
@Override
@@ -2646,47 +2641,6 @@
Binder.restoreCallingIdentity(identity);
}
}
-
- @Override
- public void createNotificationChannelFromAssistant(INotificationListener token, String pkg,
- NotificationChannel channel) throws RemoteException {
- ManagedServiceInfo info = mNotificationAssistants.checkServiceTokenLocked(token);
- int uid = mPackageManager.getPackageUid(pkg, 0, info.userid);
- mRankingHelper.createNotificationChannel(pkg, uid, channel, false /* fromTargetApp */);
- savePolicyFile();
- }
-
- @Override
- public void deleteNotificationChannelFromAssistant(INotificationListener token, String pkg,
- String channelId) throws RemoteException {
- ManagedServiceInfo info = mNotificationAssistants.checkServiceTokenLocked(token);
- if (NotificationChannel.DEFAULT_CHANNEL_ID.equals(channelId)) {
- throw new IllegalArgumentException("Cannot delete default channel");
- }
-
- int uid = mPackageManager.getPackageUid(pkg, 0, info.userid);
- cancelAllNotificationsInt(MY_UID, MY_PID, pkg, channelId, 0, 0, true,
- info.userid, REASON_CHANNEL_BANNED, null);
- mRankingHelper.deleteNotificationChannel(pkg, uid, channelId);
- savePolicyFile();
- }
-
- @Override
- public void updateNotificationChannelFromAssistant(INotificationListener token, String pkg,
- NotificationChannel channel) throws RemoteException {
- ManagedServiceInfo info = mNotificationAssistants.checkServiceTokenLocked(token);
- Preconditions.checkNotNull(channel);
- int uid = mPackageManager.getPackageUid(pkg, 0, info.userid);
- updateNotificationChannelInt(pkg, uid, channel, true);
- }
-
- @Override
- public ParceledListSlice<NotificationChannel> getNotificationChannelsFromAssistant(
- INotificationListener token, String pkg) throws RemoteException {
- ManagedServiceInfo info = mNotificationAssistants.checkServiceTokenLocked(token);
- int uid = mPackageManager.getPackageUid(pkg, 0, info.userid);
- return mRankingHelper.getNotificationChannels(pkg, uid, false /* includeDeleted */);
- }
};
private void applyAdjustment(NotificationRecord n, Adjustment adjustment) {
@@ -2695,17 +2649,10 @@
}
if (adjustment.getSignals() != null) {
Bundle.setDefusable(adjustment.getSignals(), true);
- final String overrideChannelId =
- adjustment.getSignals().getString(Adjustment.KEY_CHANNEL_ID, null);
final ArrayList<String> people =
adjustment.getSignals().getStringArrayList(Adjustment.KEY_PEOPLE);
final ArrayList<SnoozeCriterion> snoozeCriterionList =
adjustment.getSignals().getParcelableArrayList(Adjustment.KEY_SNOOZE_CRITERIA);
- if (!TextUtils.isEmpty(overrideChannelId)) {
- n.updateNotificationChannel(mRankingHelper.getNotificationChannel(
- n.sbn.getPackageName(), n.sbn.getUid(), overrideChannelId,
- false /* includeDeleted */));
- }
n.setPeopleOverride(people);
n.setSnoozeCriteria(snoozeCriterionList);
}
diff --git a/services/core/java/com/android/server/notification/RankingConfig.java b/services/core/java/com/android/server/notification/RankingConfig.java
index e13df19..4d19b52 100644
--- a/services/core/java/com/android/server/notification/RankingConfig.java
+++ b/services/core/java/com/android/server/notification/RankingConfig.java
@@ -37,7 +37,6 @@
void createNotificationChannel(String pkg, int uid, NotificationChannel channel,
boolean fromTargetApp);
void updateNotificationChannel(String pkg, int uid, NotificationChannel channel);
- void updateNotificationChannelFromAssistant(String pkg, int uid, NotificationChannel channel);
NotificationChannel getNotificationChannel(String pkg, int uid, String channelId, boolean includeDeleted);
void deleteNotificationChannel(String pkg, int uid, String channelId);
void permanentlyDeleteNotificationChannel(String pkg, int uid, String channelId);
diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java
index 65aaee0..b63b05f 100644
--- a/services/core/java/com/android/server/notification/RankingHelper.java
+++ b/services/core/java/com/android/server/notification/RankingHelper.java
@@ -609,55 +609,6 @@
}
@Override
- public void updateNotificationChannelFromAssistant(String pkg, int uid,
- NotificationChannel updatedChannel) {
- Record r = getOrCreateRecord(pkg, uid);
- if (r == null) {
- throw new IllegalArgumentException("Invalid package");
- }
- NotificationChannel channel = r.channels.get(updatedChannel.getId());
- if (channel == null || channel.isDeleted()) {
- throw new IllegalArgumentException("Channel does not exist");
- }
-
- if ((channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_IMPORTANCE) == 0) {
- channel.setImportance(updatedChannel.getImportance());
- }
- if ((channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_LIGHTS) == 0) {
- channel.enableLights(updatedChannel.shouldShowLights());
- channel.setLightColor(updatedChannel.getLightColor());
- }
- if ((channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_PRIORITY) == 0) {
- channel.setBypassDnd(updatedChannel.canBypassDnd());
- }
- if ((channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_SOUND) == 0) {
- channel.setSound(updatedChannel.getSound(), updatedChannel.getAudioAttributes());
- }
- if ((channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_VIBRATION) == 0) {
- channel.enableVibration(updatedChannel.shouldVibrate());
- channel.setVibrationPattern(updatedChannel.getVibrationPattern());
- }
- if ((channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_VISIBILITY) == 0) {
- if (updatedChannel.getLockscreenVisibility() == Notification.VISIBILITY_PUBLIC) {
- channel.setLockscreenVisibility(Ranking.VISIBILITY_NO_OVERRIDE);
- } else {
- channel.setLockscreenVisibility(updatedChannel.getLockscreenVisibility());
- }
- }
- if ((channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_SHOW_BADGE) == 0) {
- channel.setShowBadge(updatedChannel.canShowBadge());
- }
- if (updatedChannel.isDeleted()) {
- channel.setDeleted(true);
- }
- // Assistant cannot change the group
-
- MetricsLogger.action(getChannelLog(channel, pkg));
- r.channels.put(channel.getId(), channel);
- updateConfig();
- }
-
- @Override
public NotificationChannel getNotificationChannel(String pkg, int uid, String channelId,
boolean includeDeleted) {
Preconditions.checkNotNull(pkg);
diff --git a/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java b/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java
index 40af2f8..ad593be 100644
--- a/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java
+++ b/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java
@@ -497,149 +497,6 @@
new NotificationChannel("bananas", "bananas", IMPORTANCE_LOW), true);
}
- @Test
- public void testUpdate_userLockedImportance() throws Exception {
- // all fields locked by user
- final NotificationChannel channel =
- new NotificationChannel("id2", "name2", IMPORTANCE_LOW);
- channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
-
- mHelper.createNotificationChannel(PKG, UID, channel, false);
-
- // same id, try to update
- final NotificationChannel channel2 =
- new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_HIGH);
-
- mHelper.updateNotificationChannelFromAssistant(PKG, UID, channel2);
-
- // no fields should be changed
- assertEquals(channel, mHelper.getNotificationChannel(PKG, UID, channel.getId(), false));
- }
-
- @Test
- public void testUpdate_userLockedVisibility() throws Exception {
- // all fields locked by user
- final NotificationChannel channel =
- new NotificationChannel("id2", "name2", IMPORTANCE_LOW);
- channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
- channel.lockFields(NotificationChannel.USER_LOCKED_VISIBILITY);
-
- mHelper.createNotificationChannel(PKG, UID, channel, false);
-
- // same id, try to update
- final NotificationChannel channel2 =
- new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_HIGH);
- channel2.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
-
- mHelper.updateNotificationChannelFromAssistant(PKG, UID, channel2);
-
- // no fields should be changed
- assertEquals(channel, mHelper.getNotificationChannel(PKG, UID, channel.getId(), false));
- }
-
- @Test
- public void testUpdate_userLockedVibration() throws Exception {
- // all fields locked by user
- final NotificationChannel channel =
- new NotificationChannel("id2", "name2", IMPORTANCE_LOW);
- channel.enableLights(false);
- channel.lockFields(NotificationChannel.USER_LOCKED_VIBRATION);
-
- mHelper.createNotificationChannel(PKG, UID, channel, false);
-
- // same id, try to update
- final NotificationChannel channel2 =
- new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_HIGH);
- channel2.enableVibration(true);
- channel2.setVibrationPattern(new long[]{100});
-
- mHelper.updateNotificationChannelFromAssistant(PKG, UID, channel2);
-
- // no fields should be changed
- assertEquals(channel, mHelper.getNotificationChannel(PKG, UID, channel.getId(), false));
- }
-
- @Test
- public void testUpdate_userLockedLights() throws Exception {
- // all fields locked by user
- final NotificationChannel channel =
- new NotificationChannel("id2", "name2", IMPORTANCE_LOW);
- channel.enableLights(false);
- channel.lockFields(NotificationChannel.USER_LOCKED_LIGHTS);
-
- mHelper.createNotificationChannel(PKG, UID, channel, false);
-
- // same id, try to update
- final NotificationChannel channel2 =
- new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_HIGH);
- channel2.enableLights(true);
-
- mHelper.updateNotificationChannelFromAssistant(PKG, UID, channel2);
-
- // no fields should be changed
- assertEquals(channel, mHelper.getNotificationChannel(PKG, UID, channel.getId(), false));
- }
-
- @Test
- public void testUpdate_userLockedPriority() throws Exception {
- // all fields locked by user
- final NotificationChannel channel =
- new NotificationChannel("id2", "name2", IMPORTANCE_LOW);
- channel.setBypassDnd(true);
- channel.lockFields(NotificationChannel.USER_LOCKED_PRIORITY);
-
- mHelper.createNotificationChannel(PKG, UID, channel, false);
-
- // same id, try to update all fields
- final NotificationChannel channel2 =
- new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_HIGH);
- channel2.setBypassDnd(false);
-
- mHelper.updateNotificationChannelFromAssistant(PKG, UID, channel2);
-
- // no fields should be changed
- assertEquals(channel, mHelper.getNotificationChannel(PKG, UID, channel.getId(), false));
- }
-
- @Test
- public void testUpdate_userLockedRingtone() throws Exception {
- // all fields locked by user
- final NotificationChannel channel =
- new NotificationChannel("id2", "name2", IMPORTANCE_LOW);
- channel.setSound(new Uri.Builder().scheme("test").build(), mAudioAttributes);
- channel.lockFields(NotificationChannel.USER_LOCKED_SOUND);
-
- mHelper.createNotificationChannel(PKG, UID, channel, false);
-
- // same id, try to update all fields
- final NotificationChannel channel2 =
- new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_HIGH);
- channel2.setSound(new Uri.Builder().scheme("test2").build(), mAudioAttributes);
-
- mHelper.updateNotificationChannelFromAssistant(PKG, UID, channel2);
-
- // no fields should be changed
- assertEquals(channel, mHelper.getNotificationChannel(PKG, UID, channel.getId(), false));
- }
-
- @Test
- public void testUpdate_userLockedBadge() throws Exception {
- final NotificationChannel channel =
- new NotificationChannel("id2", "name2", IMPORTANCE_LOW);
- channel.setShowBadge(true);
- channel.lockFields(NotificationChannel.USER_LOCKED_SHOW_BADGE);
-
- mHelper.createNotificationChannel(PKG, UID, channel, false);
-
- final NotificationChannel channel2 =
- new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_HIGH);
- channel2.setShowBadge(false);
-
- mHelper.updateNotificationChannelFromAssistant(PKG, UID, channel2);
-
- // no fields should be changed
- assertEquals(channel, mHelper.getNotificationChannel(PKG, UID, channel.getId(), false));
- }
@Test
public void testUpdate() throws Exception {
@@ -816,30 +673,6 @@
}
@Test
- public void testUpdateDeletedChannels() throws Exception {
- NotificationChannel channel =
- new NotificationChannel("id2", "name2", IMPORTANCE_LOW);
- mHelper.createNotificationChannel(PKG, UID, channel, true);
-
- mHelper.deleteNotificationChannel(PKG, UID, channel.getId());
-
- channel.setSound(new Uri.Builder().scheme("test").build(), mAudioAttributes);
- try {
- mHelper.updateNotificationChannel(PKG, UID, channel);
- fail("Updated deleted channel");
- } catch (IllegalArgumentException e) {
- // :)
- }
-
- try {
- mHelper.updateNotificationChannelFromAssistant(PKG, UID, channel);
- fail("Updated deleted channel");
- } catch (IllegalArgumentException e) {
- // :)
- }
- }
-
- @Test
public void testCreateDeletedChannel() throws Exception {
long[] vibration = new long[]{100, 67, 145, 156};
NotificationChannel channel =