Copied over latest changes to VoicemailContract api.
In addition, modified VoicemailProviderHelpers to use "source_package" uri parameter instead of deprecated /source/ path for source specific uri and stop using other deprecated fields. Change-Id: Ia9570de2d9823ea27d57f7d602348d2a2826f2e8
This commit is contained in:
@@ -59,13 +59,23 @@ public class VoicemailContract {
|
|||||||
|
|
||||||
/** The authority used by the voicemail provider. */
|
/** The authority used by the voicemail provider. */
|
||||||
public static final String AUTHORITY = "com.android.voicemail";
|
public static final String AUTHORITY = "com.android.voicemail";
|
||||||
|
/**
|
||||||
/** URI to insert/retrieve all voicemails. */
|
* URI to insert/retrieve all voicemails.
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
public static final Uri CONTENT_URI =
|
public static final Uri CONTENT_URI =
|
||||||
Uri.parse("content://" + AUTHORITY + "/voicemail");
|
Uri.parse("content://" + AUTHORITY + "/voicemail");
|
||||||
/** URI to insert/retrieve voicemails by a given voicemail source. */
|
/**
|
||||||
|
* URI to insert/retrieve voicemails by a given voicemail source.
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
public static final Uri CONTENT_URI_SOURCE =
|
public static final Uri CONTENT_URI_SOURCE =
|
||||||
Uri.parse("content://" + AUTHORITY + "/voicemail/source/");
|
Uri.parse("content://" + AUTHORITY + "/voicemail/source/");
|
||||||
|
/**
|
||||||
|
* Parameter key used in the URI to specify the voicemail source package name.
|
||||||
|
* <p> 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.
|
// TODO: Move ACTION_NEW_VOICEMAIL to the Intent class.
|
||||||
/** Broadcast intent when a new voicemail record is inserted. */
|
/** Broadcast intent when a new voicemail record is inserted. */
|
||||||
@@ -77,15 +87,27 @@ public class VoicemailContract {
|
|||||||
*/
|
*/
|
||||||
public static final String EXTRA_SELF_CHANGE = "com.android.voicemail.extra.SELF_CHANGE";
|
public static final String EXTRA_SELF_CHANGE = "com.android.voicemail.extra.SELF_CHANGE";
|
||||||
|
|
||||||
/** The mime type for a collection of voicemails. */
|
/**
|
||||||
public static final String DIR_TYPE =
|
* The mime type for a collection of voicemails.
|
||||||
"vnd.android.cursor.dir/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 {
|
public static final class Voicemails implements BaseColumns {
|
||||||
/** Not instantiable. */
|
/** Not instantiable. */
|
||||||
private Voicemails() {
|
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.
|
* Phone number of the voicemail sender.
|
||||||
* <P>Type: TEXT</P>
|
* <P>Type: TEXT</P>
|
||||||
@@ -149,5 +171,101 @@ public class VoicemailContract {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String _DATA = "_data";
|
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.
|
||||||
|
* <P>Type: TEXT</P>
|
||||||
|
*/
|
||||||
|
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.
|
||||||
|
* <P>Type: TEXT</P>
|
||||||
|
*/
|
||||||
|
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.
|
||||||
|
* <P>Type: TEXT</P>
|
||||||
|
*/
|
||||||
|
public static final String VOICEMAIL_ACCESS_URI = "voicemail_access_uri";
|
||||||
|
/**
|
||||||
|
* The configuration state of the voicemail source.
|
||||||
|
* <P> Possible values:
|
||||||
|
* {@link #CONFIGURATION_STATE_OK},
|
||||||
|
* {@link #CONFIGURATION_STATE_NOT_CONFIGURED},
|
||||||
|
* {@link #CONFIGURATION_STATE_CAN_BE_CONFIGURED}
|
||||||
|
* <P>Type: INTEGER</P>
|
||||||
|
*/
|
||||||
|
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.
|
||||||
|
* <P> Possible values:
|
||||||
|
* {@link #DATA_CHANNEL_STATE_OK},
|
||||||
|
* {@link #DATA_CHANNEL_STATE_NO_CONNECTION}
|
||||||
|
* </P>
|
||||||
|
* <P>Type: INTEGER</P>
|
||||||
|
*/
|
||||||
|
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.
|
||||||
|
* <P> Possible values:
|
||||||
|
* {@link #NOTIFICATION_CHANNEL_STATE_OK},
|
||||||
|
* {@link #NOTIFICATION_CHANNEL_STATE_NO_CONNECTION},
|
||||||
|
* {@link #NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING}
|
||||||
|
* </P>
|
||||||
|
* <P>Type: INTEGER</P>
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.example.android.voicemail.common.core;
|
package com.example.android.voicemail.common.core;
|
||||||
|
|
||||||
import com.example.android.provider.VoicemailContract;
|
|
||||||
import com.example.android.provider.VoicemailContract.Voicemails;
|
import com.example.android.provider.VoicemailContract.Voicemails;
|
||||||
import com.example.android.voicemail.common.logging.Logger;
|
import com.example.android.voicemail.common.logging.Logger;
|
||||||
import com.example.android.voicemail.common.utils.CloseUtils;
|
import com.example.android.voicemail.common.utils.CloseUtils;
|
||||||
@@ -76,8 +75,7 @@ public final class VoicemailProviderHelpers implements VoicemailProviderHelper {
|
|||||||
* <code>com.android.providers.voicemail.permission.READ_WRITE_OWN_VOICEMAIL</code>.
|
* <code>com.android.providers.voicemail.permission.READ_WRITE_OWN_VOICEMAIL</code>.
|
||||||
*/
|
*/
|
||||||
public static VoicemailProviderHelper createFullVoicemailProvider(Context context) {
|
public static VoicemailProviderHelper createFullVoicemailProvider(Context context) {
|
||||||
return new VoicemailProviderHelpers(VoicemailContract.CONTENT_URI,
|
return new VoicemailProviderHelpers(Voicemails.CONTENT_URI, context.getContentResolver());
|
||||||
context.getContentResolver());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,9 +86,8 @@ public final class VoicemailProviderHelpers implements VoicemailProviderHelper {
|
|||||||
* <code>com.android.providers.voicemail.permission.READ_WRITE_OWN_VOICEMAIL</code>.
|
* <code>com.android.providers.voicemail.permission.READ_WRITE_OWN_VOICEMAIL</code>.
|
||||||
*/
|
*/
|
||||||
public static VoicemailProviderHelper createPackageScopedVoicemailProvider(Context context) {
|
public static VoicemailProviderHelper createPackageScopedVoicemailProvider(Context context) {
|
||||||
Uri providerUri = Uri.withAppendedPath(VoicemailContract.CONTENT_URI_SOURCE,
|
return new VoicemailProviderHelpers(Voicemails.buildSourceUri(context.getPackageName()),
|
||||||
context.getPackageName());
|
context.getContentResolver());
|
||||||
return new VoicemailProviderHelpers(providerUri, context.getContentResolver());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -241,8 +238,6 @@ public final class VoicemailProviderHelpers implements VoicemailProviderHelper {
|
|||||||
long id = cursor.getLong(cursor.getColumnIndexOrThrow(Voicemails._ID));
|
long id = cursor.getLong(cursor.getColumnIndexOrThrow(Voicemails._ID));
|
||||||
String sourcePackage = cursor.getString(
|
String sourcePackage = cursor.getString(
|
||||||
cursor.getColumnIndexOrThrow(Voicemails.SOURCE_PACKAGE));
|
cursor.getColumnIndexOrThrow(Voicemails.SOURCE_PACKAGE));
|
||||||
Uri voicemailUri = ContentUris.withAppendedId(
|
|
||||||
Uri.withAppendedPath(VoicemailContract.CONTENT_URI_SOURCE, sourcePackage), id);
|
|
||||||
VoicemailImpl voicemail = VoicemailImpl
|
VoicemailImpl voicemail = VoicemailImpl
|
||||||
.createEmptyBuilder()
|
.createEmptyBuilder()
|
||||||
.setTimestamp(cursor.getLong(cursor.getColumnIndexOrThrow(Voicemails.DATE)))
|
.setTimestamp(cursor.getLong(cursor.getColumnIndexOrThrow(Voicemails.DATE)))
|
||||||
@@ -252,7 +247,7 @@ public final class VoicemailProviderHelpers implements VoicemailProviderHelper {
|
|||||||
.setSourcePackage(sourcePackage)
|
.setSourcePackage(sourcePackage)
|
||||||
.setSourceData(cursor.getString(
|
.setSourceData(cursor.getString(
|
||||||
cursor.getColumnIndexOrThrow(Voicemails.SOURCE_DATA)))
|
cursor.getColumnIndexOrThrow(Voicemails.SOURCE_DATA)))
|
||||||
.setUri(voicemailUri)
|
.setUri(buildUriWithSourcePackage(id, sourcePackage))
|
||||||
.setHasContent(cursor.getInt(
|
.setHasContent(cursor.getInt(
|
||||||
cursor.getColumnIndexOrThrow(Voicemails.HAS_CONTENT)) == 1)
|
cursor.getColumnIndexOrThrow(Voicemails.HAS_CONTENT)) == 1)
|
||||||
.setIsRead(cursor.getInt(cursor.getColumnIndexOrThrow(Voicemails.NEW)) == 1)
|
.setIsRead(cursor.getInt(cursor.getColumnIndexOrThrow(Voicemails.NEW)) == 1)
|
||||||
@@ -262,6 +257,10 @@ public final class VoicemailProviderHelpers implements VoicemailProviderHelper {
|
|||||||
return voicemail;
|
return voicemail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Uri buildUriWithSourcePackage(long id, String sourcePackage) {
|
||||||
|
return ContentUris.withAppendedId(Voicemails.buildSourceUri(sourcePackage), id);
|
||||||
|
}
|
||||||
|
|
||||||
private Voicemail.Mailbox mapValueToMailBoxEnum(int value) {
|
private Voicemail.Mailbox mapValueToMailBoxEnum(int value) {
|
||||||
for (Voicemail.Mailbox mailbox : Voicemail.Mailbox.values()) {
|
for (Voicemail.Mailbox mailbox : Voicemail.Mailbox.values()) {
|
||||||
if (mailbox.getValue() == value) {
|
if (mailbox.getValue() == value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user