Add logging for AccountSecurity class

* Temporary, for debugging

Change-Id: Ia3798333c7f19bfdea0b19b3c85e0519a1daa8c3
This commit is contained in:
Marc Blank 2012-06-20 12:50:35 -07:00
parent 58d0db2709
commit 54eb1f2286

View File

@ -51,6 +51,8 @@ import com.android.emailcommon.utility.Utility;
public class AccountSecurity extends Activity {
private static final String TAG = "Email/AccountSecurity";
private static final boolean DEBUG = true; // STOPSHIP Don't ship with this set to true
private static final String EXTRA_ACCOUNT_ID = "ACCOUNT_ID";
private static final String EXTRA_SHOW_DIALOG = "SHOW_DIALOG";
private static final String EXTRA_PASSWORD_EXPIRING = "EXPIRING";
@ -127,6 +129,9 @@ public class AccountSecurity extends Activity {
PasswordExpirationDialog dialog =
PasswordExpirationDialog.newInstance(mAccount.getDisplayName(),
passwordExpired);
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "Showing password expiration dialog");
}
dialog.show(fm, "password_expiration");
}
return;
@ -140,6 +145,9 @@ public class AccountSecurity extends Activity {
if (fm.findFragmentByTag("security_needed") == null) {
SecurityNeededDialog dialog =
SecurityNeededDialog.newInstance(mAccount.getDisplayName());
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "Showing security needed dialog");
}
dialog.show(fm, "security_needed");
}
} else {
@ -178,7 +186,7 @@ public class AccountSecurity extends Activity {
// Step 1. Check if we are an active device administrator, and stop here to activate
if (!security.isActiveAdmin()) {
if (mTriedAddAdministrator) {
if (MailActivityEmail.DEBUG) {
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "Not active admin: repost notification");
}
repostNotification(account, security);
@ -188,13 +196,13 @@ public class AccountSecurity extends Activity {
// retrieve name of server for the format string
HostAuth hostAuth = HostAuth.restoreHostAuthWithId(this, account.mHostAuthKeyRecv);
if (hostAuth == null) {
if (MailActivityEmail.DEBUG) {
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "No HostAuth: repost notification");
}
repostNotification(account, security);
finish();
} else {
if (MailActivityEmail.DEBUG) {
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "Not active admin: post initial notification");
}
// try to become active - must happen here in activity, to get result
@ -213,7 +221,7 @@ public class AccountSecurity extends Activity {
// Step 2. Check if the current aggregate security policy is being satisfied by the
// DevicePolicyManager (the current system security level).
if (security.isActive(null)) {
if (MailActivityEmail.DEBUG) {
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "Security active; clear holds");
}
Account.clearSecurityHoldOnAllAccounts(this);
@ -232,13 +240,13 @@ public class AccountSecurity extends Activity {
// Step 5. If password is needed, try to have the user set it
if ((inactiveReasons & SecurityPolicy.INACTIVE_NEED_PASSWORD) != 0) {
if (mTriedSetPassword) {
if (MailActivityEmail.DEBUG) {
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "Password needed; repost notification");
}
repostNotification(account, security);
finish();
} else {
if (MailActivityEmail.DEBUG) {
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "Password needed; request it via DPM");
}
mTriedSetPassword = true;
@ -252,13 +260,13 @@ public class AccountSecurity extends Activity {
// Step 6. If encryption is needed, try to have the user set it
if ((inactiveReasons & SecurityPolicy.INACTIVE_NEED_ENCRYPTION) != 0) {
if (mTriedSetEncryption) {
if (MailActivityEmail.DEBUG) {
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "Encryption needed; repost notification");
}
repostNotification(account, security);
finish();
} else {
if (MailActivityEmail.DEBUG) {
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "Encryption needed; request it via DPM");
}
mTriedSetEncryption = true;
@ -270,7 +278,7 @@ public class AccountSecurity extends Activity {
}
// Step 7. No problems were found, so clear holds and exit
if (MailActivityEmail.DEBUG) {
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "Policies enforced; clear holds");
}
Account.clearSecurityHoldOnAllAccounts(this);
@ -324,7 +332,7 @@ public class AccountSecurity extends Activity {
b.setMessage(res.getString(R.string.account_security_dialog_content_fmt, accountName));
b.setPositiveButton(R.string.okay_action, this);
b.setNegativeButton(R.string.cancel_action, this);
if (MailActivityEmail.DEBUG) {
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "Posting security needed dialog");
}
return b.create();
@ -341,13 +349,13 @@ public class AccountSecurity extends Activity {
}
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
if (MailActivityEmail.DEBUG) {
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "User accepts; advance to next step");
}
activity.tryAdvanceSecurity(activity.mAccount);
break;
case DialogInterface.BUTTON_NEGATIVE:
if (MailActivityEmail.DEBUG) {
if (MailActivityEmail.DEBUG || DEBUG) {
Log.d(TAG, "User declines; repost notification");
}
activity.repostNotification(