blob: f3da079dc708774e110b0937a8648bbcc8c27fb6 [file] [log] [blame]
Julia Reynoldsc861a3d2018-02-15 10:34:49 -05001/*
2* Copyright (C) 2018 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
17package com.android.server.notification;
18
Julia Reynoldsc861a3d2018-02-15 10:34:49 -050019import android.content.Context;
20import android.util.Log;
21import android.util.Slog;
22
23/**
24 * This {@link ZenModeExtractor} updates intercepted and visual interruption states.
25 */
26public class ZenModeExtractor implements NotificationSignalExtractor {
27 private static final String TAG = "ZenModeExtractor";
28 private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);
29
30 private ZenModeHelper mZenModeHelper;
31
32 public void initialize(Context ctx, NotificationUsageStats usageStats) {
33 if (DBG) Slog.d(TAG, "Initializing " + getClass().getSimpleName() + ".");
34 }
35
36 public RankingReconsideration process(NotificationRecord record) {
37 if (record == null || record.getNotification() == null) {
38 if (DBG) Slog.d(TAG, "skipping empty notification");
39 return null;
40 }
41
42 if (mZenModeHelper == null) {
43 if (DBG) Slog.d(TAG, "skipping - no zen info available");
44 return null;
45 }
46
47 record.setIntercepted(mZenModeHelper.shouldIntercept(record));
48 if (record.isIntercepted()) {
Julia Reynoldsccc6ae62018-03-01 16:24:49 -050049 record.setSuppressedVisualEffects(
Beverlyff2df9b2018-10-10 16:54:10 -040050 mZenModeHelper.getConsolidatedNotificationPolicy().suppressedVisualEffects);
Julia Reynoldsc861a3d2018-02-15 10:34:49 -050051 } else {
52 record.setSuppressedVisualEffects(0);
53 }
54
55 return null;
56 }
57
58 @Override
59 public void setConfig(RankingConfig config) {
60 // ignore: config has no relevant information yet.
61 }
62
63 @Override
64 public void setZenHelper(ZenModeHelper helper) {
65 mZenModeHelper = helper;
66 }
67}