From 213e355c77993c718298c89bc04908a0d6c5addd Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Tue, 15 Mar 2016 10:41:49 -0700 Subject: [PATCH] Handle AccountManager failures so Shell doesn't crash. BUG: 27665208 Change-Id: Iccb6ce810c8e1c93bded58871d7ec220b7d14ba9 --- .../src/com/android/shell/BugreportProgressService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index 10c541600d873..89ebcd1b3fe62 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -1102,7 +1102,14 @@ public class BugreportProgressService extends Service { preferredDomain = "@" + preferredDomain; } - final Account[] accounts = am.getAccounts(); + final Account[] accounts; + try { + accounts = am.getAccounts(); + } catch (RuntimeException e) { + Log.e(TAG, "Could not get accounts for preferred domain " + preferredDomain, e); + return null; + } + if (DEBUG) Log.d(TAG, "Number of accounts: " + accounts.length); Account foundAccount = null; for (Account account : accounts) { if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) {