Bug 1411654 - Part 5b: Work through WrongConstant lint issues. r=mcomella
MozReview-Commit-ID: 6zJ7EMu9rgO
--- a/mobile/android/app/lint.xml
+++ b/mobile/android/app/lint.xml
@@ -33,17 +33,16 @@
<issue id="Instantiatable" severity="warning" />
<issue id="LongLogTag" severity="warning" />
<issue id="MissingPermission" severity="warning" />
<issue id="OnClick" severity="warning" />
<issue id="ReferenceType" severity="warning" />
<issue id="ResourceAsColor" severity="warning" />
<issue id="ResourceType" severity="warning" />
<issue id="ValidFragment" severity="warning" />
- <issue id="WrongConstant" severity="warning" />
<!-- New Android-Gradle lint integration regressed this check. -->
<issue id="MissingRegistered" severity="warning" />
<!-- Fixes are in progress but we would like to block future candidates.
The ** in the path are wildcards. We need these wildcards to not change our code structure.
See: http://stackoverflow.com/questions/43994420/what-path-is-the-issue-ignore-path-element-in-lint-xml-relative-to -->
<issue id="NewApi" severity="error">
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/ActivityStreamTelemetry.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/ActivityStreamTelemetry.java
@@ -1,15 +1,16 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.activitystream;
+import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.support.annotation.NonNull;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -211,18 +212,17 @@ public class ActivityStreamTelemetry {
case BrowserContract.TopSites.TYPE_SUGGESTED:
this.set(Contract.SOURCE_SUBTYPE, Contract.SUBTYPE_SUGGESTED);
break;
case BrowserContract.TopSites.TYPE_TOP:
this.set(Contract.SOURCE_SUBTYPE, Contract.SUBTYPE_TOP);
break;
// While we also have a "blank" type, it is not used by Activity Stream.
case BrowserContract.TopSites.TYPE_BLANK:
- default:
- throw new IllegalStateException("Unknown top site type: " + topSite.getType());
+ throw new IllegalStateException("Unknown top site type :" + (int) topSite.getType());
}
return this;
}
public String build() {
return data.toString();
}
--- a/mobile/android/base/java/org/mozilla/gecko/dlc/BaseAction.java
+++ b/mobile/android/base/java/org/mozilla/gecko/dlc/BaseAction.java
@@ -1,15 +1,16 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.dlc;
+import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.IntDef;
import android.util.Log;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.background.nativecode.NativeCrypto;
import org.mozilla.gecko.dlc.catalog.DownloadContent;
import org.mozilla.gecko.dlc.catalog.DownloadContentCatalog;
@@ -95,17 +96,17 @@ public abstract class BaseAction {
protected File getDestinationFile(Context context, DownloadContent content)
throws UnrecoverableDownloadContentException, RecoverableDownloadContentException {
File destinationDirectory;
if (content.isFont()) {
destinationDirectory = new File(context.getApplicationInfo().dataDir, "fonts");
} else if (content.isHyphenationDictionary()) {
destinationDirectory = new File(context.getApplicationInfo().dataDir, "hyphenation");
} else {
- throw new UnrecoverableDownloadContentException("Can't determine destination for kind: " + content.getKind());
+ throw new UnrecoverableDownloadContentException("Can't determine destination for kind: " + (String) content.getKind());
}
if (!destinationDirectory.exists() && !destinationDirectory.mkdirs()) {
throw new RecoverableDownloadContentException(RecoverableDownloadContentException.DISK_IO,
"Destination directory does not exist and cannot be created");
}
return new File(destinationDirectory, content.getFilename());
--- a/mobile/android/base/java/org/mozilla/gecko/dlc/DownloadAction.java
+++ b/mobile/android/base/java/org/mozilla/gecko/dlc/DownloadAction.java
@@ -1,15 +1,16 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.dlc;
+import android.annotation.SuppressLint;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.support.v4.net.ConnectivityManagerCompat;
import android.util.Log;
import org.mozilla.gecko.dlc.catalog.DownloadContent;
import org.mozilla.gecko.dlc.catalog.DownloadContentCatalog;
@@ -101,17 +102,17 @@ public class DownloadAction extends Base
if (!verify(temporaryFile, content.getDownloadChecksum())) {
Log.w(LOGTAG, "Wrong checksum after download, content=" + content.getId());
temporaryFile.delete();
DownloadContentTelemetry.eventDownloadFailure(content, DownloadContentTelemetry.ERROR_CHECKSUM);
continue;
}
if (!content.isAssetArchive()) {
- Log.e(LOGTAG, "Downloaded content is not of type 'asset-archive': " + content.getType());
+ Log.e(LOGTAG, "Downloaded content is not of type 'asset-archive': " + (String) content.getType());
temporaryFile.delete();
DownloadContentTelemetry.eventDownloadFailure(content, DownloadContentTelemetry.ERROR_LOGIC);
continue;
}
extract(temporaryFile, destinationFile, content.getChecksum());
catalog.markAsDownloaded(content);
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -1155,17 +1155,17 @@ if CONFIG['MOZ_INSTALL_TRACKING']:
gbjar.extra_jars += [CONFIG['ANDROID_APPCOMPAT_V7_AAR_LIB']]
gbjar.extra_jars += [CONFIG['ANDROID_SUPPORT_VECTOR_DRAWABLE_AAR_LIB']]
gbjar.extra_jars += [CONFIG['ANDROID_ANIMATED_VECTOR_DRAWABLE_AAR_LIB']]
gbjar.extra_jars += [CONFIG['ANDROID_CARDVIEW_V7_AAR_LIB']]
gbjar.extra_jars += [CONFIG['ANDROID_DESIGN_AAR_LIB']]
gbjar.extra_jars += [CONFIG['ANDROID_RECYCLERVIEW_V7_AAR_LIB']]
gbjar.extra_jars += [CONFIG['ANDROID_CUSTOMTABS_AAR_LIB']]
-gbjar.javac_flags += ['-Xlint:all,-deprecation,-fallthrough', '-J-Xmx512m', '-J-Xms128m']
+gbjar.javac_flags += ['-Xlint:all,-deprecation,-fallthrough,-cast', '-J-Xmx512m', '-J-Xms128m']
# gecko-thirdparty is a good place to put small independent libraries
gtjar = add_java_jar('gecko-thirdparty')
gtjar.sources += [ thirdparty_source_dir + f for f in [
'com/booking/rtlviewpager/PagerAdapterWrapper.java',
'com/booking/rtlviewpager/RtlViewPager.java',
'com/jakewharton/disklrucache/DiskLruCache.java',
'com/jakewharton/disklrucache/StrictLineReader.java',