diff options
Diffstat (limited to 'java/com/android/voicemail/impl/mail')
31 files changed, 600 insertions, 601 deletions
diff --git a/java/com/android/voicemail/impl/mail/Address.java b/java/com/android/voicemail/impl/mail/Address.java index ac8e8a294..7556e4d39 100644 --- a/java/com/android/voicemail/impl/mail/Address.java +++ b/java/com/android/voicemail/impl/mail/Address.java @@ -39,19 +39,19 @@ import org.apache.james.mime4j.codec.EncoderUtil; public class Address implements Parcelable { public static final String ADDRESS_DELIMETER = ","; /** Address part, in the form local_part@domain_part. No surrounding angle brackets. */ - private String mAddress; + private String address; /** * Name part. No surrounding double quote, and no MIME/base64 encoding. This must be null if * Address has no name part. */ - private String mPersonal; + private String personal; /** * When personal is set, it will return the first token of the personal string. Otherwise, it will * return the e-mail address up to the '@' sign. */ - private String mSimplifiedName; + private String simplifiedName; // Regex that matches address surrounded by '<>' optionally. '^<?([^>]+)>?$' private static final Pattern REMOVE_OPTIONAL_BRACKET = Pattern.compile("^<?([^>]+)>?$"); @@ -96,26 +96,26 @@ public class Address implements Parcelable { * first token of that name. Otherwise, it will return the e-mail address up to the '@' sign. */ public String getSimplifiedName() { - if (mSimplifiedName == null) { - if (TextUtils.isEmpty(mPersonal) && !TextUtils.isEmpty(mAddress)) { - int atSign = mAddress.indexOf('@'); - mSimplifiedName = (atSign != -1) ? mAddress.substring(0, atSign) : ""; - } else if (!TextUtils.isEmpty(mPersonal)) { + if (simplifiedName == null) { + if (TextUtils.isEmpty(personal) && !TextUtils.isEmpty(address)) { + int atSign = address.indexOf('@'); + simplifiedName = (atSign != -1) ? address.substring(0, atSign) : ""; + } else if (!TextUtils.isEmpty(personal)) { // TODO: use Contacts' NameSplitter for more reliable first-name extraction - int end = mPersonal.indexOf(' '); - while (end > 0 && mPersonal.charAt(end - 1) == ',') { + int end = personal.indexOf(' '); + while (end > 0 && personal.charAt(end - 1) == ',') { end--; } - mSimplifiedName = (end < 1) ? mPersonal : mPersonal.substring(0, end); + simplifiedName = (end < 1) ? personal : personal.substring(0, end); } else { LogUtils.w(LOG_TAG, "Unable to get a simplified name"); - mSimplifiedName = ""; + simplifiedName = ""; } } - return mSimplifiedName; + return simplifiedName; } public static synchronized Address getEmailAddress(String rawAddress) { @@ -137,11 +137,11 @@ public class Address implements Parcelable { } public String getAddress() { - return mAddress; + return address; } public void setAddress(String address) { - mAddress = REMOVE_OPTIONAL_BRACKET.matcher(address).replaceAll("$1"); + this.address = REMOVE_OPTIONAL_BRACKET.matcher(address).replaceAll("$1"); } /** @@ -150,7 +150,7 @@ public class Address implements Parcelable { * @return Name part of email address. Returns null if it is omitted. */ public String getPersonal() { - return mPersonal; + return personal; } /** @@ -160,7 +160,7 @@ public class Address implements Parcelable { * @param personal name part of email address as UTF-16 string. Null is acceptable. */ public void setPersonal(String personal) { - mPersonal = decodeAddressPersonal(personal); + this.personal = decodeAddressPersonal(personal); } /** @@ -265,14 +265,14 @@ public class Address implements Parcelable { */ @Override public String toString() { - if (mPersonal != null && !mPersonal.equals(mAddress)) { - if (mPersonal.matches(".*[\\(\\)<>@,;:\\\\\".\\[\\]].*")) { - return ensureQuotedString(mPersonal) + " <" + mAddress + ">"; + if (personal != null && !personal.equals(address)) { + if (personal.matches(".*[\\(\\)<>@,;:\\\\\".\\[\\]].*")) { + return ensureQuotedString(personal) + " <" + address + ">"; } else { - return mPersonal + " <" + mAddress + ">"; + return personal + " <" + address + ">"; } } else { - return mAddress; + return address; } } @@ -336,10 +336,10 @@ public class Address implements Parcelable { * and MIME/base64 encoded if necessary. */ public String toHeader() { - if (mPersonal != null) { - return EncoderUtil.encodeAddressDisplayName(mPersonal) + " <" + mAddress + ">"; + if (personal != null) { + return EncoderUtil.encodeAddressDisplayName(personal) + " <" + address + ">"; } else { - return mAddress; + return address; } } @@ -374,10 +374,10 @@ public class Address implements Parcelable { */ @VisibleForTesting public String toFriendly() { - if (mPersonal != null && mPersonal.length() > 0) { - return mPersonal; + if (personal != null && personal.length() > 0) { + return personal; } else { - return mAddress; + return address; } } @@ -516,7 +516,7 @@ public class Address implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { - out.writeString(mPersonal); - out.writeString(mAddress); + out.writeString(personal); + out.writeString(address); } } diff --git a/java/com/android/voicemail/impl/mail/Base64Body.java b/java/com/android/voicemail/impl/mail/Base64Body.java index def94dbb5..5c14296af 100644 --- a/java/com/android/voicemail/impl/mail/Base64Body.java +++ b/java/com/android/voicemail/impl/mail/Base64Body.java @@ -23,17 +23,17 @@ import java.io.OutputStream; import org.apache.commons.io.IOUtils; public class Base64Body implements Body { - private final InputStream mSource; + private final InputStream source; // Because we consume the input stream, we can only write out once - private boolean mAlreadyWritten; + private boolean alreadyWritten; public Base64Body(InputStream source) { - mSource = source; + this.source = source; } @Override public InputStream getInputStream() throws MessagingException { - return mSource; + return source; } /** @@ -47,15 +47,15 @@ public class Base64Body implements Body { @Override public void writeTo(OutputStream out) throws IllegalStateException, IOException, MessagingException { - if (mAlreadyWritten) { + if (alreadyWritten) { throw new IllegalStateException("Base64Body can only be written once"); } - mAlreadyWritten = true; + alreadyWritten = true; try { final Base64OutputStream b64out = new Base64OutputStream(out, Base64.DEFAULT); - IOUtils.copyLarge(mSource, b64out); + IOUtils.copyLarge(source, b64out); } finally { - mSource.close(); + source.close(); } } } diff --git a/java/com/android/voicemail/impl/mail/BodyPart.java b/java/com/android/voicemail/impl/mail/BodyPart.java index 3d15d4bad..669b08804 100644 --- a/java/com/android/voicemail/impl/mail/BodyPart.java +++ b/java/com/android/voicemail/impl/mail/BodyPart.java @@ -16,9 +16,9 @@ package com.android.voicemail.impl.mail; public abstract class BodyPart implements Part { - protected Multipart mParent; + protected Multipart parent; public Multipart getParent() { - return mParent; + return parent; } } diff --git a/java/com/android/voicemail/impl/mail/FixedLengthInputStream.java b/java/com/android/voicemail/impl/mail/FixedLengthInputStream.java index bd3c16401..473281e09 100644 --- a/java/com/android/voicemail/impl/mail/FixedLengthInputStream.java +++ b/java/com/android/voicemail/impl/mail/FixedLengthInputStream.java @@ -24,25 +24,25 @@ import java.io.InputStream; * where the protocol handler intended the client to read. */ public class FixedLengthInputStream extends InputStream { - private final InputStream mIn; - private final int mLength; - private int mCount; + private final InputStream in; + private final int length; + private int count; public FixedLengthInputStream(InputStream in, int length) { - this.mIn = in; - this.mLength = length; + this.in = in; + this.length = length; } @Override public int available() throws IOException { - return mLength - mCount; + return length - count; } @Override public int read() throws IOException { - if (mCount < mLength) { - mCount++; - return mIn.read(); + if (count < length) { + count++; + return in.read(); } else { return -1; } @@ -50,12 +50,12 @@ public class FixedLengthInputStream extends InputStream { @Override public int read(byte[] b, int offset, int length) throws IOException { - if (mCount < mLength) { - int d = mIn.read(b, offset, Math.min(mLength - mCount, length)); + if (count < this.length) { + int d = in.read(b, offset, Math.min(this.length - count, length)); if (d == -1) { return -1; } else { - mCount += d; + count += d; return d; } } else { @@ -69,11 +69,11 @@ public class FixedLengthInputStream extends InputStream { } public int getLength() { - return mLength; + return length; } @Override public String toString() { - return String.format("FixedLengthInputStream(in=%s, length=%d)", mIn.toString(), mLength); + return String.format("FixedLengthInputStream(in=%s, length=%d)", in.toString(), length); } } diff --git a/java/com/android/voicemail/impl/mail/MailTransport.java b/java/com/android/voicemail/impl/mail/MailTransport.java index c35e41450..a2a6a691a 100644 --- a/java/com/android/voicemail/impl/mail/MailTransport.java +++ b/java/com/android/voicemail/impl/mail/MailTransport.java @@ -52,17 +52,17 @@ public class MailTransport { private static final HostnameVerifier HOSTNAME_VERIFIER = HttpsURLConnection.getDefaultHostnameVerifier(); - private final Context mContext; - private final ImapHelper mImapHelper; - private final Network mNetwork; - private final String mHost; - private final int mPort; - private Socket mSocket; - private BufferedInputStream mIn; - private BufferedOutputStream mOut; - private final int mFlags; - private SocketCreator mSocketCreator; - private InetSocketAddress mAddress; + private final Context context; + private final ImapHelper imapHelper; + private final Network network; + private final String host; + private final int port; + private Socket socket; + private BufferedInputStream in; + private BufferedOutputStream out; + private final int flags; + private SocketCreator socketCreator; + private InetSocketAddress address; public MailTransport( Context context, @@ -71,12 +71,12 @@ public class MailTransport { String address, int port, int flags) { - mContext = context; - mImapHelper = imapHelper; - mNetwork = network; - mHost = address; - mPort = port; - mFlags = flags; + this.context = context; + this.imapHelper = imapHelper; + this.network = network; + host = address; + this.port = port; + this.flags = flags; } /** @@ -85,15 +85,15 @@ public class MailTransport { */ @Override public MailTransport clone() { - return new MailTransport(mContext, mImapHelper, mNetwork, mHost, mPort, mFlags); + return new MailTransport(context, imapHelper, network, host, port, flags); } public boolean canTrySslSecurity() { - return (mFlags & ImapStore.FLAG_SSL) != 0; + return (flags & ImapStore.FLAG_SSL) != 0; } public boolean canTrustAllCertificates() { - return (mFlags & ImapStore.FLAG_TRUST_ALL) != 0; + return (flags & ImapStore.FLAG_TRUST_ALL) != 0; } /** @@ -101,36 +101,36 @@ public class MailTransport { * SSL connection if indicated. */ public void open() throws MessagingException { - LogUtils.d(TAG, "*** IMAP open " + mHost + ":" + String.valueOf(mPort)); + LogUtils.d(TAG, "*** IMAP open " + host + ":" + String.valueOf(port)); List<InetSocketAddress> socketAddresses = new ArrayList<InetSocketAddress>(); - if (mNetwork == null) { - socketAddresses.add(new InetSocketAddress(mHost, mPort)); + if (network == null) { + socketAddresses.add(new InetSocketAddress(host, port)); } else { try { - InetAddress[] inetAddresses = mNetwork.getAllByName(mHost); + InetAddress[] inetAddresses = network.getAllByName(host); if (inetAddresses.length == 0) { throw new MessagingException( MessagingException.IOERROR, - "Host name " + mHost + "cannot be resolved on designated network"); + "Host name " + host + "cannot be resolved on designated network"); } for (int i = 0; i < inetAddresses.length; i++) { - socketAddresses.add(new InetSocketAddress(inetAddresses[i], mPort)); + socketAddresses.add(new InetSocketAddress(inetAddresses[i], port)); } } catch (IOException ioe) { LogUtils.d(TAG, ioe.toString()); - mImapHelper.handleEvent(OmtpEvents.DATA_CANNOT_RESOLVE_HOST_ON_NETWORK); + imapHelper.handleEvent(OmtpEvents.DATA_CANNOT_RESOLVE_HOST_ON_NETWORK); throw new MessagingException(MessagingException.IOERROR, ioe.toString()); } } boolean success = false; while (socketAddresses.size() > 0) { - mSocket = createSocket(); + socket = createSocket(); try { - mAddress = socketAddresses.remove(0); - mSocket.connect(mAddress, SOCKET_CONNECT_TIMEOUT); + address = socketAddresses.remove(0); + socket.connect(address, SOCKET_CONNECT_TIMEOUT); if (canTrySslSecurity()) { /* @@ -140,9 +140,9 @@ public class MailTransport { */ reopenTls(); } else { - mIn = new BufferedInputStream(mSocket.getInputStream(), 1024); - mOut = new BufferedOutputStream(mSocket.getOutputStream(), 512); - mSocket.setSoTimeout(SOCKET_READ_TIMEOUT); + in = new BufferedInputStream(socket.getInputStream(), 1024); + out = new BufferedOutputStream(socket.getOutputStream(), 512); + socket.setSoTimeout(SOCKET_READ_TIMEOUT); } success = true; return; @@ -150,14 +150,14 @@ public class MailTransport { LogUtils.d(TAG, ioe.toString()); if (socketAddresses.size() == 0) { // Only throw an error when there are no more sockets to try. - mImapHelper.handleEvent(OmtpEvents.DATA_ALL_SOCKET_CONNECTION_FAILED); + imapHelper.handleEvent(OmtpEvents.DATA_ALL_SOCKET_CONNECTION_FAILED); throw new MessagingException(MessagingException.IOERROR, ioe.toString()); } } finally { if (!success) { try { - mSocket.close(); - mSocket = null; + socket.close(); + socket = null; } catch (IOException ioe) { throw new MessagingException(MessagingException.IOERROR, ioe.toString()); } @@ -175,15 +175,15 @@ public class MailTransport { @VisibleForTesting void setSocketCreator(SocketCreator creator) { - mSocketCreator = creator; + socketCreator = creator; } protected Socket createSocket() throws MessagingException { - if (mSocketCreator != null) { - return mSocketCreator.createSocket(); + if (socketCreator != null) { + return socketCreator.createSocket(); } - if (mNetwork == null) { + if (network == null) { LogUtils.v(TAG, "createSocket: network not specified"); return new Socket(); } @@ -191,7 +191,7 @@ public class MailTransport { try { LogUtils.v(TAG, "createSocket: network specified"); TrafficStats.setThreadStatsTag(TrafficStatsTags.VISUAL_VOICEMAIL_TAG); - return mNetwork.getSocketFactory().createSocket(); + return network.getSocketFactory().createSocket(); } catch (IOException ioe) { LogUtils.d(TAG, ioe.toString()); throw new MessagingException(MessagingException.IOERROR, ioe.toString()); @@ -204,17 +204,17 @@ public class MailTransport { public void reopenTls() throws MessagingException { try { LogUtils.d(TAG, "open: converting to TLS socket"); - mSocket = + socket = HttpsURLConnection.getDefaultSSLSocketFactory() - .createSocket(mSocket, mAddress.getHostName(), mAddress.getPort(), true); + .createSocket(socket, address.getHostName(), address.getPort(), true); // After the socket connects to an SSL server, confirm that the hostname is as // expected if (!canTrustAllCertificates()) { - verifyHostname(mSocket, mHost); + verifyHostname(socket, host); } - mSocket.setSoTimeout(SOCKET_READ_TIMEOUT); - mIn = new BufferedInputStream(mSocket.getInputStream(), 1024); - mOut = new BufferedOutputStream(mSocket.getOutputStream(), 512); + socket.setSoTimeout(SOCKET_READ_TIMEOUT); + in = new BufferedInputStream(socket.getInputStream(), 1024); + out = new BufferedOutputStream(socket.getOutputStream(), 512); } catch (SSLException e) { LogUtils.d(TAG, e.toString()); @@ -248,7 +248,7 @@ public class MailTransport { SSLSession session = ssl.getSession(); if (session == null) { - mImapHelper.handleEvent(OmtpEvents.DATA_CANNOT_ESTABLISH_SSL_SESSION); + imapHelper.handleEvent(OmtpEvents.DATA_CANNOT_ESTABLISH_SSL_SESSION); throw new SSLException("Cannot verify SSL socket without session"); } // TODO: Instead of reporting the name of the server we think we're connecting to, @@ -256,52 +256,52 @@ public class MailTransport { // in the verifier code and is not available in the verifier API, and extracting the // CN & alts is beyond the scope of this patch. if (!HOSTNAME_VERIFIER.verify(hostname, session)) { - mImapHelper.handleEvent(OmtpEvents.DATA_SSL_INVALID_HOST_NAME); + imapHelper.handleEvent(OmtpEvents.DATA_SSL_INVALID_HOST_NAME); throw new SSLPeerUnverifiedException( "Certificate hostname not useable for server: " + session.getPeerPrincipal()); } } public boolean isOpen() { - return (mIn != null - && mOut != null - && mSocket != null - && mSocket.isConnected() - && !mSocket.isClosed()); + return (in != null + && out != null + && socket != null + && socket.isConnected() + && !socket.isClosed()); } /** Close the connection. MUST NOT return any exceptions - must be "best effort" and safe. */ public void close() { try { - mIn.close(); + in.close(); } catch (Exception e) { // May fail if the connection is already closed. } try { - mOut.close(); + out.close(); } catch (Exception e) { // May fail if the connection is already closed. } try { - mSocket.close(); + socket.close(); } catch (Exception e) { // May fail if the connection is already closed. } - mIn = null; - mOut = null; - mSocket = null; + in = null; + out = null; + socket = null; } public String getHost() { - return mHost; + return host; } public InputStream getInputStream() { - return mIn; + return in; } public OutputStream getOutputStream() { - return mOut; + return out; } /** Writes a single line to the server using \r\n termination. */ diff --git a/java/com/android/voicemail/impl/mail/Message.java b/java/com/android/voicemail/impl/mail/Message.java index ca65d3d73..4e2c64239 100644 --- a/java/com/android/voicemail/impl/mail/Message.java +++ b/java/com/android/voicemail/impl/mail/Message.java @@ -33,18 +33,18 @@ public abstract class Message implements Part, Body { BCC, } - protected String mUid; + protected String uid; - private HashSet<String> mFlags = null; + private HashSet<String> flags = null; - protected Date mInternalDate; + protected Date internalDate; public String getUid() { - return mUid; + return uid; } public void setUid(String uid) { - this.mUid = uid; + this.uid = uid; } public abstract String getSubject() throws MessagingException; @@ -52,11 +52,11 @@ public abstract class Message implements Part, Body { public abstract void setSubject(String subject) throws MessagingException; public Date getInternalDate() { - return mInternalDate; + return internalDate; } public void setInternalDate(Date internalDate) { - this.mInternalDate = internalDate; + this.internalDate = internalDate; } public abstract Date getReceivedDate() throws MessagingException; @@ -95,10 +95,10 @@ public abstract class Message implements Part, Body { } private HashSet<String> getFlagSet() { - if (mFlags == null) { - mFlags = new HashSet<String>(); + if (flags == null) { + flags = new HashSet<String>(); } - return mFlags; + return flags; } /* @@ -145,6 +145,6 @@ public abstract class Message implements Part, Body { @Override public String toString() { - return getClass().getSimpleName() + ':' + mUid; + return getClass().getSimpleName() + ':' + uid; } } diff --git a/java/com/android/voicemail/impl/mail/MessagingException.java b/java/com/android/voicemail/impl/mail/MessagingException.java index c1e3051df..fda5fbc9d 100644 --- a/java/com/android/voicemail/impl/mail/MessagingException.java +++ b/java/com/android/voicemail/impl/mail/MessagingException.java @@ -70,9 +70,9 @@ public class MessagingException extends Exception { /** The server indicates it experienced an internal error */ public static final int SERVER_ERROR = 19; - protected int mExceptionType; + protected int exceptionType; // Exception type-specific data - protected Object mExceptionData; + protected Object exceptionData; public MessagingException(String message, Throwable throwable) { this(UNSPECIFIED_EXCEPTION, message, throwable); @@ -80,8 +80,8 @@ public class MessagingException extends Exception { public MessagingException(int exceptionType, String message, Throwable throwable) { super(message, throwable); - mExceptionType = exceptionType; - mExceptionData = null; + this.exceptionType = exceptionType; + exceptionData = null; } /** @@ -120,8 +120,8 @@ public class MessagingException extends Exception { */ public MessagingException(int exceptionType, String message, Object data) { super(message); - mExceptionType = exceptionType; - mExceptionData = data; + this.exceptionType = exceptionType; + exceptionData = data; } /** @@ -130,7 +130,7 @@ public class MessagingException extends Exception { * @return Returns the exception type. */ public int getExceptionType() { - return mExceptionType; + return exceptionType; } /** * Return the exception data. Will be null if not explicitly set. @@ -138,6 +138,6 @@ public class MessagingException extends Exception { * @return Returns the exception data. */ public Object getExceptionData() { - return mExceptionData; + return exceptionData; } } diff --git a/java/com/android/voicemail/impl/mail/Multipart.java b/java/com/android/voicemail/impl/mail/Multipart.java index e8d5046d5..c226ca5ce 100644 --- a/java/com/android/voicemail/impl/mail/Multipart.java +++ b/java/com/android/voicemail/impl/mail/Multipart.java @@ -18,45 +18,45 @@ package com.android.voicemail.impl.mail; import java.util.ArrayList; public abstract class Multipart implements Body { - protected Part mParent; + protected Part parent; - protected ArrayList<BodyPart> mParts = new ArrayList<BodyPart>(); + protected ArrayList<BodyPart> parts = new ArrayList<BodyPart>(); - protected String mContentType; + protected String contentType; public void addBodyPart(BodyPart part) throws MessagingException { - mParts.add(part); + parts.add(part); } public void addBodyPart(BodyPart part, int index) throws MessagingException { - mParts.add(index, part); + parts.add(index, part); } public BodyPart getBodyPart(int index) throws MessagingException { - return mParts.get(index); + return parts.get(index); } public String getContentType() throws MessagingException { - return mContentType; + return contentType; } public int getCount() throws MessagingException { - return mParts.size(); + return parts.size(); } public boolean removeBodyPart(BodyPart part) throws MessagingException { - return mParts.remove(part); + return parts.remove(part); } public void removeBodyPart(int index) throws MessagingException { - mParts.remove(index); + parts.remove(index); } public Part getParent() throws MessagingException { - return mParent; + return parent; } public void setParent(Part parent) throws MessagingException { - this.mParent = parent; + this.parent = parent; } } diff --git a/java/com/android/voicemail/impl/mail/PackedString.java b/java/com/android/voicemail/impl/mail/PackedString.java index 701dab62b..de04b6bbc 100644 --- a/java/com/android/voicemail/impl/mail/PackedString.java +++ b/java/com/android/voicemail/impl/mail/PackedString.java @@ -36,8 +36,8 @@ public class PackedString { private static final char DELIMITER_TAG = '\2'; - private String mString; - private ArrayMap<String, String> mExploded; + private String string; + private ArrayMap<String, String> exploded; private static final ArrayMap<String, String> EMPTY_MAP = new ArrayMap<String, String>(); /** @@ -46,8 +46,8 @@ public class PackedString { * @param string packed string */ public PackedString(String string) { - mString = string; - mExploded = null; + this.string = string; + exploded = null; } /** @@ -57,10 +57,10 @@ public class PackedString { * @return returns value, or null if no string is found */ public String get(String tag) { - if (mExploded == null) { - mExploded = explode(mString); + if (exploded == null) { + exploded = explode(string); } - return mExploded.get(tag); + return exploded.get(tag); } /** @@ -70,10 +70,10 @@ public class PackedString { * @return a map of the values in the packed string */ public Map<String, String> unpack() { - if (mExploded == null) { - mExploded = explode(mString); + if (exploded == null) { + exploded = explode(string); } - return new ArrayMap<String, String>(mExploded); + return new ArrayMap<String, String>(exploded); } /** Read out all values into a map. */ @@ -118,16 +118,16 @@ public class PackedString { * PackedString representations. */ public static class Builder { - ArrayMap<String, String> mMap; + ArrayMap<String, String> map; /** Create a builder that's empty (for filling) */ public Builder() { - mMap = new ArrayMap<String, String>(); + map = new ArrayMap<String, String>(); } /** Create a builder using the values of an existing PackedString (for editing). */ public Builder(String packed) { - mMap = explode(packed); + map = explode(packed); } /** @@ -138,9 +138,9 @@ public class PackedString { */ public void put(String tag, String value) { if (value == null) { - mMap.remove(tag); + map.remove(tag); } else { - mMap.put(tag, value); + map.put(tag, value); } } @@ -151,14 +151,14 @@ public class PackedString { * @return returns value, or null if no string is found */ public String get(String tag) { - return mMap.get(tag); + return map.get(tag); } /** Pack the values and return a single, encoded string */ @Override public String toString() { StringBuilder sb = new StringBuilder(); - for (Map.Entry<String, String> entry : mMap.entrySet()) { + for (Map.Entry<String, String> entry : map.entrySet()) { if (sb.length() > 0) { sb.append(DELIMITER_ELEMENT); } diff --git a/java/com/android/voicemail/impl/mail/PeekableInputStream.java b/java/com/android/voicemail/impl/mail/PeekableInputStream.java index 08f867f82..cc362e801 100644 --- a/java/com/android/voicemail/impl/mail/PeekableInputStream.java +++ b/java/com/android/voicemail/impl/mail/PeekableInputStream.java @@ -25,40 +25,40 @@ import java.io.InputStream; * will still return the peeked byte. */ public class PeekableInputStream extends InputStream { - private final InputStream mIn; - private boolean mPeeked; - private int mPeekedByte; + private final InputStream in; + private boolean peeked; + private int peekedByte; public PeekableInputStream(InputStream in) { - this.mIn = in; + this.in = in; } @Override public int read() throws IOException { - if (!mPeeked) { - return mIn.read(); + if (!peeked) { + return in.read(); } else { - mPeeked = false; - return mPeekedByte; + peeked = false; + return peekedByte; } } public int peek() throws IOException { - if (!mPeeked) { - mPeekedByte = read(); - mPeeked = true; + if (!peeked) { + peekedByte = read(); + peeked = true; } - return mPeekedByte; + return peekedByte; } @Override public int read(byte[] b, int offset, int length) throws IOException { - if (!mPeeked) { - return mIn.read(b, offset, length); + if (!peeked) { + return in.read(b, offset, length); } else { - b[0] = (byte) mPeekedByte; - mPeeked = false; - int r = mIn.read(b, offset + 1, length - 1); + b[0] = (byte) peekedByte; + peeked = false; + int r = in.read(b, offset + 1, length - 1); if (r == -1) { return 1; } else { @@ -75,7 +75,6 @@ public class PeekableInputStream extends InputStream { @Override public String toString() { return String.format( - "PeekableInputStream(in=%s, peeked=%b, peekedByte=%d)", - mIn.toString(), mPeeked, mPeekedByte); + "PeekableInputStream(in=%s, peeked=%b, peekedByte=%d)", in.toString(), peeked, peekedByte); } } diff --git a/java/com/android/voicemail/impl/mail/TempDirectory.java b/java/com/android/voicemail/impl/mail/TempDirectory.java index 42adbeb1f..f12e45b82 100644 --- a/java/com/android/voicemail/impl/mail/TempDirectory.java +++ b/java/com/android/voicemail/impl/mail/TempDirectory.java @@ -23,18 +23,18 @@ import java.io.File; * initialization. */ public class TempDirectory { - private static File sTempDirectory = null; + private static File tempDirectory = null; public static void setTempDirectory(Context context) { - sTempDirectory = context.getCacheDir(); + tempDirectory = context.getCacheDir(); } public static File getTempDirectory() { - if (sTempDirectory == null) { + if (tempDirectory == null) { throw new RuntimeException( "TempDirectory not set. " + "If in a unit test, call Email.setTempDirectory(context) in setUp()."); } - return sTempDirectory; + return tempDirectory; } } diff --git a/java/com/android/voicemail/impl/mail/internet/BinaryTempFileBody.java b/java/com/android/voicemail/impl/mail/internet/BinaryTempFileBody.java index 753b70f23..d1521bdcb 100644 --- a/java/com/android/voicemail/impl/mail/internet/BinaryTempFileBody.java +++ b/java/com/android/voicemail/impl/mail/internet/BinaryTempFileBody.java @@ -36,7 +36,7 @@ import org.apache.commons.io.IOUtils; * closed the file is deleted and the Body should be considered disposed of. */ public class BinaryTempFileBody implements Body { - private File mFile; + private File file; /** * An alternate way to put data into a BinaryTempFileBody is to simply supply an already- created @@ -45,19 +45,19 @@ public class BinaryTempFileBody implements Body { * @param filePath The file containing the data to be stored on disk temporarily */ public void setFile(String filePath) { - mFile = new File(filePath); + file = new File(filePath); } public OutputStream getOutputStream() throws IOException { - mFile = File.createTempFile("body", null, TempDirectory.getTempDirectory()); - mFile.deleteOnExit(); - return new FileOutputStream(mFile); + file = File.createTempFile("body", null, TempDirectory.getTempDirectory()); + file.deleteOnExit(); + return new FileOutputStream(file); } @Override public InputStream getInputStream() throws MessagingException { try { - return new BinaryTempFileBodyInputStream(new FileInputStream(mFile)); + return new BinaryTempFileBodyInputStream(new FileInputStream(file)); } catch (IOException ioe) { throw new MessagingException("Unable to open body", ioe); } @@ -69,7 +69,7 @@ public class BinaryTempFileBody implements Body { Base64OutputStream base64Out = new Base64OutputStream(out, Base64.CRLF | Base64.NO_CLOSE); IOUtils.copy(in, base64Out); base64Out.close(); - mFile.delete(); + file.delete(); in.close(); } @@ -81,7 +81,7 @@ public class BinaryTempFileBody implements Body { @Override public void close() throws IOException { super.close(); - mFile.delete(); + file.delete(); } } } diff --git a/java/com/android/voicemail/impl/mail/internet/MimeBodyPart.java b/java/com/android/voicemail/impl/mail/internet/MimeBodyPart.java index 2add76c72..12a2b0b7d 100644 --- a/java/com/android/voicemail/impl/mail/internet/MimeBodyPart.java +++ b/java/com/android/voicemail/impl/mail/internet/MimeBodyPart.java @@ -27,10 +27,10 @@ import java.util.regex.Pattern; /** TODO this is a close approximation of Message, need to update along with Message. */ public class MimeBodyPart extends BodyPart { - protected MimeHeader mHeader = new MimeHeader(); - protected MimeHeader mExtendedHeader; - protected Body mBody; - protected int mSize; + protected MimeHeader header = new MimeHeader(); + protected MimeHeader extendedHeader; + protected Body body; + protected int size; // regex that matches content id surrounded by "<>" optionally. private static final Pattern REMOVE_OPTIONAL_BRACKETS = Pattern.compile("^<?([^>]+)>?$"); @@ -53,37 +53,37 @@ public class MimeBodyPart extends BodyPart { } protected String getFirstHeader(String name) throws MessagingException { - return mHeader.getFirstHeader(name); + return header.getFirstHeader(name); } @Override public void addHeader(String name, String value) throws MessagingException { - mHeader.addHeader(name, value); + header.addHeader(name, value); } @Override public void setHeader(String name, String value) throws MessagingException { - mHeader.setHeader(name, value); + header.setHeader(name, value); } @Override public String[] getHeader(String name) throws MessagingException { - return mHeader.getHeader(name); + return header.getHeader(name); } @Override public void removeHeader(String name) throws MessagingException { - mHeader.removeHeader(name); + header.removeHeader(name); } @Override public Body getBody() throws MessagingException { - return mBody; + return body; } @Override public void setBody(Body body) throws MessagingException { - this.mBody = body; + this.body = body; if (body instanceof Multipart) { Multipart multipart = ((Multipart) body); @@ -142,12 +142,12 @@ public class MimeBodyPart extends BodyPart { } public void setSize(int size) { - this.mSize = size; + this.size = size; } @Override public int getSize() throws MessagingException { - return mSize; + return size; } /** @@ -160,15 +160,15 @@ public class MimeBodyPart extends BodyPart { @Override public void setExtendedHeader(String name, String value) throws MessagingException { if (value == null) { - if (mExtendedHeader != null) { - mExtendedHeader.removeHeader(name); + if (extendedHeader != null) { + extendedHeader.removeHeader(name); } return; } - if (mExtendedHeader == null) { - mExtendedHeader = new MimeHeader(); + if (extendedHeader == null) { + extendedHeader = new MimeHeader(); } - mExtendedHeader.setHeader(name, END_OF_LINE.matcher(value).replaceAll("")); + extendedHeader.setHeader(name, END_OF_LINE.matcher(value).replaceAll("")); } /** @@ -180,21 +180,21 @@ public class MimeBodyPart extends BodyPart { */ @Override public String getExtendedHeader(String name) throws MessagingException { - if (mExtendedHeader == null) { + if (extendedHeader == null) { return null; } - return mExtendedHeader.getFirstHeader(name); + return extendedHeader.getFirstHeader(name); } /** Write the MimeMessage out in MIME format. */ @Override public void writeTo(OutputStream out) throws IOException, MessagingException { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024); - mHeader.writeTo(out); + header.writeTo(out); writer.write("\r\n"); writer.flush(); - if (mBody != null) { - mBody.writeTo(out); + if (body != null) { + body.writeTo(out); } } } diff --git a/java/com/android/voicemail/impl/mail/internet/MimeHeader.java b/java/com/android/voicemail/impl/mail/internet/MimeHeader.java index 8f0817650..00a9eccf2 100644 --- a/java/com/android/voicemail/impl/mail/internet/MimeHeader.java +++ b/java/com/android/voicemail/impl/mail/internet/MimeHeader.java @@ -45,10 +45,10 @@ public class MimeHeader { HEADER_ANDROID_ATTACHMENT_STORE_DATA }; - protected final ArrayList<Field> mFields = new ArrayList<Field>(); + protected final ArrayList<Field> fields = new ArrayList<Field>(); public void clear() { - mFields.clear(); + fields.clear(); } public String getFirstHeader(String name) throws MessagingException { @@ -60,7 +60,7 @@ public class MimeHeader { } public void addHeader(String name, String value) throws MessagingException { - mFields.add(new Field(name, value)); + fields.add(new Field(name, value)); } public void setHeader(String name, String value) throws MessagingException { @@ -73,7 +73,7 @@ public class MimeHeader { public String[] getHeader(String name) throws MessagingException { ArrayList<String> values = new ArrayList<String>(); - for (Field field : mFields) { + for (Field field : fields) { if (field.name.equalsIgnoreCase(name)) { values.add(field.value); } @@ -86,12 +86,12 @@ public class MimeHeader { public void removeHeader(String name) throws MessagingException { ArrayList<Field> removeFields = new ArrayList<Field>(); - for (Field field : mFields) { + for (Field field : fields) { if (field.name.equalsIgnoreCase(name)) { removeFields.add(field); } } - mFields.removeAll(removeFields); + fields.removeAll(removeFields); } /** @@ -101,11 +101,11 @@ public class MimeHeader { * empty */ public String writeToString() { - if (mFields.size() == 0) { + if (fields.size() == 0) { return null; } StringBuilder builder = new StringBuilder(); - for (Field field : mFields) { + for (Field field : fields) { if (!arrayContains(WRITE_OMIT_FIELDS, field.name)) { builder.append(field.name + ": " + field.value + "\r\n"); } @@ -115,7 +115,7 @@ public class MimeHeader { public void writeTo(OutputStream out) throws IOException, MessagingException { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024); - for (Field field : mFields) { + for (Field field : fields) { if (!arrayContains(WRITE_OMIT_FIELDS, field.name)) { writer.write(field.name + ": " + field.value + "\r\n"); } @@ -140,7 +140,7 @@ public class MimeHeader { @Override public String toString() { - return (mFields == null) ? null : mFields.toString(); + return (fields == null) ? null : fields.toString(); } public static final boolean arrayContains(Object[] a, Object o) { diff --git a/java/com/android/voicemail/impl/mail/internet/MimeMessage.java b/java/com/android/voicemail/impl/mail/internet/MimeMessage.java index 39378a092..2997ad8c5 100644 --- a/java/com/android/voicemail/impl/mail/internet/MimeMessage.java +++ b/java/com/android/voicemail/impl/mail/internet/MimeMessage.java @@ -53,24 +53,24 @@ import org.apache.james.mime4j.stream.Field; * It would be better to simply do it explicitly on local creation of new outgoing messages. */ public class MimeMessage extends Message { - private MimeHeader mHeader; - private MimeHeader mExtendedHeader; + private MimeHeader header; + private MimeHeader extendedHeader; // NOTE: The fields here are transcribed out of headers, and values stored here will supersede // the values found in the headers. Use caution to prevent any out-of-phase errors. In // particular, any adds/changes/deletes here must be echoed by changes in the parse() function. - private Address[] mFrom; - private Address[] mTo; - private Address[] mCc; - private Address[] mBcc; - private Address[] mReplyTo; - private Date mSentDate; - private Body mBody; - protected int mSize; - private boolean mInhibitLocalMessageId = false; + private Address[] from; + private Address[] to; + private Address[] cc; + private Address[] bcc; + private Address[] replyTo; + private Date sentDate; + private Body body; + protected int size; + private boolean inhibitLocalMessageId = false; // Shared random source for generating local message-id values - private static final java.util.Random sRandom = new java.util.Random(); + private static final java.util.Random random = new java.util.Random(); // In MIME, en_US-like date format should be used. In other words "MMM" should be encoded to // "Jan", not the other localized format like "Ene" (meaning January in locale es). @@ -86,7 +86,7 @@ public class MimeMessage extends Message { private static final Pattern END_OF_LINE = Pattern.compile("\r?\n"); public MimeMessage() { - mHeader = null; + header = null; } /** @@ -100,7 +100,7 @@ public class MimeMessage extends Message { sb.append("<"); for (int i = 0; i < 24; i++) { // We'll use a 5-bit range (0..31) - final int value = sRandom.nextInt() & 31; + final int value = random.nextInt() & 31; final char c = "0123456789abcdefghijklmnopqrstuv".charAt(value); sb.append(c); } @@ -125,14 +125,14 @@ public class MimeMessage extends Message { // Before parsing the input stream, clear all local fields that may be superceded by // the new incoming message. getMimeHeaders().clear(); - mInhibitLocalMessageId = true; - mFrom = null; - mTo = null; - mCc = null; - mBcc = null; - mReplyTo = null; - mSentDate = null; - mBody = null; + inhibitLocalMessageId = true; + from = null; + to = null; + cc = null; + bcc = null; + replyTo = null; + sentDate = null; + body = null; final MimeStreamParser parser = new MimeStreamParser(); parser.setContentHandler(new MimeMessageBuilder()); @@ -149,10 +149,10 @@ public class MimeMessage extends Message { * not creating the headers until needed. */ private MimeHeader getMimeHeaders() { - if (mHeader == null) { - mHeader = new MimeHeader(); + if (header == null) { + header = new MimeHeader(); } - return mHeader; + return header; } @Override @@ -162,40 +162,40 @@ public class MimeMessage extends Message { @Override public Date getSentDate() throws MessagingException { - if (mSentDate == null) { + if (sentDate == null) { try { DateTimeField field = (DateTimeField) DefaultFieldParser.parse( "Date: " + MimeUtility.unfoldAndDecode(getFirstHeader("Date"))); - mSentDate = field.getDate(); + sentDate = field.getDate(); // TODO: We should make it more clear what exceptions can be thrown here, // and whether they reflect a normal or error condition. } catch (Exception e) { LogUtils.v(LogUtils.TAG, "Message missing Date header"); } } - if (mSentDate == null) { + if (sentDate == null) { // If we still don't have a date, fall back to "Delivery-date" try { DateTimeField field = (DateTimeField) DefaultFieldParser.parse( "Date: " + MimeUtility.unfoldAndDecode(getFirstHeader("Delivery-date"))); - mSentDate = field.getDate(); + sentDate = field.getDate(); // TODO: We should make it more clear what exceptions can be thrown here, // and whether they reflect a normal or error condition. } catch (Exception e) { LogUtils.v(LogUtils.TAG, "Message also missing Delivery-Date header"); } } - return mSentDate; + return sentDate; } @Override public void setSentDate(Date sentDate) throws MessagingException { setHeader("Date", DATE_FORMAT.format(sentDate)); - this.mSentDate = sentDate; + this.sentDate = sentDate; } @Override @@ -253,7 +253,7 @@ public class MimeMessage extends Message { @Override public int getSize() throws MessagingException { - return mSize; + return size; } /** @@ -263,20 +263,20 @@ public class MimeMessage extends Message { @Override public Address[] getRecipients(String type) throws MessagingException { if (type == RECIPIENT_TYPE_TO) { - if (mTo == null) { - mTo = Address.parse(MimeUtility.unfold(getFirstHeader("To"))); + if (to == null) { + to = Address.parse(MimeUtility.unfold(getFirstHeader("To"))); } - return mTo; + return to; } else if (type == RECIPIENT_TYPE_CC) { - if (mCc == null) { - mCc = Address.parse(MimeUtility.unfold(getFirstHeader("CC"))); + if (cc == null) { + cc = Address.parse(MimeUtility.unfold(getFirstHeader("CC"))); } - return mCc; + return cc; } else if (type == RECIPIENT_TYPE_BCC) { - if (mBcc == null) { - mBcc = Address.parse(MimeUtility.unfold(getFirstHeader("BCC"))); + if (bcc == null) { + bcc = Address.parse(MimeUtility.unfold(getFirstHeader("BCC"))); } - return mBcc; + return bcc; } else { throw new MessagingException("Unrecognized recipient type."); } @@ -290,26 +290,26 @@ public class MimeMessage extends Message { if (type == RECIPIENT_TYPE_TO) { if (addresses == null || addresses.length == 0) { removeHeader("To"); - this.mTo = null; + this.to = null; } else { setHeader("To", MimeUtility.fold(Address.toHeader(addresses), toLength)); - this.mTo = addresses; + this.to = addresses; } } else if (type == RECIPIENT_TYPE_CC) { if (addresses == null || addresses.length == 0) { removeHeader("CC"); - this.mCc = null; + this.cc = null; } else { setHeader("CC", MimeUtility.fold(Address.toHeader(addresses), ccLength)); - this.mCc = addresses; + this.cc = addresses; } } else if (type == RECIPIENT_TYPE_BCC) { if (addresses == null || addresses.length == 0) { removeHeader("BCC"); - this.mBcc = null; + this.bcc = null; } else { setHeader("BCC", MimeUtility.fold(Address.toHeader(addresses), bccLength)); - this.mBcc = addresses; + this.bcc = addresses; } } else { throw new MessagingException("Unrecognized recipient type."); @@ -330,14 +330,14 @@ public class MimeMessage extends Message { @Override public Address[] getFrom() throws MessagingException { - if (mFrom == null) { + if (from == null) { String list = MimeUtility.unfold(getFirstHeader("From")); if (list == null || list.length() == 0) { list = MimeUtility.unfold(getFirstHeader("Sender")); } - mFrom = Address.parse(list); + from = Address.parse(list); } - return mFrom; + return from; } @Override @@ -345,18 +345,18 @@ public class MimeMessage extends Message { final int fromLength = 6; // "From: " if (from != null) { setHeader("From", MimeUtility.fold(from.toHeader(), fromLength)); - this.mFrom = new Address[] {from}; + this.from = new Address[] {from}; } else { - this.mFrom = null; + this.from = null; } } @Override public Address[] getReplyTo() throws MessagingException { - if (mReplyTo == null) { - mReplyTo = Address.parse(MimeUtility.unfold(getFirstHeader("Reply-to"))); + if (replyTo == null) { + replyTo = Address.parse(MimeUtility.unfold(getFirstHeader("Reply-to"))); } - return mReplyTo; + return replyTo; } @Override @@ -364,10 +364,10 @@ public class MimeMessage extends Message { final int replyToLength = 10; // "Reply-to: " if (replyTo == null || replyTo.length == 0) { removeHeader("Reply-to"); - mReplyTo = null; + this.replyTo = null; } else { setHeader("Reply-to", MimeUtility.fold(Address.toHeader(replyTo), replyToLength)); - mReplyTo = replyTo; + this.replyTo = replyTo; } } @@ -392,7 +392,7 @@ public class MimeMessage extends Message { @Override public String getMessageId() throws MessagingException { String messageId = getFirstHeader("Message-ID"); - if (messageId == null && !mInhibitLocalMessageId) { + if (messageId == null && !inhibitLocalMessageId) { messageId = generateMessageId(); setMessageId(messageId); } @@ -406,12 +406,12 @@ public class MimeMessage extends Message { @Override public Body getBody() throws MessagingException { - return mBody; + return body; } @Override public void setBody(Body body) throws MessagingException { - this.mBody = body; + this.body = body; if (body instanceof Multipart) { final Multipart multipart = ((Multipart) body); multipart.setParent(this); @@ -447,7 +447,7 @@ public class MimeMessage extends Message { public void removeHeader(String name) throws MessagingException { getMimeHeaders().removeHeader(name); if ("Message-ID".equalsIgnoreCase(name)) { - mInhibitLocalMessageId = true; + inhibitLocalMessageId = true; } } @@ -461,15 +461,15 @@ public class MimeMessage extends Message { @Override public void setExtendedHeader(String name, String value) throws MessagingException { if (value == null) { - if (mExtendedHeader != null) { - mExtendedHeader.removeHeader(name); + if (extendedHeader != null) { + extendedHeader.removeHeader(name); } return; } - if (mExtendedHeader == null) { - mExtendedHeader = new MimeHeader(); + if (extendedHeader == null) { + extendedHeader = new MimeHeader(); } - mExtendedHeader.setHeader(name, END_OF_LINE.matcher(value).replaceAll("")); + extendedHeader.setHeader(name, END_OF_LINE.matcher(value).replaceAll("")); } /** @@ -481,10 +481,10 @@ public class MimeMessage extends Message { */ @Override public String getExtendedHeader(String name) throws MessagingException { - if (mExtendedHeader == null) { + if (extendedHeader == null) { return null; } - return mExtendedHeader.getFirstHeader(name); + return extendedHeader.getFirstHeader(name); } /** @@ -496,15 +496,15 @@ public class MimeMessage extends Message { */ public void setExtendedHeaders(String headers) throws MessagingException { if (TextUtils.isEmpty(headers)) { - mExtendedHeader = null; + extendedHeader = null; } else { - mExtendedHeader = new MimeHeader(); + extendedHeader = new MimeHeader(); for (final String header : END_OF_LINE.split(headers)) { final String[] tokens = header.split(":", 2); if (tokens.length != 2) { throw new MessagingException("Illegal extended headers: " + headers); } - mExtendedHeader.setHeader(tokens[0].trim(), tokens[1].trim()); + extendedHeader.setHeader(tokens[0].trim(), tokens[1].trim()); } } } @@ -515,8 +515,8 @@ public class MimeMessage extends Message { * @return "CR-NL-separated extended headers - null if extended header does not exist */ public String getExtendedHeaders() { - if (mExtendedHeader != null) { - return mExtendedHeader.writeToString(); + if (extendedHeader != null) { + return extendedHeader.writeToString(); } return null; } @@ -536,8 +536,8 @@ public class MimeMessage extends Message { // because it is intended to internal use. writer.write("\r\n"); writer.flush(); - if (mBody != null) { - mBody.writeTo(out); + if (body != null) { + body.writeTo(out); } } diff --git a/java/com/android/voicemail/impl/mail/internet/MimeMultipart.java b/java/com/android/voicemail/impl/mail/internet/MimeMultipart.java index 87b88b52a..6cb2c2701 100644 --- a/java/com/android/voicemail/impl/mail/internet/MimeMultipart.java +++ b/java/com/android/voicemail/impl/mail/internet/MimeMultipart.java @@ -25,25 +25,25 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; public class MimeMultipart extends Multipart { - protected String mPreamble; + protected String preamble; - protected String mContentType; + protected String contentType; - protected String mBoundary; + protected String boundary; - protected String mSubType; + protected String subType; public MimeMultipart() throws MessagingException { - mBoundary = generateBoundary(); + boundary = generateBoundary(); setSubType("mixed"); } public MimeMultipart(String contentType) throws MessagingException { - this.mContentType = contentType; + this.contentType = contentType; try { - mSubType = MimeUtility.getHeaderParameter(contentType, null).split("/")[1]; - mBoundary = MimeUtility.getHeaderParameter(contentType, "boundary"); - if (mBoundary == null) { + subType = MimeUtility.getHeaderParameter(contentType, null).split("/")[1]; + boundary = MimeUtility.getHeaderParameter(contentType, "boundary"); + if (boundary == null) { throw new MessagingException("MultiPart does not contain boundary: " + contentType); } } catch (Exception e) { @@ -65,40 +65,40 @@ public class MimeMultipart extends Multipart { } public String getPreamble() throws MessagingException { - return mPreamble; + return preamble; } public void setPreamble(String preamble) throws MessagingException { - this.mPreamble = preamble; + this.preamble = preamble; } @Override public String getContentType() throws MessagingException { - return mContentType; + return contentType; } public void setSubType(String subType) throws MessagingException { - this.mSubType = subType; - mContentType = String.format("multipart/%s; boundary=\"%s\"", subType, mBoundary); + this.subType = subType; + contentType = String.format("multipart/%s; boundary=\"%s\"", subType, boundary); } @Override public void writeTo(OutputStream out) throws IOException, MessagingException { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024); - if (mPreamble != null) { - writer.write(mPreamble + "\r\n"); + if (preamble != null) { + writer.write(preamble + "\r\n"); } - for (int i = 0, count = mParts.size(); i < count; i++) { - BodyPart bodyPart = mParts.get(i); - writer.write("--" + mBoundary + "\r\n"); + for (int i = 0, count = parts.size(); i < count; i++) { + BodyPart bodyPart = parts.get(i); + writer.write("--" + boundary + "\r\n"); writer.flush(); bodyPart.writeTo(out); writer.write("\r\n"); } - writer.write("--" + mBoundary + "--\r\n"); + writer.write("--" + boundary + "--\r\n"); writer.flush(); } @@ -108,6 +108,6 @@ public class MimeMultipart extends Multipart { } public String getSubTypeForTest() { - return mSubType; + return subType; } } diff --git a/java/com/android/voicemail/impl/mail/internet/TextBody.java b/java/com/android/voicemail/impl/mail/internet/TextBody.java index dae562508..506e1f52e 100644 --- a/java/com/android/voicemail/impl/mail/internet/TextBody.java +++ b/java/com/android/voicemail/impl/mail/internet/TextBody.java @@ -25,15 +25,15 @@ import java.io.OutputStream; import java.io.UnsupportedEncodingException; public class TextBody implements Body { - String mBody; + String body; public TextBody(String body) { - this.mBody = body; + this.body = body; } @Override public void writeTo(OutputStream out) throws IOException, MessagingException { - byte[] bytes = mBody.getBytes("UTF-8"); + byte[] bytes = body.getBytes("UTF-8"); out.write(Base64.encode(bytes, Base64.CRLF)); } @@ -43,14 +43,14 @@ public class TextBody implements Body { * @return */ public String getText() { - return mBody; + return body; } /** Returns an InputStream that reads this body's text in UTF-8 format. */ @Override public InputStream getInputStream() throws MessagingException { try { - byte[] b = mBody.getBytes("UTF-8"); + byte[] b = body.getBytes("UTF-8"); return new ByteArrayInputStream(b); } catch (UnsupportedEncodingException usee) { return null; diff --git a/java/com/android/voicemail/impl/mail/store/ImapConnection.java b/java/com/android/voicemail/impl/mail/store/ImapConnection.java index 0a48dfc69..ac43f8d72 100644 --- a/java/com/android/voicemail/impl/mail/store/ImapConnection.java +++ b/java/com/android/voicemail/impl/mail/store/ImapConnection.java @@ -42,11 +42,11 @@ import javax.net.ssl.SSLException; public class ImapConnection { private final String TAG = "ImapConnection"; - private String mLoginPhrase; - private ImapStore mImapStore; - private MailTransport mTransport; - private ImapResponseParser mParser; - private Set<String> mCapabilities = new ArraySet<>(); + private String loginPhrase; + private ImapStore imapStore; + private MailTransport transport; + private ImapResponseParser parser; + private Set<String> capabilities = new ArraySet<>(); static final String IMAP_REDACTED_LOG = "[IMAP command redacted]"; @@ -55,7 +55,7 @@ public class ImapConnection { * counter to make tests simpler. (Some of the tests involve multiple connections but only have a * single counter to track the tag.) */ - private final AtomicInteger mNextCommandTag = new AtomicInteger(0); + private final AtomicInteger nextCommandTag = new AtomicInteger(0); ImapConnection(ImapStore store) { setStore(store); @@ -65,8 +65,8 @@ public class ImapConnection { // TODO: maybe we should throw an exception if the connection is not closed here, // if it's not currently closed, then we won't reopen it, so if the credentials have // changed, the connection will not be reestablished. - mImapStore = store; - mLoginPhrase = null; + imapStore = store; + loginPhrase = null; } /** @@ -76,42 +76,42 @@ public class ImapConnection { * @return the login command string to sent to the IMAP server */ String getLoginPhrase() { - if (mLoginPhrase == null) { - if (mImapStore.getUsername() != null && mImapStore.getPassword() != null) { + if (loginPhrase == null) { + if (imapStore.getUsername() != null && imapStore.getPassword() != null) { // build the LOGIN string once (instead of over-and-over again.) // apply the quoting here around the built-up password - mLoginPhrase = + loginPhrase = ImapConstants.LOGIN + " " - + mImapStore.getUsername() + + imapStore.getUsername() + " " - + ImapUtility.imapQuoted(mImapStore.getPassword()); + + ImapUtility.imapQuoted(imapStore.getPassword()); } } - return mLoginPhrase; + return loginPhrase; } public void open() throws IOException, MessagingException { - if (mTransport != null && mTransport.isOpen()) { + if (transport != null && transport.isOpen()) { return; } try { // copy configuration into a clean transport, if necessary - if (mTransport == null) { - mTransport = mImapStore.cloneTransport(); + if (transport == null) { + transport = imapStore.cloneTransport(); } - mTransport.open(); + transport.open(); createParser(); // The server should greet us with something like // * OK IMAP4rev1 Server // consume the response before doing anything else. - ImapResponse response = mParser.readResponse(false); + ImapResponse response = parser.readResponse(false); if (!response.isOk()) { - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_INVALID_INITIAL_SERVER_RESPONSE); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_INVALID_INITIAL_SERVER_RESPONSE); throw new MessagingException( MessagingException.AUTHENTICATION_FAILED_OR_SERVER_ERROR, "Invalid server initial response"); @@ -125,11 +125,11 @@ public class ImapConnection { doLogin(); } catch (SSLException e) { LogUtils.d(TAG, "SSLException ", e); - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_SSL_EXCEPTION); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_SSL_EXCEPTION); throw new CertificateValidationException(e.getMessage(), e); } catch (IOException ioe) { LogUtils.d(TAG, "IOException", ioe); - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_IOE_ON_OPEN); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_IOE_ON_OPEN); throw ioe; } finally { destroyResponses(); @@ -139,10 +139,10 @@ public class ImapConnection { void logout() { try { sendCommand(ImapConstants.LOGOUT, false); - if (!mParser.readResponse(true).is(0, ImapConstants.BYE)) { + if (!parser.readResponse(true).is(0, ImapConstants.BYE)) { VvmLog.e(TAG, "Server did not respond LOGOUT with BYE"); } - if (!mParser.readResponse(false).isOk()) { + if (!parser.readResponse(false).isOk()) { VvmLog.e(TAG, "Server did not respond OK after LOGOUT"); } } catch (IOException | MessagingException e) { @@ -155,14 +155,14 @@ public class ImapConnection { * {@link #setStore(ImapStore)} is called. */ void close() { - if (mTransport != null) { + if (transport != null) { logout(); - mTransport.close(); - mTransport = null; + transport.close(); + transport = null; } destroyResponses(); - mParser = null; - mImapStore = null; + parser = null; + imapStore = null; } /** Attempts to convert the connection into secure connection. */ @@ -171,7 +171,7 @@ public class ImapConnection { // Make sure the server does have this capability if (hasCapability(ImapConstants.CAPABILITY_STARTTLS)) { executeSimpleCommand(ImapConstants.STARTTLS); - mTransport.reopenTls(); + transport.reopenTls(); createParser(); // The cached capabilities should be refreshed after TLS is established. queryCapability(); @@ -181,7 +181,7 @@ public class ImapConnection { /** Logs into the IMAP server */ private void doLogin() throws IOException, MessagingException, AuthenticationFailedException { try { - if (mCapabilities.contains(ImapConstants.CAPABILITY_AUTH_DIGEST_MD5)) { + if (capabilities.contains(ImapConstants.CAPABILITY_AUTH_DIGEST_MD5)) { doDigestMd5Auth(); } else { executeSimpleCommand(getLoginPhrase(), true); @@ -195,36 +195,36 @@ public class ImapConnection { if (ImapConstants.NO.equals(status)) { switch (statusMessage) { case ImapConstants.NO_UNKNOWN_USER: - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_UNKNOWN_USER); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_UNKNOWN_USER); break; case ImapConstants.NO_UNKNOWN_CLIENT: - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_UNKNOWN_DEVICE); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_UNKNOWN_DEVICE); break; case ImapConstants.NO_INVALID_PASSWORD: - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_INVALID_PASSWORD); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_INVALID_PASSWORD); break; case ImapConstants.NO_MAILBOX_NOT_INITIALIZED: - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_MAILBOX_NOT_INITIALIZED); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_MAILBOX_NOT_INITIALIZED); break; case ImapConstants.NO_SERVICE_IS_NOT_PROVISIONED: - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_SERVICE_NOT_PROVISIONED); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_SERVICE_NOT_PROVISIONED); break; case ImapConstants.NO_SERVICE_IS_NOT_ACTIVATED: - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_SERVICE_NOT_ACTIVATED); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_SERVICE_NOT_ACTIVATED); break; case ImapConstants.NO_USER_IS_BLOCKED: - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_USER_IS_BLOCKED); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_AUTH_USER_IS_BLOCKED); break; case ImapConstants.NO_APPLICATION_ERROR: - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_REJECTED_SERVER_RESPONSE); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_REJECTED_SERVER_RESPONSE); break; default: - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_BAD_IMAP_CREDENTIAL); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_BAD_IMAP_CREDENTIAL); } throw new AuthenticationFailedException(alertText, ie); } - mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_REJECTED_SERVER_RESPONSE); + imapStore.getImapHelper().handleEvent(OmtpEvents.DATA_REJECTED_SERVER_RESPONSE); throw new MessagingException(alertText, ie); } } @@ -243,7 +243,7 @@ public class ImapConnection { String decodedChallenge = decodeBase64(responses.get(0).getStringOrEmpty(0).getString()); Map<String, String> challenge = DigestMd5Utils.parseDigestMessage(decodedChallenge); - DigestMd5Utils.Data data = new DigestMd5Utils.Data(mImapStore, mTransport, challenge); + DigestMd5Utils.Data data = new DigestMd5Utils.Data(imapStore, transport, challenge); String response = data.createResponse(); // Respond to the challenge. If the server accepts it, it will reply a response-auth which @@ -281,9 +281,9 @@ public class ImapConnection { private void queryCapability() throws IOException, MessagingException { List<ImapResponse> responses = executeSimpleCommand(ImapConstants.CAPABILITY); - mCapabilities.clear(); + capabilities.clear(); Set<String> disabledCapabilities = - mImapStore.getImapHelper().getConfig().getDisabledCapabilities(); + imapStore.getImapHelper().getConfig().getDisabledCapabilities(); for (ImapResponse response : responses) { if (response.isTagged()) { continue; @@ -292,40 +292,40 @@ public class ImapConnection { String capability = response.getStringOrEmpty(i).getString(); if (disabledCapabilities != null) { if (!disabledCapabilities.contains(capability)) { - mCapabilities.add(capability); + capabilities.add(capability); } } else { - mCapabilities.add(capability); + capabilities.add(capability); } } } - LogUtils.d(TAG, "Capabilities: " + mCapabilities.toString()); + LogUtils.d(TAG, "Capabilities: " + capabilities.toString()); } private boolean hasCapability(String capability) { - return mCapabilities.contains(capability); + return capabilities.contains(capability); } /** * Create an {@link ImapResponseParser} from {@code mTransport.getInputStream()} and set it to - * {@link #mParser}. + * {@link #parser}. * * <p>If we already have an {@link ImapResponseParser}, we {@link #destroyResponses()} and throw * it away. */ private void createParser() { destroyResponses(); - mParser = new ImapResponseParser(mTransport.getInputStream()); + parser = new ImapResponseParser(transport.getInputStream()); } public void destroyResponses() { - if (mParser != null) { - mParser.destroyResponses(); + if (parser != null) { + parser.destroyResponses(); } } public ImapResponse readResponse() throws IOException, MessagingException { - return mParser.readResponse(false); + return parser.readResponse(false); } public List<ImapResponse> executeSimpleCommand(String command) @@ -356,18 +356,18 @@ public class ImapConnection { throws IOException, MessagingException { open(); - if (mTransport == null) { + if (transport == null) { throw new IOException("Null transport"); } - String tag = Integer.toString(mNextCommandTag.incrementAndGet()); + String tag = Integer.toString(nextCommandTag.incrementAndGet()); String commandToSend = tag + " " + command; - mTransport.writeLine(commandToSend, (sensitive ? IMAP_REDACTED_LOG : command)); + transport.writeLine(commandToSend, (sensitive ? IMAP_REDACTED_LOG : command)); return tag; } List<ImapResponse> executeContinuationResponse(String response, boolean sensitive) throws IOException, MessagingException { - mTransport.writeLine(response, (sensitive ? IMAP_REDACTED_LOG : response)); + transport.writeLine(response, (sensitive ? IMAP_REDACTED_LOG : response)); return getCommandResponses(); } @@ -382,7 +382,7 @@ public class ImapConnection { final List<ImapResponse> responses = new ArrayList<ImapResponse>(); ImapResponse response; do { - response = mParser.readResponse(false); + response = parser.readResponse(false); responses.add(response); } while (!(response.isTagged() || response.isContinuationRequest())); diff --git a/java/com/android/voicemail/impl/mail/store/ImapFolder.java b/java/com/android/voicemail/impl/mail/store/ImapFolder.java index 5760ee216..3c76ec33d 100644 --- a/java/com/android/voicemail/impl/mail/store/ImapFolder.java +++ b/java/com/android/voicemail/impl/mail/store/ImapFolder.java @@ -59,21 +59,21 @@ public class ImapFolder { }; private static final int COPY_BUFFER_SIZE = 16 * 1024; - private final ImapStore mStore; - private final String mName; - private int mMessageCount = -1; - private ImapConnection mConnection; - private String mMode; - private boolean mExists; + private final ImapStore store; + private final String name; + private int messageCount = -1; + private ImapConnection connection; + private String mode; + private boolean exists; /** A set of hashes that can be used to track dirtiness */ - Object[] mHash; + Object[] hash; public static final String MODE_READ_ONLY = "mode_read_only"; public static final String MODE_READ_WRITE = "mode_read_write"; public ImapFolder(ImapStore store, String name) { - mStore = store; - mName = name; + this.store = store; + this.name = name; } /** Callback for each message retrieval. */ @@ -82,8 +82,8 @@ public class ImapFolder { } private void destroyResponses() { - if (mConnection != null) { - mConnection.destroyResponses(); + if (connection != null) { + connection.destroyResponses(); } } @@ -93,7 +93,7 @@ public class ImapFolder { throw new AssertionError("Duplicated open on ImapFolder"); } synchronized (this) { - mConnection = mStore.getConnection(); + connection = store.getConnection(); } // * FLAGS (\Answered \Flagged \Deleted \Seen \Draft NonJunk // $MDNSent) @@ -107,28 +107,28 @@ public class ImapFolder { try { doSelect(); } catch (IOException ioe) { - throw ioExceptionHandler(mConnection, ioe); + throw ioExceptionHandler(connection, ioe); } finally { destroyResponses(); } } catch (AuthenticationFailedException e) { // Don't cache this connection, so we're forced to try connecting/login again - mConnection = null; + connection = null; close(false); throw e; } catch (MessagingException e) { - mExists = false; + exists = false; close(false); throw e; } } public boolean isOpen() { - return mExists && mConnection != null; + return exists && connection != null; } public String getMode() { - return mMode; + return mode; } public void close(boolean expunge) { @@ -139,14 +139,14 @@ public class ImapFolder { VvmLog.e(TAG, "Messaging Exception", e); } } - mMessageCount = -1; + messageCount = -1; synchronized (this) { - mConnection = null; + connection = null; } } public int getMessageCount() { - return mMessageCount; + return messageCount; } String[] getSearchUids(List<ImapResponse> responses) { @@ -173,7 +173,7 @@ public class ImapFolder { try { try { final String command = ImapConstants.UID_SEARCH + " " + searchCriteria; - final String[] result = getSearchUids(mConnection.executeSimpleCommand(command)); + final String[] result = getSearchUids(connection.executeSimpleCommand(command)); VvmLog.d(TAG, "searchForUids '" + searchCriteria + "' results: " + result.length); return result; } catch (ImapException me) { @@ -181,8 +181,8 @@ public class ImapFolder { return Utility.EMPTY_STRINGS; // Not found } catch (IOException ioe) { VvmLog.d(TAG, "IOException in search: " + searchCriteria, ioe); - mStore.getImapHelper().handleEvent(OmtpEvents.DATA_GENERIC_IMAP_IOE); - throw ioExceptionHandler(mConnection, ioe); + store.getImapHelper().handleEvent(OmtpEvents.DATA_GENERIC_IMAP_IOE); + throw ioExceptionHandler(connection, ioe); } } finally { destroyResponses(); @@ -296,7 +296,7 @@ public class ImapFolder { } try { - mConnection.sendCommand( + connection.sendCommand( String.format( Locale.US, ImapConstants.UID_FETCH + " %s (%s)", @@ -307,7 +307,7 @@ public class ImapFolder { do { response = null; try { - response = mConnection.readResponse(); + response = connection.readResponse(); if (!response.isDataResponse(1, ImapConstants.FETCH)) { continue; // Ignore @@ -395,7 +395,7 @@ public class ImapFolder { // (We'll need to share a temp file. Protect it with a ref-count.) message.setBody( decodeBody( - mStore.getContext(), + store.getContext(), bodyStream, contentTransferEncoding, fetchPart.getSize(), @@ -417,8 +417,8 @@ public class ImapFolder { } } while (!response.isTagged()); } catch (IOException ioe) { - mStore.getImapHelper().handleEvent(OmtpEvents.DATA_GENERIC_IMAP_IOE); - throw ioExceptionHandler(mConnection, ioe); + store.getImapHelper().handleEvent(OmtpEvents.DATA_GENERIC_IMAP_IOE); + throw ioExceptionHandler(connection, ioe); } } @@ -476,7 +476,7 @@ public class ImapFolder { */ private void handleUntaggedResponse(ImapResponse response) { if (response.isDataResponse(1, ImapConstants.EXISTS)) { - mMessageCount = response.getStringOrEmpty(0).getNumberOrZero(); + messageCount = response.getStringOrEmpty(0).getNumberOrZero(); } } @@ -660,10 +660,10 @@ public class ImapFolder { public Message[] expunge() throws MessagingException { checkOpen(); try { - handleUntaggedResponses(mConnection.executeSimpleCommand(ImapConstants.EXPUNGE)); + handleUntaggedResponses(connection.executeSimpleCommand(ImapConstants.EXPUNGE)); } catch (IOException ioe) { - mStore.getImapHelper().handleEvent(OmtpEvents.DATA_GENERIC_IMAP_IOE); - throw ioExceptionHandler(mConnection, ioe); + store.getImapHelper().handleEvent(OmtpEvents.DATA_GENERIC_IMAP_IOE); + throw ioExceptionHandler(connection, ioe); } finally { destroyResponses(); } @@ -692,7 +692,7 @@ public class ImapFolder { allFlags = flagList.substring(1); } try { - mConnection.executeSimpleCommand( + connection.executeSimpleCommand( String.format( Locale.US, ImapConstants.UID_STORE + " %s %s" + ImapConstants.FLAGS_SILENT + " (%s)", @@ -701,8 +701,8 @@ public class ImapFolder { allFlags)); } catch (IOException ioe) { - mStore.getImapHelper().handleEvent(OmtpEvents.DATA_GENERIC_IMAP_IOE); - throw ioExceptionHandler(mConnection, ioe); + store.getImapHelper().handleEvent(OmtpEvents.DATA_GENERIC_IMAP_IOE); + throw ioExceptionHandler(connection, ioe); } finally { destroyResponses(); } @@ -714,11 +714,11 @@ public class ImapFolder { */ private void doSelect() throws IOException, MessagingException { final List<ImapResponse> responses = - mConnection.executeSimpleCommand( - String.format(Locale.US, ImapConstants.SELECT + " \"%s\"", mName)); + connection.executeSimpleCommand( + String.format(Locale.US, ImapConstants.SELECT + " \"%s\"", name)); // Assume the folder is opened read-write; unless we are notified otherwise - mMode = MODE_READ_WRITE; + mode = MODE_READ_WRITE; int messageCount = -1; for (ImapResponse response : responses) { if (response.isDataResponse(1, ImapConstants.EXISTS)) { @@ -726,12 +726,12 @@ public class ImapFolder { } else if (response.isOk()) { final ImapString responseCode = response.getResponseCodeOrEmpty(); if (responseCode.is(ImapConstants.READ_ONLY)) { - mMode = MODE_READ_ONLY; + mode = MODE_READ_ONLY; } else if (responseCode.is(ImapConstants.READ_WRITE)) { - mMode = MODE_READ_WRITE; + mode = MODE_READ_WRITE; } } else if (response.isTagged()) { // Not OK - mStore.getImapHelper().handleEvent(OmtpEvents.DATA_MAILBOX_OPEN_FAILED); + store.getImapHelper().handleEvent(OmtpEvents.DATA_MAILBOX_OPEN_FAILED); throw new MessagingException( "Can't open mailbox: " + response.getStatusResponseTextOrEmpty()); } @@ -739,8 +739,8 @@ public class ImapFolder { if (messageCount == -1) { throw new MessagingException("Did not find message count during select"); } - mMessageCount = messageCount; - mExists = true; + this.messageCount = messageCount; + exists = true; } public class Quota { @@ -757,8 +757,8 @@ public class ImapFolder { public Quota getQuota() throws MessagingException { try { final List<ImapResponse> responses = - mConnection.executeSimpleCommand( - String.format(Locale.US, ImapConstants.GETQUOTAROOT + " \"%s\"", mName)); + connection.executeSimpleCommand( + String.format(Locale.US, ImapConstants.GETQUOTAROOT + " \"%s\"", name)); for (ImapResponse response : responses) { if (!response.isDataResponse(0, ImapConstants.QUOTA)) { @@ -775,8 +775,8 @@ public class ImapFolder { } } } catch (IOException ioe) { - mStore.getImapHelper().handleEvent(OmtpEvents.DATA_GENERIC_IMAP_IOE); - throw ioExceptionHandler(mConnection, ioe); + store.getImapHelper().handleEvent(OmtpEvents.DATA_GENERIC_IMAP_IOE); + throw ioExceptionHandler(connection, ioe); } finally { destroyResponses(); } @@ -785,15 +785,15 @@ public class ImapFolder { private void checkOpen() throws MessagingException { if (!isOpen()) { - throw new MessagingException("Folder " + mName + " is not open."); + throw new MessagingException("Folder " + name + " is not open."); } } private MessagingException ioExceptionHandler(ImapConnection connection, IOException ioe) { VvmLog.d(TAG, "IO Exception detected: ", ioe); connection.close(); - if (connection == mConnection) { - mConnection = null; // To prevent close() from returning the connection to the pool. + if (connection == this.connection) { + this.connection = null; // To prevent close() from returning the connection to the pool. close(false); } return new MessagingException(MessagingException.IOERROR, "IO Error", ioe); diff --git a/java/com/android/voicemail/impl/mail/store/ImapStore.java b/java/com/android/voicemail/impl/mail/store/ImapStore.java index 838bae257..6b88080fe 100644 --- a/java/com/android/voicemail/impl/mail/store/ImapStore.java +++ b/java/com/android/voicemail/impl/mail/store/ImapStore.java @@ -34,12 +34,12 @@ public class ImapStore { */ public static final int FETCH_BODY_SANE_SUGGESTED_SIZE = (125 * 1024); - private final Context mContext; - private final ImapHelper mHelper; - private final String mUsername; - private final String mPassword; - private final MailTransport mTransport; - private ImapConnection mConnection; + private final Context context; + private final ImapHelper helper; + private final String username; + private final String password; + private final MailTransport transport; + private ImapConnection connection; public static final int FLAG_NONE = 0x00; // No flags public static final int FLAG_SSL = 0x01; // Use SSL @@ -58,32 +58,32 @@ public class ImapStore { String serverName, int flags, Network network) { - mContext = context; - mHelper = helper; - mUsername = username; - mPassword = password; - mTransport = new MailTransport(context, this.getImapHelper(), network, serverName, port, flags); + this.context = context; + this.helper = helper; + this.username = username; + this.password = password; + transport = new MailTransport(context, this.getImapHelper(), network, serverName, port, flags); } public Context getContext() { - return mContext; + return context; } public ImapHelper getImapHelper() { - return mHelper; + return helper; } public String getUsername() { - return mUsername; + return username; } public String getPassword() { - return mPassword; + return password; } /** Returns a clone of the transport associated with this store. */ MailTransport cloneTransport() { - return mTransport.clone(); + return transport.clone(); } /** Returns UIDs of Messages joined with "," as the separator. */ @@ -101,15 +101,15 @@ public class ImapStore { } static class ImapMessage extends MimeMessage { - private ImapFolder mFolder; + private ImapFolder folder; ImapMessage(String uid, ImapFolder folder) { - mUid = uid; - mFolder = folder; + this.uid = uid; + this.folder = folder; } public void setSize(int size) { - mSize = size; + this.size = size; } @Override @@ -124,17 +124,17 @@ public class ImapStore { @Override public void setFlag(String flag, boolean set) throws MessagingException { super.setFlag(flag, set); - mFolder.setFlags(new Message[] {this}, new String[] {flag}, set); + folder.setFlags(new Message[] {this}, new String[] {flag}, set); } } static class ImapException extends MessagingException { private static final long serialVersionUID = 1L; - private final String mStatus; - private final String mStatusMessage; - private final String mAlertText; - private final String mResponseCode; + private final String status; + private final String statusMessage; + private final String alertText; + private final String responseCode; public ImapException( String message, @@ -143,40 +143,40 @@ public class ImapStore { String alertText, String responseCode) { super(message); - mStatus = status; - mStatusMessage = statusMessage; - mAlertText = alertText; - mResponseCode = responseCode; + this.status = status; + this.statusMessage = statusMessage; + this.alertText = alertText; + this.responseCode = responseCode; } public String getStatus() { - return mStatus; + return status; } public String getStatusMessage() { - return mStatusMessage; + return statusMessage; } public String getAlertText() { - return mAlertText; + return alertText; } public String getResponseCode() { - return mResponseCode; + return responseCode; } } public void closeConnection() { - if (mConnection != null) { - mConnection.close(); - mConnection = null; + if (connection != null) { + connection.close(); + connection = null; } } public ImapConnection getConnection() { - if (mConnection == null) { - mConnection = new ImapConnection(this); + if (connection == null) { + connection = new ImapConnection(this); } - return mConnection; + return connection; } } diff --git a/java/com/android/voicemail/impl/mail/store/imap/DigestMd5Utils.java b/java/com/android/voicemail/impl/mail/store/imap/DigestMd5Utils.java index f156f67c1..aa2886812 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/DigestMd5Utils.java +++ b/java/com/android/voicemail/impl/mail/store/imap/DigestMd5Utils.java @@ -121,27 +121,27 @@ public class DigestMd5Utils { private static class ResponseBuilder { - private StringBuilder mBuilder = new StringBuilder(); + private StringBuilder builder = new StringBuilder(); public ResponseBuilder appendQuoted(String key, String value) { - if (mBuilder.length() != 0) { - mBuilder.append(","); + if (builder.length() != 0) { + builder.append(","); } - mBuilder.append(key).append("=\"").append(value).append("\""); + builder.append(key).append("=\"").append(value).append("\""); return this; } public ResponseBuilder append(String key, String value) { - if (mBuilder.length() != 0) { - mBuilder.append(","); + if (builder.length() != 0) { + builder.append(","); } - mBuilder.append(key).append("=").append(value); + builder.append(key).append("=").append(value); return this; } @Override public String toString() { - return mBuilder.toString(); + return builder.toString(); } } } @@ -229,20 +229,20 @@ public class DigestMd5Utils { /** Parse the key-value pair returned by the server. */ private static class DigestMessageParser { - private final String mMessage; - private int mPosition = 0; - private Map<String, String> mResult = new ArrayMap<>(); + private final String message; + private int position = 0; + private Map<String, String> result = new ArrayMap<>(); public DigestMessageParser(String message) { - mMessage = message; + this.message = message; } @Nullable public Map<String, String> parse() { try { - while (mPosition < mMessage.length()) { + while (position < message.length()) { parsePair(); - if (mPosition != mMessage.length()) { + if (position != message.length()) { expect(','); } } @@ -250,42 +250,42 @@ public class DigestMd5Utils { VvmLog.e(TAG, e.toString()); return null; } - return mResult; + return result; } private void parsePair() { String key = parseKey(); expect('='); String value = parseValue(); - mResult.put(key, value); + result.put(key, value); } private void expect(char c) { if (pop() != c) { - throw new IllegalStateException("unexpected character " + mMessage.charAt(mPosition)); + throw new IllegalStateException("unexpected character " + message.charAt(position)); } } private char pop() { char result = peek(); - mPosition++; + position++; return result; } private char peek() { - return mMessage.charAt(mPosition); + return message.charAt(position); } private void goToNext(char c) { while (peek() != c) { - mPosition++; + position++; } } private String parseKey() { - int start = mPosition; + int start = position; goToNext('='); - return mMessage.substring(start, mPosition); + return message.substring(start, position); } private String parseValue() { @@ -319,13 +319,13 @@ public class DigestMd5Utils { if (c == '\\') { result.append(pop()); } else if (c == ',') { - mPosition--; + position--; break; } else { result.append(c); } - if (mPosition == mMessage.length()) { + if (position == message.length()) { break; } } diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapElement.java b/java/com/android/voicemail/impl/mail/store/imap/ImapElement.java index ee255d1eb..c2571f3d9 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapElement.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapElement.java @@ -77,14 +77,14 @@ public abstract class ImapElement { } }; - private boolean mDestroyed = false; + private boolean destroyed = false; public abstract boolean isList(); public abstract boolean isString(); protected boolean isDestroyed() { - return mDestroyed; + return destroyed; } /** @@ -92,12 +92,12 @@ public abstract class ImapElement { * ImapTempFileLiteral}. */ public void destroy() { - mDestroyed = true; + destroyed = true; } /** Throws {@link RuntimeException} if it's already destroyed. */ protected final void checkNotDestroyed() { - if (mDestroyed) { + if (destroyed) { throw new RuntimeException("Already destroyed"); } } diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapList.java b/java/com/android/voicemail/impl/mail/store/imap/ImapList.java index e4a6ec0ac..a72883fa6 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapList.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapList.java @@ -35,13 +35,13 @@ public class ImapList extends ImapElement { } }; - private ArrayList<ImapElement> mList = new ArrayList<ImapElement>(); + private ArrayList<ImapElement> list = new ArrayList<ImapElement>(); /* package */ void add(ImapElement e) { if (e == null) { throw new RuntimeException("Can't add null"); } - mList.add(e); + list.add(e); } @Override @@ -55,7 +55,7 @@ public class ImapList extends ImapElement { } public final int size() { - return mList.size(); + return list.size(); } public final boolean isEmpty() { @@ -84,7 +84,7 @@ public class ImapList extends ImapElement { * ImapElement#NONE}. */ public final ImapElement getElementOrNone(int index) { - return (index >= mList.size()) ? ImapElement.NONE : mList.get(index); + return (index >= list.size()) ? ImapElement.NONE : list.get(index); } /** @@ -112,7 +112,7 @@ public class ImapList extends ImapElement { /* package */ final ImapElement getKeyedElementOrNull(String key, boolean prefixMatch) { for (int i = 1; i < size(); i += 2) { if (is(i - 1, key, prefixMatch)) { - return mList.get(i); + return list.get(i); } } return null; @@ -162,18 +162,18 @@ public class ImapList extends ImapElement { @Override public void destroy() { - if (mList != null) { - for (ImapElement e : mList) { + if (list != null) { + for (ImapElement e : list) { e.destroy(); } - mList = null; + list = null; } super.destroy(); } @Override public String toString() { - return mList.toString(); + return list.toString(); } /** Return the text representations of the contents concatenated with ",". */ @@ -192,7 +192,7 @@ public class ImapList extends ImapElement { */ private final StringBuilder flatten(StringBuilder sb) { sb.append('['); - for (int i = 0; i < mList.size(); i++) { + for (int i = 0; i < list.size(); i++) { if (i > 0) { sb.append(','); } @@ -217,7 +217,7 @@ public class ImapList extends ImapElement { return false; } for (int i = 0; i < size(); i++) { - if (!mList.get(i).equalsForTest(thatList.getElementOrNone(i))) { + if (!list.get(i).equalsForTest(thatList.getElementOrNone(i))) { return false; } } diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapMemoryLiteral.java b/java/com/android/voicemail/impl/mail/store/imap/ImapMemoryLiteral.java index 96a8c4ae5..46f3fc5ed 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapMemoryLiteral.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapMemoryLiteral.java @@ -26,35 +26,35 @@ import java.io.UnsupportedEncodingException; /** Subclass of {@link ImapString} used for literals backed by an in-memory byte array. */ public class ImapMemoryLiteral extends ImapString { private final String TAG = "ImapMemoryLiteral"; - private byte[] mData; + private byte[] data; /* package */ ImapMemoryLiteral(FixedLengthInputStream in) throws IOException { // We could use ByteArrayOutputStream and IOUtils.copy, but it'd perform an unnecessary // copy.... - mData = new byte[in.getLength()]; + data = new byte[in.getLength()]; int pos = 0; - while (pos < mData.length) { - int read = in.read(mData, pos, mData.length - pos); + while (pos < data.length) { + int read = in.read(data, pos, data.length - pos); if (read < 0) { break; } pos += read; } - if (pos != mData.length) { + if (pos != data.length) { VvmLog.w(TAG, "length mismatch"); } } @Override public void destroy() { - mData = null; + data = null; super.destroy(); } @Override public String getString() { try { - return new String(mData, "US-ASCII"); + return new String(data, "US-ASCII"); } catch (UnsupportedEncodingException e) { VvmLog.e(TAG, "Unsupported encoding: ", e); } @@ -63,11 +63,11 @@ public class ImapMemoryLiteral extends ImapString { @Override public InputStream getAsStream() { - return new ByteArrayInputStream(mData); + return new ByteArrayInputStream(data); } @Override public String toString() { - return String.format("{%d byte literal(memory)}", mData.length); + return String.format("{%d byte literal(memory)}", data.length); } } diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapResponse.java b/java/com/android/voicemail/impl/mail/store/imap/ImapResponse.java index d53d458da..48eb39d2d 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapResponse.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapResponse.java @@ -18,12 +18,12 @@ package com.android.voicemail.impl.mail.store.imap; /** Class represents an IMAP response. */ public class ImapResponse extends ImapList { - private final String mTag; - private final boolean mIsContinuationRequest; + private final String tag; + private final boolean isContinuationRequest; /* package */ ImapResponse(String tag, boolean isContinuationRequest) { - mTag = tag; - mIsContinuationRequest = isContinuationRequest; + this.tag = tag; + this.isContinuationRequest = isContinuationRequest; } /* package */ static boolean isStatusResponse(String symbol) { @@ -36,12 +36,12 @@ public class ImapResponse extends ImapList { /** @return whether it's a tagged response. */ public boolean isTagged() { - return mTag != null; + return tag != null; } /** @return whether it's a continuation request. */ public boolean isContinuationRequest() { - return mIsContinuationRequest; + return isContinuationRequest; } public boolean isStatusResponse() { @@ -112,7 +112,7 @@ public class ImapResponse extends ImapList { @Override public String toString() { - String tag = mTag; + String tag = this.tag; if (isContinuationRequest()) { tag = "+"; } @@ -125,16 +125,16 @@ public class ImapResponse extends ImapList { return false; } final ImapResponse thatResponse = (ImapResponse) that; - if (mTag == null) { - if (thatResponse.mTag != null) { + if (tag == null) { + if (thatResponse.tag != null) { return false; } } else { - if (!mTag.equals(thatResponse.mTag)) { + if (!tag.equals(thatResponse.tag)) { return false; } } - if (mIsContinuationRequest != thatResponse.mIsContinuationRequest) { + if (isContinuationRequest != thatResponse.isContinuationRequest) { return false; } return true; diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapResponseParser.java b/java/com/android/voicemail/impl/mail/store/imap/ImapResponseParser.java index e37106a69..68d6babbd 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapResponseParser.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapResponseParser.java @@ -33,21 +33,21 @@ public class ImapResponseParser { public static final int LITERAL_KEEP_IN_MEMORY_THRESHOLD = 2 * 1024 * 1024; /** Input stream */ - private final PeekableInputStream mIn; + private final PeekableInputStream in; - private final int mLiteralKeepInMemoryThreshold; + private final int literalKeepInMemoryThreshold; /** StringBuilder used by readUntil() */ - private final StringBuilder mBufferReadUntil = new StringBuilder(); + private final StringBuilder bufferReadUntil = new StringBuilder(); /** StringBuilder used by parseBareString() */ - private final StringBuilder mParseBareString = new StringBuilder(); + private final StringBuilder parseBareString = new StringBuilder(); /** * We store all {@link ImapResponse} in it. {@link #destroyResponses()} must be called from time * to time to destroy them and clear it. */ - private final ArrayList<ImapResponse> mResponsesToDestroy = new ArrayList<ImapResponse>(); + private final ArrayList<ImapResponse> responsesToDestroy = new ArrayList<ImapResponse>(); /** * Exception thrown when we receive BYE. It derives from IOException, so it'll be treated in the @@ -68,8 +68,8 @@ public class ImapResponseParser { /** Constructor for testing to override the literal size threshold. */ /* package for test */ ImapResponseParser(InputStream in, int literalKeepInMemoryThreshold) { - mIn = new PeekableInputStream(in); - mLiteralKeepInMemoryThreshold = literalKeepInMemoryThreshold; + this.in = new PeekableInputStream(in); + this.literalKeepInMemoryThreshold = literalKeepInMemoryThreshold; } private static IOException newEOSException() { @@ -85,7 +85,7 @@ public class ImapResponseParser { * shouldn't see EOF during parsing. */ private int peek() throws IOException { - final int next = mIn.peek(); + final int next = in.peek(); if (next == -1) { throw newEOSException(); } @@ -93,13 +93,13 @@ public class ImapResponseParser { } /** - * Read and return one byte from {@link #mIn}, and put it in {@link #mDiscourseLogger}. + * Read and return one byte from {@link #in}, and put it in {@link #mDiscourseLogger}. * * <p>Throws IOException() if reaches EOF. As long as logical response lines end with \r\n, we * shouldn't see EOF during parsing. */ private int readByte() throws IOException { - int next = mIn.read(); + int next = in.read(); if (next == -1) { throw newEOSException(); } @@ -112,10 +112,10 @@ public class ImapResponseParser { * @see #readResponse() */ public void destroyResponses() { - for (ImapResponse r : mResponsesToDestroy) { + for (ImapResponse r : responsesToDestroy) { r.destroy(); } - mResponsesToDestroy.clear(); + responsesToDestroy.clear(); } /** @@ -151,7 +151,7 @@ public class ImapResponseParser { response.destroy(); throw new ByeException(); } - mResponsesToDestroy.add(response); + responsesToDestroy.add(response); return response; } @@ -192,13 +192,13 @@ public class ImapResponseParser { * (rather than peeked) and won't be included in the result. */ /* package for test */ String readUntil(char end) throws IOException { - mBufferReadUntil.setLength(0); + bufferReadUntil.setLength(0); for (; ; ) { final int ch = readByte(); if (ch != end) { - mBufferReadUntil.append((char) ch); + bufferReadUntil.append((char) ch); } else { - return mBufferReadUntil.toString(); + return bufferReadUntil.toString(); } } } @@ -326,7 +326,7 @@ public class ImapResponseParser { * <p>If the value is "NIL", returns an empty string. */ private ImapString parseBareString() throws IOException, MessagingException { - mParseBareString.setLength(0); + parseBareString.setLength(0); for (; ; ) { final int ch = peek(); @@ -351,10 +351,10 @@ public class ImapResponseParser { ch == '"' || (0x00 <= ch && ch <= 0x1f) || ch == 0x7f) { - if (mParseBareString.length() == 0) { + if (parseBareString.length() == 0) { throw new MessagingException("Expected string, none found."); } - String s = mParseBareString.toString(); + String s = parseBareString.toString(); // NIL will be always converted into the empty string. if (ImapConstants.NIL.equalsIgnoreCase(s)) { @@ -363,11 +363,11 @@ public class ImapResponseParser { return new ImapSimpleString(s); } else if (ch == '[') { // Eat all until next ']' - mParseBareString.append((char) readByte()); - mParseBareString.append(readUntil(']')); - mParseBareString.append(']'); // readUntil won't include the end char. + parseBareString.append((char) readByte()); + parseBareString.append(readUntil(']')); + parseBareString.append(']'); // readUntil won't include the end char. } else { - mParseBareString.append((char) readByte()); + parseBareString.append((char) readByte()); } } } @@ -414,8 +414,8 @@ public class ImapResponseParser { } expect('\r'); expect('\n'); - FixedLengthInputStream in = new FixedLengthInputStream(mIn, size); - if (size > mLiteralKeepInMemoryThreshold) { + FixedLengthInputStream in = new FixedLengthInputStream(this.in, size); + if (size > literalKeepInMemoryThreshold) { return new ImapTempFileLiteral(in); } else { return new ImapMemoryLiteral(in); diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapSimpleString.java b/java/com/android/voicemail/impl/mail/store/imap/ImapSimpleString.java index 7cc866b74..76d3c6e91 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapSimpleString.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapSimpleString.java @@ -24,27 +24,27 @@ import java.io.UnsupportedEncodingException; /** Subclass of {@link ImapString} used for non literals. */ public class ImapSimpleString extends ImapString { private final String TAG = "ImapSimpleString"; - private String mString; + private String string; /* package */ ImapSimpleString(String string) { - mString = (string != null) ? string : ""; + this.string = (string != null) ? string : ""; } @Override public void destroy() { - mString = null; + string = null; super.destroy(); } @Override public String getString() { - return mString; + return string; } @Override public InputStream getAsStream() { try { - return new ByteArrayInputStream(mString.getBytes("US-ASCII")); + return new ByteArrayInputStream(string.getBytes("US-ASCII")); } catch (UnsupportedEncodingException e) { VvmLog.e(TAG, "Unsupported encoding: ", e); } @@ -54,6 +54,6 @@ public class ImapSimpleString extends ImapString { @Override public String toString() { // Purposefully not return just mString, in order to prevent using it instead of getString. - return "\"" + mString + "\""; + return "\"" + string + "\""; } } diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapString.java b/java/com/android/voicemail/impl/mail/store/imap/ImapString.java index d5c555126..099e569a8 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapString.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapString.java @@ -64,9 +64,9 @@ public abstract class ImapString extends ImapElement { private static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss Z", Locale.US); - private boolean mIsInteger; - private int mParsedInteger; - private Date mParsedDate; + private boolean isInteger; + private int parsedInteger; + private Date parsedDate; @Override public final boolean isList() { @@ -94,12 +94,12 @@ public abstract class ImapString extends ImapElement { /** @return whether it can be parsed as a number. */ public final boolean isNumber() { - if (mIsInteger) { + if (isInteger) { return true; } try { - mParsedInteger = Integer.parseInt(getString()); - mIsInteger = true; + parsedInteger = Integer.parseInt(getString()); + isInteger = true; return true; } catch (NumberFormatException e) { return false; @@ -116,19 +116,19 @@ public abstract class ImapString extends ImapElement { if (!isNumber()) { return defaultValue; } - return mParsedInteger; + return parsedInteger; } /** @return whether it can be parsed as a date using {@link #DATE_TIME_FORMAT}. */ public final boolean isDate() { - if (mParsedDate != null) { + if (parsedDate != null) { return true; } if (isEmpty()) { return false; } try { - mParsedDate = DATE_TIME_FORMAT.parse(getString()); + parsedDate = DATE_TIME_FORMAT.parse(getString()); return true; } catch (ParseException e) { VvmLog.w("ImapString", getString() + " can't be parsed as a date."); @@ -141,7 +141,7 @@ public abstract class ImapString extends ImapElement { if (!isDate()) { return null; } - return mParsedDate; + return parsedDate; } /** @return whether the value case-insensitively equals to {@code s}. */ diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapTempFileLiteral.java b/java/com/android/voicemail/impl/mail/store/imap/ImapTempFileLiteral.java index ab64d8537..417adcc02 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapTempFileLiteral.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapTempFileLiteral.java @@ -33,20 +33,20 @@ import org.apache.commons.io.IOUtils; public class ImapTempFileLiteral extends ImapString { private final String TAG = "ImapTempFileLiteral"; - /* package for test */ final File mFile; + /* package for test */ final File file; /** Size is purely for toString() */ - private final int mSize; + private final int size; /* package */ ImapTempFileLiteral(FixedLengthInputStream stream) throws IOException { - mSize = stream.getLength(); - mFile = File.createTempFile("imap", ".tmp", TempDirectory.getTempDirectory()); + size = stream.getLength(); + file = File.createTempFile("imap", ".tmp", TempDirectory.getTempDirectory()); // Unfortunately, we can't really use deleteOnExit(), because temp filenames are random // so it'd simply cause a memory leak. // deleteOnExit() simply adds filenames to a static list and the list will never shrink. // mFile.deleteOnExit(); - OutputStream out = new FileOutputStream(mFile); + OutputStream out = new FileOutputStream(file); IOUtils.copy(stream, out); out.close(); } @@ -69,7 +69,7 @@ public class ImapTempFileLiteral extends ImapString { public InputStream getAsStream() { checkNotDestroyed(); try { - return new FileInputStream(mFile); + return new FileInputStream(file); } catch (FileNotFoundException e) { // It's probably possible if we're low on storage and the system clears the cache dir. LogUtils.w(TAG, "ImapTempFileLiteral: Temp file not found"); @@ -98,8 +98,8 @@ public class ImapTempFileLiteral extends ImapString { @Override public void destroy() { try { - if (!isDestroyed() && mFile.exists()) { - mFile.delete(); + if (!isDestroyed() && file.exists()) { + file.delete(); } } catch (RuntimeException re) { // Just log and ignore. @@ -110,10 +110,10 @@ public class ImapTempFileLiteral extends ImapString { @Override public String toString() { - return String.format("{%d byte literal(file)}", mSize); + return String.format("{%d byte literal(file)}", size); } public boolean tempFileExistsForTest() { - return mFile.exists(); + return file.exists(); } } diff --git a/java/com/android/voicemail/impl/mail/utility/CountingOutputStream.java b/java/com/android/voicemail/impl/mail/utility/CountingOutputStream.java index c3586105f..0136b0272 100644 --- a/java/com/android/voicemail/impl/mail/utility/CountingOutputStream.java +++ b/java/com/android/voicemail/impl/mail/utility/CountingOutputStream.java @@ -23,26 +23,26 @@ import java.io.OutputStream; * count available to callers. */ public class CountingOutputStream extends OutputStream { - private long mCount; - private final OutputStream mOutputStream; + private long count; + private final OutputStream outputStream; public CountingOutputStream(OutputStream outputStream) { - mOutputStream = outputStream; + this.outputStream = outputStream; } public long getCount() { - return mCount; + return count; } @Override public void write(byte[] buffer, int offset, int count) throws IOException { - mOutputStream.write(buffer, offset, count); - mCount += count; + outputStream.write(buffer, offset, count); + this.count += count; } @Override public void write(int oneByte) throws IOException { - mOutputStream.write(oneByte); - mCount++; + outputStream.write(oneByte); + count++; } } diff --git a/java/com/android/voicemail/impl/mail/utils/LogUtils.java b/java/com/android/voicemail/impl/mail/utils/LogUtils.java index f6c3c6ba3..772048d49 100644 --- a/java/com/android/voicemail/impl/mail/utils/LogUtils.java +++ b/java/com/android/voicemail/impl/mail/utils/LogUtils.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2015 The Android Open Source Project +/* + * Copyright (C) 2015 The Android Open Source Project * * <p>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 @@ -46,7 +46,7 @@ public class LogUtils { */ private static final int MAX_ENABLED_LOG_LEVEL = DEBUG; - private static Boolean sDebugLoggingEnabledForTests = null; + private static Boolean debugLoggingEnabledForTests = null; /** Enable debug logging for unit tests. */ @VisibleForTesting @@ -55,7 +55,7 @@ public class LogUtils { } protected static void setDebugLoggingEnabledForTestsInternal(boolean enabled) { - sDebugLoggingEnabledForTests = Boolean.valueOf(enabled); + debugLoggingEnabledForTests = Boolean.valueOf(enabled); } /** Returns true if the build configuration prevents debug logging. */ @@ -69,8 +69,8 @@ public class LogUtils { if (buildPreventsDebugLogging()) { return false; } - if (sDebugLoggingEnabledForTests != null) { - return sDebugLoggingEnabledForTests.booleanValue(); + if (debugLoggingEnabledForTests != null) { + return debugLoggingEnabledForTests.booleanValue(); } return Log.isLoggable(tag, Log.DEBUG) || Log.isLoggable(TAG, Log.DEBUG); } |