checkstyle: obey NeedBraces on multi-line stmts
We still allow them in single-line statements, like: if (foo) bar; for (int i : ints) bar; Everything else should use braces to help readability and avoid silly human mistakes that might result in bugs. These changes were completely automated via a python script.
This commit is contained in:
parent
ea31ed3079
commit
a6b804e93a
@ -468,10 +468,11 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
new IntentFilter(Downloader.LOCAL_ACTION_PROGRESS));
|
||||
downloadHandler.setProgressListener(this);
|
||||
|
||||
if (downloadHandler.getTotalBytes() == 0)
|
||||
if (downloadHandler.getTotalBytes() == 0) {
|
||||
mHeaderFragment.startProgress();
|
||||
else
|
||||
} else {
|
||||
mHeaderFragment.updateProgress(downloadHandler.getBytesRead(), downloadHandler.getTotalBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -523,9 +524,10 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
private final BroadcastReceiver downloaderProgressReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (mHeaderFragment != null)
|
||||
if (mHeaderFragment != null) {
|
||||
mHeaderFragment.updateProgress(intent.getIntExtra(Downloader.EXTRA_BYTES_READ, -1),
|
||||
intent.getIntExtra(Downloader.EXTRA_TOTAL_BYTES, -1));
|
||||
intent.getIntExtra(Downloader.EXTRA_TOTAL_BYTES, -1));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -618,8 +620,9 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
menu.clear();
|
||||
if (app == null)
|
||||
if (app == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mPm.getLaunchIntentForPackage(app.packageName) != null && app.canAndWantToUpdate()) {
|
||||
MenuItemCompat.setShowAsAction(menu.add(
|
||||
@ -773,10 +776,11 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
return true;
|
||||
|
||||
case IGNORETHIS:
|
||||
if (app.ignoreThisUpdate >= app.suggestedVercode)
|
||||
if (app.ignoreThisUpdate >= app.suggestedVercode) {
|
||||
app.ignoreThisUpdate = 0;
|
||||
else
|
||||
} else {
|
||||
app.ignoreThisUpdate = app.suggestedVercode;
|
||||
}
|
||||
item.setChecked(app.ignoreThisUpdate > 0);
|
||||
return true;
|
||||
|
||||
@ -803,8 +807,9 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
}
|
||||
|
||||
// Ignore call if another download is running.
|
||||
if (downloadHandler != null && !downloadHandler.isComplete())
|
||||
if (downloadHandler != null && !downloadHandler.isComplete()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String repoaddress = getRepoAddress(apk);
|
||||
if (repoaddress == null) return;
|
||||
@ -988,10 +993,11 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
switch (event.type) {
|
||||
case ApkDownloader.EVENT_ERROR:
|
||||
final int res;
|
||||
if (event.getData().getInt(ApkDownloader.EVENT_DATA_ERROR_TYPE) == ApkDownloader.ERROR_HASH_MISMATCH)
|
||||
if (event.getData().getInt(ApkDownloader.EVENT_DATA_ERROR_TYPE) == ApkDownloader.ERROR_HASH_MISMATCH) {
|
||||
res = R.string.corrupt_download;
|
||||
else
|
||||
} else {
|
||||
res = R.string.details_notinstalled;
|
||||
}
|
||||
// this must be on the main UI thread
|
||||
Toast.makeText(this, res, Toast.LENGTH_LONG).show();
|
||||
cleanUpFinishedDownload();
|
||||
@ -1004,8 +1010,9 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
}
|
||||
|
||||
if (finished) {
|
||||
if (mHeaderFragment != null)
|
||||
if (mHeaderFragment != null) {
|
||||
mHeaderFragment.removeProgress();
|
||||
}
|
||||
downloadHandler = null;
|
||||
}
|
||||
}
|
||||
@ -1215,10 +1222,11 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
|
||||
// App ID
|
||||
final TextView packageNameView = (TextView) view.findViewById(R.id.package_name);
|
||||
if (prefs.expertMode())
|
||||
if (prefs.expertMode()) {
|
||||
packageNameView.setText(app.packageName);
|
||||
else
|
||||
} else {
|
||||
packageNameView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Summary
|
||||
final TextView summaryView = (TextView) view.findViewById(R.id.summary);
|
||||
@ -1232,73 +1240,83 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
|
||||
// Website button
|
||||
View tv = view.findViewById(R.id.website);
|
||||
if (!TextUtils.isEmpty(app.webURL))
|
||||
if (!TextUtils.isEmpty(app.webURL)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
else
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Email button
|
||||
tv = view.findViewById(R.id.email);
|
||||
if (!TextUtils.isEmpty(app.email))
|
||||
if (!TextUtils.isEmpty(app.email)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
else
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Source button
|
||||
tv = view.findViewById(R.id.source);
|
||||
if (!TextUtils.isEmpty(app.sourceURL))
|
||||
if (!TextUtils.isEmpty(app.sourceURL)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
else
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Issues button
|
||||
tv = view.findViewById(R.id.issues);
|
||||
if (!TextUtils.isEmpty(app.trackerURL))
|
||||
if (!TextUtils.isEmpty(app.trackerURL)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
else
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Changelog button
|
||||
tv = view.findViewById(R.id.changelog);
|
||||
if (!TextUtils.isEmpty(app.changelogURL))
|
||||
if (!TextUtils.isEmpty(app.changelogURL)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
else
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Donate button
|
||||
tv = view.findViewById(R.id.donate);
|
||||
if (!TextUtils.isEmpty(app.donateURL))
|
||||
if (!TextUtils.isEmpty(app.donateURL)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
else
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Bitcoin
|
||||
tv = view.findViewById(R.id.bitcoin);
|
||||
if (!TextUtils.isEmpty(app.bitcoinAddr))
|
||||
if (!TextUtils.isEmpty(app.bitcoinAddr)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
else
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Litecoin
|
||||
tv = view.findViewById(R.id.litecoin);
|
||||
if (!TextUtils.isEmpty(app.litecoinAddr))
|
||||
if (!TextUtils.isEmpty(app.litecoinAddr)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
else
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Flattr
|
||||
tv = view.findViewById(R.id.flattr);
|
||||
if (!TextUtils.isEmpty(app.flattrID))
|
||||
if (!TextUtils.isEmpty(app.flattrID)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
else
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Categories TextView
|
||||
final TextView categories = (TextView) view.findViewById(R.id.categories);
|
||||
if (prefs.expertMode() && app.categories != null)
|
||||
if (prefs.expertMode() && app.categories != null) {
|
||||
categories.setText(app.categories.toString().replaceAll(",", ", "));
|
||||
else
|
||||
} else {
|
||||
categories.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
Apk curApk = null;
|
||||
for (int i = 0; i < getApks().getCount(); i++) {
|
||||
@ -1544,8 +1562,9 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AppDetails activity = (AppDetails) getActivity();
|
||||
if (activity == null || activity.downloadHandler == null)
|
||||
if (activity == null || activity.downloadHandler == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
activity.downloadHandler.cancel(true);
|
||||
activity.cleanUpFinishedDownload();
|
||||
|
@ -59,10 +59,11 @@ public class CompatibilityChecker extends Compatibility {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (final String abi : cpuAbis) {
|
||||
if (first)
|
||||
if (first) {
|
||||
first = false;
|
||||
else
|
||||
} else {
|
||||
builder.append(", ");
|
||||
}
|
||||
builder.append(abi);
|
||||
}
|
||||
cpuAbisDesc = builder.toString();
|
||||
|
@ -232,12 +232,14 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL
|
||||
|
||||
if (!TextUtils.isEmpty(query)) {
|
||||
// an old format for querying via packageName
|
||||
if (query.startsWith("pname:"))
|
||||
if (query.startsWith("pname:")) {
|
||||
packageName = query.split(":")[1];
|
||||
}
|
||||
|
||||
// sometimes, search URLs include pub: or other things before the query string
|
||||
if (query.contains(":"))
|
||||
if (query.contains(":")) {
|
||||
query = query.split(":")[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(packageName)) {
|
||||
|
@ -309,8 +309,9 @@ public class FDroidApp extends Application {
|
||||
}
|
||||
|
||||
public void sendViaBluetooth(Activity activity, int resultCode, String packageName) {
|
||||
if (resultCode == Activity.RESULT_CANCELED)
|
||||
if (resultCode == Activity.RESULT_CANCELED) {
|
||||
return;
|
||||
}
|
||||
String bluetoothPackageName = null;
|
||||
String className = null;
|
||||
boolean found = false;
|
||||
|
@ -124,14 +124,15 @@ public class Hasher {
|
||||
for (int i = 0; i < data.length(); i++) {
|
||||
char halfbyte = data.charAt(i);
|
||||
int value;
|
||||
if ('0' <= halfbyte && halfbyte <= '9')
|
||||
if ('0' <= halfbyte && halfbyte <= '9') {
|
||||
value = halfbyte - '0';
|
||||
else if ('a' <= halfbyte && halfbyte <= 'f')
|
||||
} else if ('a' <= halfbyte && halfbyte <= 'f') {
|
||||
value = halfbyte - 'a' + 10;
|
||||
else if ('A' <= halfbyte && halfbyte <= 'F')
|
||||
} else if ('A' <= halfbyte && halfbyte <= 'F') {
|
||||
value = halfbyte - 'A' + 10;
|
||||
else
|
||||
} else {
|
||||
throw new IllegalArgumentException("Bad hex digit");
|
||||
}
|
||||
rawdata[i / 2] += (byte) (i % 2 == 0 ? value << 4 : value);
|
||||
}
|
||||
return rawdata;
|
||||
|
@ -18,8 +18,9 @@ public class NfcHelper {
|
||||
|
||||
@TargetApi(14)
|
||||
private static NfcAdapter getAdapter(Context context) {
|
||||
if (Build.VERSION.SDK_INT < 14)
|
||||
if (Build.VERSION.SDK_INT < 14) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return NfcAdapter.getDefaultAdapter(context.getApplicationContext());
|
||||
}
|
||||
@ -38,8 +39,9 @@ public class NfcHelper {
|
||||
|
||||
@TargetApi(16)
|
||||
static void setAndroidBeam(Activity activity, String packageName) {
|
||||
if (Build.VERSION.SDK_INT < 16)
|
||||
if (Build.VERSION.SDK_INT < 16) {
|
||||
return;
|
||||
}
|
||||
PackageManager pm = activity.getPackageManager();
|
||||
NfcAdapter nfcAdapter = getAdapter(activity);
|
||||
if (nfcAdapter != null) {
|
||||
@ -58,11 +60,13 @@ public class NfcHelper {
|
||||
|
||||
@TargetApi(16)
|
||||
static void disableAndroidBeam(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT < 16)
|
||||
if (Build.VERSION.SDK_INT < 16) {
|
||||
return;
|
||||
}
|
||||
NfcAdapter nfcAdapter = getAdapter(activity);
|
||||
if (nfcAdapter != null)
|
||||
if (nfcAdapter != null) {
|
||||
nfcAdapter.setBeamPushUris(null, activity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,10 +24,11 @@ public class NfcNotEnabledActivity extends ActionBarActivity {
|
||||
if (nfcAdapter == null) {
|
||||
return;
|
||||
}
|
||||
if (nfcAdapter.isEnabled())
|
||||
if (nfcAdapter.isEnabled()) {
|
||||
intent.setAction(Settings.ACTION_NFCSHARING_SETTINGS);
|
||||
else
|
||||
} else {
|
||||
intent.setAction(Settings.ACTION_NFC_SETTINGS);
|
||||
}
|
||||
}
|
||||
|
||||
// this API was added in 4.0 aka Ice Cream Sandwich
|
||||
|
@ -48,10 +48,11 @@ public class QrGenAsyncTask extends AsyncTask<String, Void, Void> {
|
||||
x = display.getWidth();
|
||||
y = display.getHeight();
|
||||
}
|
||||
if (x < y)
|
||||
if (x < y) {
|
||||
qrCodeDimension = x;
|
||||
else
|
||||
} else {
|
||||
qrCodeDimension = y;
|
||||
}
|
||||
Utils.debugLog(TAG, "generating QRCode Bitmap of " + qrCodeDimension + "x" + qrCodeDimension);
|
||||
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(qrData, null,
|
||||
Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), qrCodeDimension);
|
||||
|
@ -164,8 +164,9 @@ public class RepoUpdater {
|
||||
public void processDownloadedFile(File downloadedFile) throws UpdateException {
|
||||
InputStream indexInputStream = null;
|
||||
try {
|
||||
if (downloadedFile == null || !downloadedFile.exists())
|
||||
if (downloadedFile == null || !downloadedFile.exists()) {
|
||||
throw new UpdateException(repo, downloadedFile + " does not exist!");
|
||||
}
|
||||
|
||||
// Due to a bug in Android 5.0 Lollipop, the inclusion of spongycastle causes
|
||||
// breakage when verifying the signature of the downloaded .jar. For more
|
||||
@ -306,8 +307,9 @@ public class RepoUpdater {
|
||||
*/
|
||||
private void verifyAndStoreTOFUCerts(String certFromIndexXml, X509Certificate rawCertFromJar)
|
||||
throws SigningException {
|
||||
if (repo.pubkey != null)
|
||||
if (repo.pubkey != null) {
|
||||
return; // there is a repo.pubkey already, nothing to TOFU
|
||||
}
|
||||
|
||||
/* The first time a repo is added, it can be added with the signing certificate's
|
||||
* fingerprint. In that case, check that fingerprint against what is
|
||||
@ -348,8 +350,9 @@ public class RepoUpdater {
|
||||
// repo and repo.pubkey must be pre-loaded from the database
|
||||
if (TextUtils.isEmpty(repo.pubkey)
|
||||
|| TextUtils.isEmpty(certFromJar)
|
||||
|| TextUtils.isEmpty(certFromIndexXml))
|
||||
|| TextUtils.isEmpty(certFromIndexXml)) {
|
||||
throw new SigningException(repo, "A empty repo or signing certificate is invalid!");
|
||||
}
|
||||
|
||||
// though its called repo.pubkey, its actually a X509 certificate
|
||||
if (repo.pubkey.equals(certFromJar)
|
||||
|
@ -173,8 +173,9 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
protected static void sendStatus(Context context, int statusCode, String message, int progress) {
|
||||
Intent intent = new Intent(LOCAL_ACTION_STATUS);
|
||||
intent.putExtra(EXTRA_STATUS_CODE, statusCode);
|
||||
if (!TextUtils.isEmpty(message))
|
||||
if (!TextUtils.isEmpty(message)) {
|
||||
intent.putExtra(EXTRA_MESSAGE, message);
|
||||
}
|
||||
intent.putExtra(EXTRA_PROGRESS, progress);
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
||||
}
|
||||
@ -190,11 +191,13 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (TextUtils.isEmpty(action))
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!action.equals(Downloader.LOCAL_ACTION_PROGRESS))
|
||||
if (!action.equals(Downloader.LOCAL_ACTION_PROGRESS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String repoAddress = intent.getStringExtra(Downloader.EXTRA_ADDRESS);
|
||||
int downloadedSize = intent.getIntExtra(Downloader.EXTRA_BYTES_READ, -1);
|
||||
@ -220,11 +223,13 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (TextUtils.isEmpty(action))
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!action.equals(LOCAL_ACTION_STATUS))
|
||||
if (!action.equals(LOCAL_ACTION_STATUS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String message = intent.getStringExtra(EXTRA_MESSAGE);
|
||||
int resultCode = intent.getIntExtra(EXTRA_STATUS_CODE, -1);
|
||||
@ -317,8 +322,9 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
|
||||
// this could be cellular or wifi
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
if (activeNetwork == null)
|
||||
if (activeNetwork == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (activeNetwork.getType() != ConnectivityManager.TYPE_WIFI
|
||||
|
@ -275,38 +275,44 @@ public final class Utils {
|
||||
public static String formatFingerprint(Context context, String fingerprint) {
|
||||
if (TextUtils.isEmpty(fingerprint)
|
||||
|| fingerprint.length() != 64 // SHA-256 is 64 hex chars
|
||||
|| fingerprint.matches(".*[^0-9a-fA-F].*")) // its a hex string
|
||||
|| fingerprint.matches(".*[^0-9a-fA-F].*")) { // its a hex string
|
||||
return context.getString(R.string.bad_fingerprint);
|
||||
}
|
||||
String displayFP = fingerprint.substring(0, 2);
|
||||
for (int i = 2; i < fingerprint.length(); i = i + 2)
|
||||
for (int i = 2; i < fingerprint.length(); i = i + 2) {
|
||||
displayFP += " " + fingerprint.substring(i, i + 2);
|
||||
}
|
||||
return displayFP;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static Uri getLocalRepoUri(Repo repo) {
|
||||
if (TextUtils.isEmpty(repo.address))
|
||||
if (TextUtils.isEmpty(repo.address)) {
|
||||
return Uri.parse("http://wifi-not-enabled");
|
||||
}
|
||||
Uri uri = Uri.parse(repo.address);
|
||||
Uri.Builder b = uri.buildUpon();
|
||||
if (!TextUtils.isEmpty(repo.fingerprint))
|
||||
if (!TextUtils.isEmpty(repo.fingerprint)) {
|
||||
b.appendQueryParameter("fingerprint", repo.fingerprint);
|
||||
}
|
||||
String scheme = Preferences.get().isLocalRepoHttpsEnabled() ? "https" : "http";
|
||||
b.scheme(scheme);
|
||||
return b.build();
|
||||
}
|
||||
|
||||
public static Uri getSharingUri(Repo repo) {
|
||||
if (TextUtils.isEmpty(repo.address))
|
||||
if (TextUtils.isEmpty(repo.address)) {
|
||||
return Uri.parse("http://wifi-not-enabled");
|
||||
}
|
||||
Uri localRepoUri = getLocalRepoUri(repo);
|
||||
Uri.Builder b = localRepoUri.buildUpon();
|
||||
b.scheme(localRepoUri.getScheme().replaceFirst("http", "fdroidrepo"));
|
||||
b.appendQueryParameter("swap", "1");
|
||||
if (!TextUtils.isEmpty(FDroidApp.bssid)) {
|
||||
b.appendQueryParameter("bssid", FDroidApp.bssid);
|
||||
if (!TextUtils.isEmpty(FDroidApp.ssid))
|
||||
if (!TextUtils.isEmpty(FDroidApp.ssid)) {
|
||||
b.appendQueryParameter("ssid", FDroidApp.ssid);
|
||||
}
|
||||
}
|
||||
return b.build();
|
||||
}
|
||||
@ -350,8 +356,9 @@ public final class Utils {
|
||||
}
|
||||
|
||||
public static String calcFingerprint(Certificate cert) {
|
||||
if (cert == null)
|
||||
if (cert == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return calcFingerprint(cert.getEncoded());
|
||||
} catch (CertificateEncodingException e) {
|
||||
@ -360,8 +367,9 @@ public final class Utils {
|
||||
}
|
||||
|
||||
private static String calcFingerprint(byte[] key) {
|
||||
if (key == null)
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
if (key.length < 256) {
|
||||
Log.e(TAG, "key was shorter than 256 bytes (" + key.length + "), cannot be valid!");
|
||||
return null;
|
||||
@ -426,8 +434,9 @@ public final class Utils {
|
||||
}
|
||||
|
||||
public static CommaSeparatedList make(List<String> list) {
|
||||
if (list == null || list.isEmpty())
|
||||
if (list == null || list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (i > 0) {
|
||||
@ -439,8 +448,9 @@ public final class Utils {
|
||||
}
|
||||
|
||||
public static CommaSeparatedList make(String[] list) {
|
||||
if (list == null || list.length == 0)
|
||||
if (list == null || list.length == 0) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
if (i > 0) {
|
||||
@ -453,8 +463,9 @@ public final class Utils {
|
||||
|
||||
@Nullable
|
||||
public static CommaSeparatedList make(@Nullable String list) {
|
||||
if (TextUtils.isEmpty(list))
|
||||
if (TextUtils.isEmpty(list)) {
|
||||
return null;
|
||||
}
|
||||
return new CommaSeparatedList(list);
|
||||
}
|
||||
|
||||
@ -480,8 +491,9 @@ public final class Utils {
|
||||
|
||||
public boolean contains(String v) {
|
||||
for (final String s : this) {
|
||||
if (s.equals(v))
|
||||
if (s.equals(v)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -522,8 +534,9 @@ public final class Utils {
|
||||
|
||||
byte[] dataBytes = new byte[524288];
|
||||
int nread;
|
||||
while ((nread = bis.read(dataBytes)) != -1)
|
||||
while ((nread = bis.read(dataBytes)) != -1) {
|
||||
md.update(dataBytes, 0, nread);
|
||||
}
|
||||
|
||||
byte[] mdbytes = md.digest();
|
||||
return toHexString(mdbytes);
|
||||
@ -609,16 +622,18 @@ public final class Utils {
|
||||
XMLReader reader) {
|
||||
switch (tag) {
|
||||
case "ul":
|
||||
if (opening)
|
||||
if (opening) {
|
||||
listNum = -1;
|
||||
else
|
||||
} else {
|
||||
output.append('\n');
|
||||
}
|
||||
break;
|
||||
case "ol":
|
||||
if (opening)
|
||||
if (opening) {
|
||||
listNum = 1;
|
||||
else
|
||||
} else {
|
||||
output.append('\n');
|
||||
}
|
||||
break;
|
||||
case "li":
|
||||
if (opening) {
|
||||
|
@ -56,8 +56,9 @@ public class TabManager {
|
||||
FragmentTransaction ft) {
|
||||
int pos = tab.getPosition();
|
||||
pager.setCurrentItem(pos);
|
||||
if (pos == INDEX_CAN_UPDATE)
|
||||
if (pos == INDEX_CAN_UPDATE) {
|
||||
removeNotification(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -78,8 +79,9 @@ public class TabManager {
|
||||
if (actionBarSpinner != null) {
|
||||
actionBarSpinner.setSelection(index);
|
||||
}
|
||||
if (index == INDEX_CAN_UPDATE)
|
||||
if (index == INDEX_CAN_UPDATE) {
|
||||
removeNotification(1);
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshTabLabel(int index) {
|
||||
|
@ -250,20 +250,23 @@ public class App extends ValueObject implements Comparable<App> {
|
||||
Log.w(TAG, "Could not get app info: " + installerPackageName, e);
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(installerPackageLabel))
|
||||
if (TextUtils.isEmpty(installerPackageLabel)) {
|
||||
installerPackageLabel = installerPackageName;
|
||||
}
|
||||
|
||||
final CharSequence appDescription = appInfo.loadDescription(pm);
|
||||
if (TextUtils.isEmpty(appDescription))
|
||||
if (TextUtils.isEmpty(appDescription)) {
|
||||
this.summary = "(installed by " + installerPackageLabel + ")";
|
||||
else
|
||||
} else {
|
||||
this.summary = (String) appDescription.subSequence(0, 40);
|
||||
}
|
||||
this.packageName = appInfo.packageName;
|
||||
this.added = new Date(packageInfo.firstInstallTime);
|
||||
this.lastUpdated = new Date(packageInfo.lastUpdateTime);
|
||||
this.description = "<p>";
|
||||
if (!TextUtils.isEmpty(appDescription))
|
||||
if (!TextUtils.isEmpty(appDescription)) {
|
||||
this.description += appDescription + "\n";
|
||||
}
|
||||
this.description += "(installed by " + installerPackageLabel
|
||||
+ ", first installed on " + this.added
|
||||
+ ", last updated on " + this.lastUpdated + ")</p>";
|
||||
@ -358,14 +361,17 @@ public class App extends ValueObject implements Comparable<App> {
|
||||
|
||||
public boolean isValid() {
|
||||
if (TextUtils.isEmpty(this.name)
|
||||
|| TextUtils.isEmpty(this.packageName))
|
||||
|| TextUtils.isEmpty(this.packageName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.installedApk == null)
|
||||
if (this.installedApk == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(this.installedApk.sig))
|
||||
if (TextUtils.isEmpty(this.installedApk.sig)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final File apkFile = this.installedApk.installedFile;
|
||||
return !(apkFile == null || !apkFile.canRead());
|
||||
|
@ -350,10 +350,12 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
boolean nameExists = columnExists(db, TABLE_REPO, "name");
|
||||
boolean descriptionExists = columnExists(db, TABLE_REPO, "description");
|
||||
if (oldVersion < 21 && !(nameExists && descriptionExists)) {
|
||||
if (!nameExists)
|
||||
if (!nameExists) {
|
||||
db.execSQL("alter table " + TABLE_REPO + " add column name text");
|
||||
if (!descriptionExists)
|
||||
}
|
||||
if (!descriptionExists) {
|
||||
db.execSQL("alter table " + TABLE_REPO + " add column description text");
|
||||
}
|
||||
insertNameAndDescription(db, R.string.fdroid_repo_address,
|
||||
R.string.fdroid_repo_name, R.string.fdroid_repo_description);
|
||||
insertNameAndDescription(db, R.string.fdroid_archive_address,
|
||||
@ -372,8 +374,9 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
*/
|
||||
private void addFingerprintToRepo(SQLiteDatabase db, int oldVersion) {
|
||||
if (oldVersion < 44) {
|
||||
if (!columnExists(db, TABLE_REPO, "fingerprint"))
|
||||
if (!columnExists(db, TABLE_REPO, "fingerprint")) {
|
||||
db.execSQL("alter table " + TABLE_REPO + " add column fingerprint text");
|
||||
}
|
||||
List<Repo> oldrepos = new ArrayList<>();
|
||||
Cursor cursor = db.query(TABLE_REPO,
|
||||
new String[] {"address", "pubkey"},
|
||||
|
@ -73,8 +73,9 @@ public final class LocalRepoKeyStore {
|
||||
private File keyStoreFile;
|
||||
|
||||
public static LocalRepoKeyStore get(Context context) throws InitException {
|
||||
if (localRepoKeyStore == null)
|
||||
if (localRepoKeyStore == null) {
|
||||
localRepoKeyStore = new LocalRepoKeyStore(context);
|
||||
}
|
||||
return localRepoKeyStore;
|
||||
}
|
||||
|
||||
@ -240,8 +241,9 @@ public final class LocalRepoKeyStore {
|
||||
public Certificate getCertificate() {
|
||||
try {
|
||||
Key key = keyStore.getKey(INDEX_CERT_ALIAS, "".toCharArray());
|
||||
if (key instanceof PrivateKey)
|
||||
if (key instanceof PrivateKey) {
|
||||
return keyStore.getCertificate(INDEX_CERT_ALIAS);
|
||||
}
|
||||
} catch (GeneralSecurityException e) {
|
||||
Log.e(TAG, "Unable to get certificate for local repo", e);
|
||||
}
|
||||
|
@ -96,8 +96,9 @@ public final class LocalRepoManager {
|
||||
|
||||
@NonNull
|
||||
public static LocalRepoManager get(Context context) {
|
||||
if (localRepoManager == null)
|
||||
if (localRepoManager == null) {
|
||||
localRepoManager = new LocalRepoManager(context);
|
||||
}
|
||||
return localRepoManager;
|
||||
}
|
||||
|
||||
@ -118,17 +119,23 @@ public final class LocalRepoManager {
|
||||
xmlIndexJar = new SanitizedFile(repoDir, "index.jar");
|
||||
xmlIndexJarUnsigned = new SanitizedFile(repoDir, "index.unsigned.jar");
|
||||
|
||||
if (!fdroidDir.exists())
|
||||
if (!fdroidDir.mkdir())
|
||||
if (!fdroidDir.exists()) {
|
||||
if (!fdroidDir.mkdir()) {
|
||||
Log.e(TAG, "Unable to create empty base: " + fdroidDir);
|
||||
}
|
||||
}
|
||||
|
||||
if (!repoDir.exists())
|
||||
if (!repoDir.mkdir())
|
||||
if (!repoDir.exists()) {
|
||||
if (!repoDir.mkdir()) {
|
||||
Log.e(TAG, "Unable to create empty repo: " + repoDir);
|
||||
}
|
||||
}
|
||||
|
||||
if (!iconsDir.exists())
|
||||
if (!iconsDir.mkdir())
|
||||
if (!iconsDir.exists()) {
|
||||
if (!iconsDir.mkdir()) {
|
||||
Log.e(TAG, "Unable to create icons folder: " + iconsDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String writeFdroidApkToWebroot() {
|
||||
@ -140,8 +147,9 @@ public final class LocalRepoManager {
|
||||
SanitizedFile apkFile = SanitizedFile.knownSanitized(appInfo.publicSourceDir);
|
||||
SanitizedFile fdroidApkLink = new SanitizedFile(webRoot, "fdroid.client.apk");
|
||||
attemptToDelete(fdroidApkLink);
|
||||
if (Utils.symlinkOrCopyFileQuietly(apkFile, fdroidApkLink))
|
||||
if (Utils.symlinkOrCopyFileQuietly(apkFile, fdroidApkLink)) {
|
||||
fdroidClientURL = "/" + fdroidApkLink.getName();
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Could not set up F-Droid apk in the webroot", e);
|
||||
}
|
||||
@ -249,8 +257,9 @@ public final class LocalRepoManager {
|
||||
|
||||
if (app.installedApk != null) {
|
||||
SanitizedFile outFile = new SanitizedFile(repoDir, app.installedApk.apkName);
|
||||
if (Utils.symlinkOrCopyFileQuietly(app.installedApk.installedFile, outFile))
|
||||
if (Utils.symlinkOrCopyFileQuietly(app.installedApk.installedFile, outFile)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// if we got here, something went wrong
|
||||
throw new IllegalStateException("Unable to copy APK");
|
||||
@ -261,8 +270,9 @@ public final class LocalRepoManager {
|
||||
App app;
|
||||
try {
|
||||
app = new App(context.getApplicationContext(), pm, packageName);
|
||||
if (!app.isValid())
|
||||
if (!app.isValid()) {
|
||||
return;
|
||||
}
|
||||
PackageInfo packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_META_DATA);
|
||||
app.icon = getIconFile(packageName, packageInfo.versionCode).getName();
|
||||
} catch (PackageManager.NameNotFoundException | CertificateEncodingException | IOException e) {
|
||||
@ -464,16 +474,18 @@ public final class LocalRepoManager {
|
||||
buff.append(',');
|
||||
}
|
||||
String out = buff.toString();
|
||||
if (!TextUtils.isEmpty(out))
|
||||
if (!TextUtils.isEmpty(out)) {
|
||||
serializer.text(out.substring(0, out.length() - 1));
|
||||
}
|
||||
}
|
||||
serializer.endTag("", "permissions");
|
||||
}
|
||||
|
||||
private void tagFeatures(App app) throws IOException {
|
||||
serializer.startTag("", "features");
|
||||
if (app.installedApk.features != null)
|
||||
if (app.installedApk.features != null) {
|
||||
serializer.text(Utils.CommaSeparatedList.str(app.installedApk.features));
|
||||
}
|
||||
serializer.endTag("", "features");
|
||||
}
|
||||
|
||||
|
@ -279,8 +279,9 @@ public class SwapService extends Service {
|
||||
values.put(RepoProvider.DataColumns.ADDRESS, peer.getRepoAddress());
|
||||
values.put(RepoProvider.DataColumns.DESCRIPTION, "");
|
||||
String fingerprint = peer.getFingerprint();
|
||||
if (!TextUtils.isEmpty(fingerprint))
|
||||
if (!TextUtils.isEmpty(fingerprint)) {
|
||||
values.put(RepoProvider.DataColumns.FINGERPRINT, peer.getFingerprint());
|
||||
}
|
||||
values.put(RepoProvider.DataColumns.IN_USE, true);
|
||||
values.put(RepoProvider.DataColumns.IS_SWAP, true);
|
||||
Uri uri = RepoProvider.Helper.insert(this, values);
|
||||
|
@ -152,8 +152,9 @@ class BonjourFinder extends PeerFinder implements ServiceListener {
|
||||
|
||||
isScanning = false;
|
||||
|
||||
if (jmdns == null)
|
||||
if (jmdns == null) {
|
||||
return;
|
||||
}
|
||||
jmdns.removeServiceListener(HTTP_SERVICE_TYPE, this);
|
||||
jmdns.removeServiceListener(HTTPS_SERVICE_TYPE, this);
|
||||
jmdns = null;
|
||||
|
@ -35,8 +35,9 @@ public final class BluetoothSwap extends SwapType {
|
||||
if (adapter == null) {
|
||||
return new NoBluetoothType(context);
|
||||
}
|
||||
if (mInstance == null)
|
||||
if (mInstance == null) {
|
||||
mInstance = new BluetoothSwap(context, adapter);
|
||||
}
|
||||
|
||||
return mInstance;
|
||||
}
|
||||
@ -59,8 +60,9 @@ public final class BluetoothSwap extends SwapType {
|
||||
@Override
|
||||
public synchronized void start() {
|
||||
|
||||
if (isConnected())
|
||||
if (isConnected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
receiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@ -90,8 +92,9 @@ public final class BluetoothSwap extends SwapType {
|
||||
server = null;
|
||||
}*/
|
||||
|
||||
if (server == null)
|
||||
if (server == null) {
|
||||
server = new BluetoothServer(this, context.getFilesDir());
|
||||
}
|
||||
|
||||
sendBroadcast(SwapService.EXTRA_STARTING);
|
||||
|
||||
@ -100,8 +103,9 @@ public final class BluetoothSwap extends SwapType {
|
||||
|
||||
/*
|
||||
Utils.debugLog(TAG, "Prefixing Bluetooth adapter name with " + BLUETOOTH_NAME_TAG + " to make it identifiable as a swap device.");
|
||||
if (!deviceBluetoothName.startsWith(BLUETOOTH_NAME_TAG))
|
||||
if (!deviceBluetoothName.startsWith(BLUETOOTH_NAME_TAG)) {
|
||||
adapter.setName(BLUETOOTH_NAME_TAG + deviceBluetoothName);
|
||||
}
|
||||
|
||||
if (!adapter.getName().startsWith(BLUETOOTH_NAME_TAG)) {
|
||||
Log.e(TAG, "Couldn't change the name of the Bluetooth adapter, it will not get recognized by other swap clients.");
|
||||
|
@ -40,8 +40,9 @@ public class BonjourBroadcast extends SwapType {
|
||||
* of JmDNS, and there is only ever a single LocalHTTPD port to
|
||||
* advertise anyway.
|
||||
*/
|
||||
if (pairService != null || jmdns != null)
|
||||
if (pairService != null || jmdns != null) {
|
||||
clearCurrentMDNSService();
|
||||
}
|
||||
String repoName = Preferences.get().getLocalRepoName();
|
||||
HashMap<String, String> values = new HashMap<>();
|
||||
values.put("path", "/fdroid/repo");
|
||||
|
@ -95,8 +95,9 @@ public class BluetoothDownloader extends Downloader {
|
||||
|
||||
@Override
|
||||
protected void close() {
|
||||
if (connection != null)
|
||||
if (connection != null) {
|
||||
connection.closeQuietly();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -89,8 +89,9 @@ public class HttpDownloader extends Downloader {
|
||||
}
|
||||
|
||||
protected void setupConnection() throws IOException {
|
||||
if (connection != null)
|
||||
if (connection != null) {
|
||||
return;
|
||||
}
|
||||
Preferences prefs = Preferences.get();
|
||||
if (prefs.isProxyEnabled() && !isSwapUrl()) {
|
||||
SocketAddress sa = new InetSocketAddress(prefs.getProxyHost(), prefs.getProxyPort());
|
||||
|
@ -40,8 +40,9 @@ public class LocalHTTPD extends NanoHTTPD {
|
||||
super(hostname, port);
|
||||
this.webRoot = webRoot;
|
||||
this.context = context.getApplicationContext();
|
||||
if (useHttps)
|
||||
if (useHttps) {
|
||||
enableHTTPS();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,8 +80,9 @@ public class WifiStateChangeService extends Service {
|
||||
wifiState = wifiManager.getWifiState();
|
||||
|
||||
while (FDroidApp.ipAddressString == null) {
|
||||
if (isCancelled()) // can be canceled by a change via WifiStateChangeReceiver
|
||||
if (isCancelled()) { // can be canceled by a change via WifiStateChangeReceiver
|
||||
return null;
|
||||
}
|
||||
if (wifiState == WifiManager.WIFI_STATE_ENABLED) {
|
||||
wifiInfo = wifiManager.getConnectionInfo();
|
||||
FDroidApp.ipAddressString = formatIpAddress(wifiInfo.getIpAddress());
|
||||
@ -90,14 +91,16 @@ public class WifiStateChangeService extends Service {
|
||||
return null;
|
||||
}
|
||||
String netmask = formatIpAddress(dhcpInfo.netmask);
|
||||
if (!TextUtils.isEmpty(FDroidApp.ipAddressString) && netmask != null)
|
||||
if (!TextUtils.isEmpty(FDroidApp.ipAddressString) && netmask != null) {
|
||||
FDroidApp.subnetInfo = new SubnetUtils(FDroidApp.ipAddressString, netmask).getInfo();
|
||||
}
|
||||
} else if (wifiState == WifiManager.WIFI_STATE_DISABLED
|
||||
|| wifiState == WifiManager.WIFI_STATE_DISABLING) {
|
||||
// try once to see if its a hotspot
|
||||
setIpInfoFromNetworkInterface();
|
||||
if (FDroidApp.ipAddressString == null)
|
||||
if (FDroidApp.ipAddressString == null) {
|
||||
return null;
|
||||
}
|
||||
} else { // a hotspot can be active during WIFI_STATE_UNKNOWN
|
||||
setIpInfoFromNetworkInterface();
|
||||
}
|
||||
@ -107,8 +110,9 @@ public class WifiStateChangeService extends Service {
|
||||
Utils.debugLog(TAG, "waiting for an IP address...");
|
||||
}
|
||||
}
|
||||
if (isCancelled()) // can be canceled by a change via WifiStateChangeReceiver
|
||||
if (isCancelled()) { // can be canceled by a change via WifiStateChangeReceiver
|
||||
return null;
|
||||
}
|
||||
|
||||
if (wifiInfo != null) {
|
||||
String ssid = wifiInfo.getSSID();
|
||||
@ -124,23 +128,26 @@ public class WifiStateChangeService extends Service {
|
||||
|
||||
// TODO: Can this be moved to the swap service instead?
|
||||
String scheme;
|
||||
if (Preferences.get().isLocalRepoHttpsEnabled())
|
||||
if (Preferences.get().isLocalRepoHttpsEnabled()) {
|
||||
scheme = "https";
|
||||
else
|
||||
} else {
|
||||
scheme = "http";
|
||||
}
|
||||
FDroidApp.repo.name = Preferences.get().getLocalRepoName();
|
||||
FDroidApp.repo.address = String.format(Locale.ENGLISH, "%s://%s:%d/fdroid/repo",
|
||||
scheme, FDroidApp.ipAddressString, FDroidApp.port);
|
||||
|
||||
if (isCancelled()) // can be canceled by a change via WifiStateChangeReceiver
|
||||
if (isCancelled()) { // can be canceled by a change via WifiStateChangeReceiver
|
||||
return null;
|
||||
}
|
||||
|
||||
Context context = WifiStateChangeService.this.getApplicationContext();
|
||||
LocalRepoManager lrm = LocalRepoManager.get(context);
|
||||
lrm.writeIndexPage(Utils.getSharingUri(FDroidApp.repo).toString());
|
||||
|
||||
if (isCancelled()) // can be canceled by a change via WifiStateChangeReceiver
|
||||
if (isCancelled()) { // can be canceled by a change via WifiStateChangeReceiver
|
||||
return null;
|
||||
}
|
||||
|
||||
// the fingerprint for the local repo's signing key
|
||||
LocalRepoKeyStore localRepoKeyStore = LocalRepoKeyStore.get(context);
|
||||
@ -154,8 +161,9 @@ public class WifiStateChangeService extends Service {
|
||||
* because if this is the first time the singleton is run, it
|
||||
* can take a while to instantiate.
|
||||
*/
|
||||
if (Preferences.get().isLocalRepoHttpsEnabled())
|
||||
if (Preferences.get().isLocalRepoHttpsEnabled()) {
|
||||
localRepoKeyStore.setupHTTPSCertificate();
|
||||
}
|
||||
|
||||
} catch (LocalRepoKeyStore.InitException | InterruptedException e) {
|
||||
Log.e(TAG, "Unable to configure a fingerprint or HTTPS for the local repo", e);
|
||||
@ -204,8 +212,9 @@ public class WifiStateChangeService extends Service {
|
||||
|| netIf.getDisplayName().contains("eth0")
|
||||
|| netIf.getDisplayName().contains("ap0")) {
|
||||
FDroidApp.ipAddressString = inetAddress.getHostAddress();
|
||||
if (Build.VERSION.SDK_INT < 9)
|
||||
if (Build.VERSION.SDK_INT < 9) {
|
||||
return;
|
||||
}
|
||||
// the following methods were not added until android-9/Gingerbread
|
||||
for (InterfaceAddress address : netIf.getInterfaceAddresses()) {
|
||||
if (inetAddress.equals(address.getAddress()) && !TextUtils.isEmpty(FDroidApp.ipAddressString)) {
|
||||
|
@ -32,8 +32,9 @@ public class BluetoothClient {
|
||||
return connection;
|
||||
} catch (IOException e1) {
|
||||
|
||||
if (connection != null)
|
||||
if (connection != null) {
|
||||
connection.closeQuietly();
|
||||
}
|
||||
|
||||
throw e1;
|
||||
|
||||
|
@ -135,8 +135,9 @@ public class BluetoothServer extends Thread {
|
||||
break;
|
||||
}
|
||||
|
||||
if (isInterrupted())
|
||||
if (isInterrupted()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
connection.closeQuietly();
|
||||
@ -183,8 +184,9 @@ public class BluetoothServer extends Thread {
|
||||
|
||||
Log.e(TAG, "error processing request; sending 500 response", e);
|
||||
|
||||
if (builder == null)
|
||||
if (builder == null) {
|
||||
builder = new Response.Builder();
|
||||
}
|
||||
|
||||
return builder
|
||||
.setStatusCode(500)
|
||||
|
@ -91,14 +91,16 @@ public final class Request {
|
||||
|
||||
String requestLine = readLine();
|
||||
|
||||
if (requestLine == null || requestLine.trim().length() == 0)
|
||||
if (requestLine == null || requestLine.trim().length() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String[] parts = requestLine.split("\\s+");
|
||||
|
||||
// First part is the method (GET/HEAD), second is the path (/fdroid/repo/index.jar)
|
||||
if (parts.length < 2)
|
||||
if (parts.length < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
method = parts[0].toUpperCase(Locale.ENGLISH);
|
||||
path = parts[1];
|
||||
@ -143,8 +145,9 @@ public final class Request {
|
||||
int b = input.read();
|
||||
|
||||
if (((char) b) == '\n') {
|
||||
if (baos.size() > 0)
|
||||
if (baos.size() > 0) {
|
||||
line = new String(baos.toByteArray());
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
@ -180,10 +183,11 @@ public final class Request {
|
||||
headers.put(header, value);
|
||||
}
|
||||
|
||||
if (input.available() > 0)
|
||||
if (input.available() > 0) {
|
||||
responseLine = readLine();
|
||||
else
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return headers;
|
||||
|
@ -182,8 +182,9 @@ public class ManageReposActivity extends ActionBarActivity {
|
||||
Uri uri = Uri.parse(text);
|
||||
fingerprint = uri.getQueryParameter("fingerprint");
|
||||
// uri might contain a QR-style, all uppercase URL:
|
||||
if (TextUtils.isEmpty(fingerprint))
|
||||
if (TextUtils.isEmpty(fingerprint)) {
|
||||
fingerprint = uri.getQueryParameter("FINGERPRINT");
|
||||
}
|
||||
text = NewRepoConfig.sanitizeRepoUri(uri);
|
||||
} catch (MalformedURLException e) {
|
||||
text = null;
|
||||
@ -683,8 +684,9 @@ public class ManageReposActivity extends ActionBarActivity {
|
||||
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
String bssid = wifiInfo.getBSSID();
|
||||
if (TextUtils.isEmpty(bssid)) /* not all devices have wifi */
|
||||
if (TextUtils.isEmpty(bssid)) { /* not all devices have wifi */
|
||||
return;
|
||||
}
|
||||
bssid = bssid.toLowerCase(Locale.ENGLISH);
|
||||
String newRepoBssid = Uri.decode(newRepo.getBssid()).toLowerCase(Locale.ENGLISH);
|
||||
if (!bssid.equals(newRepoBssid)) {
|
||||
|
@ -156,8 +156,9 @@ public class RepoDetailsActivity extends ActionBarActivity {
|
||||
|
||||
@TargetApi(9)
|
||||
void processIntent(Intent i) {
|
||||
if (Build.VERSION.SDK_INT < 9)
|
||||
if (Build.VERSION.SDK_INT < 9) {
|
||||
return;
|
||||
}
|
||||
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(i.getAction())) {
|
||||
Parcelable[] rawMsgs =
|
||||
i.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
|
||||
@ -176,8 +177,9 @@ public class RepoDetailsActivity extends ActionBarActivity {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
int statusCode = intent.getIntExtra(UpdateService.EXTRA_STATUS_CODE, -1);
|
||||
if (statusCode == UpdateService.STATUS_COMPLETE_WITH_CHANGES)
|
||||
if (statusCode == UpdateService.STATUS_COMPLETE_WITH_CHANGES) {
|
||||
updateRepoView();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -83,8 +83,9 @@ public class AvailableAppsFragment extends AppListFragment implements
|
||||
// hierarchy can touch its views."
|
||||
final Activity activity = getActivity();
|
||||
// this nullguard is temporary, this Fragment really needs to merged into the Activity
|
||||
if (activity == null)
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -162,12 +163,15 @@ public class AvailableAppsFragment extends AppListFragment implements
|
||||
|
||||
@Override
|
||||
protected Uri getDataUri() {
|
||||
if (currentCategory == null || currentCategory.equals(AppProvider.Helper.getCategoryAll(getActivity())))
|
||||
if (currentCategory == null || currentCategory.equals(AppProvider.Helper.getCategoryAll(getActivity()))) {
|
||||
return AppProvider.getContentUri();
|
||||
if (currentCategory.equals(AppProvider.Helper.getCategoryRecentlyUpdated(getActivity())))
|
||||
}
|
||||
if (currentCategory.equals(AppProvider.Helper.getCategoryRecentlyUpdated(getActivity()))) {
|
||||
return AppProvider.getRecentlyUpdatedUri();
|
||||
if (currentCategory.equals(AppProvider.Helper.getCategoryWhatsNew(getActivity())))
|
||||
}
|
||||
if (currentCategory.equals(AppProvider.Helper.getCategoryWhatsNew(getActivity()))) {
|
||||
return AppProvider.getNewlyAddedUri();
|
||||
}
|
||||
return AppProvider.getCategoryUri(currentCategory);
|
||||
}
|
||||
|
||||
|
@ -153,19 +153,21 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
case Preferences.PREF_PROXY_HOST:
|
||||
EditTextPreference textPref = (EditTextPreference) findPreference(key);
|
||||
String text = Preferences.get().getProxyHost();
|
||||
if (TextUtils.isEmpty(text) || text.equals(Preferences.DEFAULT_PROXY_HOST))
|
||||
if (TextUtils.isEmpty(text) || text.equals(Preferences.DEFAULT_PROXY_HOST)) {
|
||||
textPref.setSummary(R.string.proxy_host_summary);
|
||||
else
|
||||
} else {
|
||||
textPref.setSummary(text);
|
||||
}
|
||||
break;
|
||||
|
||||
case Preferences.PREF_PROXY_PORT:
|
||||
EditTextPreference textPref2 = (EditTextPreference) findPreference(key);
|
||||
int port = Preferences.get().getProxyPort();
|
||||
if (port == Preferences.DEFAULT_PROXY_PORT)
|
||||
if (port == Preferences.DEFAULT_PROXY_PORT) {
|
||||
textPref2.setSummary(R.string.proxy_port_summary);
|
||||
else
|
||||
} else {
|
||||
textPref2.setSummary(String.valueOf(port));
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -379,14 +379,16 @@ public class SwapAppsView extends ListView implements
|
||||
|
||||
private void resetView() {
|
||||
|
||||
if (app == null)
|
||||
if (app == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
progressView.setVisibility(View.GONE);
|
||||
progressView.setIndeterminate(true);
|
||||
|
||||
if (app.name != null)
|
||||
if (app.name != null) {
|
||||
nameView.setText(app.name);
|
||||
}
|
||||
|
||||
ImageLoader.getInstance().displayImage(app.iconUrl, iconView, displayImageOptions);
|
||||
|
||||
|
@ -603,7 +603,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
||||
Utils.debugLog(TAG, "Initiating Bluetooth swap, will ensure the Bluetooth devices is enabled and discoverable before starting server.");
|
||||
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||
|
||||
if (adapter != null)
|
||||
if (adapter != null) {
|
||||
if (adapter.isEnabled()) {
|
||||
Utils.debugLog(TAG, "Bluetooth enabled, will check if device is discoverable with device.");
|
||||
ensureBluetoothDiscoverableThenStart();
|
||||
@ -612,6 +612,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
||||
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
|
||||
startActivityForResult(enableBtIntent, REQUEST_BLUETOOTH_ENABLE_FOR_SWAP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureBluetoothDiscoverableThenStart() {
|
||||
|
@ -118,8 +118,9 @@ public class WifiQrView extends ScrollView implements SwapWorkflowActivity.Inner
|
||||
|
||||
private void setUIFromWifi() {
|
||||
|
||||
if (TextUtils.isEmpty(FDroidApp.repo.address))
|
||||
if (TextUtils.isEmpty(FDroidApp.repo.address)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String scheme = Preferences.get().isLocalRepoHttpsEnabled() ? "https://" : "http://";
|
||||
|
||||
|
@ -17,14 +17,17 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
|
||||
|
||||
public void testKnownApks() {
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
for (int i = 0; i < 7; i++) {
|
||||
TestUtils.insertApk(this, "org.fdroid.fdroid", i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
for (int i = 0; i < 9; i++) {
|
||||
TestUtils.insertApk(this, "org.example", i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < 3; i++) {
|
||||
TestUtils.insertApk(this, "com.example", i);
|
||||
}
|
||||
|
||||
TestUtils.insertApk(this, "com.apk.thingo", 1);
|
||||
|
||||
@ -64,20 +67,24 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
|
||||
|
||||
assertResultCount(known.length, knownApks);
|
||||
|
||||
for (Apk knownApk : knownApks)
|
||||
for (Apk knownApk : knownApks) {
|
||||
assertContains(knownApks, knownApk);
|
||||
}
|
||||
}
|
||||
|
||||
public void testFindByApp() {
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
for (int i = 0; i < 7; i++) {
|
||||
TestUtils.insertApk(this, "org.fdroid.fdroid", i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
for (int i = 0; i < 9; i++) {
|
||||
TestUtils.insertApk(this, "org.example", i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < 3; i++) {
|
||||
TestUtils.insertApk(this, "com.example", i);
|
||||
}
|
||||
|
||||
TestUtils.insertApk(this, "com.apk.thingo", 1);
|
||||
|
||||
@ -157,8 +164,9 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
|
||||
// Insert some random apks either side of the "com.example", so that
|
||||
// the Helper.find() method doesn't stumble upon the app we are interested
|
||||
// in by shear dumb luck...
|
||||
for (int i = 0; i < 10; i++)
|
||||
for (int i = 0; i < 10; i++) {
|
||||
TestUtils.insertApk(this, "org.fdroid.apk." + i, i);
|
||||
}
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(ApkProvider.DataColumns.VERSION, "v1.1");
|
||||
@ -167,8 +175,9 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
|
||||
TestUtils.insertApk(this, "com.example", 11, values);
|
||||
|
||||
// ...and a few more for good measure...
|
||||
for (int i = 15; i < 20; i++)
|
||||
for (int i = 15; i < 20; i++) {
|
||||
TestUtils.insertApk(this, "com.other.thing." + i, i);
|
||||
}
|
||||
|
||||
Apk apk = ApkProvider.Helper.find(getMockContext(), "com.example", 11);
|
||||
|
||||
|
@ -433,8 +433,9 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase {
|
||||
}
|
||||
|
||||
private boolean updateRepo(RepoUpdater updater, String indexJarPath) throws UpdateException {
|
||||
if (!testFilesDir.canWrite())
|
||||
if (!testFilesDir.canWrite()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File indexJar = TestUtils.copyAssetToDir(context, indexJarPath, testFilesDir);
|
||||
updater.processDownloadedFile(indexJar);
|
||||
|
@ -28,8 +28,9 @@ public class RepoUpdaterTest extends InstrumentationTestCase {
|
||||
}
|
||||
|
||||
public void testExtractIndexFromJar() {
|
||||
if (!testFilesDir.canWrite())
|
||||
if (!testFilesDir.canWrite()) {
|
||||
return;
|
||||
}
|
||||
File simpleIndexJar = TestUtils.copyAssetToDir(context, "simpleIndex.jar", testFilesDir);
|
||||
|
||||
// these are supposed to succeed
|
||||
@ -42,8 +43,9 @@ public class RepoUpdaterTest extends InstrumentationTestCase {
|
||||
}
|
||||
|
||||
public void testExtractIndexFromJarWithoutSignatureJar() {
|
||||
if (!testFilesDir.canWrite())
|
||||
if (!testFilesDir.canWrite()) {
|
||||
return;
|
||||
}
|
||||
// this is supposed to fail
|
||||
try {
|
||||
File jarFile = TestUtils.copyAssetToDir(context, "simpleIndexWithoutSignature.jar", testFilesDir);
|
||||
@ -55,8 +57,9 @@ public class RepoUpdaterTest extends InstrumentationTestCase {
|
||||
}
|
||||
|
||||
public void testExtractIndexFromJarWithCorruptedManifestJar() {
|
||||
if (!testFilesDir.canWrite())
|
||||
if (!testFilesDir.canWrite()) {
|
||||
return;
|
||||
}
|
||||
// this is supposed to fail
|
||||
try {
|
||||
File jarFile = TestUtils.copyAssetToDir(context, "simpleIndexWithCorruptedManifest.jar", testFilesDir);
|
||||
@ -71,8 +74,9 @@ public class RepoUpdaterTest extends InstrumentationTestCase {
|
||||
}
|
||||
|
||||
public void testExtractIndexFromJarWithCorruptedSignature() {
|
||||
if (!testFilesDir.canWrite())
|
||||
if (!testFilesDir.canWrite()) {
|
||||
return;
|
||||
}
|
||||
// this is supposed to fail
|
||||
try {
|
||||
File jarFile = TestUtils.copyAssetToDir(context, "simpleIndexWithCorruptedSignature.jar", testFilesDir);
|
||||
@ -87,8 +91,9 @@ public class RepoUpdaterTest extends InstrumentationTestCase {
|
||||
}
|
||||
|
||||
public void testExtractIndexFromJarWithCorruptedCertificate() {
|
||||
if (!testFilesDir.canWrite())
|
||||
if (!testFilesDir.canWrite()) {
|
||||
return;
|
||||
}
|
||||
// this is supposed to fail
|
||||
try {
|
||||
File jarFile = TestUtils.copyAssetToDir(context, "simpleIndexWithCorruptedCertificate.jar", testFilesDir);
|
||||
@ -103,8 +108,9 @@ public class RepoUpdaterTest extends InstrumentationTestCase {
|
||||
}
|
||||
|
||||
public void testExtractIndexFromJarWithCorruptedEverything() {
|
||||
if (!testFilesDir.canWrite())
|
||||
if (!testFilesDir.canWrite()) {
|
||||
return;
|
||||
}
|
||||
// this is supposed to fail
|
||||
try {
|
||||
File jarFile = TestUtils.copyAssetToDir(context, "simpleIndexWithCorruptedEverything.jar", testFilesDir);
|
||||
@ -119,8 +125,9 @@ public class RepoUpdaterTest extends InstrumentationTestCase {
|
||||
}
|
||||
|
||||
public void testExtractIndexFromMasterKeyIndexJar() {
|
||||
if (!testFilesDir.canWrite())
|
||||
if (!testFilesDir.canWrite()) {
|
||||
return;
|
||||
}
|
||||
// this is supposed to fail
|
||||
try {
|
||||
File jarFile = TestUtils.copyAssetToDir(context, "masterKeyIndex.jar", testFilesDir);
|
||||
|
@ -86,7 +86,9 @@
|
||||
<module name="LeftCurly">
|
||||
<property name="maxLineLength" value="100"/>
|
||||
</module>
|
||||
<!--<module name="NeedBraces" />-->
|
||||
<module name="NeedBraces">
|
||||
<property name="allowSingleLineStatement" value="true"/>
|
||||
</module>
|
||||
<module name="RightCurly"/>
|
||||
<module name="RightCurly">
|
||||
<property name="option" value="alone"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user