summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2015-03-04 21:02:27 -0800
committerNancy Chen <nancychen@google.com>2015-03-11 08:45:00 -0700
commit8b97ee3c4830d44d3d4bbdf29bd9a3543f16e565 (patch)
tree97f4703e3d91afbd68bb195d4e80a5881044e0a5 /core
parent4a2ca9da48e177b3cf191a435bd62a7e6b706d3e (diff)
downloadframeworks_base-8b97ee3c4830d44d3d4bbdf29bd9a3543f16e565.zip
frameworks_base-8b97ee3c4830d44d3d4bbdf29bd9a3543f16e565.tar.gz
frameworks_base-8b97ee3c4830d44d3d4bbdf29bd9a3543f16e565.tar.bz2
Helper methods for voicemail status provider.
Added method to make it easier to insert into the voicemail status table. Also takes in a phone account for future multi-SIM support. Remove VvmSyncService class in favor of moving most of the code to OmtpVvmSyncService. Bug: 19236241 Change-Id: I5d9def276fbdbc6f825fb35e9fa31bfc3cead1ba
Diffstat (limited to 'core')
-rw-r--r--core/java/android/provider/VoicemailContract.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/core/java/android/provider/VoicemailContract.java b/core/java/android/provider/VoicemailContract.java
index 03cf6e3..0da4fd5 100644
--- a/core/java/android/provider/VoicemailContract.java
+++ b/core/java/android/provider/VoicemailContract.java
@@ -24,8 +24,10 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.ContentObserver;
+import android.database.Cursor;
import android.net.Uri;
import android.provider.CallLog.Calls;
+import android.telecom.PhoneAccountHandle;
import android.telecom.Voicemail;
import java.util.List;
@@ -428,5 +430,50 @@ public class VoicemailContract {
return Status.CONTENT_URI.buildUpon()
.appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName).build();
}
+
+ /**
+ * A helper method to set the status of a voicemail source.
+ *
+ * @param context The context from the package calling the method. This will be the source.
+ * @param accountHandle The handle for the account the source is associated with.
+ * @param configurationState See {@link Status#CONFIGURATION_STATE}
+ * @param dataChannelState See {@link Status#DATA_CHANNEL_STATE}
+ * @param notificationChannelState See {@link Status#NOTIFICATION_CHANNEL_STATE}
+ */
+ public static void setStatus(Context context, PhoneAccountHandle accountHandle,
+ int configurationState, int dataChannelState, int notificationChannelState) {
+ ContentResolver contentResolver = context.getContentResolver();
+ Uri statusUri = buildSourceUri(context.getPackageName());
+ ContentValues values = new ContentValues();
+ values.put(Status.PHONE_ACCOUNT_COMPONENT_NAME,
+ accountHandle.getComponentName().toString());
+ values.put(Status.PHONE_ACCOUNT_ID, accountHandle.getId());
+ values.put(Status.CONFIGURATION_STATE, configurationState);
+ values.put(Status.DATA_CHANNEL_STATE, dataChannelState);
+ values.put(Status.NOTIFICATION_CHANNEL_STATE, notificationChannelState);
+
+ if (isStatusPresent(contentResolver, statusUri)) {
+ contentResolver.update(statusUri, values, null, null);
+ } else {
+ contentResolver.insert(statusUri, values);
+ }
+ }
+
+ /**
+ * Determines if a voicemail source exists in the status table.
+ *
+ * @param contentResolver A content resolver constructed from the appropriate context.
+ * @param statusUri The content uri for the source.
+ * @return {@code true} if a status entry for this source exists
+ */
+ private static boolean isStatusPresent(ContentResolver contentResolver, Uri statusUri) {
+ Cursor cursor = null;
+ try {
+ cursor = contentResolver.query(statusUri, null, null, null, null);
+ return cursor != null && cursor.getCount() != 0;
+ } finally {
+ if (cursor != null) cursor.close();
+ }
+ }
}
}