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.rtt;
18 
19 import android.content.Context;
20 import android.database.sqlite.SQLiteDatabase;
21 import android.database.sqlite.SQLiteOpenHelper;
22 import android.os.SystemClock;
23 import com.android.dialer.common.LogUtil;
24 import com.android.dialer.rtt.RttTranscriptContract.RttTranscriptColumn;
25 
26 /** Database helper class for RTT transcript. */
27 final class RttTranscriptDatabaseHelper extends SQLiteOpenHelper {
28 
29   static final String TABLE = "rtt_transcript";
30 
31   private static final String CREATE_TABLE_SQL =
32       "create table if not exists "
33           + TABLE
34           + " ("
35           + (RttTranscriptColumn.TRANSCRIPT_ID + " integer primary key, ")
36           + (RttTranscriptColumn.TRANSCRIPT_DATA + " blob not null")
37           + ");";
38 
RttTranscriptDatabaseHelper(Context context)39   RttTranscriptDatabaseHelper(Context context) {
40     super(context, "rtt_transcript.db", null, 1);
41   }
42 
43   @Override
onCreate(SQLiteDatabase db)44   public void onCreate(SQLiteDatabase db) {
45     LogUtil.enterBlock("RttTranscriptDatabaseHelper.onCreate");
46     long startTime = SystemClock.elapsedRealtime();
47     db.execSQL(CREATE_TABLE_SQL);
48     LogUtil.i(
49         "RttTranscriptDatabaseHelper.onCreate",
50         "took: %dms",
51         SystemClock.elapsedRealtime() - startTime);
52   }
53 
54   @Override
onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)55   public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {}
56 }
57