summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/voicemailstatus
diff options
context:
space:
mode:
authoruabdullah <uabdullah@google.com>2018-02-11 16:49:45 -0800
committerCopybara-Service <copybara-piper@google.com>2018-02-12 11:42:06 -0800
commitcdcda1a127c4841c2710c17f64a2f522c62cd512 (patch)
tree5addb70bf9c778c1617b20e700baf9bf67983c2b /java/com/android/dialer/voicemailstatus
parentc9213fe63ee5727c55980f549ff10dac87f2e4f0 (diff)
Use UI Listeners for querying voicemail status table
Earlier we were using the legacy CallLogQueryHandler for querying the voicemail status table. However we should be using UI Listeners instead in NUI. This CL queries the voicemail status table and returns a list of voicemail status', which are then used to display the corresponding error messages. This CL also moved VoicemailStatus out of the legacy dialer/database and moves it to dialer/voicemailstatus and ensures that there are no dependencies on the legacy dialer/database in the NUI. Bug: 73139237 Test: Unit tests PiperOrigin-RevId: 185321023 Change-Id: Id16ea475b6a52da380fbf8b3590dc75cbcdc370e
Diffstat (limited to 'java/com/android/dialer/voicemailstatus')
-rw-r--r--java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java1
-rw-r--r--java/com/android/dialer/voicemailstatus/VoicemailStatusQuery.java91
2 files changed, 91 insertions, 1 deletions
diff --git a/java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java b/java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java
index 313fc1be1..16a8c7b69 100644
--- a/java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java
+++ b/java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java
@@ -18,7 +18,6 @@ package com.android.dialer.voicemailstatus;
import android.database.Cursor;
import android.provider.VoicemailContract.Status;
-import com.android.dialer.database.VoicemailStatusQuery;
/**
* Utility used by the call log UI to determine what user message, if any, related to voicemail
diff --git a/java/com/android/dialer/voicemailstatus/VoicemailStatusQuery.java b/java/com/android/dialer/voicemailstatus/VoicemailStatusQuery.java
new file mode 100644
index 000000000..4a6e9f703
--- /dev/null
+++ b/java/com/android/dialer/voicemailstatus/VoicemailStatusQuery.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.dialer.voicemailstatus;
+
+import android.os.Build.VERSION;
+import android.os.Build.VERSION_CODES;
+import android.provider.VoicemailContract.Status;
+import android.support.annotation.RequiresApi;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/** The query for the call voicemail status table. */
+public class VoicemailStatusQuery {
+
+ // TODO(maxwelb): Column indices should be removed in favor of Cursor#getColumnIndex
+ public static final int SOURCE_PACKAGE_INDEX = 0;
+ public static final int SETTINGS_URI_INDEX = 1;
+ public static final int VOICEMAIL_ACCESS_URI_INDEX = 2;
+ public static final int CONFIGURATION_STATE_INDEX = 3;
+ public static final int DATA_CHANNEL_STATE_INDEX = 4;
+ public static final int NOTIFICATION_CHANNEL_STATE_INDEX = 5;
+
+ @RequiresApi(VERSION_CODES.N)
+ public static final int QUOTA_OCCUPIED_INDEX = 6;
+
+ @RequiresApi(VERSION_CODES.N)
+ public static final int QUOTA_TOTAL_INDEX = 7;
+
+ @RequiresApi(VERSION_CODES.N_MR1)
+ // The PHONE_ACCOUNT columns were added in M, but aren't queryable until N MR1
+ public static final int PHONE_ACCOUNT_COMPONENT_NAME = 8;
+
+ @RequiresApi(VERSION_CODES.N_MR1)
+ public static final int PHONE_ACCOUNT_ID = 9;
+
+ @RequiresApi(VERSION_CODES.N_MR1)
+ public static final int SOURCE_TYPE_INDEX = 10;
+
+ private static final String[] PROJECTION_M =
+ new String[] {
+ Status.SOURCE_PACKAGE, // 0
+ Status.SETTINGS_URI, // 1
+ Status.VOICEMAIL_ACCESS_URI, // 2
+ Status.CONFIGURATION_STATE, // 3
+ Status.DATA_CHANNEL_STATE, // 4
+ Status.NOTIFICATION_CHANNEL_STATE // 5
+ };
+
+ @RequiresApi(VERSION_CODES.N)
+ private static final String[] PROJECTION_N;
+
+ @RequiresApi(VERSION_CODES.N_MR1)
+ private static final String[] PROJECTION_NMR1;
+
+ static {
+ List<String> projectionList = new ArrayList<>(Arrays.asList(PROJECTION_M));
+ projectionList.add(Status.QUOTA_OCCUPIED); // 6
+ projectionList.add(Status.QUOTA_TOTAL); // 7
+ PROJECTION_N = projectionList.toArray(new String[projectionList.size()]);
+
+ projectionList.add(Status.PHONE_ACCOUNT_COMPONENT_NAME); // 8
+ projectionList.add(Status.PHONE_ACCOUNT_ID); // 9
+ projectionList.add(Status.SOURCE_TYPE); // 10
+ PROJECTION_NMR1 = projectionList.toArray(new String[projectionList.size()]);
+ }
+
+ public static String[] getProjection() {
+ if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) {
+ return PROJECTION_NMR1;
+ }
+ if (VERSION.SDK_INT >= VERSION_CODES.N) {
+ return PROJECTION_N;
+ }
+ return PROJECTION_M;
+ }
+}