summaryrefslogtreecommitdiff
path: root/src/com/android/dialer/database/DialerDatabaseHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/dialer/database/DialerDatabaseHelper.java')
-rw-r--r--src/com/android/dialer/database/DialerDatabaseHelper.java40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/com/android/dialer/database/DialerDatabaseHelper.java b/src/com/android/dialer/database/DialerDatabaseHelper.java
index cc8631d99..1f926c140 100644
--- a/src/com/android/dialer/database/DialerDatabaseHelper.java
+++ b/src/com/android/dialer/database/DialerDatabaseHelper.java
@@ -75,7 +75,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
* 0-98 KitKat
* </pre>
*/
- public static final int DATABASE_VERSION = 7;
+ public static final int DATABASE_VERSION = 8;
public static final String DATABASE_NAME = "dialer.db";
/**
@@ -115,6 +115,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
static final String IS_SUPER_PRIMARY = "is_super_primary";
static final String IN_VISIBLE_GROUP = "in_visible_group";
static final String IS_PRIMARY = "is_primary";
+ static final String CARRIER_PRESENCE = "carrier_presence";
static final String LAST_SMARTDIAL_UPDATE_TIME = "last_smartdial_update_time";
}
@@ -151,6 +152,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
Data.IS_SUPER_PRIMARY, // 11
Contacts.IN_VISIBLE_GROUP, // 12
Data.IS_PRIMARY, // 13
+ Data.CARRIER_PRESENCE, // 14
};
static final int PHONE_ID = 0;
@@ -167,6 +169,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
static final int PHONE_IS_SUPER_PRIMARY = 11;
static final int PHONE_IN_VISIBLE_GROUP = 12;
static final int PHONE_IS_PRIMARY = 13;
+ static final int PHONE_CARRIER_PRESENCE = 14;
/** Selects only rows that have been updated after a certain time stamp.*/
static final String SELECT_UPDATED_CLAUSE =
@@ -268,20 +271,23 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
public final String phoneNumber;
public final String lookupKey;
public final long photoId;
+ public final int carrierPresence;
public ContactNumber(long id, long dataID, String displayName, String phoneNumber,
- String lookupKey, long photoId) {
+ String lookupKey, long photoId, int carrierPresence) {
this.dataId = dataID;
this.id = id;
this.displayName = displayName;
this.phoneNumber = phoneNumber;
this.lookupKey = lookupKey;
this.photoId = photoId;
+ this.carrierPresence = carrierPresence;
}
@Override
public int hashCode() {
- return Objects.hashCode(id, dataId, displayName, phoneNumber, lookupKey, photoId);
+ return Objects.hashCode(id, dataId, displayName, phoneNumber, lookupKey, photoId,
+ carrierPresence);
}
@Override
@@ -296,7 +302,8 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
&& Objects.equal(this.displayName, that.displayName)
&& Objects.equal(this.phoneNumber, that.phoneNumber)
&& Objects.equal(this.lookupKey, that.lookupKey)
- && Objects.equal(this.photoId, that.photoId);
+ && Objects.equal(this.photoId, that.photoId)
+ && Objects.equal(this.carrierPresence, that.carrierPresence);
}
return false;
}
@@ -398,7 +405,8 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
+ SmartDialDbColumns.STARRED + " INTEGER, "
+ SmartDialDbColumns.IS_SUPER_PRIMARY + " INTEGER, "
+ SmartDialDbColumns.IN_VISIBLE_GROUP + " INTEGER, "
- + SmartDialDbColumns.IS_PRIMARY + " INTEGER"
+ + SmartDialDbColumns.IS_PRIMARY + " INTEGER, "
+ + SmartDialDbColumns.CARRIER_PRESENCE + " INTEGER NOT NULL DEFAULT 0"
+ ");");
db.execSQL("CREATE TABLE " + Tables.PREFIX_TABLE + " ("
@@ -473,6 +481,11 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
oldVersion = 7;
}
+ if (oldVersion < 8) {
+ upgradeToVersion8(db);
+ oldVersion = 8;
+ }
+
if (oldVersion != DATABASE_VERSION) {
throw new IllegalStateException(
"error upgrading the database to version " + DATABASE_VERSION);
@@ -481,6 +494,10 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
setProperty(db, DATABASE_VERSION_PROPERTY, String.valueOf(DATABASE_VERSION));
}
+ public void upgradeToVersion8(SQLiteDatabase db) {
+ db.execSQL("ALTER TABLE smartdial_table ADD carrier_presence INTEGER NOT NULL DEFAULT 0");
+ }
+
/**
* Stores a key-value pair in the {@link Tables#PROPERTIES} table.
*/
@@ -705,8 +722,9 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
SmartDialDbColumns.IS_SUPER_PRIMARY + ", " +
SmartDialDbColumns.IN_VISIBLE_GROUP+ ", " +
SmartDialDbColumns.IS_PRIMARY + ", " +
+ SmartDialDbColumns.CARRIER_PRESENCE + ", " +
SmartDialDbColumns.LAST_SMARTDIAL_UPDATE_TIME + ") " +
- " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
final SQLiteStatement insert = db.compileStatement(sqlInsert);
final String numberSqlInsert = "INSERT INTO " + Tables.PREFIX_TABLE + " (" +
@@ -753,7 +771,8 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
insert.bindLong(10, updatedContactCursor.getInt(PhoneQuery.PHONE_IS_SUPER_PRIMARY));
insert.bindLong(11, updatedContactCursor.getInt(PhoneQuery.PHONE_IN_VISIBLE_GROUP));
insert.bindLong(12, updatedContactCursor.getInt(PhoneQuery.PHONE_IS_PRIMARY));
- insert.bindLong(13, currentMillis);
+ insert.bindLong(13, updatedContactCursor.getInt(PhoneQuery.PHONE_CARRIER_PRESENCE));
+ insert.bindLong(14, currentMillis);
insert.executeInsert();
final String contactPhoneNumber =
updatedContactCursor.getString(PhoneQuery.PHONE_NUMBER);
@@ -1020,7 +1039,8 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
SmartDialDbColumns.PHOTO_ID + ", " +
SmartDialDbColumns.NUMBER + ", " +
SmartDialDbColumns.CONTACT_ID + ", " +
- SmartDialDbColumns.LOOKUP_KEY +
+ SmartDialDbColumns.LOOKUP_KEY + ", " +
+ SmartDialDbColumns.CARRIER_PRESENCE +
" FROM " + Tables.SMARTDIAL_TABLE + " WHERE " +
SmartDialDbColumns.CONTACT_ID + " IN " +
" (SELECT " + PrefixColumns.CONTACT_ID +
@@ -1044,6 +1064,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
final int columnNumber = 3;
final int columnId = 4;
final int columnLookupKey = 5;
+ final int columnCarrierPresence = 6;
if (DEBUG) {
stopWatch.lap("Found column IDs");
}
@@ -1061,6 +1082,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
final long id = cursor.getLong(columnId);
final long photoId = cursor.getLong(columnPhotoId);
final String lookupKey = cursor.getString(columnLookupKey);
+ final int carrierPresence = cursor.getInt(columnCarrierPresence);
/** If a contact already exists and another phone number of the contact is being
* processed, skip the second instance.
@@ -1081,7 +1103,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
/** If a contact has not been added, add it to the result and the hash set.*/
duplicates.add(contactMatch);
result.add(new ContactNumber(id, dataID, displayName, phoneNumber, lookupKey,
- photoId));
+ photoId, carrierPresence));
counter++;
if (DEBUG) {
stopWatch.lap("Added one result: Name: " + displayName);