Auto-advance policy accept by triggering syncs.
Exchange goes through multiple steps to set up accounts. Each step requires a sync request to occur, so this change requests syncs as necessary. Bug: 9074056 Change-Id: I0f35a06409c6a77c82d004958ecc323cf8030ab4
This commit is contained in:
parent
b30058ef88
commit
bd1e0b79e4
|
@ -29,11 +29,13 @@ import android.content.Intent;
|
|||
import android.content.OperationApplicationException;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.email.provider.EmailProvider;
|
||||
import com.android.email.service.EmailBroadcastProcessorService;
|
||||
import com.android.email.service.EmailServiceUtils;
|
||||
import com.android.email2.ui.MailActivityEmail;
|
||||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
|
@ -557,6 +559,7 @@ public class SecurityPolicy {
|
|||
try {
|
||||
context.getContentResolver().applyBatch(EmailContent.AUTHORITY, ops);
|
||||
account.refresh(context);
|
||||
syncAccount(context, account);
|
||||
} catch (RemoteException e) {
|
||||
// This is fatal to a remote process
|
||||
throw new IllegalStateException("Exception setting account policy.");
|
||||
|
@ -565,6 +568,22 @@ public class SecurityPolicy {
|
|||
}
|
||||
}
|
||||
|
||||
private static void syncAccount(final Context context, final Account account) {
|
||||
final EmailServiceUtils.EmailServiceInfo info =
|
||||
EmailServiceUtils.getServiceInfo(context, account.getProtocol(context));
|
||||
final android.accounts.Account amAccount =
|
||||
new android.accounts.Account(account.mEmailAddress, info.accountType);
|
||||
final Bundle extras = new Bundle(3);
|
||||
extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
|
||||
extras.putBoolean(ContentResolver.SYNC_EXTRAS_DO_NOT_RETRY, true);
|
||||
extras.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
|
||||
ContentResolver.requestSync(amAccount, EmailContent.AUTHORITY, extras);
|
||||
}
|
||||
|
||||
public void syncAccount(final Account account) {
|
||||
syncAccount(mContext, account);
|
||||
}
|
||||
|
||||
public void setAccountPolicy(long accountId, Policy policy, String securityKey) {
|
||||
Account account = Account.restoreAccountWithId(mContext, accountId);
|
||||
Policy oldPolicy = null;
|
||||
|
|
|
@ -225,6 +225,7 @@ public class AccountSecurity extends Activity {
|
|||
Log.d(TAG, "Security active; clear holds");
|
||||
}
|
||||
Account.clearSecurityHoldOnAllAccounts(this);
|
||||
security.syncAccount(account);
|
||||
security.clearNotification();
|
||||
finish();
|
||||
return;
|
||||
|
@ -282,6 +283,7 @@ public class AccountSecurity extends Activity {
|
|||
Log.d(TAG, "Policies enforced; clear holds");
|
||||
}
|
||||
Account.clearSecurityHoldOnAllAccounts(this);
|
||||
security.syncAccount(account);
|
||||
security.clearNotification();
|
||||
finish();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue