summaryrefslogtreecommitdiff
path: root/java/com/android/dialer
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2017-08-01 11:24:45 -0700
committerEric Erfanian <erfanian@google.com>2017-08-01 15:13:56 -0700
commit6adbdbe32d0aa6b0d71c2034dda427452c7b0b8b (patch)
tree803346bb0d681d4f455243c3e5965a5bec394577 /java/com/android/dialer
parentd2035dc3bfabc3a885f9d0016a5d5846645dae94 (diff)
Handle null in voicemail config status
The VVM tab is shown when there are more then one "active" voicemail sources in the voicemail status table. A configuration status of 0 is active, and 1 is inactive. If the configuration state is null, getInt() will return 0 which maps to active, and incorrectly showing the VVM tab. In this CL, null is checked first. The helper class is also made static. Bug: 64122858 Test: VoicemailStatusHelperTest PiperOrigin-RevId: 163858350 Change-Id: I3fca52aaca92492f1969092e2d9f443677cb3b8d
Diffstat (limited to 'java/com/android/dialer')
-rw-r--r--java/com/android/dialer/app/list/ListsFragment.java4
-rw-r--r--java/com/android/dialer/voicemailstatus/VisualVoicemailEnabledChecker.java4
-rw-r--r--java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java20
3 files changed, 14 insertions, 14 deletions
diff --git a/java/com/android/dialer/app/list/ListsFragment.java b/java/com/android/dialer/app/list/ListsFragment.java
index 3f03db1e8..dbb6c8b5c 100644
--- a/java/com/android/dialer/app/list/ListsFragment.java
+++ b/java/com/android/dialer/app/list/ListsFragment.java
@@ -75,7 +75,6 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis
private SharedPreferences mPrefs;
private boolean mHasFetchedVoicemailStatus;
private boolean mShowVoicemailTabAfterVoicemailStatusIsFetched;
- private VoicemailStatusHelper mVoicemailStatusHelper;
private final ArrayList<OnPageChangeListener> mOnPageChangeListeners = new ArrayList<>();
/** The position of the currently selected tab. */
private int mTabIndex = TAB_INDEX_SPEED_DIAL;
@@ -99,7 +98,6 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis
LogUtil.d("ListsFragment.onCreate", null);
Trace.beginSection(TAG + " onCreate");
super.onCreate(savedInstanceState);
- mVoicemailStatusHelper = new VoicemailStatusHelper();
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
Trace.endSection();
}
@@ -294,7 +292,7 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis
// Update hasActiveVoicemailProvider, which controls the number of tabs displayed.
boolean hasActiveVoicemailProvider =
- mVoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor) > 0;
+ VoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor) > 0;
if (hasActiveVoicemailProvider != mAdapter.hasActiveVoicemailProvider()) {
mAdapter.setHasActiveVoicemailProvider(hasActiveVoicemailProvider);
mAdapter.notifyDataSetChanged();
diff --git a/java/com/android/dialer/voicemailstatus/VisualVoicemailEnabledChecker.java b/java/com/android/dialer/voicemailstatus/VisualVoicemailEnabledChecker.java
index a1fc29edf..3f519ad82 100644
--- a/java/com/android/dialer/voicemailstatus/VisualVoicemailEnabledChecker.java
+++ b/java/com/android/dialer/voicemailstatus/VisualVoicemailEnabledChecker.java
@@ -45,7 +45,6 @@ public class VisualVoicemailEnabledChecker implements CallLogQueryHandler.Listen
private SharedPreferences mPrefs;
private boolean mHasActiveVoicemailProvider;
private CallLogQueryHandler mCallLogQueryHandler;
- private VoicemailStatusHelper mVoicemailStatusHelper;
private Context mContext;
private Callback mCallback;
@@ -53,7 +52,6 @@ public class VisualVoicemailEnabledChecker implements CallLogQueryHandler.Listen
mContext = context;
mCallback = callback;
mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
- mVoicemailStatusHelper = new VoicemailStatusHelper();
mHasActiveVoicemailProvider = mPrefs.getBoolean(PREF_KEY_HAS_ACTIVE_VOICEMAIL_PROVIDER, false);
}
@@ -77,7 +75,7 @@ public class VisualVoicemailEnabledChecker implements CallLogQueryHandler.Listen
@Override
public void onVoicemailStatusFetched(Cursor statusCursor) {
boolean hasActiveVoicemailProvider =
- mVoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor) > 0;
+ VoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor) > 0;
if (hasActiveVoicemailProvider != mHasActiveVoicemailProvider) {
mHasActiveVoicemailProvider = hasActiveVoicemailProvider;
mPrefs
diff --git a/java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java b/java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java
index 9df45c211..313fc1be1 100644
--- a/java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java
+++ b/java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java
@@ -21,15 +21,17 @@ import android.provider.VoicemailContract.Status;
import com.android.dialer.database.VoicemailStatusQuery;
/**
- * Interface used by the call log UI to determine what user message, if any, related to voicemail
+ * Utility used by the call log UI to determine what user message, if any, related to voicemail
* source status needs to be shown. The messages are returned in the order of importance.
*
- * <p>The implementation of this interface interacts with the voicemail content provider to fetch
- * statuses of all the registered voicemail sources and determines if any status message needs to be
- * shown. The user of this interface must observe/listen to provider changes and invoke this class
- * to check if any message needs to be shown.
+ * <p>This class interacts with the voicemail content provider to fetch statuses of all the
+ * registered voicemail sources and determines if any status message needs to be shown. The user of
+ * this class must observe/listen to provider changes and invoke this class to check if any message
+ * needs to be shown.
*/
-public class VoicemailStatusHelper {
+public final class VoicemailStatusHelper {
+
+ private VoicemailStatusHelper() {}
/**
* Returns the number of active voicemail sources installed.
@@ -39,7 +41,7 @@ public class VoicemailStatusHelper {
* @param cursor The caller is responsible for the life cycle of the cursor and resetting the
* position
*/
- public int getNumberActivityVoicemailSources(Cursor cursor) {
+ public static int getNumberActivityVoicemailSources(Cursor cursor) {
int count = 0;
if (!cursor.moveToFirst()) {
return 0;
@@ -60,8 +62,10 @@ public class VoicemailStatusHelper {
* activation is attempted, it will transition into CONFIGURING then into OK or other error state,
* NOT_CONFIGURED is never set through an error.
*/
- private boolean isVoicemailSourceActive(Cursor cursor) {
+ private static boolean isVoicemailSourceActive(Cursor cursor) {
return cursor.getString(VoicemailStatusQuery.SOURCE_PACKAGE_INDEX) != null
+ // getInt() returns 0 when null
+ && !cursor.isNull(VoicemailStatusQuery.CONFIGURATION_STATE_INDEX)
&& cursor.getInt(VoicemailStatusQuery.CONFIGURATION_STATE_INDEX)
!= Status.CONFIGURATION_STATE_NOT_CONFIGURED;
}