1 /*
2  * Copyright (C) 2017 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.phonelookup.database.contract;
18 
19 import android.net.Uri;
20 import com.android.dialer.constants.Constants;
21 
22 /** Contract for the PhoneLookupHistory content provider. */
23 public class PhoneLookupHistoryContract {
24   public static final String AUTHORITY = Constants.get().getPhoneLookupHistoryProviderAuthority();
25 
26   public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
27 
28   /** PhoneLookupHistory table. */
29   public static final class PhoneLookupHistory {
30 
31     public static final String TABLE = "PhoneLookupHistory";
32 
33     public static final String NUMBER_QUERY_PARAM = "number";
34 
35     /** The content URI for this table. */
36     public static final Uri CONTENT_URI =
37         Uri.withAppendedPath(PhoneLookupHistoryContract.CONTENT_URI, TABLE);
38 
39     /** Returns a URI for a specific normalized number */
contentUriForNumber(String normalizedNumber)40     public static Uri contentUriForNumber(String normalizedNumber) {
41       return CONTENT_URI
42           .buildUpon()
43           .appendQueryParameter(NUMBER_QUERY_PARAM, Uri.encode(normalizedNumber))
44           .build();
45     }
46 
47     /** The MIME type of a {@link android.content.ContentProvider#getType(Uri)} single entry. */
48     public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_lookup_history";
49 
50     /**
51      * The phone number's E164 representation if it has one, or otherwise normalized number if it
52      * cannot be normalized to E164. Required, primary key for the table.
53      *
54      * <p>Type: TEXT
55      */
56     public static final String NORMALIZED_NUMBER = "normalized_number";
57 
58     /**
59      * The {@link com.android.dialer.phonelookup.PhoneLookupInfo} proto for the number. Required.
60      *
61      * <p>Type: BLOB
62      */
63     public static final String PHONE_LOOKUP_INFO = "phone_lookup_info";
64 
65     /**
66      * Epoch time in milliseconds this entry was last modified. Required.
67      *
68      * <p>Type: INTEGER (long)
69      */
70     public static final String LAST_MODIFIED = "last_modified";
71   }
72 }
73