1 /* 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 17 package com.android.dialer.blockreportspam; 18 19 import android.content.Context; 20 import android.content.Intent; 21 import android.support.v4.content.LocalBroadcastManager; 22 import com.android.dialer.common.LogUtil; 23 import com.android.dialer.protos.ProtoParsers; 24 25 /** 26 * Notifies that a dialog for blocking a number and/or marking it as spam/not spam should be shown. 27 */ 28 public final class ShowBlockReportSpamDialogNotifier { 29 ShowBlockReportSpamDialogNotifier()30 private ShowBlockReportSpamDialogNotifier() {} 31 32 /** 33 * Notifies that a dialog for blocking a number and optionally report it as spam should be shown. 34 */ notifyShowDialogToBlockNumberAndOptionallyReportSpam( Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo)35 public static void notifyShowDialogToBlockNumberAndOptionallyReportSpam( 36 Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo) { 37 LogUtil.enterBlock( 38 "ShowBlockReportSpamDialogNotifier.notifyShowDialogToBlockNumberAndOptionallyReportSpam"); 39 40 Intent intent = new Intent(); 41 intent.setAction( 42 ShowBlockReportSpamDialogReceiver 43 .ACTION_SHOW_DIALOG_TO_BLOCK_NUMBER_AND_OPTIONALLY_REPORT_SPAM); 44 ProtoParsers.put( 45 intent, ShowBlockReportSpamDialogReceiver.EXTRA_DIALOG_INFO, blockReportSpamDialogInfo); 46 47 LocalBroadcastManager.getInstance(context).sendBroadcast(intent); 48 } 49 50 /** Notifies that a dialog for blocking a number should be shown. */ notifyShowDialogToBlockNumber( Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo)51 public static void notifyShowDialogToBlockNumber( 52 Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo) { 53 LogUtil.enterBlock("ShowBlockReportSpamDialogNotifier.notifyShowDialogToBlockNumber"); 54 55 Intent intent = new Intent(); 56 intent.setAction(ShowBlockReportSpamDialogReceiver.ACTION_SHOW_DIALOG_TO_BLOCK_NUMBER); 57 ProtoParsers.put( 58 intent, ShowBlockReportSpamDialogReceiver.EXTRA_DIALOG_INFO, blockReportSpamDialogInfo); 59 60 LocalBroadcastManager.getInstance(context).sendBroadcast(intent); 61 } 62 63 /** Notifies that a dialog for reporting a number as not spam should be shown. */ notifyShowDialogToReportNotSpam( Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo)64 public static void notifyShowDialogToReportNotSpam( 65 Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo) { 66 LogUtil.enterBlock("ShowBlockReportSpamDialogNotifier.notifyShowDialogToReportNotSpam"); 67 68 Intent intent = new Intent(); 69 intent.setAction(ShowBlockReportSpamDialogReceiver.ACTION_SHOW_DIALOG_TO_REPORT_NOT_SPAM); 70 ProtoParsers.put( 71 intent, ShowBlockReportSpamDialogReceiver.EXTRA_DIALOG_INFO, blockReportSpamDialogInfo); 72 73 LocalBroadcastManager.getInstance(context).sendBroadcast(intent); 74 } 75 76 /** Notifies that a dialog for unblocking a number should be shown. */ notifyShowDialogToUnblockNumber( Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo)77 public static void notifyShowDialogToUnblockNumber( 78 Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo) { 79 LogUtil.enterBlock("ShowBlockReportSpamDialogNotifier.notifyShowDialogToUnblockNumber"); 80 81 Intent intent = new Intent(); 82 intent.setAction(ShowBlockReportSpamDialogReceiver.ACTION_SHOW_DIALOG_TO_UNBLOCK_NUMBER); 83 ProtoParsers.put( 84 intent, ShowBlockReportSpamDialogReceiver.EXTRA_DIALOG_INFO, blockReportSpamDialogInfo); 85 86 LocalBroadcastManager.getInstance(context).sendBroadcast(intent); 87 } 88 } 89