prevent crash

pull/201/head
M66B 4 years ago
parent 18cd0d9788
commit 2b259a6a85

@ -19,6 +19,9 @@ package eu.faircode.email;
Copyright 2018-2021 by Marcel Bokhorst (M66B) Copyright 2018-2021 by Marcel Bokhorst (M66B)
*/ */
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_GMAIL;
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_OAUTH;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
@ -93,9 +96,6 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_GMAIL;
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_OAUTH;
// IMAP standards: https://imapwiki.org/Specs // IMAP standards: https://imapwiki.org/Specs
public class EmailService implements AutoCloseable { public class EmailService implements AutoCloseable {
@ -313,7 +313,7 @@ public class EmailService implements AutoCloseable {
account.user, account.password, account.user, account.password,
new ServiceAuthenticator.IAuthenticated() { new ServiceAuthenticator.IAuthenticated() {
@Override @Override
public void onPasswordChanged(String newPassword) { public void onPasswordChanged(Context context, String newPassword) {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
int accounts = db.account().setAccountPassword(account.id, newPassword); int accounts = db.account().setAccountPassword(account.id, newPassword);
int identities = db.identity().setIdentityPassword(account.id, account.user, newPassword, account.auth_type); int identities = db.identity().setIdentityPassword(account.id, account.user, newPassword, account.auth_type);
@ -330,7 +330,7 @@ public class EmailService implements AutoCloseable {
identity.user, identity.password, identity.user, identity.password,
new ServiceAuthenticator.IAuthenticated() { new ServiceAuthenticator.IAuthenticated() {
@Override @Override
public void onPasswordChanged(String newPassword) { public void onPasswordChanged(Context context, String newPassword) {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
int count = db.identity().setIdentityPassword(identity.id, newPassword); int count = db.identity().setIdentityPassword(identity.id, newPassword);
EntityLog.log(context, identity.email + " token refreshed=" + count); EntityLog.log(context, identity.email + " token refreshed=" + count);

@ -19,6 +19,8 @@ package eu.faircode.email;
Copyright 2018-2021 by Marcel Bokhorst (M66B) Copyright 2018-2021 by Marcel Bokhorst (M66B)
*/ */
import static eu.faircode.email.GmailState.TYPE_GOOGLE;
import android.accounts.AuthenticatorException; import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException; import android.accounts.OperationCanceledException;
import android.content.Context; import android.content.Context;
@ -41,8 +43,6 @@ import javax.mail.Authenticator;
import javax.mail.MessagingException; import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication; import javax.mail.PasswordAuthentication;
import static eu.faircode.email.GmailState.TYPE_GOOGLE;
public class ServiceAuthenticator extends Authenticator { public class ServiceAuthenticator extends Authenticator {
private Context context; private Context context;
private int auth; private int auth;
@ -98,7 +98,7 @@ public class ServiceAuthenticator extends Authenticator {
if (!Objects.equals(password, newPassword)) { if (!Objects.equals(password, newPassword)) {
password = newPassword; password = newPassword;
if (intf != null) if (intf != null)
intf.onPasswordChanged(password); intf.onPasswordChanged(context, password);
} }
return authState.getAccessToken(); return authState.getAccessToken();
@ -113,7 +113,7 @@ public class ServiceAuthenticator extends Authenticator {
if (!Objects.equals(password, newPassword)) { if (!Objects.equals(password, newPassword)) {
password = newPassword; password = newPassword;
if (intf != null) if (intf != null)
intf.onPasswordChanged(password); intf.onPasswordChanged(context, password);
} }
return authState.getAccessToken(); return authState.getAccessToken();
@ -122,7 +122,7 @@ public class ServiceAuthenticator extends Authenticator {
} }
interface IAuthenticated { interface IAuthenticated {
void onPasswordChanged(String newPassword); void onPasswordChanged(Context context, String newPassword);
} }
private static void OAuthRefresh(Context context, String id, AuthState authState, boolean expire, long keep_alive) private static void OAuthRefresh(Context context, String id, AuthState authState, boolean expire, long keep_alive)

Loading…
Cancel
Save