summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Menke <grantmenke@google.com>2023-04-27 17:28:21 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-04-27 17:28:21 +0000
commit7f419fcd8d5c92d32af93ff2af6dfef7e1ef2191 (patch)
treeea3960be2a150bf1177c04bb4eba7507b511c7e9
parent92dcfab5140d38c882cb1d1b4059889340a03588 (diff)
parentd24120081434e3f4d06a74c82ef50bae6eb636f5 (diff)
downloadCallLogProvider-7f419fcd8d5c92d32af93ff2af6dfef7e1ef2191.tar.gz
Catch all types of exceptions in CallLogBackupAgent#runBackup. am: d241200814
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/providers/CallLogProvider/+/22898582 Change-Id: I9c4718703256f5a63efd1385169e7faac5aee169 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--src/com/android/calllogbackup/CallLogBackupAgent.java2
-rw-r--r--tests/src/com/android/calllogbackup/CallLogBackupAgentTest.java15
2 files changed, 16 insertions, 1 deletions
diff --git a/src/com/android/calllogbackup/CallLogBackupAgent.java b/src/com/android/calllogbackup/CallLogBackupAgent.java
index 02adacc..b0b0c1c 100644
--- a/src/com/android/calllogbackup/CallLogBackupAgent.java
+++ b/src/com/android/calllogbackup/CallLogBackupAgent.java
@@ -646,7 +646,7 @@ public class CallLogBackupAgent extends BackupAgent {
if (isDebug()) {
Log.d(TAG, "Wrote call to backup: " + call + " with byte array: " + baos);
}
- } catch (IOException e) {
+ } catch (Exception e) {
mBackupRestoreEventLoggerProxy.logItemsBackupFailed(
CALLLOGS, /* count */ 1, ERROR_BACKUP_CALL_FAILED);
Log.e(TAG, "Failed to backup call: " + call, e);
diff --git a/tests/src/com/android/calllogbackup/CallLogBackupAgentTest.java b/tests/src/com/android/calllogbackup/CallLogBackupAgentTest.java
index d768dbd..96ac049 100644
--- a/tests/src/com/android/calllogbackup/CallLogBackupAgentTest.java
+++ b/tests/src/com/android/calllogbackup/CallLogBackupAgentTest.java
@@ -233,6 +233,21 @@ public class CallLogBackupAgentTest extends AndroidTestCase {
assertEquals(backupRestoreLoggerFailCount, 1);
}
+ public void testRunBackup_OneNewCall_NullBackupDataOutput() throws Exception {
+ CallLogBackupState state = new CallLogBackupState();
+ state.version = CallLogBackupAgent.VERSION;
+ state.callIds = new TreeSet<>();
+ List<Call> calls = new LinkedList<>();
+ calls.add(makeCall(101, 0L, 0L, "555-5555"));
+
+ // Invoke runBackup() with a null value for BackupDataOutput causing an exception:
+ mCallLogBackupAgent.runBackup(state, null, calls);
+
+ // Ensure the {@link BackupRestoreEventLogger} is informed of the failed backed up call:
+ assertEquals(backupRestoreLoggerSuccessCount, 0);
+ assertEquals(backupRestoreLoggerFailCount, 1);
+ }
+
public void testRunBackup_OneNewCall() throws Exception {
CallLogBackupState state = new CallLogBackupState();
state.version = CallLogBackupAgent.VERSION;