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