diff options
author | Yorke Lee <yorkelee@google.com> | 2015-05-20 13:05:17 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2015-06-04 13:11:48 -0700 |
commit | 47fc56dd40613fae565d0c4d630f5f0b5fc310ff (patch) | |
tree | 2e796fe141d5aa19a26e8cdda20e3349d43c496e /src/com | |
parent | cabd7cf832f5b160c30bff9c7b975bbf21a95d8e (diff) | |
download | packages_providers_ContactsProvider-47fc56dd40613fae565d0c4d630f5f0b5fc310ff.zip packages_providers_ContactsProvider-47fc56dd40613fae565d0c4d630f5f0b5fc310ff.tar.gz packages_providers_ContactsProvider-47fc56dd40613fae565d0c4d630f5f0b5fc310ff.tar.bz2 |
Fix broken CP2 unit tests and voicemail cleanup
* Delete voicemails when VoicemailCleanupService runs by
checking whether delete is called internally.
* Delete unnecessary MockPackageManager class, and consolidate
all logic into ContactsMockPackageManager
* Separate permissions tests and delete logic tests in
VoicemailProviderTest
* Correct the number of exposed Call columns in CallLogProviderTest
Bug: 20669398
Change-Id: I695b82b639b93f3ce85bf6e20000279f19e4a14a
Diffstat (limited to 'src/com')
-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, |