John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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.server.notification; |
| 18 | |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 19 | import android.app.AlarmManager; |
| 20 | import android.app.PendingIntent; |
| 21 | import android.content.BroadcastReceiver; |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 22 | import android.content.ComponentName; |
| 23 | import android.content.Context; |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 24 | import android.content.Intent; |
| 25 | import android.content.IntentFilter; |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 26 | import android.content.pm.PackageManager.NameNotFoundException; |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 27 | import android.net.Uri; |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 28 | import android.os.Handler; |
Julia Reynolds | 7034caf | 2016-03-09 10:41:00 -0500 | [diff] [blame] | 29 | import android.os.HandlerThread; |
Julia Reynolds | 7034caf | 2016-03-09 10:41:00 -0500 | [diff] [blame] | 30 | import android.os.Process; |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 31 | import android.os.UserHandle; |
| 32 | import android.os.UserManager; |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 33 | import android.service.notification.Condition; |
| 34 | import android.service.notification.IConditionProvider; |
| 35 | import android.service.notification.ZenModeConfig; |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 36 | import android.service.notification.ZenModeConfig.EventInfo; |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 37 | import android.util.ArraySet; |
| 38 | import android.util.Log; |
| 39 | import android.util.Slog; |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 40 | import android.util.SparseArray; |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 41 | |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 42 | import com.android.server.notification.CalendarTracker.CheckEventResult; |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 43 | import com.android.server.notification.NotificationManagerService.DumpFilter; |
| 44 | |
| 45 | import java.io.PrintWriter; |
Julia Reynolds | 2c93da9 | 2016-03-15 16:39:24 -0400 | [diff] [blame] | 46 | import java.util.ArrayList; |
| 47 | import java.util.List; |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * Built-in zen condition provider for calendar event-based conditions. |
| 51 | */ |
| 52 | public class EventConditionProvider extends SystemConditionProviderService { |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 53 | private static final String TAG = "ConditionProviders.ECP"; |
| 54 | private static final boolean DEBUG = Log.isLoggable("ConditionProviders", Log.DEBUG); |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 55 | |
| 56 | public static final ComponentName COMPONENT = |
| 57 | new ComponentName("android", EventConditionProvider.class.getName()); |
| 58 | private static final String NOT_SHOWN = "..."; |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 59 | private static final String SIMPLE_NAME = EventConditionProvider.class.getSimpleName(); |
| 60 | private static final String ACTION_EVALUATE = SIMPLE_NAME + ".EVALUATE"; |
| 61 | private static final int REQUEST_CODE_EVALUATE = 1; |
| 62 | private static final String EXTRA_TIME = "time"; |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 63 | private static final long CHANGE_DELAY = 2 * 1000; // coalesce chatty calendar changes |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 64 | |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 65 | private final Context mContext = this; |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 66 | private final ArraySet<Uri> mSubscriptions = new ArraySet<Uri>(); |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 67 | private final SparseArray<CalendarTracker> mTrackers = new SparseArray<>(); |
| 68 | private final Handler mWorker; |
Julia Reynolds | 7034caf | 2016-03-09 10:41:00 -0500 | [diff] [blame] | 69 | private final HandlerThread mThread; |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 70 | |
| 71 | private boolean mConnected; |
| 72 | private boolean mRegistered; |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 73 | private boolean mBootComplete; // don't hammer the calendar provider until boot completes. |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 74 | private long mNextAlarmTime; |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 75 | |
Julia Reynolds | 7034caf | 2016-03-09 10:41:00 -0500 | [diff] [blame] | 76 | public EventConditionProvider() { |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 77 | if (DEBUG) Slog.d(TAG, "new " + SIMPLE_NAME + "()"); |
Julia Reynolds | 7034caf | 2016-03-09 10:41:00 -0500 | [diff] [blame] | 78 | mThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND); |
| 79 | mThread.start(); |
| 80 | mWorker = new Handler(mThread.getLooper()); |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public ComponentName getComponent() { |
| 85 | return COMPONENT; |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public boolean isValidConditionId(Uri id) { |
| 90 | return ZenModeConfig.isValidEventConditionId(id); |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public void dump(PrintWriter pw, DumpFilter filter) { |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 95 | pw.print(" "); pw.print(SIMPLE_NAME); pw.println(":"); |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 96 | pw.print(" mConnected="); pw.println(mConnected); |
| 97 | pw.print(" mRegistered="); pw.println(mRegistered); |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 98 | pw.print(" mBootComplete="); pw.println(mBootComplete); |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 99 | dumpUpcomingTime(pw, "mNextAlarmTime", mNextAlarmTime, System.currentTimeMillis()); |
Julia Reynolds | 2c93da9 | 2016-03-15 16:39:24 -0400 | [diff] [blame] | 100 | synchronized (mSubscriptions) { |
| 101 | pw.println(" mSubscriptions="); |
| 102 | for (Uri conditionId : mSubscriptions) { |
| 103 | pw.print(" "); |
| 104 | pw.println(conditionId); |
| 105 | } |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 106 | } |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 107 | pw.println(" mTrackers="); |
| 108 | for (int i = 0; i < mTrackers.size(); i++) { |
| 109 | pw.print(" user="); pw.println(mTrackers.keyAt(i)); |
| 110 | mTrackers.valueAt(i).dump(" ", pw); |
| 111 | } |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | @Override |
| 115 | public void onBootComplete() { |
| 116 | if (DEBUG) Slog.d(TAG, "onBootComplete"); |
| 117 | if (mBootComplete) return; |
| 118 | mBootComplete = true; |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 119 | final IntentFilter filter = new IntentFilter(); |
| 120 | filter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED); |
| 121 | filter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED); |
| 122 | mContext.registerReceiver(new BroadcastReceiver() { |
| 123 | @Override |
| 124 | public void onReceive(Context context, Intent intent) { |
| 125 | reloadTrackers(); |
| 126 | } |
| 127 | }, filter); |
| 128 | reloadTrackers(); |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | @Override |
| 132 | public void onConnected() { |
| 133 | if (DEBUG) Slog.d(TAG, "onConnected"); |
| 134 | mConnected = true; |
| 135 | } |
| 136 | |
| 137 | @Override |
| 138 | public void onDestroy() { |
| 139 | super.onDestroy(); |
| 140 | if (DEBUG) Slog.d(TAG, "onDestroy"); |
| 141 | mConnected = false; |
| 142 | } |
| 143 | |
| 144 | @Override |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 145 | public void onSubscribe(Uri conditionId) { |
| 146 | if (DEBUG) Slog.d(TAG, "onSubscribe " + conditionId); |
| 147 | if (!ZenModeConfig.isValidEventConditionId(conditionId)) { |
Julia Reynolds | 2c93da9 | 2016-03-15 16:39:24 -0400 | [diff] [blame] | 148 | notifyCondition(createCondition(conditionId, Condition.STATE_FALSE)); |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 149 | return; |
| 150 | } |
Julia Reynolds | 2c93da9 | 2016-03-15 16:39:24 -0400 | [diff] [blame] | 151 | synchronized (mSubscriptions) { |
| 152 | if (mSubscriptions.add(conditionId)) { |
| 153 | evaluateSubscriptions(); |
| 154 | } |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 155 | } |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | @Override |
| 159 | public void onUnsubscribe(Uri conditionId) { |
| 160 | if (DEBUG) Slog.d(TAG, "onUnsubscribe " + conditionId); |
Julia Reynolds | 2c93da9 | 2016-03-15 16:39:24 -0400 | [diff] [blame] | 161 | synchronized (mSubscriptions) { |
| 162 | if (mSubscriptions.remove(conditionId)) { |
| 163 | evaluateSubscriptions(); |
| 164 | } |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 165 | } |
| 166 | } |
| 167 | |
| 168 | @Override |
| 169 | public void attachBase(Context base) { |
| 170 | attachBaseContext(base); |
| 171 | } |
| 172 | |
| 173 | @Override |
| 174 | public IConditionProvider asInterface() { |
| 175 | return (IConditionProvider) onBind(null); |
| 176 | } |
| 177 | |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 178 | private void reloadTrackers() { |
| 179 | if (DEBUG) Slog.d(TAG, "reloadTrackers"); |
| 180 | for (int i = 0; i < mTrackers.size(); i++) { |
| 181 | mTrackers.valueAt(i).setCallback(null); |
| 182 | } |
| 183 | mTrackers.clear(); |
| 184 | for (UserHandle user : UserManager.get(mContext).getUserProfiles()) { |
Xiaohui Chen | 6655630 | 2015-10-21 11:19:42 -0700 | [diff] [blame] | 185 | final Context context = user.isSystem() ? mContext : getContextForUser(mContext, user); |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 186 | if (context == null) { |
| 187 | Slog.w(TAG, "Unable to create context for user " + user.getIdentifier()); |
| 188 | continue; |
| 189 | } |
| 190 | mTrackers.put(user.getIdentifier(), new CalendarTracker(mContext, context)); |
| 191 | } |
| 192 | evaluateSubscriptions(); |
| 193 | } |
| 194 | |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 195 | private void evaluateSubscriptions() { |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 196 | if (!mWorker.hasCallbacks(mEvaluateSubscriptionsW)) { |
| 197 | mWorker.post(mEvaluateSubscriptionsW); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | private void evaluateSubscriptionsW() { |
| 202 | if (DEBUG) Slog.d(TAG, "evaluateSubscriptions"); |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 203 | if (!mBootComplete) { |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 204 | if (DEBUG) Slog.d(TAG, "Skipping evaluate before boot complete"); |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 205 | return; |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 206 | } |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 207 | final long now = System.currentTimeMillis(); |
Julia Reynolds | 2c93da9 | 2016-03-15 16:39:24 -0400 | [diff] [blame] | 208 | List<Condition> conditionsToNotify = new ArrayList<>(); |
| 209 | synchronized (mSubscriptions) { |
| 210 | for (int i = 0; i < mTrackers.size(); i++) { |
| 211 | mTrackers.valueAt(i).setCallback( |
| 212 | mSubscriptions.isEmpty() ? null : mTrackerCallback); |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 213 | } |
Julia Reynolds | 2c93da9 | 2016-03-15 16:39:24 -0400 | [diff] [blame] | 214 | setRegistered(!mSubscriptions.isEmpty()); |
| 215 | long reevaluateAt = 0; |
| 216 | for (Uri conditionId : mSubscriptions) { |
| 217 | final EventInfo event = ZenModeConfig.tryParseEventConditionId(conditionId); |
| 218 | if (event == null) { |
| 219 | conditionsToNotify.add(createCondition(conditionId, Condition.STATE_FALSE)); |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 220 | continue; |
| 221 | } |
Julia Reynolds | 2c93da9 | 2016-03-15 16:39:24 -0400 | [diff] [blame] | 222 | CheckEventResult result = null; |
Beverly | cf0fbcec | 2018-09-07 16:52:16 -0400 | [diff] [blame] | 223 | if (event.calName == null) { // any calendar |
Julia Reynolds | 2c93da9 | 2016-03-15 16:39:24 -0400 | [diff] [blame] | 224 | // event could exist on any tracker |
| 225 | for (int i = 0; i < mTrackers.size(); i++) { |
| 226 | final CalendarTracker tracker = mTrackers.valueAt(i); |
| 227 | final CheckEventResult r = tracker.checkEvent(event, now); |
| 228 | if (result == null) { |
| 229 | result = r; |
| 230 | } else { |
| 231 | result.inEvent |= r.inEvent; |
| 232 | result.recheckAt = Math.min(result.recheckAt, r.recheckAt); |
| 233 | } |
| 234 | } |
| 235 | } else { |
| 236 | // event should exist on one tracker |
| 237 | final int userId = EventInfo.resolveUserId(event.userId); |
| 238 | final CalendarTracker tracker = mTrackers.get(userId); |
| 239 | if (tracker == null) { |
| 240 | Slog.w(TAG, "No calendar tracker found for user " + userId); |
| 241 | conditionsToNotify.add(createCondition(conditionId, Condition.STATE_FALSE)); |
| 242 | continue; |
| 243 | } |
| 244 | result = tracker.checkEvent(event, now); |
| 245 | } |
| 246 | if (result.recheckAt != 0 |
| 247 | && (reevaluateAt == 0 || result.recheckAt < reevaluateAt)) { |
| 248 | reevaluateAt = result.recheckAt; |
| 249 | } |
| 250 | if (!result.inEvent) { |
| 251 | conditionsToNotify.add(createCondition(conditionId, Condition.STATE_FALSE)); |
| 252 | continue; |
| 253 | } |
| 254 | conditionsToNotify.add(createCondition(conditionId, Condition.STATE_TRUE)); |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 255 | } |
Julia Reynolds | 2c93da9 | 2016-03-15 16:39:24 -0400 | [diff] [blame] | 256 | rescheduleAlarm(now, reevaluateAt); |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 257 | } |
Julia Reynolds | 2c93da9 | 2016-03-15 16:39:24 -0400 | [diff] [blame] | 258 | for (Condition condition : conditionsToNotify) { |
| 259 | if (condition != null) { |
| 260 | notifyCondition(condition); |
| 261 | } |
| 262 | } |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 263 | if (DEBUG) Slog.d(TAG, "evaluateSubscriptions took " + (System.currentTimeMillis() - now)); |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 264 | } |
| 265 | |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 266 | private void rescheduleAlarm(long now, long time) { |
| 267 | mNextAlarmTime = time; |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 268 | final AlarmManager alarms = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); |
| 269 | final PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, |
| 270 | REQUEST_CODE_EVALUATE, |
| 271 | new Intent(ACTION_EVALUATE) |
| 272 | .addFlags(Intent.FLAG_RECEIVER_FOREGROUND) |
| 273 | .putExtra(EXTRA_TIME, time), |
| 274 | PendingIntent.FLAG_UPDATE_CURRENT); |
| 275 | alarms.cancel(pendingIntent); |
| 276 | if (time == 0 || time < now) { |
| 277 | if (DEBUG) Slog.d(TAG, "Not scheduling evaluate: " + (time == 0 ? "no time specified" |
| 278 | : "specified time in the past")); |
| 279 | return; |
| 280 | } |
| 281 | if (DEBUG) Slog.d(TAG, String.format("Scheduling evaluate for %s, in %s, now=%s", |
| 282 | ts(time), formatDuration(time - now), ts(now))); |
| 283 | alarms.setExact(AlarmManager.RTC_WAKEUP, time, pendingIntent); |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 284 | } |
| 285 | |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 286 | private Condition createCondition(Uri id, int state) { |
| 287 | final String summary = NOT_SHOWN; |
| 288 | final String line1 = NOT_SHOWN; |
| 289 | final String line2 = NOT_SHOWN; |
| 290 | return new Condition(id, summary, line1, line2, 0, state, Condition.FLAG_RELEVANT_ALWAYS); |
| 291 | } |
| 292 | |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 293 | private void setRegistered(boolean registered) { |
| 294 | if (mRegistered == registered) return; |
| 295 | if (DEBUG) Slog.d(TAG, "setRegistered " + registered); |
| 296 | mRegistered = registered; |
| 297 | if (mRegistered) { |
| 298 | final IntentFilter filter = new IntentFilter(); |
| 299 | filter.addAction(Intent.ACTION_TIME_CHANGED); |
| 300 | filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); |
| 301 | filter.addAction(ACTION_EVALUATE); |
| 302 | registerReceiver(mReceiver, filter); |
| 303 | } else { |
| 304 | unregisterReceiver(mReceiver); |
| 305 | } |
| 306 | } |
| 307 | |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 308 | private static Context getContextForUser(Context context, UserHandle user) { |
| 309 | try { |
| 310 | return context.createPackageContextAsUser(context.getPackageName(), 0, user); |
| 311 | } catch (NameNotFoundException e) { |
| 312 | return null; |
| 313 | } |
| 314 | } |
| 315 | |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 316 | private final CalendarTracker.Callback mTrackerCallback = new CalendarTracker.Callback() { |
| 317 | @Override |
| 318 | public void onChanged() { |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 319 | if (DEBUG) Slog.d(TAG, "mTrackerCallback.onChanged"); |
| 320 | mWorker.removeCallbacks(mEvaluateSubscriptionsW); |
| 321 | mWorker.postDelayed(mEvaluateSubscriptionsW, CHANGE_DELAY); |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 322 | } |
| 323 | }; |
| 324 | |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 325 | private final BroadcastReceiver mReceiver = new BroadcastReceiver() { |
John Spurlock | 2f096ed | 2015-05-04 11:58:26 -0400 | [diff] [blame] | 326 | @Override |
| 327 | public void onReceive(Context context, Intent intent) { |
| 328 | if (DEBUG) Slog.d(TAG, "onReceive " + intent.getAction()); |
| 329 | evaluateSubscriptions(); |
| 330 | } |
| 331 | }; |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 332 | |
| 333 | private final Runnable mEvaluateSubscriptionsW = new Runnable() { |
| 334 | @Override |
| 335 | public void run() { |
| 336 | evaluateSubscriptionsW(); |
| 337 | } |
| 338 | }; |
John Spurlock | d60258f | 2015-04-30 09:30:52 -0400 | [diff] [blame] | 339 | } |