Merge "Disable Eas Authenticator if Exchange is not installed" into ub-mail-master
This commit is contained in:
commit
aaa26e8c3f
@ -32,6 +32,8 @@ import android.text.TextUtils;
|
||||
import com.android.email.NotificationController;
|
||||
import com.android.email.R;
|
||||
import com.android.email.activity.ComposeActivityEmail;
|
||||
import com.android.email.service.EasAuthenticatorService;
|
||||
import com.android.email.service.EasAuthenticatorServiceAlternate;
|
||||
import com.android.email.service.EmailServiceUtils;
|
||||
import com.android.email.service.EmailServiceUtils.EmailServiceInfo;
|
||||
import com.android.emailcommon.Logging;
|
||||
@ -154,7 +156,20 @@ public class AccountReconciler {
|
||||
boolean exchangeAccountDeleted = false;
|
||||
|
||||
LogUtils.d(Logging.LOG_TAG, "reconcileAccountsInternal");
|
||||
// See if we should have the Eas authenticators enabled.
|
||||
|
||||
if (!EmailServiceUtils.isServiceAvailable(context,
|
||||
context.getString(R.string.protocol_eas))) {
|
||||
LogUtils.d(Logging.LOG_TAG, "disabling eas authenticator");
|
||||
EmailServiceUtils.setComponentEnabled(context, EasAuthenticatorServiceAlternate.class,
|
||||
false);
|
||||
EmailServiceUtils.setComponentEnabled(context, EasAuthenticatorService.class, false);
|
||||
} else {
|
||||
LogUtils.d(Logging.LOG_TAG, "enabling eas authenticator");
|
||||
EmailServiceUtils.setComponentEnabled(context, EasAuthenticatorServiceAlternate.class,
|
||||
true);
|
||||
EmailServiceUtils.setComponentEnabled(context, EasAuthenticatorService.class, true);
|
||||
}
|
||||
// First, look through our EmailProvider accounts to make sure there's a corresponding
|
||||
// AccountManager account
|
||||
for (final Account providerAccount : emailProviderAccounts) {
|
||||
|
@ -316,8 +316,10 @@ public class EmailBroadcastProcessorService extends IntentService {
|
||||
LogUtils.i(Logging.LOG_TAG, "Onetime initialization: 1");
|
||||
progress = 1;
|
||||
if (VendorPolicyLoader.getInstance(this).useAlternateExchangeStrings()) {
|
||||
setComponentEnabled(EasAuthenticatorServiceAlternate.class, true);
|
||||
setComponentEnabled(EasAuthenticatorService.class, false);
|
||||
EmailServiceUtils.setComponentEnabled(this,
|
||||
EasAuthenticatorServiceAlternate.class, true);
|
||||
EmailServiceUtils.setComponentEnabled(this,
|
||||
EasAuthenticatorService.class, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,14 +369,6 @@ public class EmailBroadcastProcessorService extends IntentService {
|
||||
}
|
||||
}
|
||||
|
||||
private void setComponentEnabled(Class<?> clazz, boolean enabled) {
|
||||
final ComponentName c = new ComponentName(this, clazz.getName());
|
||||
getPackageManager().setComponentEnabledSetting(c,
|
||||
enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
|
||||
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
|
||||
private void onSystemAccountChanged() {
|
||||
LogUtils.i(Logging.LOG_TAG, "System accounts updated.");
|
||||
reconcileAndStartServices();
|
||||
|
@ -22,6 +22,7 @@ import android.accounts.AccountManagerFuture;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
@ -29,6 +30,7 @@ import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
@ -727,4 +729,13 @@ public class EmailServiceUtils {
|
||||
return EmailServiceVersion.CURRENT;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setComponentEnabled(final Context context, Class<?> clazz, boolean enabled) {
|
||||
final ComponentName c = new ComponentName(context, clazz.getName());
|
||||
context.getPackageManager().setComponentEnabledSetting(c,
|
||||
enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
|
||||
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user