diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/providers/contacts/CallLogProvider.java | 1 | ||||
-rw-r--r-- | src/com/android/providers/contacts/DbModifierWithNotification.java | 24 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/com/android/providers/contacts/CallLogProvider.java b/src/com/android/providers/contacts/CallLogProvider.java index b5dbd06..f83e4a7 100644 --- a/src/com/android/providers/contacts/CallLogProvider.java +++ b/src/com/android/providers/contacts/CallLogProvider.java @@ -125,7 +125,6 @@ public class CallLogProvider extends ContentProvider { sCallsProjectionMap.put(Calls.PHONE_ACCOUNT_COMPONENT_NAME, Calls.PHONE_ACCOUNT_COMPONENT_NAME); sCallsProjectionMap.put(Calls.PHONE_ACCOUNT_ID, Calls.PHONE_ACCOUNT_ID); sCallsProjectionMap.put(Calls.PHONE_ACCOUNT_ADDRESS, Calls.PHONE_ACCOUNT_ADDRESS); - sCallsProjectionMap.put(Calls.PHONE_ACCOUNT_HIDDEN, Calls.PHONE_ACCOUNT_HIDDEN); sCallsProjectionMap.put(Calls.NEW, Calls.NEW); sCallsProjectionMap.put(Calls.VOICEMAIL_URI, Calls.VOICEMAIL_URI); sCallsProjectionMap.put(Calls.TRANSCRIPTION, Calls.TRANSCRIPTION); diff --git a/src/com/android/providers/contacts/DbModifierWithNotification.java b/src/com/android/providers/contacts/DbModifierWithNotification.java index 3576849..23a4333 100644 --- a/src/com/android/providers/contacts/DbModifierWithNotification.java +++ b/src/com/android/providers/contacts/DbModifierWithNotification.java @@ -160,7 +160,7 @@ public class DbModifierWithNotification implements DatabaseModifier { // the server and thus is synced or "clean". Otherwise, it means that a local change // is being made to the database, so the entries should be marked as "dirty" so that // the corresponding sync adapter knows they need to be synced. - final int isDirty = isSelfModifying(packagesModified) ? 0 : 1; + final int isDirty = isSelfModifyingOrInternal(packagesModified) ? 0 : 1; values.put(VoicemailContract.Voicemails.DIRTY, isDirty); } @@ -185,8 +185,10 @@ public class DbModifierWithNotification implements DatabaseModifier { // mark the entry as "deleted"--deleted entries should be hidden from the user. // Once the changes are synced to the server, delete will be called again, this time // removing the rows from the table. + // If the deletion is being made by the package that inserted the voicemail or by + // CP2 (cleanup after uninstall), then we don't need to wait for sync, so just delete it. final int count; - if (mIsCallsTable && isVoicemail && !isSelfModifying(packagesModified)) { + if (mIsCallsTable && isVoicemail && !isSelfModifyingOrInternal(packagesModified)) { ContentValues values = new ContentValues(); values.put(VoicemailContract.Voicemails.DIRTY, 1); values.put(VoicemailContract.Voicemails.DELETED, 1); @@ -236,9 +238,21 @@ public class DbModifierWithNotification implements DatabaseModifier { return impactedPackages; } - private boolean isSelfModifying(Set<String> packagesModified) { - return packagesModified.size() == 1 && getCallingPackages().contains( - Iterables.getOnlyElement(packagesModified)); + /** + * @param packagesModified source packages that inserted the voicemail that is being modified + * @return {@code true} if the caller is modifying its own voicemail, or this is an internal + * transaction, {@code false} otherwise. + */ + private boolean isSelfModifyingOrInternal(Set<String> packagesModified) { + final Collection<String> callingPackages = getCallingPackages(); + if (callingPackages == null) { + return false; + } + // The last clause has the same effect as doing Process.myUid() == Binder.getCallingUid(), + // but allows us to mock the results for testing. + return packagesModified.size() == 1 && (callingPackages.contains( + Iterables.getOnlyElement(packagesModified)) + || callingPackages.contains(mContext.getPackageName())); } private void notifyVoicemailChange(Uri notificationUri, Set<String> modifiedPackages, |