summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorDebashish Chatterjee <debashishc@google.com>2011-08-09 10:35:07 +0100
committerDebashish Chatterjee <debashishc@google.com>2011-08-10 10:54:26 +0100
commit2e757d904e62dbf5bc0b028626fa9319ccc38c45 (patch)
treebbc8a6ede11e85427615ff1cdbad7c8559432076 /src/com/android
parent13a121b7252020fb9226ce3d2bfe4973e2c682cd (diff)
downloadpackages_providers_ContactsProvider-2e757d904e62dbf5bc0b028626fa9319ccc38c45.zip
packages_providers_ContactsProvider-2e757d904e62dbf5bc0b028626fa9319ccc38c45.tar.gz
packages_providers_ContactsProvider-2e757d904e62dbf5bc0b028626fa9319ccc38c45.tar.bz2
Notify callog uri if a change is made through voicemail provider.
DbModifierWithVmNotification till now only notified to voicemail uri content observers for change made through call log provider. We need the otherway round as well so that any change made to a voicemail entry through the voicemail provider should be notified to listeners of calllog uri. This is needed to make call log auto refresh work when a new voicemail is inserted. DbModifierWithVmNotification is now renamed to DbModifierWithNotification and suports both ways notification. Notifications generated by call log provider as well is now routed through this class. Bug: 5055868 Change-Id: I2de8c9867445bcb86ce94a8600acc726266c8008
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/providers/contacts/CallLogProvider.java33
-rw-r--r--src/com/android/providers/contacts/DbModifierWithNotification.java (renamed from src/com/android/providers/contacts/DbModifierWithVmNotification.java)54
-rw-r--r--src/com/android/providers/contacts/VoicemailContentTable.java3
-rw-r--r--src/com/android/providers/contacts/VoicemailStatusTable.java2
4 files changed, 53 insertions, 39 deletions
diff --git a/src/com/android/providers/contacts/CallLogProvider.java b/src/com/android/providers/contacts/CallLogProvider.java
index 24bfbbc..f37e62b 100644
--- a/src/com/android/providers/contacts/CallLogProvider.java
+++ b/src/com/android/providers/contacts/CallLogProvider.java
@@ -182,7 +182,6 @@ public class CallLogProvider extends ContentProvider {
}
long rowId = getDatabaseModifier(mCallsInserter).insert(values);
if (rowId > 0) {
- notifyChange();
return ContentUris.withAppendedId(uri, rowId);
}
return null;
@@ -214,12 +213,8 @@ public class CallLogProvider extends ContentProvider {
throw new UnsupportedOperationException("Cannot update URL: " + uri);
}
- int count = getDatabaseModifier(db).update(Tables.CALLS, values,
- selectionBuilder.build(), selectionArgs);
- if (count > 0) {
- notifyChange();
- }
- return count;
+ return getDatabaseModifier(db).update(Tables.CALLS, values, selectionBuilder.build(),
+ selectionArgs);
}
@Override
@@ -231,35 +226,33 @@ public class CallLogProvider extends ContentProvider {
final int matchedUriId = sURIMatcher.match(uri);
switch (matchedUriId) {
case CALLS:
- int count = getDatabaseModifier(db).delete(Tables.CALLS,
+ return getDatabaseModifier(db).delete(Tables.CALLS,
selectionBuilder.build(), selectionArgs);
- if (count > 0) {
- notifyChange();
- }
- return count;
-
default:
throw new UnsupportedOperationException("Cannot delete that URL: " + uri);
}
}
- protected void notifyChange() {
- getContext().getContentResolver().notifyChange(CallLog.CONTENT_URI, null,
- false /* wake up sync adapters */);
- }
-
// Work around to let the test code override the context. getContext() is final so cannot be
// overridden.
protected Context context() {
return getContext();
}
+ /**
+ * Returns a {@link DatabaseModifier} that takes care of sending necessary notifications
+ * after the operation is performed.
+ */
private DatabaseModifier getDatabaseModifier(SQLiteDatabase db) {
- return new DbModifierWithVmNotification(Tables.CALLS, db, context());
+ return new DbModifierWithNotification(Tables.CALLS, db, context());
}
+ /**
+ * Same as {@link #getDatabaseModifier(SQLiteDatabase)} but used for insert helper operations
+ * only.
+ */
private DatabaseModifier getDatabaseModifier(DatabaseUtils.InsertHelper insertHelper) {
- return new DbModifierWithVmNotification(Tables.CALLS, insertHelper, context());
+ return new DbModifierWithNotification(Tables.CALLS, insertHelper, context());
}
private boolean hasVoicemailValue(ContentValues values) {
diff --git a/src/com/android/providers/contacts/DbModifierWithVmNotification.java b/src/com/android/providers/contacts/DbModifierWithNotification.java
index 2e004d4..c13f4a8 100644
--- a/src/com/android/providers/contacts/DbModifierWithVmNotification.java
+++ b/src/com/android/providers/contacts/DbModifierWithNotification.java
@@ -37,6 +37,7 @@ import android.database.DatabaseUtils.InsertHelper;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Binder;
+import android.provider.CallLog.Calls;
import android.provider.VoicemailContract;
import android.provider.VoicemailContract.Status;
import android.provider.VoicemailContract.Voicemails;
@@ -51,8 +52,10 @@ import java.util.Set;
/**
* An implementation of {@link DatabaseModifier} for voicemail related tables which additionally
* generates necessary notifications after the modification operation is performed.
+ * The class generates notifications for both voicemail as well as call log URI depending on which
+ * of then got affected by the change.
*/
-public class DbModifierWithVmNotification implements DatabaseModifier {
+public class DbModifierWithNotification implements DatabaseModifier {
private static final String TAG = "DbModifierWithVmNotification";
private static final String[] PROJECTION = new String[] {
@@ -67,19 +70,19 @@ public class DbModifierWithVmNotification implements DatabaseModifier {
private final InsertHelper mInsertHelper;
private final Context mContext;
private final Uri mBaseUri;
- private final boolean mIsVoicemailContentTable;
+ private final boolean mIsCallsTable;
private final VoicemailPermissions mVoicemailPermissions;
- public DbModifierWithVmNotification(String tableName, SQLiteDatabase db, Context context) {
+ public DbModifierWithNotification(String tableName, SQLiteDatabase db, Context context) {
this(tableName, db, null, context);
}
- public DbModifierWithVmNotification(String tableName, InsertHelper insertHelper,
+ public DbModifierWithNotification(String tableName, InsertHelper insertHelper,
Context context) {
this(tableName, null, insertHelper, context);
}
- private DbModifierWithVmNotification(String tableName, SQLiteDatabase db,
+ private DbModifierWithNotification(String tableName, SQLiteDatabase db,
InsertHelper insertHelper, Context context) {
mTableName = tableName;
mDb = db;
@@ -87,7 +90,7 @@ public class DbModifierWithVmNotification implements DatabaseModifier {
mContext = context;
mBaseUri = mTableName.equals(Tables.VOICEMAIL_STATUS) ?
Status.CONTENT_URI : Voicemails.CONTENT_URI;
- mIsVoicemailContentTable = !mTableName.equals(Tables.VOICEMAIL_STATUS);
+ mIsCallsTable = mTableName.equals(Tables.CALLS);
mVoicemailPermissions = new VoicemailPermissions(mContext);
}
@@ -96,7 +99,11 @@ public class DbModifierWithVmNotification implements DatabaseModifier {
Set<String> packagesModified = getModifiedPackages(values);
long rowId = mDb.insert(table, nullColumnHack, values);
if (rowId > 0 && packagesModified.size() != 0) {
- notifyOnInsert(ContentUris.withAppendedId(mBaseUri, rowId), packagesModified);
+ notifyVoicemailChangeOnInsert(ContentUris.withAppendedId(mBaseUri, rowId),
+ packagesModified);
+ }
+ if (rowId > 0 && mIsCallsTable) {
+ notifyCallLogChange();
}
return rowId;
}
@@ -106,17 +113,26 @@ public class DbModifierWithVmNotification implements DatabaseModifier {
Set<String> packagesModified = getModifiedPackages(values);
long rowId = mInsertHelper.insert(values);
if (rowId > 0 && packagesModified.size() != 0) {
- notifyOnInsert(ContentUris.withAppendedId(mBaseUri, rowId), packagesModified);
+ notifyVoicemailChangeOnInsert(
+ ContentUris.withAppendedId(mBaseUri, rowId), packagesModified);
+ }
+ if (rowId > 0 && mIsCallsTable) {
+ notifyCallLogChange();
}
return rowId;
}
- private void notifyOnInsert(Uri notificationUri, Set<String> packagesModified) {
- if (mIsVoicemailContentTable) {
- notifyChange(notificationUri, packagesModified, VoicemailContract.ACTION_NEW_VOICEMAIL,
- Intent.ACTION_PROVIDER_CHANGED);
+ private void notifyCallLogChange() {
+ mContext.getContentResolver().notifyChange(Calls.CONTENT_URI, null, false);
+ }
+
+ private void notifyVoicemailChangeOnInsert(Uri notificationUri, Set<String> packagesModified) {
+ if (mIsCallsTable) {
+ notifyVoicemailChange(notificationUri, packagesModified,
+ VoicemailContract.ACTION_NEW_VOICEMAIL, Intent.ACTION_PROVIDER_CHANGED);
} else {
- notifyChange(notificationUri, packagesModified, Intent.ACTION_PROVIDER_CHANGED);
+ notifyVoicemailChange(notificationUri, packagesModified,
+ Intent.ACTION_PROVIDER_CHANGED);
}
}
@@ -126,7 +142,10 @@ public class DbModifierWithVmNotification implements DatabaseModifier {
packagesModified.addAll(getModifiedPackages(values));
int count = mDb.update(table, values, whereClause, whereArgs);
if (count > 0 && packagesModified.size() != 0) {
- notifyChange(mBaseUri, packagesModified, Intent.ACTION_PROVIDER_CHANGED);
+ notifyVoicemailChange(mBaseUri, packagesModified, Intent.ACTION_PROVIDER_CHANGED);
+ }
+ if (count > 0 && mIsCallsTable) {
+ notifyCallLogChange();
}
return count;
}
@@ -136,7 +155,10 @@ public class DbModifierWithVmNotification implements DatabaseModifier {
Set<String> packagesModified = getModifiedPackages(whereClause, whereArgs);
int count = mDb.delete(table, whereClause, whereArgs);
if (count > 0 && packagesModified.size() != 0) {
- notifyChange(mBaseUri, packagesModified, Intent.ACTION_PROVIDER_CHANGED);
+ notifyVoicemailChange(mBaseUri, packagesModified, Intent.ACTION_PROVIDER_CHANGED);
+ }
+ if (count > 0 && mIsCallsTable) {
+ notifyCallLogChange();
}
return count;
}
@@ -173,7 +195,7 @@ public class DbModifierWithVmNotification implements DatabaseModifier {
return impactedPackages;
}
- private void notifyChange(Uri notificationUri, Set<String> modifiedPackages,
+ private void notifyVoicemailChange(Uri notificationUri, Set<String> modifiedPackages,
String... intentActions) {
// Notify the observers.
// Must be done only once, even if there are multiple broadcast intents.
diff --git a/src/com/android/providers/contacts/VoicemailContentTable.java b/src/com/android/providers/contacts/VoicemailContentTable.java
index d085bdb..ce2bc51 100644
--- a/src/com/android/providers/contacts/VoicemailContentTable.java
+++ b/src/com/android/providers/contacts/VoicemailContentTable.java
@@ -51,7 +51,6 @@ public class VoicemailContentTable implements VoicemailTable.Delegate {
/** The private directory in which to store the data associated with the voicemail. */
private static final String DATA_DIRECTORY = "voicemail-data";
- private static final String[] MIME_TYPE_ONLY_PROJECTION = new String[] { Voicemails.MIME_TYPE };
private static final String[] FILENAME_ONLY_PROJECTION = new String[] { Voicemails._DATA };
private final String mTableName;
@@ -255,6 +254,6 @@ public class VoicemailContentTable implements VoicemailTable.Delegate {
}
private DatabaseModifier getDatabaseModifier(SQLiteDatabase db) {
- return new DbModifierWithVmNotification(mTableName, db, mContext);
+ return new DbModifierWithNotification(mTableName, db, mContext);
}
}
diff --git a/src/com/android/providers/contacts/VoicemailStatusTable.java b/src/com/android/providers/contacts/VoicemailStatusTable.java
index 504af46..24714ed 100644
--- a/src/com/android/providers/contacts/VoicemailStatusTable.java
+++ b/src/com/android/providers/contacts/VoicemailStatusTable.java
@@ -121,6 +121,6 @@ public class VoicemailStatusTable implements VoicemailTable.Delegate {
}
private DatabaseModifier getDatabaseModifier(SQLiteDatabase db) {
- return new DbModifierWithVmNotification(mTableName, db, mContext);
+ return new DbModifierWithNotification(mTableName, db, mContext);
}
}