• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.calllog.database;
18 
19 import static com.android.dialer.calllog.database.AnnotatedCallLog.Columns.CONTACT_NAME;
20 import static com.android.dialer.calllog.database.AnnotatedCallLog.Columns.ID;
21 import static com.android.dialer.calllog.database.AnnotatedCallLog.Columns.TIMESTAMP;
22 
23 import android.content.Context;
24 import android.database.sqlite.SQLiteDatabase;
25 import android.database.sqlite.SQLiteOpenHelper;
26 import com.android.dialer.common.LogUtil;
27 
28 /** {@link SQLiteOpenHelper} for the AnnotatedCallLog database. */
29 class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper {
30 
AnnotatedCallLogDatabaseHelper(Context appContext, String databaseName)31   AnnotatedCallLogDatabaseHelper(Context appContext, String databaseName) {
32     super(appContext, databaseName, null, 1);
33   }
34 
35   private static final String CREATE_SQL =
36       new StringBuilder()
37           .append("create table if not exists " + AnnotatedCallLog.TABLE_NAME + " (")
38           .append(ID + " integer primary key, ")
39           .append(TIMESTAMP + " integer, ")
40           .append(CONTACT_NAME + " string")
41           .append(");")
42           .toString();
43 
44   @Override
onCreate(SQLiteDatabase db)45   public void onCreate(SQLiteDatabase db) {
46     LogUtil.enterBlock("AnnotatedCallLogDatabaseHelper.onCreate");
47     long startTime = System.currentTimeMillis();
48     db.execSQL(CREATE_SQL);
49     // TODO: Consider logging impression.
50     LogUtil.i(
51         "AnnotatedCallLogDatabaseHelper.onCreate",
52         "took: %dms",
53         System.currentTimeMillis() - startTime);
54   }
55 
56   @Override
onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)57   public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {}
58 }
59