Clean up a bunch of warnings

Bug: 9565838
Change-Id: I5e95562bbf463f057cbcc4a9884427a774473b45
This commit is contained in:
Scott Kennedy 2013-06-25 15:15:02 -07:00
parent 038924037b
commit 1b8e0fa23f
24 changed files with 38 additions and 114 deletions

View File

@ -89,7 +89,7 @@ public class Rfc822Output {
/**
* Gets both the plain text and HTML versions of the message body.
*/
/*package*/ static String[] buildBodyText(Body body, int flags, boolean useSmartReply) {
/*package*/ static String[] buildBodyText(Body body, boolean useSmartReply) {
if (body == null) {
return new String[2];
}
@ -149,7 +149,7 @@ public class Rfc822Output {
// Analyze message and determine if we have multiparts
Body body = Body.restoreBodyWithMessageId(context, message.mId);
String[] bodyText = buildBodyText(body, message.mFlags, useSmartReply);
String[] bodyText = buildBodyText(body, useSmartReply);
// If a list of attachments hasn't been passed in, build one from the message
if (attachments == null) {

View File

@ -262,7 +262,7 @@ public final class Account extends EmailContent implements AccountColumns, Parce
mPolicyKey = cursor.getLong(CONTENT_POLICY_KEY);
}
private long getId(Uri u) {
private static long getId(Uri u) {
return Long.parseLong(u.getPathSegments().get(1));
}

View File

@ -385,7 +385,7 @@ public final class Policy extends EmailContent implements EmailContent.PolicyCol
return result;
}
private void appendPolicy(StringBuilder sb, String code, int value) {
private static void appendPolicy(StringBuilder sb, String code, int value) {
sb.append(code);
sb.append(":");
sb.append(value);

View File

@ -17,7 +17,6 @@
package com.android.emailcommon.service;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;

View File

@ -386,9 +386,8 @@ public class NotificationController {
mContext.getString(R.string.login_failed_ticker, account.mDisplayName),
mContext.getString(R.string.login_failed_title),
account.getDisplayName(),
AccountSettings.createAccountSettingsIntent(mContext, accountId,
account.mDisplayName, reason),
getLoginFailedNotificationId(accountId));
AccountSettings.createAccountSettingsIntent(accountId,
account.mDisplayName, reason), getLoginFailedNotificationId(accountId));
}
/**
@ -464,8 +463,7 @@ public class NotificationController {
* account settings screen where he can view the list of enforced policies
*/
public void showSecurityChangedNotification(Account account) {
Intent intent =
AccountSettings.createAccountSettingsIntent(mContext, account.mId, null, null);
Intent intent = AccountSettings.createAccountSettingsIntent(account.mId, null, null);
String accountName = account.getDisplayName();
String ticker =
mContext.getString(R.string.security_changed_ticker_fmt, accountName);
@ -479,8 +477,7 @@ public class NotificationController {
* account settings screen where he can view the list of unsupported policies
*/
public void showSecurityUnsupportedNotification(Account account) {
Intent intent =
AccountSettings.createAccountSettingsIntent(mContext, account.mId, null, null);
Intent intent = AccountSettings.createAccountSettingsIntent(account.mId, null, null);
String accountName = account.getDisplayName();
String ticker =
mContext.getString(R.string.security_unsupported_ticker_fmt, accountName);
@ -640,9 +637,7 @@ public class NotificationController {
newAccountList.add(accountId);
}
} finally {
if (c != null) {
c.close();
}
c.close();
}
// NOTE: Looping over three lists is not necessarily the most efficient. However, the
// account lists are going to be very small, so, this will not be necessarily bad.

View File

@ -265,7 +265,7 @@ public class Preferences {
try {
return parseEmailSet(mSharedPreferences.getString(TRUSTED_SENDERS, ""));
} catch (JSONException e) {
return Collections.EMPTY_SET;
return Collections.emptySet();
}
}
@ -311,7 +311,7 @@ public class Preferences {
* Gets whether the require manual sync dialog has been shown for the specified account.
* It should only be shown once per account.
*/
public boolean getHasShownRequireManualSync(Context context, Account account) {
public boolean getHasShownRequireManualSync(Account account) {
return getBoolean(account.getEmailAddress(), REQUIRE_MANUAL_SYNC_DIALOG_SHOWN, false);
}
@ -319,7 +319,7 @@ public class Preferences {
* Sets whether the require manual sync dialog has been shown for the specified account.
* It should only be shown once per account.
*/
public void setHasShownRequireManualSync(Context context, Account account, boolean value) {
public void setHasShownRequireManualSync(Account account, boolean value) {
setBoolean(account.getEmailAddress(), REQUIRE_MANUAL_SYNC_DIALOG_SHOWN, value);
}
@ -331,7 +331,7 @@ public class Preferences {
*/
public boolean shouldShowRequireManualSync(Context context, Account account) {
return Account.isAutomaticSyncDisabledByRoaming(context, account.mId)
&& !getHasShownRequireManualSync(context, account);
&& !getHasShownRequireManualSync(account);
}
public void clear() {

View File

@ -22,7 +22,6 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.res.Resources;
public class RequireManualSyncDialog extends AlertDialog implements OnClickListener {
@ -30,7 +29,7 @@ public class RequireManualSyncDialog extends AlertDialog implements OnClickListe
super(context);
setMessage(context.getResources().getString(R.string.require_manual_sync_message));
setButton(DialogInterface.BUTTON_POSITIVE, context.getString(android.R.string.ok), this);
Preferences.getPreferences(context).setHasShownRequireManualSync(context, account, true);
Preferences.getPreferences(context).setHasShownRequireManualSync(account, true);
}
/** {@inheritDoc} */

View File

@ -67,11 +67,8 @@ public class InsertQuickResponseDialog extends DialogFragment
final InsertQuickResponseDialog dialog = new InsertQuickResponseDialog();
// If a target is set, it MUST implement Callback. Fail-fast if not.
final Callback callback;
if (callbackFragment != null) {
try {
callback = (Callback) callbackFragment;
} catch (ClassCastException e) {
if (!(callbackFragment instanceof Callback)) {
throw new ClassCastException(callbackFragment.toString()
+ " must implement Callback");
}
@ -89,10 +86,7 @@ public class InsertQuickResponseDialog extends DialogFragment
// If target not set, the parent activity MUST implement Callback. Fail-fast if not.
final Fragment targetFragment = getTargetFragment();
if (targetFragment != null) {
final Callback callback;
try {
callback = (Callback) getActivity();
} catch (ClassCastException e) {
if (!(getActivity() instanceof Callback)) {
throw new ClassCastException(getActivity().toString() + " must implement Callback");
}
}

View File

@ -123,16 +123,4 @@ public class UiUtilities {
public static void setVisibilitySafe(View parent, int viewId, int visibility) {
setVisibilitySafe(parent.findViewById(viewId), visibility);
}
private static int sDebugForcedPaneMode = 0;
/**
* Force 1-pane UI or 2-pane UI.
*
* @param paneMode Set 1 if 1-pane UI should be used. Set 2 if 2-pane UI should be used.
* Set 0 to use the default UI.
*/
static void setDebugPaneMode(int paneMode) {
sDebugForcedPaneMode = paneMode;
}
}

View File

@ -331,7 +331,6 @@ public class AccountCheckSettingsFragment extends Fragment {
}
private void onEditCertificateOk() {
Callbacks callbackTarget = getCallbackTarget();
getCallbackTarget().onCheckSettingsComplete(CHECK_SETTINGS_CLIENT_CERTIFICATE_NEEDED);
finish();
}

View File

@ -292,7 +292,7 @@ public class AccountSecurity extends Activity {
* Mark an account as not-ready-for-sync and post a notification to bring the user back here
* eventually.
*/
private void repostNotification(final Account account, final SecurityPolicy security) {
private static void repostNotification(final Account account, final SecurityPolicy security) {
if (account == null) return;
Utility.runAsync(new Runnable() {
@Override
@ -360,7 +360,7 @@ public class AccountSecurity extends Activity {
if (MailActivityEmail.DEBUG || DEBUG) {
LogUtils.d(TAG, "User declines; repost notification");
}
activity.repostNotification(
AccountSecurity.repostNotification(
activity.mAccount, SecurityPolicy.getInstance(activity));
activity.finish();
break;

View File

@ -33,7 +33,6 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.view.KeyEvent;
@ -52,7 +51,6 @@ import com.android.emailcommon.service.ServiceProxy;
import com.android.emailcommon.utility.IntentUtilities;
import com.android.emailcommon.utility.Utility;
import com.android.mail.providers.Folder;
import com.android.mail.providers.UIProvider;
import com.android.mail.providers.UIProvider.EditSettingsExtras;
import com.android.mail.ui.FeedbackEnabledActivity;
import com.android.mail.utils.LogUtils;
@ -114,7 +112,6 @@ public class AccountSettings extends PreferenceActivity implements FeedbackEnabl
private int mNumGeneralHeaderClicked = 0;
private long mRequestedAccountId;
private Header mRequestedAccountHeader;
private Header[] mAccountListHeaders;
private Header mAppPreferencesHeader;
/* package */ Fragment mCurrentFragment;
@ -137,8 +134,7 @@ public class AccountSettings extends PreferenceActivity implements FeedbackEnabl
* Display (and edit) settings for a specific account, or -1 for any/all accounts
*/
public static void actionSettings(Activity fromActivity, long accountId) {
fromActivity.startActivity(
createAccountSettingsIntent(fromActivity, accountId, null, null));
fromActivity.startActivity(createAccountSettingsIntent(accountId, null, null));
}
/**
@ -146,7 +142,7 @@ public class AccountSettings extends PreferenceActivity implements FeedbackEnabl
* for any/all accounts. If an account name string is provided, a warning dialog will be
* displayed as well.
*/
public static Intent createAccountSettingsIntent(Context context, long accountId,
public static Intent createAccountSettingsIntent(long accountId,
String loginWarningAccountName, String loginWarningReason) {
final Uri.Builder b = IntentUtilities.createActivityIntentUrlBuilder("settings");
IntentUtilities.setAccountId(b, accountId);
@ -380,9 +376,6 @@ public class AccountSettings extends PreferenceActivity implements FeedbackEnabl
*/
@Override
public void onBuildHeaders(List<Header> target) {
// Assume the account is unspecified
mRequestedAccountHeader = null;
// Always add app preferences as first header
target.clear();
target.add(getAppPreferencesHeader());
@ -396,7 +389,6 @@ public class AccountSettings extends PreferenceActivity implements FeedbackEnabl
if (header.id != mDeletingAccountId) {
target.add(header);
if (header.id == mRequestedAccountId) {
mRequestedAccountHeader = header;
mRequestedAccountId = -1;
}
}

View File

@ -90,7 +90,7 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi
mName.addTextChangedListener(validationTextWatcher);
mName.setKeyListener(TextKeyListener.getInstance(false, Capitalize.WORDS));
Account account = SetupData.getAccount();
final Account account = SetupData.getAccount();
if (account == null) {
throw new IllegalStateException("unexpected null account");
}
@ -116,7 +116,7 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi
mName.setVisibility(View.GONE);
accountNameLabel.setVisibility(View.GONE);
} else {
if (account != null && account.getSenderName() != null) {
if (account.getSenderName() != null) {
mName.setText(account.getSenderName());
} else if (flowMode != SetupData.FLOW_MODE_FORCE_CREATE
&& flowMode != SetupData.FLOW_MODE_EDIT) {

View File

@ -18,7 +18,6 @@ package com.android.email.activity.setup;
import android.app.ActionBar;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
@ -171,7 +170,6 @@ public class MailboxSettings extends PreferenceActivity {
mMailbox = Mailbox.restoreMailboxWithId(c, mMailboxId);
mMaxLookback = 0;
if (mMailbox != null) {
final ContentResolver cr = c.getContentResolver();
// Get the max lookback from our policy, if we have one.
final Long policyKey = Utility.getFirstRowLong(c, ContentUris.withAppendedId(
Account.CONTENT_URI, mMailbox.mAccountKey), POLICY_KEY_PROJECTION,

View File

@ -37,8 +37,7 @@ public abstract class Sender {
* Static named constructor. It should be overrode by extending class.
* Because this method will be called through reflection, it can not be protected.
*/
public static Sender newInstance(Context context, Account account)
throws MessagingException {
public static Sender newInstance(Account account) throws MessagingException {
throw new MessagingException("Sender.newInstance: Unknown scheme in "
+ account.mDisplayName);
}

View File

@ -62,7 +62,7 @@ public abstract class Store {
* Static named constructor. It should be overrode by extending class.
* Because this method will be called through reflection, it can not be protected.
*/
static Store newInstance(Account account, Context context) throws MessagingException {
static Store newInstance(Account account) throws MessagingException {
throw new MessagingException("Store#newInstance: Unknown scheme in "
+ account.mDisplayName);
}

View File

@ -582,7 +582,6 @@ class ImapFolder extends Folder {
Utility.combine(fetchFields.toArray(new String[fetchFields.size()]), ' ')
), false);
ImapResponse response;
int messageNumber = 0;
do {
response = null;
try {
@ -680,7 +679,7 @@ class ImapFolder extends Folder {
* Removes any content transfer encoding from the stream and returns a Body.
* This code is taken/condensed from MimeUtility.decodeBody
*/
private Body decodeBody(InputStream in, String contentTransferEncoding, int size,
private static Body decodeBody(InputStream in, String contentTransferEncoding, int size,
MessageRetrievalListener listener) throws IOException {
// Get a properly wrapped input stream
in = MimeUtility.getInputStreamForContentTransferEncoding(in, contentTransferEncoding);

View File

@ -189,7 +189,7 @@ public class MailTransport {
* @throws IOException if something goes wrong handshaking with the server
* @throws SSLPeerUnverifiedException if the server cannot prove its identity
*/
private void verifyHostname(Socket socket, String hostname) throws IOException {
private static void verifyHostname(Socket socket, String hostname) throws IOException {
// The code at the start of OpenSSLSocketImpl.startHandshake()
// ensures that the call is idempotent, so we can safely call it.
SSLSocket ssl = (SSLSocket) socket;

View File

@ -715,35 +715,6 @@ public final class ContentCache {
}
}
private static class CacheCounter implements Comparable<CacheCounter> {
String uri;
Integer count;
CacheCounter(String _uri, Integer _count) {
uri = _uri;
count = _count;
}
@Override
public int compareTo(CacheCounter another) {
return another.count > count ? 1 : another.count == count ? 0 : -1;
}
}
private static void dumpNotCacheableQueries() {
int size = sNotCacheableMap.size();
CacheCounter[] array = new CacheCounter[size];
int i = 0;
for (Map.Entry<String, Integer> entry: sNotCacheableMap.entrySet()) {
array[i++] = new CacheCounter(entry.getKey(), entry.getValue());
}
Arrays.sort(array);
for (CacheCounter cc: array) {
LogUtils.d("NotCacheable", cc.count + ": " + cc.uri);
}
}
// For use with unit tests
public static void invalidateAllCaches() {
for (ContentCache cache: sContentCaches) {
@ -812,7 +783,7 @@ public final class ContentCache {
}
}
private void append(StringBuilder sb, String name, Object value) {
private static void append(StringBuilder sb, String name, Object value) {
sb.append(", ");
sb.append(name);
sb.append(": ");

View File

@ -2733,10 +2733,6 @@ public class EmailProvider extends ContentProvider {
return Long.toString(Account.ACCOUNT_ID_COMBINED_VIEW + type);
}
private static String getVirtualMailboxIdString(long accountId, int type) {
return Long.toString(getVirtualMailboxId(accountId, type));
}
public static long getVirtualMailboxId(long accountId, int type) {
return (accountId << 32) + type;
}
@ -4022,7 +4018,7 @@ public class EmailProvider extends ContentProvider {
undoValues.put(MessageColumns.FLAG_FAVORITE, msg.mFlagFavorite);
}
}
if (undoValues == null || undoValues.size() == 0) {
if (undoValues.size() == 0) {
return -1;
}
final Boolean suppressUndo =

View File

@ -119,7 +119,7 @@ public class WidgetProvider extends BaseWidgetProvider {
editor.apply();
}
private long migrateLegacyWidgetAccountId(long accountId) {
private static long migrateLegacyWidgetAccountId(long accountId) {
if (accountId == Account.ACCOUNT_ID_COMBINED_VIEW) {
return EmailProvider.COMBINED_ACCOUNT_ID;
}
@ -130,7 +130,7 @@ public class WidgetProvider extends BaseWidgetProvider {
* @param accountId The migrated accountId
* @return
*/
private long migrateLegacyWidgetMailboxId(long mailboxId, long accountId) {
private static long migrateLegacyWidgetMailboxId(long mailboxId, long accountId) {
if (mailboxId == Mailbox.QUERY_ALL_INBOXES) {
return EmailProvider.getVirtualMailboxId(accountId, Mailbox.TYPE_INBOX);
} else if (mailboxId == Mailbox.QUERY_ALL_UNREAD) {

View File

@ -32,7 +32,6 @@ import com.android.emailcommon.Configuration;
import com.android.emailcommon.Device;
import com.android.emailcommon.VendorPolicyLoader;
import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.HostAuth;
import com.android.emailcommon.service.IAccountService;
import com.android.emailcommon.utility.EmailAsyncTask;

View File

@ -667,8 +667,7 @@ public class ImapService extends Service {
// Dispatch here for specific change types
if (deleteFromTrash) {
// Move message to trash
processPendingDeleteFromTrash(context, remoteStore, account, mailbox,
oldMessage);
processPendingDeleteFromTrash(remoteStore, account, mailbox, oldMessage);
}
}
@ -922,7 +921,7 @@ public class ImapService extends Service {
} else if (mailbox.mType == Mailbox.TYPE_TRASH) {
deleteUpdate = false;
LogUtils.d(Logging.LOG_TAG, "Upsync skipped for mailbox=trash, id=" + messageId);
} else if (newMessage != null && newMessage.mMailboxKey != mailbox.mId) {
} else if (newMessage.mMailboxKey != mailbox.mId) {
deleteUpdate = false;
LogUtils.d(Logging.LOG_TAG, "Upsync skipped; mailbox changed, id=" + messageId);
} else {
@ -1145,7 +1144,7 @@ public class ImapService extends Service {
* @param oldMailbox The local trash mailbox
* @param oldMessage The message that was deleted from the trash
*/
private static void processPendingDeleteFromTrash(Context context, Store remoteStore,
private static void processPendingDeleteFromTrash(Store remoteStore,
Account account, Mailbox oldMailbox, EmailContent.Message oldMessage)
throws MessagingException {
@ -1311,8 +1310,8 @@ public class ImapService extends Service {
}
}
private int searchMailboxImpl(final Context context, long accountId, SearchParams searchParams,
final long destMailboxId) throws MessagingException {
private static int searchMailboxImpl(final Context context, final long accountId,
final SearchParams searchParams, final long destMailboxId) throws MessagingException {
final Account account = Account.restoreAccountWithId(context, accountId);
final Mailbox mailbox = Mailbox.restoreMailboxWithId(context, searchParams.mMailboxId);
final Mailbox destMailbox = Mailbox.restoreMailboxWithId(context, destMailboxId);

View File

@ -59,8 +59,8 @@ public class PopImapSyncAdapterService extends Service {
@Override
public void onPerformSync(android.accounts.Account account, Bundle extras,
String authority, ContentProviderClient provider, SyncResult syncResult) {
PopImapSyncAdapterService.performSync(getContext(), account, extras, authority,
provider, syncResult);
PopImapSyncAdapterService.performSync(getContext(), account, extras, provider,
syncResult);
}
}
@ -156,8 +156,7 @@ public class PopImapSyncAdapterService extends Service {
* Partial integration with system SyncManager; we initiate manual syncs upon request
*/
private static void performSync(Context context, android.accounts.Account account,
Bundle extras, String authority, ContentProviderClient provider,
SyncResult syncResult) {
Bundle extras, ContentProviderClient provider, SyncResult syncResult) {
// Find an EmailProvider account with the Account's email address
Cursor c = null;
try {
@ -198,7 +197,6 @@ public class PopImapSyncAdapterService extends Service {
LogUtils.d(TAG, extras.toString());
long mailboxId =
extras.getLong(Mailbox.SYNC_EXTRA_MAILBOX_ID, Mailbox.NO_MAILBOX);
boolean isInbox = false;
if (mailboxId == Mailbox.NO_MAILBOX) {
// Update folders.
EmailServiceProxy service =
@ -206,7 +204,6 @@ public class PopImapSyncAdapterService extends Service {
service.updateFolderList(acct.mId);
mailboxId = Mailbox.findMailboxOfType(context, acct.mId,
Mailbox.TYPE_INBOX);
isInbox = true;
}
if (mailboxId == Mailbox.NO_MAILBOX) return;
boolean uiRefresh =