1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 package com.android.calendar.alerts 17 18 import android.content.BroadcastReceiver 19 import android.content.Context 20 import android.content.Intent 21 import android.os.AsyncTask 22 import android.util.Pair 23 import java.util.HashSet 24 import java.util.List 25 26 /** 27 * Utilities for managing notification dismissal across devices. 28 */ 29 class GlobalDismissManager : BroadcastReceiver() { 30 class AlarmId(var mEventId: Long, var mStart: Long) 31 32 @Override 33 @SuppressWarnings("unchecked") onReceivenull34 override fun onReceive(context: Context?, intent: Intent?) { 35 object : AsyncTask<Pair<Context?, Intent?>?, Void?, Void?>() { 36 @Override 37 protected override fun doInBackground(vararg params: Pair<Context?, Intent?>?): Void? { 38 return null 39 } 40 }.execute(Pair<Context?, Intent?>(context, intent)) 41 } 42 43 companion object { 44 /** 45 * Globally dismiss notifications that are backed by the same events. 46 * 47 * @param context application context 48 * @param alarmIds Unique identifiers for events that have been dismissed by the user. 49 * @return true if notification_sender_id is available 50 */ dismissGloballynull51 @JvmStatic fun dismissGlobally(context: Context?, alarmIds: List<AlarmId>) { 52 val eventIds: HashSet<Long> = HashSet<Long>(alarmIds.size) 53 for (alarmId in alarmIds) { 54 eventIds.add(alarmId.mEventId) 55 } 56 } 57 } 58 }