Make sure account capabilities get set properly in UIProvider
* Change getCapabilities API to take an account, rather than the id of the account * getCapabilities() can therefore execute even before Exchange is fully up and running Change-Id: Id4c2a9942ea7a21e0c56401c50206b680274b43e
This commit is contained in:
parent
64a1fadf38
commit
0b5f15d61e
|
@ -0,0 +1,18 @@
|
|||
/* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.emailcommon.provider;
|
||||
|
||||
parcelable Account;
|
|
@ -27,6 +27,7 @@ import com.android.emailcommon.Api;
|
|||
import com.android.emailcommon.Device;
|
||||
import com.android.emailcommon.TempDirectory;
|
||||
import com.android.emailcommon.mail.MessagingException;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Policy;
|
||||
|
||||
|
@ -459,12 +460,12 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getCapabilities(final long accountId) throws RemoteException {
|
||||
public int getCapabilities(final Account acct) throws RemoteException {
|
||||
setTask(new ProxyTask() {
|
||||
@Override
|
||||
public void run() throws RemoteException{
|
||||
if (mCallback != null) mService.setCallback(mCallback);
|
||||
mReturn = mService.getCapabilities(accountId);
|
||||
mReturn = mService.getCapabilities(acct);
|
||||
}
|
||||
}, "getCapabilities");
|
||||
waitForCompletion();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package com.android.emailcommon.service;
|
||||
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.service.IEmailServiceCallback;
|
||||
import com.android.emailcommon.service.SearchParams;
|
||||
import android.os.Bundle;
|
||||
|
@ -61,5 +62,5 @@ interface IEmailService {
|
|||
void sendMail(long accountId);
|
||||
|
||||
// API level 3
|
||||
int getCapabilities(long accountId);
|
||||
int getCapabilities(in Account acct);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,8 @@ public abstract class ServiceProxy {
|
|||
public void onServiceConnected(ComponentName name, IBinder binder) {
|
||||
onConnected(binder);
|
||||
if (DEBUG_PROXY) {
|
||||
Log.v(mTag, "Connected: " + name.getShortClassName());
|
||||
Log.v(mTag, "Connected: " + name.getShortClassName() + " at " +
|
||||
(System.currentTimeMillis() - mStartTime) + "ms");
|
||||
}
|
||||
// Run our task on a new thread
|
||||
new Thread(new Runnable() {
|
||||
|
@ -86,7 +87,8 @@ public abstract class ServiceProxy {
|
|||
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
if (DEBUG_PROXY) {
|
||||
Log.v(mTag, "Disconnected: " + name.getShortClassName());
|
||||
Log.v(mTag, "Disconnected: " + name.getShortClassName() + " at " +
|
||||
(System.currentTimeMillis() - mStartTime) + "ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,8 +171,9 @@ public abstract class ServiceProxy {
|
|||
// Can be ignored safely
|
||||
}
|
||||
if (DEBUG_PROXY) {
|
||||
Log.v(mTag, "Wait for " + mName + " finished in " +
|
||||
Log.v(mTag, "Wait for " + mName + (mDead ? " finished in " : " timed out in ") +
|
||||
(System.currentTimeMillis() - time) + "ms");
|
||||
mDead = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,24 +16,23 @@
|
|||
|
||||
package com.android.imap2;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteCallbackList;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteCallbackList;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import com.android.emailcommon.Api;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Attachment;
|
||||
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.android.emailcommon.provider.ProviderUnavailableException;
|
||||
|
@ -194,7 +193,7 @@ public class Imap2SyncManager extends SyncManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getCapabilities(long accountId) throws RemoteException {
|
||||
public int getCapabilities(Account acct) throws RemoteException {
|
||||
return AccountCapabilities.SYNCABLE_FOLDERS |
|
||||
//AccountCapabilities.FOLDER_SERVER_SEARCH |
|
||||
AccountCapabilities.UNDO;
|
||||
|
|
|
@ -2665,6 +2665,21 @@ outer:
|
|||
.appendQueryParameter("account", account).build().toString();
|
||||
}
|
||||
|
||||
private int getCapabilities(Context context, long accountId) {
|
||||
EmailServiceProxy service = EmailServiceUtils.getServiceForAccount(context,
|
||||
mServiceCallback, accountId);
|
||||
int capabilities = 0;
|
||||
try {
|
||||
service.setTimeout(10);
|
||||
Account acct = Account.restoreAccountWithId(context, accountId);
|
||||
if (acct == null) return 0;
|
||||
capabilities = service.getCapabilities(acct);
|
||||
} catch (RemoteException e) {
|
||||
// Nothing to do
|
||||
}
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a "single account" SQLite query, given a projection from UnifiedEmail
|
||||
*
|
||||
|
@ -2674,19 +2689,13 @@ outer:
|
|||
private String genQueryAccount(String[] uiProjection, String id) {
|
||||
final ContentValues values = new ContentValues();
|
||||
final long accountId = Long.parseLong(id);
|
||||
final Context context = getContext();
|
||||
|
||||
final Set<String> projectionColumns = ImmutableSet.copyOf(uiProjection);
|
||||
|
||||
if (projectionColumns.contains(UIProvider.AccountColumns.CAPABILITIES)) {
|
||||
// Get account capabilities from the service
|
||||
EmailServiceProxy service = EmailServiceUtils.getServiceForAccount(getContext(),
|
||||
mServiceCallback, accountId);
|
||||
int capabilities = 0;
|
||||
try {
|
||||
capabilities = service.getCapabilities(accountId);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
values.put(UIProvider.AccountColumns.CAPABILITIES, capabilities);
|
||||
values.put(UIProvider.AccountColumns.CAPABILITIES, getCapabilities(context, accountId));
|
||||
}
|
||||
if (projectionColumns.contains(UIProvider.AccountColumns.SETTINGS_INTENT_URI)) {
|
||||
values.put(UIProvider.AccountColumns.SETTINGS_INTENT_URI,
|
||||
|
@ -2729,7 +2738,6 @@ outer:
|
|||
textZoomToUiValue(textZoom));
|
||||
}
|
||||
// Set default inbox, if we've got an inbox; otherwise, say initial sync needed
|
||||
final Context context = getContext();
|
||||
long mailboxId = Mailbox.findMailboxOfType(context, accountId, Mailbox.TYPE_INBOX);
|
||||
if (projectionColumns.contains(UIProvider.AccountColumns.SettingsColumns.DEFAULT_INBOX) &&
|
||||
mailboxId != Mailbox.NO_MAILBOX) {
|
||||
|
|
|
@ -372,7 +372,7 @@ public class EmailServiceUtils {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getCapabilities(long accountId) throws RemoteException {
|
||||
public int getCapabilities(Account acct) throws RemoteException {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ public class ImapService extends Service {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getCapabilities(long accountId) throws RemoteException {
|
||||
public int getCapabilities(Account acct) throws RemoteException {
|
||||
return AccountCapabilities.SYNCABLE_FOLDERS |
|
||||
AccountCapabilities.FOLDER_SERVER_SEARCH |
|
||||
AccountCapabilities.UNDO;
|
||||
|
|
|
@ -184,7 +184,7 @@ public class Pop3Service extends Service {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getCapabilities(long accountId) throws RemoteException {
|
||||
public int getCapabilities(Account acct) throws RemoteException {
|
||||
return AccountCapabilities.UNDO;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue