Voicemails are inserted by what is called as a "voicemail source" - * application, which is responsible for syncing voicemail data between a remote - * server and the local voicemail content provider. "voicemail source" - * application should use the source specific {@link #CONTENT_URI_SOURCE} URI - * to insert and retrieve voicemails. - * - *
In addition to the {@link ContentObserver} notifications the voicemail - * provider also generates broadcast intents to notify change for applications - * that are not active and therefore cannot listen to ContentObserver - * notifications. Broadcast intents with following actions are generated: - *
This field must be set in all requests that originate from a voicemail source. - */ - public static final String PARAM_KEY_SOURCE_PACKAGE = "source_package"; - - // TODO: Move ACTION_NEW_VOICEMAIL to the Intent class. - /** Broadcast intent when a new voicemail record is inserted. */ - public static final String ACTION_NEW_VOICEMAIL = "android.intent.action.NEW_VOICEMAIL"; - /** - * Extra included in {@value Intent#ACTION_PROVIDER_CHANGED} and - * {@value #ACTION_NEW_VOICEMAIL} broadcast intents to indicate if the receiving - * package made this change. - */ - public static final String EXTRA_SELF_CHANGE = "com.android.voicemail.extra.SELF_CHANGE"; - - /** - * The mime type for a collection of voicemails. - * @deprecated */ - public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemails"; - - /** Defines fields exposed through the /voicemail path of this content provider. */ - public static final class Voicemails implements BaseColumns { - /** Not instantiable. */ - private Voicemails() { - } - - /** URI to insert/retrieve voicemails by a given voicemail source. */ - public static final Uri CONTENT_URI = - Uri.parse("content://" + AUTHORITY + "/voicemail"); - /** URI to insert/retrieve voicemails by a given voicemail source. */ - public static final Uri CONTENT_URI_SOURCE = - Uri.parse("content://" + AUTHORITY + "/voicemail/source/"); - - /** The mime type for a collection of voicemails. */ - public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemails"; - - /** - * Phone number of the voicemail sender. - *
Type: TEXT
- */ - public static final String NUMBER = Calls.NUMBER; - /** - * The date the voicemail was sent, in milliseconds since the epoch - *Type: INTEGER (long)
- */ - public static final String DATE = Calls.DATE; - /** - * The duration of the voicemail in seconds. - *Type: INTEGER (long)
- */ - public static final String DURATION = Calls.DURATION; - /** - * Whether this is a new voicemail (i.e. has not been heard). - *Type: INTEGER (boolean)
- */ - public static final String NEW = Calls.NEW; - /** - * The mail box state of the voicemail. - *Possible values: {@link #STATE_INBOX}, {@link #STATE_DELETED}, - * {@link #STATE_UNDELETED}. - *
Type: INTEGER
- */ - public static final String STATE = "state"; - /** Value of {@link #STATE} when the voicemail is in inbox. */ - public static int STATE_INBOX = 0; - /** Value of {@link #STATE} when the voicemail has been marked as deleted. */ - public static int STATE_DELETED = 1; - /** Value of {@link #STATE} when the voicemail has marked as undeleted. */ - public static int STATE_UNDELETED = 2; - /** - * Package name of the source application that inserted the voicemail. - *Type: TEXT
- */ - public static final String SOURCE_PACKAGE = "source_package"; - /** - * Application-specific data available to the source application that - * inserted the voicemail. This is typically used to store the source - * specific message id to identify this voicemail on the remote - * voicemail server. - *Type: TEXT
- *Note that this is NOT the voicemail media content data. - */ - public static final String SOURCE_DATA = "source_data"; - /** - * Whether the media content for this voicemail is available for - * consumption. - *
Type: INTEGER (boolean)
- */ - public static final String HAS_CONTENT = "has_content"; - /** - * MIME type of the media content for the voicemail. - *Type: TEXT
- */ - public static final String MIME_TYPE = "mime_type"; - /** - * Path to the media content file. Internal only field. - * @hide - */ - public static final String _DATA = "_data"; - - /** - * 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(); - } - } - - /** Defines fields exposed through the /status path of this content provider. */ - public static final class Status implements BaseColumns { - /** URI to insert/retrieve status of voicemail source. */ - public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/status"); - /** The mime type for a collection of voicemail source statuses. */ - public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemail.source.status"; - /** The mime type for a collection of voicemails. */ - public static final String ITEM_TYPE = "vnd.android.cursor.item/voicemail.source.status"; - - /** Not instantiable. */ - private Status() { - } - /** - * The package name of the voicemail source. There can only be a one entry per source. - *Type: TEXT
- */ - public static final String SOURCE_PACKAGE = "source_package"; - /** - * The URI to call to invoke source specific voicemail settings screen. On a user request - * to setup voicemail an intent with action VIEW with this URI will be fired by the system. - *Type: TEXT
- */ - public static final String SETTINGS_URI = "settings_uri"; - /** - * The URI to call when the user requests to directly access the voicemail from the remote - * server. In case of an IVR voicemail system this is typically set to the the voicemail - * number specified using a tel:/ URI. - *Type: TEXT
- */ - public static final String VOICEMAIL_ACCESS_URI = "voicemail_access_uri"; - /** - * The configuration state of the voicemail source. - *Possible values: - * {@link #CONFIGURATION_STATE_OK}, - * {@link #CONFIGURATION_STATE_NOT_CONFIGURED}, - * {@link #CONFIGURATION_STATE_CAN_BE_CONFIGURED} - *
Type: INTEGER
- */ - public static final String CONFIGURATION_STATE = "configuration_state"; - public static final int CONFIGURATION_STATE_OK = 0; - public static final int CONFIGURATION_STATE_NOT_CONFIGURED = 1; - /** - * This state must be used when the source has verified that the current user can be - * upgraded to visual voicemail and would like to show a set up invitation message. - */ - public static final int CONFIGURATION_STATE_CAN_BE_CONFIGURED = 2; - /** - * The data channel state of the voicemail source. This the channel through which the source - * pulls voicemail data from a remote server. - *Possible values: - * {@link #DATA_CHANNEL_STATE_OK}, - * {@link #DATA_CHANNEL_STATE_NO_CONNECTION} - *
- *Type: INTEGER
- */ - public static final String DATA_CHANNEL_STATE = "data_channel_state"; - public static final int DATA_CHANNEL_STATE_OK = 0; - public static final int DATA_CHANNEL_STATE_NO_CONNECTION = 1; - /** - * The notification channel state of the voicemail source. This is the channel through which - * the source gets notified of new voicemails on the remote server. - *Possible values: - * {@link #NOTIFICATION_CHANNEL_STATE_OK}, - * {@link #NOTIFICATION_CHANNEL_STATE_NO_CONNECTION}, - * {@link #NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING} - *
- *Type: INTEGER
- */ - public static final String NOTIFICATION_CHANNEL_STATE = "notification_channel_state"; - public static final int NOTIFICATION_CHANNEL_STATE_OK = 0; - public static final int NOTIFICATION_CHANNEL_STATE_NO_CONNECTION = 1; - /** - * Use this state when the notification can only tell that there are pending messages on - * the server but no details of the sender/time etc are known. - */ - public static final int NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING = 2; - - /** - * A convenience method to build status 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 Status.CONTENT_URI.buildUpon() - .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName).build(); - } - } -} diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java index c2a34aee0..121840af1 100644 --- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java +++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java @@ -16,6 +16,16 @@ package com.example.android.voicemail; +import com.example.android.voicemail.common.core.Voicemail; +import com.example.android.voicemail.common.core.VoicemailImpl; +import com.example.android.voicemail.common.core.VoicemailProviderHelper; +import com.example.android.voicemail.common.core.VoicemailProviderHelpers; +import com.example.android.voicemail.common.inject.InjectView; +import com.example.android.voicemail.common.inject.Injector; +import com.example.android.voicemail.common.logging.Logger; +import com.example.android.voicemail.common.ui.DialogHelperImpl; +import com.example.android.voicemail.common.utils.CloseUtils; + import android.app.Activity; import android.app.Dialog; import android.content.Intent; @@ -28,16 +38,6 @@ import android.view.View; import android.widget.Button; import android.widget.TextView; -import com.example.android.voicemail.common.core.Voicemail; -import com.example.android.voicemail.common.core.VoicemailImpl; -import com.example.android.voicemail.common.core.VoicemailProviderHelper; -import com.example.android.voicemail.common.core.VoicemailProviderHelpers; -import com.example.android.voicemail.common.inject.InjectView; -import com.example.android.voicemail.common.inject.Injector; -import com.example.android.voicemail.common.logging.Logger; -import com.example.android.voicemail.common.ui.DialogHelperImpl; -import com.example.android.voicemail.common.utils.CloseUtils; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -131,7 +131,6 @@ public class AddVoicemailActivity extends Activity { return VoicemailImpl.createForInsertion(time, sender) .setDuration(duration) .setSourcePackage(sourcePackageName) - .setMailbox(Voicemail.Mailbox.INBOX) .build(); } diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java index 17f03c7b3..dc451cb34 100644 --- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java +++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java @@ -16,8 +16,6 @@ package com.example.android.voicemail.common.core; -import com.example.android.provider.VoicemailContract; - import android.net.Uri; /** @@ -26,41 +24,6 @@ import android.net.Uri; * The presence of a field is indicated by a corresponding 'has' method. */ public interface Voicemail { - /** - * Which mailbox the message is sitting in. - *- * Note that inbox and deleted are alone insufficient, because we may have a provider that is - * not able to undelete (re-upload) a message. Thus we need a state to represent the (common) - * case where the user has deleted a message (which results in the message being removed from - * the server) and then restored the message (where we are unable to re-upload the message to - * the server). That's what the undeleted state is for. - *
- * The presence of an undeleted mailbox prevents the voicemail source from having to keep a list - * of all such deleted-then-restored message ids, without which it would be unable to tell the - * difference between a message that has been deleted-then-restored by the user and a message - * which has been deleted on the server and should now be removed (for example one removed via - * an IVR). - */ - public enum Mailbox { - /** After being fetched from the server, a message usually starts in the inbox. */ - INBOX(VoicemailContract.Voicemails.STATE_INBOX), - /** Indicates that a message has been deleted. */ - DELETED(VoicemailContract.Voicemails.STATE_DELETED), - /** Restored from having been deleted, distinct from being in the inbox. */ - UNDELETED(VoicemailContract.Voicemails.STATE_UNDELETED); - - private final int mValue; - - private Mailbox(int value) { - mValue = value; - } - - /** Returns the DB value of this mailbox state. */ - public int getValue() { - return mValue; - } - } - /** * The identifier of the voicemail in the content provider. *
@@ -116,11 +79,6 @@ public interface Voicemail { public boolean hasUri(); - /** Tells us which mailbox the message is sitting in, returns null if this is not set. */ - public Voicemail.Mailbox getMailbox(); - - public boolean hasMailbox(); - /** * Tells us if the voicemail message has been marked as read. *
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java index b3eab917d..5f2e0cd21 100644 --- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java +++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java @@ -20,9 +20,7 @@ import static com.example.android.voicemail.common.utils.DbQueryUtils.concatenat import static com.example.android.voicemail.common.utils.DbQueryUtils.concatenateClausesWithOr; import static com.example.android.voicemail.common.utils.DbQueryUtils.getEqualityClause; -import com.example.android.voicemail.common.core.Voicemail.Mailbox; -import com.example.android.provider.VoicemailContract.Voicemails; - +import android.provider.VoicemailContract.Voicemails; import android.text.TextUtils; import java.util.ArrayList; @@ -31,8 +29,8 @@ import java.util.List; /** * Factory class to create {@link VoicemailFilter} objects for various filtering needs. *
- * Factory methods like {@link #createWithMailbox(Mailbox)}, {@link #createWithReadStatus(boolean)} - * and {@link #createWithMatchingFields(Voicemail)} can be used to create a voicemail filter that + * Factory methods like {@link #createWithReadStatus(boolean)} and + * {@link #createWithMatchingFields(Voicemail)} can be used to create a voicemail filter that * matches the value of the specific field. *
* It is possible to combine multiple filters with OR or AND operation using the methods
@@ -44,13 +42,6 @@ import java.util.List;
* content provider database and is therefore less recommended.
*/
public class VoicemailFilterFactory {
- /** Predefined filter for inbox only messages. */
- public static final VoicemailFilter INBOX_MESSAGES_FILTER = createWithOrOf(
- createWithMailbox(Mailbox.INBOX), createWithMailbox(Mailbox.UNDELETED));
- /** Predefined filter for trashed messages. */
- public static final VoicemailFilter TRASHED_MESSAGES_FILTER =
- createWithMailbox(Mailbox.DELETED);
-
/**
* Creates a voicemail filter with the specified where clause. Use this method only if you know
* and want to directly use the column names of the content provider. For most of the usages
@@ -78,12 +69,6 @@ public class VoicemailFilterFactory {
getWhereClauseForMatchingFields(fieldMatch));
}
- /** Creates a voicemail filter with the specified mailbox state. */
- public static VoicemailFilter createWithMailbox(Mailbox mailbox) {
- return createWithMatchingFields(
- VoicemailImpl.createEmptyBuilder().setMailbox(mailbox).build());
- }
-
/** Creates a voicemail filter with the specified read status. */
public static VoicemailFilter createWithReadStatus(boolean isRead) {
return createWithMatchingFields(
@@ -111,11 +96,7 @@ public class VoicemailFilterFactory {
private static String getWhereClauseForMatchingFields(Voicemail fieldMatch) {
List