Merge "Delete deleteConversationNotificationChannels from NotificationManagerService." into sc-dev

This commit is contained in:
Yuri Lin
2021-03-29 19:39:25 +00:00
committed by Android (Google) Code Review
3 changed files with 0 additions and 74 deletions

View File

@@ -104,7 +104,6 @@ interface INotificationManager
void createConversationNotificationChannelForPackage(String pkg, int uid, in NotificationChannel parentChannel, String conversationId);
NotificationChannel getNotificationChannelForPackage(String pkg, int uid, String channelId, String conversationId, boolean includeDeleted);
void deleteNotificationChannel(String pkg, String channelId);
void deleteConversationNotificationChannels(String pkg, int uid, String conversationId);
ParceledListSlice getNotificationChannels(String callingPkg, String targetPkg, int userId);
ParceledListSlice getNotificationChannelsForPackage(String pkg, int uid, boolean includeDeleted);
int getNumNotificationChannelsForPackage(String pkg, int uid, boolean includeDeleted);

View File

@@ -3616,34 +3616,6 @@ public class NotificationManagerService extends SystemService {
handleSavePolicyFile();
}
@Override
public void deleteConversationNotificationChannels(String pkg, int uid,
String conversationId) {
checkCallerIsSystem();
List<NotificationChannel> channels =
mPreferencesHelper.getNotificationChannelsByConversationId(
pkg, uid, conversationId);
if (!channels.isEmpty()) {
// Preflight for fg service notifications in these channels: do nothing
// unless they're all eligible
final int appUserId = UserHandle.getUserId(uid);
for (NotificationChannel nc : channels) {
final String channelId = nc.getId();
mAmi.stopForegroundServicesForChannel(pkg, appUserId, channelId);
cancelAllNotificationsInt(MY_UID, MY_PID, pkg, nc.getId(), 0, 0, true,
appUserId, REASON_CHANNEL_REMOVED, null);
mPreferencesHelper.deleteNotificationChannel(pkg, uid, channelId);
mListeners.notifyNotificationChannelChanged(pkg,
UserHandle.getUserHandleForUid(uid),
mPreferencesHelper.getNotificationChannel(
pkg, uid, channelId, true),
NOTIFICATION_CHANNEL_OR_GROUP_DELETED);
}
handleSavePolicyFile();
}
}
@Override
public NotificationChannelGroup getNotificationChannelGroup(String pkg, String groupId) {
checkCallerIsSystemOrSameApp(pkg);

View File

@@ -6971,51 +6971,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
assertNotNull(friendChannel.getId());
}
@Test
public void deleteConversationNotificationChannels() throws Exception {
NotificationChannel messagesParent =
new NotificationChannel("messages", "messages", IMPORTANCE_HIGH);
Parcel msgParcel = Parcel.obtain();
messagesParent.writeToParcel(msgParcel, 0);
msgParcel.setDataPosition(0);
NotificationChannel callsParent =
new NotificationChannel("calls", "calls", IMPORTANCE_HIGH);
Parcel callParcel = Parcel.obtain();
callsParent.writeToParcel(callParcel, 0);
callParcel.setDataPosition(0);
mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(
messagesParent, callsParent)));
String conversationId = "friend";
mBinderService.createConversationNotificationChannelForPackage(
PKG, mUid, NotificationChannel.CREATOR.createFromParcel(msgParcel),
conversationId);
mBinderService.createConversationNotificationChannelForPackage(
PKG, mUid, NotificationChannel.CREATOR.createFromParcel(callParcel),
conversationId);
NotificationChannel messagesChild = mBinderService.getConversationNotificationChannel(
PKG, 0, PKG, messagesParent.getId(), false, conversationId);
NotificationChannel callsChild = mBinderService.getConversationNotificationChannel(
PKG, 0, PKG, callsParent.getId(), false, conversationId);
assertEquals(messagesParent.getId(), messagesChild.getParentChannelId());
assertEquals(conversationId, messagesChild.getConversationId());
assertEquals(callsParent.getId(), callsChild.getParentChannelId());
assertEquals(conversationId, callsChild.getConversationId());
mBinderService.deleteConversationNotificationChannels(PKG, mUid, conversationId);
assertNull(mBinderService.getConversationNotificationChannel(
PKG, 0, PKG, messagesParent.getId(), false, conversationId));
assertNull(mBinderService.getConversationNotificationChannel(
PKG, 0, PKG, callsParent.getId(), false, conversationId));
}
@Test
public void testCorrectCategory_systemOn_appCannotTurnOff() {
int requested = 0;