diff options
author | Grant Menke <grantmenke@google.com> | 2023-04-27 17:27:53 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-04-27 17:27:53 +0000 |
commit | 6e1ffc113bd109706ff0f488e29db5d21f326094 (patch) | |
tree | ea3960be2a150bf1177c04bb4eba7507b511c7e9 | |
parent | 87751f602996b4cd13ec50193221629f8398d812 (diff) | |
parent | d24120081434e3f4d06a74c82ef50bae6eb636f5 (diff) | |
download | CallLogProvider-6e1ffc113bd109706ff0f488e29db5d21f326094.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: I39757ac15c760e5cb01bee9d5e839916dfca0ced
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | src/com/android/calllogbackup/CallLogBackupAgent.java | 2 | ||||
-rw-r--r-- | tests/src/com/android/calllogbackup/CallLogBackupAgentTest.java | 15 |
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; |