Throw some more final keywords in
This commit is contained in:
parent
26894fcb01
commit
7b4cee35c7
@ -160,7 +160,7 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
|
||||
}
|
||||
|
||||
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 {
|
||||
return Integer.parseInt(port);
|
||||
} catch (NumberFormatException e) {
|
||||
@ -194,7 +194,7 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
|
||||
* Updated...
|
||||
*/
|
||||
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;
|
||||
try {
|
||||
maxHistoryDays = Integer.parseInt(daysString);
|
||||
@ -307,7 +307,7 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
|
||||
|
||||
public static void setup(Context context) {
|
||||
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";
|
||||
Log.e(TAG, error);
|
||||
throw new RuntimeException(error);
|
||||
@ -317,7 +317,7 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
|
||||
|
||||
public static Preferences get() {
|
||||
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";
|
||||
Log.e(TAG, error);
|
||||
throw new RuntimeException(error);
|
||||
|
@ -97,7 +97,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
|
||||
super.endElement(uri, localName, qName);
|
||||
final String curel = localName;
|
||||
String str = curchars.toString().trim();
|
||||
final String str = curchars.toString().trim();
|
||||
|
||||
if (curel.equals("application") && curapp != null) {
|
||||
apps.add(curapp);
|
||||
|
@ -106,9 +106,7 @@ public class App extends ValueObject implements Comparable<App> {
|
||||
return name.compareToIgnoreCase(app.name);
|
||||
}
|
||||
|
||||
public App() {
|
||||
|
||||
}
|
||||
public App() { }
|
||||
|
||||
public App(Cursor cursor) {
|
||||
|
||||
@ -254,7 +252,7 @@ public class App extends ValueObject implements Comparable<App> {
|
||||
|
||||
this.name = (String) appInfo.loadLabel(pm);
|
||||
|
||||
SanitizedFile apkFile = SanitizedFile.knownSanitized(appInfo.publicSourceDir);
|
||||
final SanitizedFile apkFile = SanitizedFile.knownSanitized(appInfo.publicSourceDir);
|
||||
final Apk apk = new Apk();
|
||||
apk.version = packageInfo.versionName;
|
||||
apk.vercode = packageInfo.versionCode;
|
||||
@ -274,7 +272,7 @@ public class App extends ValueObject implements Comparable<App> {
|
||||
final FeatureInfo[] features = packageInfo.reqFeatures;
|
||||
|
||||
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) {
|
||||
featureNames.add(feature.name);
|
||||
@ -287,8 +285,8 @@ public class App extends ValueObject implements Comparable<App> {
|
||||
|
||||
byte[] rawCertBytes;
|
||||
|
||||
JarFile apkJar = new JarFile(apkFile);
|
||||
JarEntry aSignedEntry = (JarEntry) apkJar.getEntry("AndroidManifest.xml");
|
||||
final JarFile apkJar = new JarFile(apkFile);
|
||||
final JarEntry aSignedEntry = (JarEntry) apkJar.getEntry("AndroidManifest.xml");
|
||||
|
||||
if (aSignedEntry == null) {
|
||||
apkJar.close();
|
||||
@ -300,7 +298,7 @@ public class App extends ValueObject implements Comparable<App> {
|
||||
// details, check out https://gitlab.com/fdroid/fdroidclient/issues/111.
|
||||
try {
|
||||
FDroidApp.disableSpongyCastleOnLollipop();
|
||||
InputStream tmpIn = apkJar.getInputStream(aSignedEntry);
|
||||
final InputStream tmpIn = apkJar.getInputStream(aSignedEntry);
|
||||
byte[] buff = new byte[2048];
|
||||
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!");
|
||||
}
|
||||
|
||||
Certificate signer = aSignedEntry.getCertificates()[0];
|
||||
final Certificate signer = aSignedEntry.getCertificates()[0];
|
||||
rawCertBytes = signer.getEncoded();
|
||||
} finally {
|
||||
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
|
||||
* 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++) {
|
||||
byte v = rawCertBytes[j];
|
||||
int d = (v >> 4) & 0xF;
|
||||
@ -356,7 +354,7 @@ public class App extends ValueObject implements Comparable<App> {
|
||||
if (TextUtils.isEmpty(this.installedApk.sig))
|
||||
return false;
|
||||
|
||||
File apkFile = this.installedApk.installedFile;
|
||||
final File apkFile = this.installedApk.installedFile;
|
||||
if (apkFile == null || !apkFile.canRead())
|
||||
return false;
|
||||
|
||||
@ -365,7 +363,7 @@ public class App extends ValueObject implements Comparable<App> {
|
||||
|
||||
public ContentValues toContentValues() {
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
final ContentValues values = new ContentValues();
|
||||
values.put(AppProvider.DataColumns.APP_ID, id);
|
||||
values.put(AppProvider.DataColumns.NAME, name);
|
||||
values.put(AppProvider.DataColumns.SUMMARY, summary);
|
||||
|
@ -108,7 +108,7 @@ public class AppProvider extends FDroidProvider {
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
List<String> categories = new ArrayList<>(categorySet);
|
||||
final List<String> categories = new ArrayList<>(categorySet);
|
||||
Collections.sort(categories);
|
||||
|
||||
// Populate the category list with the real categories, and the
|
||||
|
@ -135,7 +135,7 @@ abstract public class RepoUpdater {
|
||||
File indexFile = null;
|
||||
try {
|
||||
|
||||
Downloader downloader = downloadIndex();
|
||||
final Downloader downloader = downloadIndex();
|
||||
hasChanged = downloader.hasChanged();
|
||||
|
||||
if (hasChanged) {
|
||||
@ -144,9 +144,9 @@ abstract public class RepoUpdater {
|
||||
indexFile = getIndexFromFile(downloadedFile);
|
||||
|
||||
// Process the index...
|
||||
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
|
||||
XMLReader reader = parser.getXMLReader();
|
||||
RepoXMLHandler handler = new RepoXMLHandler(repo, progressListener);
|
||||
final SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
|
||||
final XMLReader reader = parser.getXMLReader();
|
||||
final RepoXMLHandler handler = new RepoXMLHandler(repo, progressListener);
|
||||
|
||||
if (progressListener != null) {
|
||||
// Only bother spending the time to count the expected apps
|
||||
|
@ -28,14 +28,14 @@ public class SignedRepoUpdater extends RepoUpdater {
|
||||
}
|
||||
|
||||
private boolean verifyCerts(JarEntry item) throws UpdateException {
|
||||
Certificate[] certs = item.getCertificates();
|
||||
final Certificate[] certs = item.getCertificates();
|
||||
if (certs == null || certs.length == 0) {
|
||||
throw new UpdateException(repo, "No signature found in index");
|
||||
}
|
||||
|
||||
Log.d(TAG, "Index has " + certs.length + " signature(s)");
|
||||
boolean match = false;
|
||||
for (Certificate cert : certs) {
|
||||
for (final Certificate cert : certs) {
|
||||
String certdata = Hasher.hex(cert);
|
||||
if (repo.pubkey == null && repo.fingerprint != null) {
|
||||
String certFingerprint = Utils.calcFingerprint(cert);
|
||||
|
Loading…
x
Reference in New Issue
Block a user