summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Shrauner <shrauner@google.com>2014-05-27 14:01:49 -0700
committerJay Shrauner <shrauner@google.com>2014-05-27 14:05:56 -0700
commitf3440d33a9da544b202c05d1d5e4849674bcf5bf (patch)
treeafab5d974956a0161c704f5e43eb2325932883de
parent4ce1fc7669a0a9ecf104fe1a48df6a2bb6675c59 (diff)
downloadandroid_packages_apps_Email-f3440d33a9da544b202c05d1d5e4849674bcf5bf.tar.gz
android_packages_apps_Email-f3440d33a9da544b202c05d1d5e4849674bcf5bf.tar.bz2
android_packages_apps_Email-f3440d33a9da544b202c05d1d5e4849674bcf5bf.zip
Fix NPE in setAccountPolicy
Check for null returned by Account.restoreAccountWithId as with other places where it is called. Bug:15286267 Change-Id: I56d59564a1fa814f5c52b44c12303014eea2b0b0
-rw-r--r--src/com/android/email/SecurityPolicy.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/com/android/email/SecurityPolicy.java b/src/com/android/email/SecurityPolicy.java
index de1a04eaf..db725b819 100644
--- a/src/com/android/email/SecurityPolicy.java
+++ b/src/com/android/email/SecurityPolicy.java
@@ -586,6 +586,10 @@ public class SecurityPolicy {
public void setAccountPolicy(long accountId, Policy policy, String securityKey,
boolean notify) {
Account account = Account.restoreAccountWithId(mContext, accountId);
+ // In case the account has been deleted, just return
+ if (account == null) {
+ return;
+ }
Policy oldPolicy = null;
if (account.mPolicyKey > 0) {
oldPolicy = Policy.restorePolicyWithId(mContext, account.mPolicyKey);
@@ -791,6 +795,9 @@ public class SecurityPolicy {
boolean result = false;
Cursor c = context.getContentResolver().query(Policy.CONTENT_URI,
Policy.ID_PROJECTION, HAS_PASSWORD_EXPIRATION, null, null);
+ if (c == null) {
+ return false;
+ }
try {
while (c.moveToNext()) {
long policyId = c.getLong(Policy.ID_PROJECTION_COLUMN);