Throw some more final keywords in

This commit is contained in:
Daniel Martí 2015-04-30 20:40:19 +02:00
parent 26894fcb01
commit 7b4cee35c7
6 changed files with 22 additions and 24 deletions

View File

@ -160,7 +160,7 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
} }
public int getProxyPort() { public int getProxyPort() {
String port = preferences.getString(PREF_PROXY_PORT, String.valueOf(DEFAULT_PROXY_PORT)); final String port = preferences.getString(PREF_PROXY_PORT, String.valueOf(DEFAULT_PROXY_PORT));
try { try {
return Integer.parseInt(port); return Integer.parseInt(port);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
@ -194,7 +194,7 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
* Updated... * Updated...
*/ */
public Date calcMaxHistory() { public Date calcMaxHistory() {
String daysString = preferences.getString(PREF_UPD_HISTORY, Integer.toString(DEFAULT_UPD_HISTORY)); final String daysString = preferences.getString(PREF_UPD_HISTORY, Integer.toString(DEFAULT_UPD_HISTORY));
int maxHistoryDays; int maxHistoryDays;
try { try {
maxHistoryDays = Integer.parseInt(daysString); maxHistoryDays = Integer.parseInt(daysString);
@ -307,7 +307,7 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
public static void setup(Context context) { public static void setup(Context context) {
if (instance != null) { if (instance != null) {
String error = "Attempted to reinitialize preferences after it " + final String error = "Attempted to reinitialize preferences after it " +
"has already been initialized in FDroidApp"; "has already been initialized in FDroidApp";
Log.e(TAG, error); Log.e(TAG, error);
throw new RuntimeException(error); throw new RuntimeException(error);
@ -317,7 +317,7 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
public static Preferences get() { public static Preferences get() {
if (instance == null) { if (instance == null) {
String error = "Attempted to access preferences before it " + final String error = "Attempted to access preferences before it " +
"has been initialized in FDroidApp"; "has been initialized in FDroidApp";
Log.e(TAG, error); Log.e(TAG, error);
throw new RuntimeException(error); throw new RuntimeException(error);

View File

@ -97,7 +97,7 @@ public class RepoXMLHandler extends DefaultHandler {
super.endElement(uri, localName, qName); super.endElement(uri, localName, qName);
final String curel = localName; final String curel = localName;
String str = curchars.toString().trim(); final String str = curchars.toString().trim();
if (curel.equals("application") && curapp != null) { if (curel.equals("application") && curapp != null) {
apps.add(curapp); apps.add(curapp);

View File

@ -106,9 +106,7 @@ public class App extends ValueObject implements Comparable<App> {
return name.compareToIgnoreCase(app.name); return name.compareToIgnoreCase(app.name);
} }
public App() { public App() { }
}
public App(Cursor cursor) { public App(Cursor cursor) {
@ -254,7 +252,7 @@ public class App extends ValueObject implements Comparable<App> {
this.name = (String) appInfo.loadLabel(pm); this.name = (String) appInfo.loadLabel(pm);
SanitizedFile apkFile = SanitizedFile.knownSanitized(appInfo.publicSourceDir); final SanitizedFile apkFile = SanitizedFile.knownSanitized(appInfo.publicSourceDir);
final Apk apk = new Apk(); final Apk apk = new Apk();
apk.version = packageInfo.versionName; apk.version = packageInfo.versionName;
apk.vercode = packageInfo.versionCode; apk.vercode = packageInfo.versionCode;
@ -274,7 +272,7 @@ public class App extends ValueObject implements Comparable<App> {
final FeatureInfo[] features = packageInfo.reqFeatures; final FeatureInfo[] features = packageInfo.reqFeatures;
if (features != null && features.length > 0) { if (features != null && features.length > 0) {
List<String> featureNames = new ArrayList<>(features.length); final List<String> featureNames = new ArrayList<>(features.length);
for (FeatureInfo feature : features) { for (FeatureInfo feature : features) {
featureNames.add(feature.name); featureNames.add(feature.name);
@ -287,8 +285,8 @@ public class App extends ValueObject implements Comparable<App> {
byte[] rawCertBytes; byte[] rawCertBytes;
JarFile apkJar = new JarFile(apkFile); final JarFile apkJar = new JarFile(apkFile);
JarEntry aSignedEntry = (JarEntry) apkJar.getEntry("AndroidManifest.xml"); final JarEntry aSignedEntry = (JarEntry) apkJar.getEntry("AndroidManifest.xml");
if (aSignedEntry == null) { if (aSignedEntry == null) {
apkJar.close(); apkJar.close();
@ -300,7 +298,7 @@ public class App extends ValueObject implements Comparable<App> {
// details, check out https://gitlab.com/fdroid/fdroidclient/issues/111. // details, check out https://gitlab.com/fdroid/fdroidclient/issues/111.
try { try {
FDroidApp.disableSpongyCastleOnLollipop(); FDroidApp.disableSpongyCastleOnLollipop();
InputStream tmpIn = apkJar.getInputStream(aSignedEntry); final InputStream tmpIn = apkJar.getInputStream(aSignedEntry);
byte[] buff = new byte[2048]; byte[] buff = new byte[2048];
while (tmpIn.read(buff, 0, buff.length) != -1) { while (tmpIn.read(buff, 0, buff.length) != -1) {
/* /*
@ -316,7 +314,7 @@ public class App extends ValueObject implements Comparable<App> {
throw new CertificateEncodingException("No Certificates found!"); throw new CertificateEncodingException("No Certificates found!");
} }
Certificate signer = aSignedEntry.getCertificates()[0]; final Certificate signer = aSignedEntry.getCertificates()[0];
rawCertBytes = signer.getEncoded(); rawCertBytes = signer.getEncoded();
} finally { } finally {
FDroidApp.enableSpongyCastleOnLollipop(); FDroidApp.enableSpongyCastleOnLollipop();
@ -332,7 +330,7 @@ public class App extends ValueObject implements Comparable<App> {
* if I'm right... If I'm not right, I really don't know! see lines * if I'm right... If I'm not right, I really don't know! see lines
* 67->75 in getsig.java bundled with Fdroidserver * 67->75 in getsig.java bundled with Fdroidserver
*/ */
byte[] fdroidSig = new byte[rawCertBytes.length * 2]; final byte[] fdroidSig = new byte[rawCertBytes.length * 2];
for (int j = 0; j < rawCertBytes.length; j++) { for (int j = 0; j < rawCertBytes.length; j++) {
byte v = rawCertBytes[j]; byte v = rawCertBytes[j];
int d = (v >> 4) & 0xF; int d = (v >> 4) & 0xF;
@ -356,7 +354,7 @@ public class App extends ValueObject implements Comparable<App> {
if (TextUtils.isEmpty(this.installedApk.sig)) if (TextUtils.isEmpty(this.installedApk.sig))
return false; return false;
File apkFile = this.installedApk.installedFile; final File apkFile = this.installedApk.installedFile;
if (apkFile == null || !apkFile.canRead()) if (apkFile == null || !apkFile.canRead())
return false; return false;
@ -365,7 +363,7 @@ public class App extends ValueObject implements Comparable<App> {
public ContentValues toContentValues() { public ContentValues toContentValues() {
ContentValues values = new ContentValues(); final ContentValues values = new ContentValues();
values.put(AppProvider.DataColumns.APP_ID, id); values.put(AppProvider.DataColumns.APP_ID, id);
values.put(AppProvider.DataColumns.NAME, name); values.put(AppProvider.DataColumns.NAME, name);
values.put(AppProvider.DataColumns.SUMMARY, summary); values.put(AppProvider.DataColumns.SUMMARY, summary);

View File

@ -108,7 +108,7 @@ public class AppProvider extends FDroidProvider {
} }
cursor.close(); cursor.close();
} }
List<String> categories = new ArrayList<>(categorySet); final List<String> categories = new ArrayList<>(categorySet);
Collections.sort(categories); Collections.sort(categories);
// Populate the category list with the real categories, and the // Populate the category list with the real categories, and the

View File

@ -135,7 +135,7 @@ abstract public class RepoUpdater {
File indexFile = null; File indexFile = null;
try { try {
Downloader downloader = downloadIndex(); final Downloader downloader = downloadIndex();
hasChanged = downloader.hasChanged(); hasChanged = downloader.hasChanged();
if (hasChanged) { if (hasChanged) {
@ -144,9 +144,9 @@ abstract public class RepoUpdater {
indexFile = getIndexFromFile(downloadedFile); indexFile = getIndexFromFile(downloadedFile);
// Process the index... // Process the index...
SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); final SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
XMLReader reader = parser.getXMLReader(); final XMLReader reader = parser.getXMLReader();
RepoXMLHandler handler = new RepoXMLHandler(repo, progressListener); final RepoXMLHandler handler = new RepoXMLHandler(repo, progressListener);
if (progressListener != null) { if (progressListener != null) {
// Only bother spending the time to count the expected apps // Only bother spending the time to count the expected apps

View File

@ -28,14 +28,14 @@ public class SignedRepoUpdater extends RepoUpdater {
} }
private boolean verifyCerts(JarEntry item) throws UpdateException { private boolean verifyCerts(JarEntry item) throws UpdateException {
Certificate[] certs = item.getCertificates(); final Certificate[] certs = item.getCertificates();
if (certs == null || certs.length == 0) { if (certs == null || certs.length == 0) {
throw new UpdateException(repo, "No signature found in index"); throw new UpdateException(repo, "No signature found in index");
} }
Log.d(TAG, "Index has " + certs.length + " signature(s)"); Log.d(TAG, "Index has " + certs.length + " signature(s)");
boolean match = false; boolean match = false;
for (Certificate cert : certs) { for (final Certificate cert : certs) {
String certdata = Hasher.hex(cert); String certdata = Hasher.hex(cert);
if (repo.pubkey == null && repo.fingerprint != null) { if (repo.pubkey == null && repo.fingerprint != null) {
String certFingerprint = Utils.calcFingerprint(cert); String certFingerprint = Utils.calcFingerprint(cert);