2010-02-02 19:17:48 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 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.
|
|
|
|
*/
|
|
|
|
|
2011-06-27 19:12:41 +00:00
|
|
|
package com.android.email.service;
|
2010-02-02 19:17:48 +00:00
|
|
|
|
2010-08-20 16:53:46 +00:00
|
|
|
import android.app.Service;
|
2010-02-02 19:17:48 +00:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2010-02-02 23:06:52 +00:00
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.IBinder;
|
|
|
|
import android.os.RemoteException;
|
2010-02-02 19:17:48 +00:00
|
|
|
|
2011-06-27 19:12:41 +00:00
|
|
|
import com.android.emailcommon.Api;
|
|
|
|
import com.android.emailcommon.provider.HostAuth;
|
|
|
|
import com.android.emailcommon.service.EmailServiceProxy;
|
|
|
|
import com.android.emailcommon.service.IEmailService;
|
|
|
|
import com.android.emailcommon.service.IEmailServiceCallback;
|
|
|
|
import com.android.emailcommon.service.SearchParams;
|
|
|
|
|
2010-02-02 19:17:48 +00:00
|
|
|
/**
|
2011-06-27 19:12:41 +00:00
|
|
|
* Utility functions for EmailService support.
|
2010-02-02 19:17:48 +00:00
|
|
|
*/
|
2011-06-27 19:12:41 +00:00
|
|
|
public class EmailServiceUtils {
|
2010-02-02 19:17:48 +00:00
|
|
|
/**
|
2011-06-27 19:12:41 +00:00
|
|
|
* Starts an EmailService by name
|
2010-02-02 19:17:48 +00:00
|
|
|
*/
|
2011-06-27 19:12:41 +00:00
|
|
|
public static void startService(Context context, String intentAction) {
|
|
|
|
context.startService(new Intent(intentAction));
|
2010-02-02 19:17:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-06-27 19:12:41 +00:00
|
|
|
* Returns an {@link IEmailService} for the service; otherwise returns an empty
|
|
|
|
* {@link IEmailService} implementation.
|
2010-02-02 19:17:48 +00:00
|
|
|
*
|
|
|
|
* @param context
|
|
|
|
* @param callback Object to get callback, or can be null
|
|
|
|
*/
|
2011-06-27 19:12:41 +00:00
|
|
|
public static IEmailService getService(Context context, String intentAction,
|
2010-02-02 19:17:48 +00:00
|
|
|
IEmailServiceCallback callback) {
|
2011-06-27 19:12:41 +00:00
|
|
|
return new EmailServiceProxy(context, intentAction, callback);
|
2011-02-13 02:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-06-27 19:12:41 +00:00
|
|
|
* Determine if the EmailService is available
|
2011-02-13 02:56:09 +00:00
|
|
|
*/
|
2011-06-27 19:12:41 +00:00
|
|
|
public static boolean isServiceAvailable(Context context, String intentAction) {
|
|
|
|
return new EmailServiceProxy(context, intentAction, null).test();
|
2010-02-02 23:06:52 +00:00
|
|
|
}
|
|
|
|
|
2011-06-27 19:12:41 +00:00
|
|
|
public static void startExchangeService(Context context) {
|
|
|
|
startService(context, EmailServiceProxy.EXCHANGE_INTENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IEmailService getExchangeService(Context context,
|
|
|
|
IEmailServiceCallback callback) {
|
|
|
|
return getService(context, EmailServiceProxy.EXCHANGE_INTENT, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isExchangeAvailable(Context context) {
|
|
|
|
return isServiceAvailable(context, EmailServiceProxy.EXCHANGE_INTENT);
|
2010-02-24 19:51:59 +00:00
|
|
|
}
|
|
|
|
|
2010-02-02 23:06:52 +00:00
|
|
|
/**
|
|
|
|
* An empty {@link IEmailService} implementation which is used instead of
|
2010-08-27 18:31:37 +00:00
|
|
|
* {@link com.android.exchange.ExchangeService} on the build with no exchange support.
|
2010-02-02 23:06:52 +00:00
|
|
|
*
|
|
|
|
* <p>In theory, the service in question isn't used on the no-exchange-support build,
|
|
|
|
* because we won't have any exchange accounts in that case, so we wouldn't have to have this
|
|
|
|
* class. However, there are a few places we do use the service even if there's no exchange
|
|
|
|
* accounts (e.g. setLogging), so this class is added for safety and simplicity.
|
|
|
|
*/
|
2010-08-20 16:53:46 +00:00
|
|
|
public static class NullEmailService extends Service implements IEmailService {
|
2010-02-02 23:06:52 +00:00
|
|
|
public static final NullEmailService INSTANCE = new NullEmailService();
|
|
|
|
|
2011-02-13 02:56:09 +00:00
|
|
|
public int getApiLevel() {
|
|
|
|
return Api.LEVEL;
|
|
|
|
}
|
|
|
|
|
2010-02-02 23:06:52 +00:00
|
|
|
public Bundle autoDiscover(String userName, String password) throws RemoteException {
|
|
|
|
return Bundle.EMPTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean createFolder(long accountId, String name) throws RemoteException {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean deleteFolder(long accountId, String name) throws RemoteException {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void hostChanged(long accountId) throws RemoteException {
|
|
|
|
}
|
|
|
|
|
2011-02-14 22:39:27 +00:00
|
|
|
public void loadAttachment(long attachmentId, boolean background) throws RemoteException {
|
2010-02-02 23:06:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void loadMore(long messageId) throws RemoteException {
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean renameFolder(long accountId, String oldName, String newName)
|
|
|
|
throws RemoteException {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void sendMeetingResponse(long messageId, int response) throws RemoteException {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCallback(IEmailServiceCallback cb) throws RemoteException {
|
|
|
|
}
|
|
|
|
|
2011-03-31 20:29:23 +00:00
|
|
|
public void setLogging(int flags) throws RemoteException {
|
2010-02-02 23:06:52 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 03:00:20 +00:00
|
|
|
public void startSync(long mailboxId, boolean userRequest) throws RemoteException {
|
2010-02-02 23:06:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void stopSync(long mailboxId) throws RemoteException {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateFolderList(long accountId) throws RemoteException {
|
|
|
|
}
|
|
|
|
|
2011-06-14 01:48:05 +00:00
|
|
|
public Bundle validate(HostAuth hostAuth) throws RemoteException {
|
2010-06-02 20:25:03 +00:00
|
|
|
return null;
|
2010-02-02 23:06:52 +00:00
|
|
|
}
|
|
|
|
|
2010-11-16 19:01:20 +00:00
|
|
|
public void deleteAccountPIMData(long accountId) throws RemoteException {
|
|
|
|
}
|
|
|
|
|
2011-06-02 19:06:22 +00:00
|
|
|
public int searchMessages(long accountId, SearchParams searchParams, long destMailboxId) {
|
2011-03-31 20:29:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-02-02 23:06:52 +00:00
|
|
|
public IBinder asBinder() {
|
|
|
|
return null;
|
|
|
|
}
|
2010-08-20 16:53:46 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public IBinder onBind(Intent intent) {
|
|
|
|
return null;
|
|
|
|
}
|
2010-02-02 19:17:48 +00:00
|
|
|
}
|
|
|
|
}
|