Opportunistic cleanup

not making any real code changes:
* removed deprecated, unused methods
* remove 'throws' clauses when that exception is never thrown
* renamed method Controller#moveMessage()-->moveMessages()

Change-Id: Ifd006f760f0c19283e94a11a45c71295c8da35f7
This commit is contained in:
Todd Kennedy 2011-04-27 11:42:21 -07:00
parent f66058581c
commit e87ff6c3cb
17 changed files with 69 additions and 113 deletions

View File

@ -74,8 +74,7 @@ public abstract class Folder {
* @return True if further commands are not expected to have to open the
* connection.
*/
// TODO not used, get rid of this - it's a transport function
public abstract boolean isOpen();
public abstract boolean isOpenForTest();
/**
* Returns the mode the folder was opened with. This may be different than the mode the open

View File

@ -362,22 +362,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService {
return false;
}
/**
* Deprecated (or at least unused); moves are recognized by sync adapters as messages whose
* mailboxKey has changed
*
* @param messageId the id of the messge to be moved
* @param mailboxId the id of the destination mailbox
*/
@Deprecated
public void moveMessage(final long messageId, final long mailboxId) throws RemoteException {
setTask(new ProxyTask() {
public void run() throws RemoteException {
mService.moveMessage(messageId, mailboxId);
}
}, "moveMessage");
}
/**
* Request the service to delete the account's PIM (personal information management) data. This
* data includes any data that is 1) associated with the account and 2) created/stored by the

View File

@ -48,8 +48,6 @@ interface IEmailService {
oneway void sendMeetingResponse(long messageId, int response);
oneway void moveMessage(long messageId, long mailboxId);
// Must not be oneway; unless an exception is thrown, the caller is guaranteed that the action
// has been completed
void deleteAccountPIMData(long accountId);

View File

@ -35,6 +35,7 @@ import com.android.emailcommon.service.EmailServiceStatus;
import com.android.emailcommon.service.IEmailService;
import com.android.emailcommon.service.IEmailServiceCallback;
import com.android.emailcommon.utility.AttachmentUtilities;
import com.android.emailcommon.utility.EmailAsyncTask;
import com.android.emailcommon.utility.Utility;
import android.app.Service;
@ -778,24 +779,24 @@ public class Controller {
}
/**
* Moving messages to another folder
* Moves messages to a new mailbox.
*
* This function has no callback, no result reporting, because the desired outcome
* is reflected entirely by changes to one or more cursors.
*
* Note this method assumes all the messages, and the destination mailbox belong to the same
* Note this method assumes all of the given message and mailbox IDs belong to the same
* account.
*
* @param messageIds The IDs of the messages to move
* @param newMailboxId The id of the folder we're supposed to move the folder to
* @return the AsyncTask that will execute the move (for testing only)
* @param messageIds IDs of the messages that are to be moved
* @param newMailboxId ID of the new mailbox that the messages will be moved to
* @return an asynchronous task that executes the move (for testing only)
*/
public AsyncTask<Void, Void, Void> moveMessage(final long[] messageIds,
public EmailAsyncTask<Void, Void, Void> moveMessages(final long[] messageIds,
final long newMailboxId) {
if (messageIds == null || messageIds.length == 0) {
throw new InvalidParameterException();
}
return Utility.runAsync(new Runnable() {
return EmailAsyncTask.runAsyncParallel(new Runnable() {
public void run() {
Account account = Account.getAccountForMessageId(mProviderContext, messageIds[0]);
if (account != null) {
@ -1636,18 +1637,15 @@ public class Controller {
}
@Override
public void sendMessageStatus(long messageId, String subject, int statusCode, int progress)
throws RemoteException {
public void sendMessageStatus(long messageId, String subject, int statusCode, int progress){
}
@Override
public void syncMailboxListStatus(long accountId, int statusCode, int progress)
throws RemoteException {
public void syncMailboxListStatus(long accountId, int statusCode, int progress) {
}
@Override
public void syncMailboxStatus(long mailboxId, int statusCode, int progress)
throws RemoteException {
public void syncMailboxStatus(long mailboxId, int statusCode, int progress) {
}
};
@ -1659,18 +1657,18 @@ public class Controller {
private final IEmailService.Stub mBinder = new IEmailService.Stub() {
public Bundle validate(String protocol, String host, String userName, String password,
int port, boolean ssl, boolean trustCertificates) throws RemoteException {
int port, boolean ssl, boolean trustCertificates) {
return null;
}
public Bundle autoDiscover(String userName, String password) throws RemoteException {
public Bundle autoDiscover(String userName, String password) {
return null;
}
public void startSync(long mailboxId, boolean userRequest) throws RemoteException {
public void startSync(long mailboxId, boolean userRequest) {
}
public void stopSync(long mailboxId) throws RemoteException {
public void stopSync(long mailboxId) {
}
public void loadAttachment(long attachmentId, boolean background)
@ -1712,43 +1710,39 @@ public class Controller {
}
}
public void updateFolderList(long accountId) throws RemoteException {
public void updateFolderList(long accountId) {
}
public void hostChanged(long accountId) throws RemoteException {
public void hostChanged(long accountId) {
}
public void setLogging(int flags) throws RemoteException {
public void setLogging(int flags) {
}
public void sendMeetingResponse(long messageId, int response) throws RemoteException {
public void sendMeetingResponse(long messageId, int response) {
}
public void loadMore(long messageId) throws RemoteException {
public void loadMore(long messageId) {
}
// The following three methods are not implemented in this version
public boolean createFolder(long accountId, String name) throws RemoteException {
public boolean createFolder(long accountId, String name) {
return false;
}
public boolean deleteFolder(long accountId, String name) throws RemoteException {
public boolean deleteFolder(long accountId, String name) {
return false;
}
public boolean renameFolder(long accountId, String oldName, String newName)
throws RemoteException {
public boolean renameFolder(long accountId, String oldName, String newName) {
return false;
}
public void setCallback(IEmailServiceCallback cb) throws RemoteException {
public void setCallback(IEmailServiceCallback cb) {
sCallbackList.register(cb);
}
public void moveMessage(long messageId, long mailboxId) throws RemoteException {
}
public void deleteAccountPIMData(long accountId) throws RemoteException {
public void deleteAccountPIMData(long accountId) {
}
public int searchMessages(long accountId, long mailboxId, boolean includeSubfolders,
@ -1757,7 +1751,7 @@ public class Controller {
}
@Override
public int getApiLevel() throws RemoteException {
public int getApiLevel() {
return Api.LEVEL;
}
};

View File

@ -134,9 +134,6 @@ public class ExchangeUtils {
return null;
}
public void moveMessage(long messageId, long mailboxId) throws RemoteException {
}
public void deleteAccountPIMData(long accountId) throws RemoteException {
}

View File

@ -108,7 +108,7 @@ public final class ActivityHelper {
public static void moveMessages(final Context context, final long newMailboxId,
final long[] messageIds) {
Controller.getInstance(context).moveMessage(messageIds, newMailboxId);
Controller.getInstance(context).moveMessages(messageIds, newMailboxId);
EmailAsyncTask.runAsyncSerial(new Runnable() {
@Override
public void run() {

View File

@ -874,7 +874,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
}
}
} else {
controller.moveMessage(messageIds, targetItem.mMailboxId);
controller.moveMessages(messageIds, targetItem.mMailboxId);
}
}
});

View File

@ -17,7 +17,6 @@
package com.android.email.mail;
import com.android.email.Email;
import com.android.email.LegacyConversions;
import com.android.email.R;
import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.Folder;
@ -36,7 +35,6 @@ import android.text.TextUtils;
import android.util.Log;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
/**

View File

@ -24,7 +24,6 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.URI;
/**
* This interface defines a "transport", which is defined here as being one layer below the
@ -75,15 +74,6 @@ public interface Transport {
*/
public int getPort();
/**
* Returns the user info parts of the Uri, if any were supplied. Typically, [0] is the user
* and [1] is the password.
* @return Returns the user info parts of the Uri. Null if none were supplied.
* @deprecated do not use this method. user info parts should not be stored in the transport.
*/
@Deprecated
public String[] getUserInfoParts();
/**
* Set the desired security mode for this connection.
* @param connectionSecurity A value indicating the desired security mode.

View File

@ -87,7 +87,7 @@ class ImapFolder extends Folder {
public void open(OpenMode mode, PersistentDataCallbacks callbacks)
throws MessagingException {
try {
if (isOpen()) {
if (isOpenForTest()) {
if (mMode == mode) {
// Make sure the connection is valid.
// If it's not we'll close it down and continue on to get a new one.
@ -137,7 +137,7 @@ class ImapFolder extends Folder {
}
@Override
public boolean isOpen() {
public boolean isOpenForTest() {
return mExists && mConnection != null;
}
@ -1031,7 +1031,7 @@ class ImapFolder extends Folder {
}
private void checkOpen() throws MessagingException {
if (!isOpen()) {
if (!isOpenForTest()) {
throw new MessagingException("Folder " + mName + " is not open.");
}
}

View File

@ -19,7 +19,6 @@ package com.android.email.mail.store;
import com.android.email.Email;
import com.android.email.mail.Store;
import com.android.email.mail.Transport;
import com.android.email.mail.store.imap.ImapConstants;
import com.android.email.mail.transport.MailTransport;
import com.android.emailcommon.Logging;
import com.android.emailcommon.internet.MimeMessage;
@ -943,8 +942,7 @@ public class Pop3Store extends Store {
}
@Override
// TODO this is deprecated, eventually discard
public boolean isOpen() {
public boolean isOpenForTest() {
return mTransport.isOpen();
}

View File

@ -35,7 +35,6 @@ import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.URI;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
@ -98,12 +97,6 @@ public class MailTransport implements Transport {
return newObject;
}
@Override
@Deprecated
public String[] getUserInfoParts() {
return mUserInfoParts;
}
@Override
public void setHost(String host) {
mHost = host;

View File

@ -180,7 +180,8 @@ public class ControllerProviderOpsTests extends ProviderTestCase2<EmailProvider>
long message2Id = message2.mId;
// Because moveMessage runs asynchronously, call get() to force it to complete
mTestController.moveMessage(new long[] {message1Id, message2Id}, boxDestId).get();
mTestController.moveMessages(
new long[] { message1Id, message2Id }, boxDestId).waitForFinish();
// now read back a fresh copy and confirm it's in the trash
assertEquals(boxDestId, EmailContent.Message.restoreMessageWithId(mProviderContext,
@ -194,7 +195,7 @@ public class ControllerProviderOpsTests extends ProviderTestCase2<EmailProvider>
* - message/mailbox/account all exist
* - trash mailbox exists
*/
public void testDeleteMessage() throws InterruptedException, ExecutionException {
public void testDeleteMessage() {
Account account1 = ProviderTestUtils.setupAccount("message-delete", true, mProviderContext);
long account1Id = account1.mId;
Mailbox box = ProviderTestUtils.setupMailbox("box1", account1Id, true, mProviderContext);
@ -268,7 +269,7 @@ public class ControllerProviderOpsTests extends ProviderTestCase2<EmailProvider>
/**
* Test deleting message when there is no trash mailbox
*/
public void testDeleteMessageNoTrash() throws InterruptedException, ExecutionException {
public void testDeleteMessageNoTrash() {
Account account1 =
ProviderTestUtils.setupAccount("message-delete-notrash", true, mProviderContext);
long account1Id = account1.mId;

View File

@ -1450,9 +1450,9 @@ public class ImapStoreUnitTests extends InstrumentationTestCase {
assertEquals(1, folder.getMessageCount());
assertEquals(OpenMode.READ_WRITE, folder.getMode());
assertTrue(folder.isOpen());
assertTrue(folder.isOpenForTest());
folder.close(false);
assertFalse(folder.isOpen());
assertFalse(folder.isOpenForTest());
// READ-ONLY
expectNoop(mock, true); // Need it because we reuse the connection.

View File

@ -246,7 +246,7 @@ public class Pop3StoreUnitTests extends InstrumentationTestCase {
/**
* Test small Store & Folder functions that manage folders & namespace
*/
public void testStoreFoldersFunctions() throws MessagingException {
public void testStoreFoldersFunctions() {
// getPersonalNamespaces() always returns INBOX folder
Folder[] folders = mStore.updateFolders();
@ -326,7 +326,7 @@ public class Pop3StoreUnitTests extends InstrumentationTestCase {
/**
* Lightweight test to confirm that POP3 hasn't implemented any folder roles yet.
*/
public void testNoFolderRolesYet() throws MessagingException {
public void testNoFolderRolesYet() {
Folder[] remoteFolders = mStore.updateFolders();
for (Folder folder : remoteFolders) {
assertEquals(Folder.FolderRole.UNKNOWN, folder.getRole());
@ -426,7 +426,7 @@ public class Pop3StoreUnitTests extends InstrumentationTestCase {
// NOTE: everything from here down is copied from testOneUnread() and should be consolidated
// confirm that we're closed at this point
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpen());
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpenForTest());
// and confirm that the next connection will be OK
checkOneUnread(mockTransport);
@ -468,7 +468,7 @@ public class Pop3StoreUnitTests extends InstrumentationTestCase {
// NOTE: everything from here down is copied from testOneUnread() and should be consolidated
// confirm that we're closed at this point
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpen());
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpenForTest());
// and confirm that the next connection will be OK
checkOneUnread(mockTransport);
@ -511,7 +511,7 @@ public class Pop3StoreUnitTests extends InstrumentationTestCase {
// NOTE: everything from here down is copied from testOneUnread() and should be consolidated
// confirm that we're closed at this point
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpen());
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpenForTest());
// and confirm that the next connection will be OK
checkOneUnread(mockTransport);
@ -563,7 +563,7 @@ public class Pop3StoreUnitTests extends InstrumentationTestCase {
// NOTE: everything from here down is copied from testOneUnread() and should be consolidated
// confirm that we're closed at this point
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpen());
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpenForTest());
// and confirm that the next connection will be OK
checkOneUnread(mockTransport);
@ -610,7 +610,7 @@ public class Pop3StoreUnitTests extends InstrumentationTestCase {
// NOTE: everything from here down is copied from testOneUnread() and should be consolidated
// confirm that we're closed at this point
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpen());
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpenForTest());
// and confirm that the next connection will be OK
checkOneUnread(mockTransport);
@ -669,7 +669,7 @@ public class Pop3StoreUnitTests extends InstrumentationTestCase {
// NOTE: everything from here down is copied from testOneUnread() and should be consolidated
// confirm that we're closed at this point
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpen());
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpenForTest());
// and confirm that the next connection will be OK
checkOneUnread(mockTransport);
@ -716,7 +716,7 @@ public class Pop3StoreUnitTests extends InstrumentationTestCase {
// NOTE: everything from here down is copied from testOneUnread() and should be consolidated
// confirm that we're closed at this point
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpen());
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpenForTest());
// and confirm that the next connection will be OK
checkOneUnread(mockTransport);
@ -765,7 +765,7 @@ public class Pop3StoreUnitTests extends InstrumentationTestCase {
// test is, can we recover? So I'll try a new connection, without the failure.
// confirm that we're closed at this point
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpen());
assertFalse("folder should be 'closed' after an IOError", mFolder.isOpenForTest());
// and confirm that the next connection will be OK
checkOneUnread(mockTransport);

View File

@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.regex.Pattern;
@ -163,14 +162,17 @@ public class MockTransport implements Transport {
}
}
@Override
public boolean canTrySslSecurity() {
return (mConnectionSecurity == CONNECTION_SECURITY_SSL);
}
@Override
public boolean canTryTlsSecurity() {
return (mConnectionSecurity == Transport.CONNECTION_SECURITY_TLS);
}
@Override
public boolean canTrustAllCertificates() {
return mTrustCertificates;
}
@ -209,6 +211,7 @@ public class MockTransport implements Transport {
mHost = host;
}
@Override
public String getHost() {
return mHost;
}
@ -217,6 +220,7 @@ public class MockTransport implements Transport {
mLocalAddress = address;
}
@Override
public InputStream getInputStream() {
SmtpSenderUnitTests.assertTrue(mOpen);
return new MockInputStream();
@ -227,10 +231,12 @@ public class MockTransport implements Transport {
* until we need something more complex, we'll just return the actual MockTransport. Then we
* don't have to worry about dealing with test metadata like the expects list or socket state.
*/
@Override
public Transport newInstanceWithConfiguration() {
return this;
}
@Override
public OutputStream getOutputStream() {
Assert.assertTrue(mOpen);
return new MockOutputStream();
@ -241,25 +247,23 @@ public class MockTransport implements Transport {
SmtpSenderUnitTests.fail("setPort() not implemented");
}
@Override
public int getPort() {
SmtpSenderUnitTests.fail("getPort() not implemented");
return 0;
}
@Override
public int getSecurity() {
return mConnectionSecurity;
}
@Deprecated
public String[] getUserInfoParts() {
SmtpSenderUnitTests.fail("getUserInfoParts() not implemented");
return null;
}
@Override
public boolean isOpen() {
return mOpen;
}
@Override
public void open() /* throws MessagingException, CertificateValidationException */ {
mOpen = true;
mInputOpen = true;
@ -275,6 +279,7 @@ public class MockTransport implements Transport {
*
* Logs the read text if DEBUG_LOG_STREAMS is true.
*/
@Override
public String readLine() throws IOException {
SmtpSenderUnitTests.assertTrue(mOpen);
if (!mInputOpen) {
@ -303,6 +308,7 @@ public class MockTransport implements Transport {
return line;
}
@Override
public void reopenTls() /* throws MessagingException */ {
SmtpSenderUnitTests.assertTrue(mOpen);
Transaction expect = mPairs.remove(0);
@ -310,6 +316,7 @@ public class MockTransport implements Transport {
mTlsStarted = true;
}
@Override
public void setSecurity(int connectionSecurity, boolean trustAllCertificates) {
mConnectionSecurity = connectionSecurity;
mTrustCertificates = trustAllCertificates;
@ -318,11 +325,6 @@ public class MockTransport implements Transport {
public void setSoTimeout(int timeoutMilliseconds) /* throws SocketException */ {
}
@Deprecated
public void setUri(URI uri, int defaultPort) {
SmtpSenderUnitTests.assertTrue("Don't call setUri on a mock transport", false);
}
/**
* Accepts a single string (command or text) that was written by the code under test.
* Because we are essentially mocking a server, we check to see if this string was expected.
@ -332,6 +334,7 @@ public class MockTransport implements Transport {
*
* Logs the written text if DEBUG_LOG_STREAMS is true.
*/
@Override
public void writeLine(String s, String sensitiveReplacement) throws IOException {
if (DEBUG_LOG_STREAMS) {
Log.d(LOG_TAG, ">>> " + s);
@ -356,8 +359,8 @@ public class MockTransport implements Transport {
*/
private class MockInputStream extends InputStream {
byte[] mNextLine = null;
int mNextIndex = 0;
private byte[] mNextLine = null;
private int mNextIndex = 0;
/**
* Reads from the same input buffer as readLine()
@ -394,7 +397,7 @@ public class MockTransport implements Transport {
*/
private class MockOutputStream extends OutputStream {
StringBuilder sb = new StringBuilder();
private StringBuilder sb = new StringBuilder();
@Override
public void write(int oneByte) throws IOException {
@ -410,6 +413,7 @@ public class MockTransport implements Transport {
}
}
@Override
public InetAddress getLocalAddress() {
if (isOpen()) {
return mLocalAddress;

View File

@ -110,7 +110,7 @@ public class MockFolder extends Folder {
}
@Override
public boolean isOpen() {
public boolean isOpenForTest() {
return false;
}