Buggy code:
private static final short CONNECTION_SECURITY_TLS_REQUIRED = 2 ; private static final short CONNECTION_SECURITY_SSL_OPTIONAL = 3 ; private static final short CONNECTION_SECURITY_SSL_REQUIRED = 4 ; private static final Flag [ ] PERMANENT_FLAGS = new Flag [ ] { Flag . DELETED , Flag . SEEN , Flag . ANSWERED } ; private static final Message [ ] EMPTY_MESSAGE_ARRAY = new Message [ 0 ] ; private static final String INITIAL_SYNC_KEY = "0" ; private static final String PING_COMMAND = "Ping" ; private static final String PROVISION_COMMAND = "Provision" ; private static final int COMMAND_TIMEOUT = 30 * 1000 ; private static final int CONNECTION_TIMEOUT = 20 * 1000 ; private static final int SEND_MAIL_TIMEOUT = ( 15 * 60 ) * 1000 ; private static final int HTTP_NEED_PROVISIONING = 449 ; private static final String PROVISION_STATUS_OK = "1" ; private static final String PROVISION_STATUS_PARTIAL = "2" ; public static final String EAS_12_POLICY_TYPE = "MS-EAS-Provisioning-WBXML" ; public static final String EAS_2_POLICY_TYPE = "MS-WAP-Provisioning-XML" ; private static final int IDLE_READ_TIMEOUT_INCREMENT = ( 5 * 60 ) * 1000 ; private static final int IDLE_FAILURE_COUNT_LIMIT = 10 ; private static final int MAX_DELAY_TIME = ( 5 * 60 ) * 1000 ; private static final int NORMAL_DELAY_TIME = 5000 ; private static final int EMAIL_WINDOW_SIZE = 10 ; private static final int MAX_DEVICE_ID_SIZE = 32 ; public static ServerSettings decodeUri ( String uri ) { } public static String createUri ( ServerSettings server ) { } private String mProtocolVersion = null ; private Double mProtocolVersionDouble = null ; private String mDeviceId = null ; private Object mInitializationLock = new Object ( ) ; private final String mDeviceType = "K9Mail" ; private String mHost ; private int mPort ; private String mUsername ; private String mPassword ; private short mConnectionSecurity ; private boolean mSecure ; private HttpClient mHttpClient = null ; private String mAuthString = null ; private String mCmdString = null ; private HashMap < String , EasStore . EasFolder > mFolderList = new HashMap < String , EasStore . EasFolder > ( ) ; public EasStore ( Account account ) throws MessagingException { } public String getStoreSyncKey ( ) { } public void setStoreSyncKey ( String syncKey ) { } @ Override public void checkSettings ( ) throws MessagingException { } public void validateAccount ( ) throws MessagingException { } private String getPolicyType ( ) { } private ProvisionParser canProvision ( ) throws MessagingException , IOException { } private String acknowledgeProvision ( String tempKey , String result ) throws MessagingException , IOException { } private String acknowledgeProvisionImpl ( String tempKey , String status , boolean remoteWipe ) throws MessagingException , IOException { } protected boolean isAuthError ( int code ) { } protected boolean isProvisionError ( int code ) { } private static void setupProtocolVersion ( EasStore service , Header versionHeader ) throws MessagingException { } private Double getProtocolVersionDouble ( ) { } protected HttpResponse sendHttpClientPost ( String cmd , byte [ ] bytes ) throws MessagingException , IOException { } protected HttpResponse executePostWithTimeout ( HttpClient client , HttpPost method , int timeout , boolean noProvision ) throws IOException { } protected HttpResponse sendHttpClientPost ( String cmd , HttpEntity entity , int timeout ) throws MessagingException , IOException { } protected HttpResponse sendHttpClientOptions ( ) throws MessagingException , IOException { } private void setHeaders ( HttpRequestBase method , boolean usePolicyKey ) { } private String makeUriString ( String cmd , String extra ) throws IOException { } private void cacheAuthAndCmdString ( ) { } @ Override public List < ? extends Folder > getPersonalNamespaces ( boolean forceListAll ) throws MessagingException { } private void init ( ) throws MessagingException , IOException { } private List < ? extends Folder > getInitialFolderList ( ) throws MessagingException { } private boolean tryProvision ( ) throws MessagingException , IOException { ProvisionParser pp = canProvision ( ) ; if ( pp != null ) { String policyKey = acknowledgeProvision ( pp . getPolicyKey ( ) , EasStore . PROVISION_STATUS_OK ) ; mAccount . setSecurityKey ( policyKey ) ; <START_BUG> mAccount . saveSyncKey ( Preferences . getPreferences ( app . getApplicationContext ( ) ) ) ; <END_BUG> return true ; } else { return false ; } } private void syncFoldersFromLocalStore ( ) { } @ Override public Folder getFolder ( String serverId ) { } @ Override public boolean isMoveCapable ( ) { } @ Override public boolean isCopyCapable ( ) { } @ Override public boolean isSendCapable ( ) { } @ Override public boolean keepPushStateInSync ( ) { } @ Override public void sendMessages ( Message [ ] messages ) throws MessagingException { } private void setupHttpClient ( ) throws MessagingException { } private void reclaimConnection ( HttpResponse response ) throws IOException { } public class EasFolder extends Folder { private String mName ; private String mServerId ; private int mType ; private boolean mIsOpen = false ; private String mSyncKey = null ; protected EasStore getStore ( ) { } public EasFolder ( String name , String serverId , int type ) { } public String getSyncKey ( ) throws MessagingException { } public void setSyncKey ( String key ) throws MessagingException { } @ Override public boolean isSyncMode ( ) { } @ Override public void open ( OpenMode mode ) throws MessagingException { } @ Override public void copyMessages ( Message [ ] messages , Folder folder ) throws MessagingException { } @ Override public void moveMessages ( Message [ ] messages , Folder folder ) throws MessagingException { } @ Override public void delete ( Message [ ] msgs , String trashFolderName ) throws MessagingException { } private void moveOrCopyMessages ( Message [ ] messages , String folderName , boolean isMove ) throws MessagingException { } @ Override public int getMessageCount ( ) throws MessagingException { } @ Override public int getUnreadMessageCount ( ) throws MessagingException { } @ Override public int getFlaggedMessageCount ( ) throws MessagingException { } @ Override public boolean isOpen ( ) { }

Fix:
mAccount . saveSecurityKey ( Preferences . getPreferences ( app . getApplicationContext ( ) ) ) ;