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.dialer.database; 18 19 import android.net.Uri; 20 import android.provider.BaseColumns; 21 import com.android.dialer.constants.Constants; 22 23 /** 24 * The contract between the filtered number provider and applications. Contains definitions for the 25 * supported URIs and columns. Currently only accessible within Dialer. 26 */ 27 public final class FilteredNumberContract { 28 29 public static final String AUTHORITY = Constants.get().getFilteredNumberProviderAuthority(); 30 31 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); 32 33 /** The type of filtering to be applied, e.g. block the number or allow the number. */ 34 public interface FilteredNumberTypes { 35 36 int UNDEFINED = 0; 37 /** Dialer will disconnect the call without sending the caller to voicemail. */ 38 int BLOCKED_NUMBER = 1; 39 } 40 41 /** The original source of the filtered number, e.g. the user manually added it. */ 42 public interface FilteredNumberSources { 43 44 int UNDEFINED = 0; 45 /** The user manually added this number through Dialer (e.g. from the call log or InCallUI). */ 46 int USER = 1; 47 } 48 49 public interface FilteredNumberColumns { 50 51 // TYPE: INTEGER 52 String _ID = "_id"; 53 /** 54 * Represents the number to be filtered, normalized to compare phone numbers for equality. 55 * 56 * <p>TYPE: TEXT 57 */ 58 String NORMALIZED_NUMBER = "normalized_number"; 59 /** 60 * Represents the number to be filtered, for formatting and used with country iso for contact 61 * lookups. 62 * 63 * <p>TYPE: TEXT 64 */ 65 String NUMBER = "number"; 66 /** 67 * The country code representing the country detected when the phone number was added to the 68 * database. Most numbers don't have the country code, so a best guess is provided by the 69 * country detector system. The country iso is also needed in order to format phone numbers 70 * correctly. 71 * 72 * <p>TYPE: TEXT 73 */ 74 String COUNTRY_ISO = "country_iso"; 75 /** 76 * The number of times the number has been filtered by Dialer. When this number is incremented, 77 * LAST_TIME_FILTERED should also be updated to the current time. 78 * 79 * <p>TYPE: INTEGER 80 */ 81 String TIMES_FILTERED = "times_filtered"; 82 /** 83 * Set to the current time when the phone number is filtered. When this is updated, 84 * TIMES_FILTERED should also be incremented. 85 * 86 * <p>TYPE: LONG 87 */ 88 String LAST_TIME_FILTERED = "last_time_filtered"; 89 // TYPE: LONG 90 String CREATION_TIME = "creation_time"; 91 /** 92 * Indicates the type of filtering to be applied. 93 * 94 * <p>TYPE: INTEGER See {@link FilteredNumberTypes} 95 */ 96 String TYPE = "type"; 97 /** 98 * Integer representing the original source of the filtered number. 99 * 100 * <p>TYPE: INTEGER See {@link FilteredNumberSources} 101 */ 102 String SOURCE = "source"; 103 } 104 105 /** 106 * Constants for the table of filtered numbers. 107 * 108 * <h3>Operations</h3> 109 * 110 * <dl> 111 * <dt><b>Insert</b> 112 * <dd>Required fields: NUMBER, NORMALIZED_NUMBER, TYPE, SOURCE. A default value will be used for 113 * the other fields if left null. 114 * <dt><b>Update</b> 115 * <dt><b>Delete</b> 116 * <dt><b>Query</b> 117 * <dd>{@link #CONTENT_URI} can be used for any query, append an ID to retrieve a specific 118 * filtered number entry. 119 * </dl> 120 */ 121 public static class FilteredNumber implements BaseColumns { 122 123 public static final String FILTERED_NUMBERS_TABLE = "filtered_numbers_table"; 124 125 /** 126 * The MIME type of a {@link android.content.ContentProvider#getType(Uri)} single filtered 127 * number. 128 */ 129 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/filtered_numbers_table"; 130 131 public static final Uri CONTENT_URI = 132 Uri.withAppendedPath(AUTHORITY_URI, FILTERED_NUMBERS_TABLE); 133 134 /** This utility class cannot be instantiated. */ FilteredNumber()135 private FilteredNumber() {} 136 } 137 } 138