diff options
author | Nancy Chen <nancychen@google.com> | 2015-02-12 09:44:41 -0800 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2015-03-02 20:43:58 +0000 |
commit | 7c07dfa5529dd8049a526de227cae8abc2f72226 (patch) | |
tree | dd1c58bf53f0fe91b13b130ba403023327526fac /core | |
parent | 204f80e0aac4fed8e4e29406b3a9eb689b9b5287 (diff) | |
download | frameworks_base-7c07dfa5529dd8049a526de227cae8abc2f72226.zip frameworks_base-7c07dfa5529dd8049a526de227cae8abc2f72226.tar.gz frameworks_base-7c07dfa5529dd8049a526de227cae8abc2f72226.tar.bz2 |
Add frameworks classes and methods necessary for VVM syncadapter structure.
+ VvmSyncService is the base class for all visual voicemail sync
services that run the visual voicemail sync adapter. This class handles
writing to the voicemail provider and receiving changes from the
voicemail provider.
+ AuthenticatorService is a stub class for visual voicemail sync
adapters that do not use an Account (all sync adapters must have an
account associated with them, so a stub account is necessary).
+ Voicemail parcelable object to pass voicemail data around easier. This
is mostly copied from VoicemailProviderDemo
+ Extra helper methods in VoicemailContract to help insert and delete
from the voicemail provider.
+ Add multi-sim fields to VoicemailContract.Voicemails
Bug: 19236241
Change-Id: I603e3e5908704cd043e46221680d8bb600ed2cf4
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/provider/VoicemailContract.java | 95 |
1 files changed, 94 insertions, 1 deletions
diff --git a/core/java/android/provider/VoicemailContract.java b/core/java/android/provider/VoicemailContract.java index d707f35..03cf6e3 100644 --- a/core/java/android/provider/VoicemailContract.java +++ b/core/java/android/provider/VoicemailContract.java @@ -19,10 +19,16 @@ package android.provider; import android.Manifest; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; +import android.content.ContentResolver; +import android.content.ContentValues; +import android.content.Context; import android.content.Intent; import android.database.ContentObserver; import android.net.Uri; import android.provider.CallLog.Calls; +import android.telecom.Voicemail; + +import java.util.List; /** * The contract between the voicemail provider and applications. Contains @@ -199,13 +205,100 @@ public class VoicemailContract { */ public static final String _DATA = "_data"; + // Note: PHONE_ACCOUNT_* constant values are "subscription_*" due to a historic naming + // that was encoded into call log databases. + + /** + * The component name of the account in string form. + * <P>Type: TEXT</P> + */ + public static final String PHONE_ACCOUNT_COMPONENT_NAME = "subscription_component_name"; + + /** + * The identifier of a account that is unique to a specified component. + * <P>Type: TEXT</P> + */ + public static final String PHONE_ACCOUNT_ID = "subscription_id"; + + /** + * Flag used to indicate that local, unsynced changes are present. + * Currently, this is used to indicate that the voicemail was read or deleted. + * The value will be 1 if dirty is true, 0 if false. + * <P>Type: INTEGER (boolean)</P> + */ + public static final String DIRTY = "dirty"; + + /** + * Flag used to indicate that the voicemail was deleted but not synced to the server. + * A deleted row should be ignored. + * The value will be 1 if deleted is true, 0 if false. + * <P>Type: INTEGER (boolean)</P> + */ + public static final String DELETED = "deleted"; + /** * A convenience method to build voicemail URI specific to a source package by appending * {@link VoicemailContract#PARAM_KEY_SOURCE_PACKAGE} param to the base URI. */ public static Uri buildSourceUri(String packageName) { return Voicemails.CONTENT_URI.buildUpon() - .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName).build(); + .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName) + .build(); + } + + /** + * Inserts a new voicemail into the voicemail content provider. + * + * @param context The context of the app doing the inserting + * @param voicemail Data to be inserted + * @return {@link Uri} of the newly inserted {@link Voicemail} + */ + public static Uri insert(Context context, Voicemail voicemail) { + ContentResolver contentResolver = context.getContentResolver(); + ContentValues contentValues = getContentValues(voicemail); + return contentResolver.insert(Voicemails.CONTENT_URI, contentValues); + } + + /** + * Inserts a list of voicemails into the voicemail content provider. + * + * @param context The context of the app doing the inserting + * @param voicemails Data to be inserted + * @return the number of voicemails inserted + */ + public static int insert(Context context, List<Voicemail> voicemails) { + ContentResolver contentResolver = context.getContentResolver(); + int count = voicemails.size(); + for (int i = 0; i < count; i++) { + ContentValues contentValues = getContentValues(voicemails.get(i)); + contentResolver.insert(Voicemails.CONTENT_URI, contentValues); + } + return count; + } + + /** + * Clears all voicemails accessible to this voicemail content provider for the calling + * package. By default, a package only has permission to delete voicemails it inserted. + * + * @return the number of voicemails deleted + */ + public static int deleteAll(Context context) { + return context.getContentResolver().delete( + buildSourceUri(context.getPackageName()), "", new String[0]); + } + + /** + * Maps structured {@link Voicemail} to {@link ContentValues} in content provider. + */ + private static ContentValues getContentValues(Voicemail voicemail) { + ContentValues contentValues = new ContentValues(); + contentValues.put(Voicemails.DATE, String.valueOf(voicemail.getTimestampMillis())); + contentValues.put(Voicemails.NUMBER, voicemail.getNumber()); + contentValues.put(Voicemails.DURATION, String.valueOf(voicemail.getDuration())); + contentValues.put(Voicemails.SOURCE_PACKAGE, voicemail.getSourcePackage()); + contentValues.put(Voicemails.SOURCE_DATA, voicemail.getSourceData()); + contentValues.put(Voicemails.IS_READ, voicemail.isRead() ? 1 : 0); + return contentValues; } } |