Add exception handling and retry when configuring VVM.
In VoicemailStatus#apply there is a possibility for the call to
ContentResolver#insert(.., ...) to throw an IllegalArgumentException if
the content resolver can't be started. If this happened there was a
possibility of the entire Phone process dying.
Added exception handling to the apply method, and in the
OmtpVvmCarrierConfigHelper added code to retry configuration if it fails.
Bug: 29837276
Change-Id: I419e866e0b44b69932f4d0b9d2b46067ce2efcfe
diff --git a/src/com/android/phone/VoicemailStatus.java b/src/com/android/phone/VoicemailStatus.java
index 4d7d388..00130f1 100644
--- a/src/com/android/phone/VoicemailStatus.java
+++ b/src/com/android/phone/VoicemailStatus.java
@@ -83,17 +83,29 @@
return this;
}
- public void apply() {
+ /**
+ * Apply the changes to the {@link VoicemailStatus} {@link #Editor}.
+ *
+ * @return {@code true} if the changes were successfully applied, {@code false} otherwise.
+ */
+ public boolean apply() {
if (mPhoneAccountHandle == null) {
- return;
+ return false;
}
mValues.put(Status.PHONE_ACCOUNT_COMPONENT_NAME,
mPhoneAccountHandle.getComponentName().flattenToString());
mValues.put(Status.PHONE_ACCOUNT_ID, mPhoneAccountHandle.getId());
ContentResolver contentResolver = mContext.getContentResolver();
Uri statusUri = VoicemailContract.Status.buildSourceUri(mContext.getPackageName());
- contentResolver.insert(statusUri, mValues);
+ try {
+ contentResolver.insert(statusUri, mValues);
+ } catch (IllegalArgumentException iae) {
+ VvmLog.e(TAG, "apply :: failed to insert content resolver ", iae);
+ mValues.clear();
+ return false;
+ }
mValues.clear();
+ return true;
}
public ContentValues getValues() {
@@ -114,8 +126,9 @@
}
@Override
- public void apply() {
+ public boolean apply() {
// Do nothing
+ return true;
}
public void deferredApply() {