• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 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 
17 package com.android.calendar.alerts;
18 
19 import android.content.BroadcastReceiver;
20 import android.content.ContentResolver;
21 import android.content.ContentValues;
22 import android.content.Context;
23 import android.content.Intent;
24 import android.content.SharedPreferences;
25 import android.database.Cursor;
26 import android.net.Uri;
27 import android.os.AsyncTask;
28 import android.os.Bundle;
29 import android.provider.CalendarContract.CalendarAlerts;
30 import android.provider.CalendarContract.Calendars;
31 import android.provider.CalendarContract.Events;
32 import android.util.Log;
33 import android.util.Pair;
34 
35 import com.android.calendar.R;
36 
37 import java.io.IOException;
38 import java.util.HashMap;
39 import java.util.HashSet;
40 import java.util.Iterator;
41 import java.util.LinkedHashSet;
42 import java.util.List;
43 import java.util.Map;
44 import java.util.Set;
45 
46 /**
47  * Utilities for managing notification dismissal across devices.
48  */
49 public class GlobalDismissManager extends BroadcastReceiver {
50     public static class AlarmId {
51         public long mEventId;
52         public long mStart;
53 
AlarmId(long id, long start)54         public AlarmId(long id, long start) {
55             mEventId = id;
56             mStart = start;
57         }
58     }
59 
60     /**
61      * Globally dismiss notifications that are backed by the same events.
62      *
63      * @param context application context
64      * @param alarmIds Unique identifiers for events that have been dismissed by the user.
65      * @return true if notification_sender_id is available
66      */
dismissGlobally(Context context, List<AlarmId> alarmIds)67     public static void dismissGlobally(Context context, List<AlarmId> alarmIds) {
68         Set<Long> eventIds = new HashSet<Long>(alarmIds.size());
69         for (AlarmId alarmId: alarmIds) {
70             eventIds.add(alarmId.mEventId);
71         }
72     }
73 
74     @Override
75     @SuppressWarnings("unchecked")
onReceive(Context context, Intent intent)76     public void onReceive(Context context, Intent intent) {
77         new AsyncTask<Pair<Context, Intent>, Void, Void>() {
78             @Override
79             protected Void doInBackground(Pair<Context, Intent>... params) {
80                 return null;
81             }
82         }.execute(new Pair<Context, Intent>(context, intent));
83     }
84 }
85