diff --git a/app/src/androidTest/java/org/fdroid/fdroid/UiWatchers.java b/app/src/androidTest/java/org/fdroid/fdroid/UiWatchers.java index 0109a4097..5e8800f96 100644 --- a/app/src/androidTest/java/org/fdroid/fdroid/UiWatchers.java +++ b/app/src/androidTest/java/org/fdroid/fdroid/UiWatchers.java @@ -24,13 +24,12 @@ import androidx.test.uiautomator.UiWatcher; import android.util.Log; import java.util.ArrayList; -import java.util.Collections; import java.util.List; @SuppressWarnings("MemberName") -public class UiWatchers { +class UiWatchers { private static final String LOG_TAG = UiWatchers.class.getSimpleName(); - private final List mErrors = new ArrayList(); + private final List mErrors = new ArrayList<>(); /** * We can use the UiDevice registerWatcher to register a small script to be executed when the @@ -120,26 +119,18 @@ public class UiWatchers { Log.i(LOG_TAG, "Registered GUI Exception watchers"); } - public void onAnrDetected(String errorText) { + private void onAnrDetected(String errorText) { mErrors.add(errorText); } - public void onCrashDetected(String errorText) { + private void onCrashDetected(String errorText) { mErrors.add(errorText); } - public void reset() { - mErrors.clear(); - } - - public List getErrors() { - return Collections.unmodifiableList(mErrors); - } - /** * Current implementation ignores the exception and continues. */ - public void postHandler(String buttonText) { + private void postHandler(String buttonText) { // TODO: Add custom error logging here String formatedOutput = String.format("UI Exception Message: %-20s\n", UiDevice .getInstance().getCurrentPackageName()); diff --git a/app/src/androidTest/java/org/fdroid/fdroid/work/WorkManagerTestRule.java b/app/src/androidTest/java/org/fdroid/fdroid/work/WorkManagerTestRule.java index fb6f6dc8e..26466963a 100644 --- a/app/src/androidTest/java/org/fdroid/fdroid/work/WorkManagerTestRule.java +++ b/app/src/androidTest/java/org/fdroid/fdroid/work/WorkManagerTestRule.java @@ -12,17 +12,13 @@ import org.junit.rules.TestWatcher; import org.junit.runner.Description; public class WorkManagerTestRule extends TestWatcher { - Context targetContext; - Context testContext; - Configuration configuration; WorkManager workManager; @Override protected void starting(Description description) { final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); - targetContext = instrumentation.getTargetContext(); - testContext = instrumentation.getContext(); - configuration = new Configuration.Builder() + Context targetContext = instrumentation.getTargetContext(); + Configuration configuration = new Configuration.Builder() .setMinimumLoggingLevel(Log.DEBUG) .setExecutor(new SynchronousExecutor()) .build(); diff --git a/app/src/full/java/org/fdroid/fdroid/nearby/SelectAppsView.java b/app/src/full/java/org/fdroid/fdroid/nearby/SelectAppsView.java index 08e0ade1d..980acf79f 100644 --- a/app/src/full/java/org/fdroid/fdroid/nearby/SelectAppsView.java +++ b/app/src/full/java/org/fdroid/fdroid/nearby/SelectAppsView.java @@ -82,10 +82,8 @@ public class SelectAppsView extends SwapView { String packageName = adapter.getItem(position).packageName; if (getActivity().getSwapService().hasSelectedPackage(packageName)) { getActivity().getSwapService().deselectPackage(packageName); - adapter.updateCheckedIndicatorView(position, false); } else { getActivity().getSwapService().selectPackage(packageName); - adapter.updateCheckedIndicatorView(position, true); } LocalRepoService.create(getContext(), getActivity().getSwapService().getAppsToSwap()); } @@ -203,15 +201,6 @@ public class SelectAppsView extends SwapView { } } - public void updateCheckedIndicatorView(int position, boolean checked) { - final int firstListItemPosition = listView.getFirstVisiblePosition(); - final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1; - - if (position >= firstListItemPosition && position <= lastListItemPosition) { - final int childIndex = position - firstListItemPosition; - } - } - @Override public int getCount() { return filteredPackages.size(); diff --git a/app/src/full/java/org/fdroid/fdroid/nearby/StartSwapView.java b/app/src/full/java/org/fdroid/fdroid/nearby/StartSwapView.java index 51cf6d0a8..3894c0a47 100644 --- a/app/src/full/java/org/fdroid/fdroid/nearby/StartSwapView.java +++ b/app/src/full/java/org/fdroid/fdroid/nearby/StartSwapView.java @@ -170,15 +170,6 @@ public class StartSwapView extends SwapView { }); } - private void uiShowNotSearchingForPeers() { - peopleNearbyProgress.setVisibility(View.GONE); - if (peopleNearbyList.getAdapter().getCount() > 0) { - peopleNearbyText.setText(getContext().getString(R.string.swap_people_nearby)); - } else { - peopleNearbyText.setText(getContext().getString(R.string.swap_no_peers_nearby)); - } - } - private void uiInitBluetooth() { if (bluetooth != null && ContextCompat.checkSelfPermission(getContext(), Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) { diff --git a/app/src/full/java/org/fdroid/fdroid/nearby/TreeUriUtils.java b/app/src/full/java/org/fdroid/fdroid/nearby/TreeUriUtils.java index bc2f69be8..47bc4cb9b 100644 --- a/app/src/full/java/org/fdroid/fdroid/nearby/TreeUriUtils.java +++ b/app/src/full/java/org/fdroid/fdroid/nearby/TreeUriUtils.java @@ -1,99 +1,12 @@ package org.fdroid.fdroid.nearby; -import android.annotation.SuppressLint; -import android.annotation.TargetApi; -import android.content.Context; -import android.net.Uri; -import android.os.Build; -import android.os.storage.StorageManager; -import android.provider.DocumentsContract; - -import java.io.File; -import java.lang.reflect.Array; -import java.lang.reflect.Method; - -import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; - - /** * @see Android 5.0 DocumentFile from tree URI */ public final class TreeUriUtils { public static final String TAG = "TreeUriUtils"; - private static final String PRIMARY_VOLUME_NAME = "primary"; - public static final String SIGNED_FILE_NAME = "index-v1.jar"; - public static final String DATA_FILE_NAME = "index-v1.json"; + static final String SIGNED_FILE_NAME = "index-v1.jar"; + static final String DATA_FILE_NAME = "index-v1.json"; - @Nullable - public static String getFullPathFromTreeUri(Context context, @Nullable final Uri treeUri) { - if (treeUri == null) return null; - String volumePath = getVolumePath(getVolumeIdFromTreeUri(treeUri), context); - if (volumePath == null) return File.separator; - if (volumePath.endsWith(File.separator)) - volumePath = volumePath.substring(0, volumePath.length() - 1); - - String documentPath = getDocumentPathFromTreeUri(treeUri); - if (documentPath.endsWith(File.separator)) - documentPath = documentPath.substring(0, documentPath.length() - 1); - - if (documentPath.length() > 0) { - if (documentPath.startsWith(File.separator)) - return volumePath + documentPath; - else - return volumePath + File.separator + documentPath; - } else return volumePath; - } - - - @SuppressLint("ObsoleteSdkInt") - private static String getVolumePath(final String volumeId, Context context) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return null; - try { - StorageManager mStorageManager = ContextCompat.getSystemService(context, StorageManager.class); - Class storageVolumeClazz = Class.forName("android.os.storage.StorageVolume"); - Method getVolumeList = mStorageManager.getClass().getMethod("getVolumeList"); - Method getUuid = storageVolumeClazz.getMethod("getUuid"); - Method getPath = storageVolumeClazz.getMethod("getPath"); - Method isPrimary = storageVolumeClazz.getMethod("isPrimary"); - Object result = getVolumeList.invoke(mStorageManager); - - final int length = Array.getLength(result); - for (int i = 0; i < length; i++) { - Object storageVolumeElement = Array.get(result, i); - String uuid = (String) getUuid.invoke(storageVolumeElement); - Boolean primary = (Boolean) isPrimary.invoke(storageVolumeElement); - - // primary volume? - if (primary && PRIMARY_VOLUME_NAME.equals(volumeId)) - return (String) getPath.invoke(storageVolumeElement); - - // other volumes? - if (uuid != null && uuid.equals(volumeId)) - return (String) getPath.invoke(storageVolumeElement); - } - // not found. - return null; - } catch (Exception ex) { - return null; - } - } - - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - private static String getVolumeIdFromTreeUri(final Uri treeUri) { - final String docId = DocumentsContract.getTreeDocumentId(treeUri); - final String[] split = docId.split(":"); - if (split.length > 0) return split[0]; - else return null; - } - - - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - private static String getDocumentPathFromTreeUri(final Uri treeUri) { - final String docId = DocumentsContract.getTreeDocumentId(treeUri); - final String[] split = docId.split(":"); - if ((split.length >= 2) && (split[1] != null)) return split[1]; - else return File.separator; - } } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 00374ffae..0b7a4ab47 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -118,13 +118,6 @@ android:value=".views.main.MainActivity" /> - - * This is helpful for bailing out of the {@link FDroidApp#onCreate} method early, preventing * problems that arise from executing the code twice. This happens due to the `android:process` - * statement in AndroidManifest.xml causes another process to be created to run - * {@link org.fdroid.fdroid.acra.CrashReportActivity}. This was causing lots of things to be + * statement in AndroidManifest.xml causes another process to be created to run ACRA. + * This was causing lots of things to be * started/run twice including {@link CleanCacheWorker} and {@link WifiStateChangeService}. *

* Note that it is not perfect, because some devices seem to not provide a list of running app diff --git a/app/src/main/java/org/fdroid/fdroid/Hasher.java b/app/src/main/java/org/fdroid/fdroid/Hasher.java index 0a05745d4..2156f9cc8 100644 --- a/app/src/main/java/org/fdroid/fdroid/Hasher.java +++ b/app/src/main/java/org/fdroid/fdroid/Hasher.java @@ -20,10 +20,6 @@ package org.fdroid.fdroid; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.cert.Certificate; @@ -32,7 +28,6 @@ import java.security.cert.CertificateEncodingException; public class Hasher { private MessageDigest digest; - private File file; private final byte[] array; private String hashCache; @@ -56,24 +51,7 @@ public class Hasher { if (hashCache != null) { return hashCache; } - if (file != null) { - byte[] buffer = new byte[1024]; - int read; - InputStream input = null; - try { - input = new BufferedInputStream(new FileInputStream(file)); - while ((read = input.read(buffer)) > 0) { // NOPMD Avoid assignments in operands - digest.update(buffer, 0, read); - } - } catch (Exception e) { - hashCache = ""; - return hashCache; - } finally { - Utils.closeQuietly(input); - } - } else { - digest.update(array); - } + digest.update(array); hashCache = hex(digest.digest()); return hashCache; } @@ -100,7 +78,7 @@ public class Hasher { return new String(csig); } - public static byte[] unhex(String data) { + static byte[] unhex(String data) { byte[] rawdata = new byte[data.length() / 2]; for (int i = 0; i < data.length(); i++) { char halfbyte = data.charAt(i); diff --git a/app/src/main/java/org/fdroid/fdroid/Preferences.java b/app/src/main/java/org/fdroid/fdroid/Preferences.java index b824d26f7..53facc0b0 100644 --- a/app/src/main/java/org/fdroid/fdroid/Preferences.java +++ b/app/src/main/java/org/fdroid/fdroid/Preferences.java @@ -113,7 +113,6 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh public static final String PREF_PROXY_HOST = "proxyHost"; public static final String PREF_PROXY_PORT = "proxyPort"; public static final String PREF_SHOW_NFC_DURING_SWAP = "showNfcDuringSwap"; - public static final String PREF_POST_PRIVILEGED_INSTALL = "postPrivilegedInstall"; public static final String PREF_PREVENT_SCREENSHOTS = "preventScreenshots"; public static final String PREF_PANIC_EXIT = "pref_panic_exit"; public static final String PREF_PANIC_HIDE = "pref_panic_hide"; @@ -137,7 +136,6 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh public static final int DEFAULT_PROXY_PORT = 8118; // TODO move to preferences.xml private static final int DEFAULT_LAST_UPDATE_CHECK = -1; private static final boolean DEFAULT_SHOW_NFC_DURING_SWAP = true; - private static final boolean DEFAULT_POST_PRIVILEGED_INSTALL = false; private static final boolean DEFAULT_PANIC_EXIT = true; private static final boolean IGNORED_B = false; @@ -217,14 +215,6 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh return preferences.getBoolean(PREF_PRIVILEGED_INSTALLER, true); } - public boolean isPostPrivilegedInstall() { - return preferences.getBoolean(PREF_POST_PRIVILEGED_INSTALL, DEFAULT_POST_PRIVILEGED_INSTALL); - } - - public void setPostPrivilegedInstall(boolean postInstall) { - preferences.edit().putBoolean(PREF_POST_PRIVILEGED_INSTALL, postInstall).apply(); - } - /** * Get the update interval in milliseconds. */ @@ -338,18 +328,14 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh } } - public long getLastUpdateCheck() { + long getLastUpdateCheck() { return preferences.getLong(PREF_LAST_UPDATE_CHECK, DEFAULT_LAST_UPDATE_CHECK); } - public void setLastUpdateCheck(long lastUpdateCheck) { + void setLastUpdateCheck(long lastUpdateCheck) { preferences.edit().putLong(PREF_LAST_UPDATE_CHECK, lastUpdateCheck).apply(); } - public void resetLastUpdateCheck() { - setLastUpdateCheck(DEFAULT_LAST_UPDATE_CHECK); - } - /** * The first time the app has been run since fresh install or clearing all data. */ @@ -611,14 +597,10 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh showAppsRequiringAntiFeaturesListeners.remove(listener); } - public void registerUnstableUpdatesChangeListener(ChangeListener listener) { + void registerUnstableUpdatesChangeListener(ChangeListener listener) { unstableUpdatesListeners.add(listener); } - public void unregisterUnstableUpdatesChangeListener(ChangeListener listener) { - unstableUpdatesListeners.remove(listener); - } - @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Utils.debugLog(TAG, "Invalidating preference '" + key + "'."); @@ -648,14 +630,6 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh } } - public void registerLocalRepoNameListeners(ChangeListener listener) { - localRepoNameListeners.add(listener); - } - - public void unregisterLocalRepoNameListeners(ChangeListener listener) { - localRepoNameListeners.remove(listener); - } - public void registerLocalRepoHttpsListeners(ChangeListener listener) { localRepoHttpsListeners.add(listener); } diff --git a/app/src/main/java/org/fdroid/fdroid/ProgressBufferedInputStream.java b/app/src/main/java/org/fdroid/fdroid/ProgressBufferedInputStream.java deleted file mode 100644 index f98a49556..000000000 --- a/app/src/main/java/org/fdroid/fdroid/ProgressBufferedInputStream.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.fdroid.fdroid; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; - -import androidx.annotation.NonNull; - -class ProgressBufferedInputStream extends BufferedInputStream { - - private final ProgressListener progressListener; - private final int totalBytes; - - private int currentBytes; - - /** - * Reports progress to the specified {@link ProgressListener}, with the - * progress based on the {@code totalBytes}. - */ - ProgressBufferedInputStream(InputStream in, ProgressListener progressListener, int totalBytes) { - super(in); - this.progressListener = progressListener; - this.totalBytes = totalBytes; - } - - @Override - public synchronized int read(@NonNull byte[] buffer, int byteOffset, int byteCount) throws IOException { - if (progressListener != null) { - currentBytes += byteCount; - /* don't send every change to keep things efficient. 333333 bytes to keep all - * the digits changing because it looks pretty, < 9000 since the reads won't - * line up exactly */ - if (currentBytes % 333333 < 9000) { - progressListener.onProgress(currentBytes, totalBytes); - } - } - return super.read(buffer, byteOffset, byteCount); - } -} diff --git a/app/src/main/java/org/fdroid/fdroid/UpdateJobService.java b/app/src/main/java/org/fdroid/fdroid/UpdateJobService.java index bc4dd8abc..ad1c56397 100644 --- a/app/src/main/java/org/fdroid/fdroid/UpdateJobService.java +++ b/app/src/main/java/org/fdroid/fdroid/UpdateJobService.java @@ -20,7 +20,7 @@ public class UpdateJobService extends JobService { @Override public boolean onStopJob(JobParameters params) { - UpdateService.stopNow(this); + UpdateService.stopNow(); return true; } } diff --git a/app/src/main/java/org/fdroid/fdroid/UpdateService.java b/app/src/main/java/org/fdroid/fdroid/UpdateService.java index 15ae3b8ba..8c73b9dae 100644 --- a/app/src/main/java/org/fdroid/fdroid/UpdateService.java +++ b/app/src/main/java/org/fdroid/fdroid/UpdateService.java @@ -63,10 +63,8 @@ import org.fdroid.index.RepoUpdater; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.TimeUnit; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; -import io.reactivex.rxjava3.core.Completable; import io.reactivex.rxjava3.core.Single; import io.reactivex.rxjava3.disposables.Disposable; import io.reactivex.rxjava3.schedulers.Schedulers; @@ -225,41 +223,7 @@ public class UpdateService extends JobIntentService { return updateService != null; } - private static volatile boolean isScheduleIfStillOnWifiRunning; - - /** - * Waits for a period of time for the WiFi to settle, then if the WiFi is - * still active, it schedules an update. This is to encourage the use of - * unlimited networks over metered networks for index updates and auto - * downloads of app updates. Starting with {@code android-21}, this uses - * {@link android.app.job.JobScheduler} instead. - * - * @return a {@link Completable} that schedules the update. If this process is already running, - * a {@code Completable} that completes immediately is returned. - */ - @NonNull - public static Completable scheduleIfStillOnWifi(Context context) { - if (Build.VERSION.SDK_INT >= 21) { - throw new IllegalStateException("This should never be used on android-21 or newer!"); - } - if (isScheduleIfStillOnWifiRunning || !Preferences.get().isBackgroundDownloadAllowed()) { - return Completable.complete(); - } - isScheduleIfStillOnWifiRunning = true; - - return Completable.timer(2, TimeUnit.MINUTES) - .andThen(Completable.fromAction(() -> { - if (Preferences.get().isBackgroundDownloadAllowed()) { - Utils.debugLog(TAG, "scheduling update because there is good internet"); - schedule(context); - } - isScheduleIfStillOnWifiRunning = false; - })) - .subscribeOn(Schedulers.computation()) - .observeOn(AndroidSchedulers.mainThread()); - } - - public static void stopNow(Context context) { + public static void stopNow() { if (updateService != null) { updateService.stopSelf(JOB_ID); updateService = null; @@ -595,19 +559,6 @@ public class UpdateService extends JobIntentService { sendStatus(context, STATUS_INFO, message, percent); } - public static void reportProcessIndexProgress(Context context, String indexUrl, long bytesRead, long totalBytes) { - Utils.debugLog(TAG, "Processing " + indexUrl + "(" + bytesRead + "/" + totalBytes + ")"); - String downloadedSize = Utils.getFriendlySize(bytesRead); - String totalSize = Utils.getFriendlySize(totalBytes); - int percent = -1; - if (totalBytes > 0) { - percent = Utils.getPercent(bytesRead, totalBytes); - } - String message = context.getString(R.string.status_processing_xml_percent, indexUrl, downloadedSize, - totalSize, percent); - sendStatus(context, STATUS_INFO, message, percent); - } - /** * If an updater is unable to know how many apps it has to process (i.e. it * is streaming apps to the database or performing a large database query diff --git a/app/src/main/java/org/fdroid/fdroid/Utils.java b/app/src/main/java/org/fdroid/fdroid/Utils.java index ef5cf0f75..9732e54e7 100644 --- a/app/src/main/java/org/fdroid/fdroid/Utils.java +++ b/app/src/main/java/org/fdroid/fdroid/Utils.java @@ -19,13 +19,11 @@ package org.fdroid.fdroid; -import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.res.Resources; -import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.Rect; import android.net.Uri; @@ -77,28 +75,23 @@ import java.net.InetSocketAddress; import java.net.Proxy; import java.net.ServerSocket; import java.net.Socket; -import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.cert.Certificate; import java.security.cert.CertificateEncodingException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.Formatter; -import java.util.HashMap; import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.TimeZone; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; import androidx.core.util.Consumer; import androidx.core.util.Supplier; @@ -143,8 +136,6 @@ public final class Utils { private static Handler toastHandler; - public static final String FALLBACK_ICONS_DIR = "icons"; - /* * @param dpiMultiplier Lets you grab icons for densities larger or * smaller than that of your device by some fraction. Useful, for example, @@ -376,13 +367,6 @@ public final class Utils { return b.build(); } - /** - * Create a standard {@link PackageManager} {@link Uri} for pointing to an app. - */ - public static Uri getPackageUri(String packageName) { - return Uri.parse("package:" + packageName); - } - /** * This is only needed for making a fingerprint from the {@code pubkey} * entry in {@code index.xml}. @@ -566,19 +550,6 @@ public final class Utils { return null; } - public static int parseInt(String str, int fallback) { - if (str == null || str.length() == 0) { - return fallback; - } - int result; - try { - result = Integer.parseInt(str); - } catch (NumberFormatException e) { - result = fallback; - } - return result; - } - @Nullable public static String[] parseCommaSeparatedString(String values) { return values == null || values.length() == 0 ? null : values.split(","); @@ -673,14 +644,6 @@ public final class Utils { return safePackageNamePattern.matcher(packageName).matches(); } - /** - * Calculate the number of days since the given date. - */ - public static int daysSince(@NonNull Date date) { - long msDiff = Calendar.getInstance().getTimeInMillis() - date.getTime(); - return (int) TimeUnit.MILLISECONDS.toDays(msDiff); - } - /** * Calculate the number of days since the given date. */ @@ -813,74 +776,6 @@ public final class Utils { return null; } - /** - * Try to get the {@link PackageInfo} with signature info for the {@code packageName} provided. - * - * @return null on failure - */ - @SuppressLint("PackageManagerGetSignatures") - public static PackageInfo getPackageInfoWithSignatures(Context context, String packageName) { - try { - return context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES); - } catch (PackageManager.NameNotFoundException e) { - debugLog(TAG, "Could not get PackageInfo: ", e); - } - return null; - } - - /** - * Useful for debugging during development, so that arbitrary queries can be made, and their - * results inspected in the debugger. - */ - @SuppressWarnings("unused") - @RequiresApi(api = 11) - public static List> dumpCursor(Cursor cursor) { - List> data = new ArrayList<>(); - - if (cursor == null) { - return data; - } - - cursor.moveToFirst(); - while (!cursor.isAfterLast()) { - Map row = new HashMap<>(cursor.getColumnCount()); - for (String col : cursor.getColumnNames()) { - int i = cursor.getColumnIndex(col); - switch (cursor.getType(i)) { - case Cursor.FIELD_TYPE_NULL: - row.put(col, null); - break; - - case Cursor.FIELD_TYPE_INTEGER: - row.put(col, Integer.toString(cursor.getInt(i))); - break; - - case Cursor.FIELD_TYPE_FLOAT: - row.put(col, Double.toString(cursor.getFloat(i))); - break; - - case Cursor.FIELD_TYPE_STRING: - row.put(col, cursor.getString(i)); - break; - - case Cursor.FIELD_TYPE_BLOB: - row.put(col, new String(cursor.getBlob(i), Charset.defaultCharset())); - break; - } - } - data.add(row); - cursor.moveToNext(); - } - - cursor.close(); - return data; - } - - public static int dpToPx(int dp, Context ctx) { - Resources r = ctx.getResources(); - return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); - } - /** * Converts a {@code long} bytes value, like from {@link File#length()}, to * an {@code int} value that is kilobytes, suitable for things like diff --git a/app/src/main/java/org/fdroid/fdroid/acra/CrashReportActivity.java b/app/src/main/java/org/fdroid/fdroid/acra/CrashReportActivity.java deleted file mode 100644 index 2613745ef..000000000 --- a/app/src/main/java/org/fdroid/fdroid/acra/CrashReportActivity.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.fdroid.fdroid.acra; - -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.os.Bundle; -import android.widget.EditText; - -import org.acra.dialog.CrashReportDialog; -import org.acra.dialog.CrashReportDialogHelper; -import org.fdroid.fdroid.R; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import com.google.android.material.textfield.TextInputLayout; - -public class CrashReportActivity extends CrashReportDialog - implements DialogInterface.OnDismissListener, DialogInterface.OnClickListener { - - private static final String STATE_COMMENT = "comment"; - private CrashReportDialogHelper helper; - private EditText comment; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - helper = new CrashReportDialogHelper(this, getIntent()); - if (savedInstanceState != null) { - comment.setText(savedInstanceState.getString(STATE_COMMENT)); - } - } - - @Override - protected void setDialog(@NonNull android.app.AlertDialog alertDialog) { - super.setDialog(alertDialog); - } - - @NonNull - @Override - protected android.app.AlertDialog getDialog() { - final AlertDialog dialog = new AlertDialog.Builder(this) - .setTitle(R.string.crash_dialog_title) - .setView(R.layout.crash_report_dialog) - .setPositiveButton(R.string.ok, this) - .setNegativeButton(R.string.cancel, this) - .create(); - - dialog.setCanceledOnTouchOutside(false); - dialog.setOnDismissListener(this); - dialog.setOnShowListener(d -> { - TextInputLayout commentLayout = dialog.findViewById(android.R.id.input); - comment = commentLayout.getEditText(); - }); - return dialog; - } - - @Override - public void onDismiss(DialogInterface dialog) { - finish(); - } - - @Override - public void onClick(@NonNull DialogInterface dialog, int which) { - if (which == DialogInterface.BUTTON_POSITIVE) { - helper.sendCrash(comment.getText().toString(), ""); - } else { - helper.cancelReports(); - } - finish(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - outState.putString(STATE_COMMENT, comment.getText().toString()); - super.onSaveInstanceState(outState); - } -} diff --git a/app/src/main/java/org/fdroid/fdroid/acra/CrashReportSender.java b/app/src/main/java/org/fdroid/fdroid/acra/CrashReportSender.java deleted file mode 100644 index f53b8afd6..000000000 --- a/app/src/main/java/org/fdroid/fdroid/acra/CrashReportSender.java +++ /dev/null @@ -1,65 +0,0 @@ - -package org.fdroid.fdroid.acra; - -import android.content.Context; -import android.content.Intent; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.acra.ReportField; -import org.acra.config.ConfigUtils; -import org.acra.config.CoreConfiguration; -import org.acra.config.MailSenderConfiguration; -import org.acra.data.CrashReportData; -import org.acra.sender.ReportSender; - -import java.util.List; - -public class CrashReportSender implements ReportSender { - - private final CoreConfiguration config; - private final MailSenderConfiguration mailConfig; - - public CrashReportSender(CoreConfiguration config) { - this.config = config; - this.mailConfig = ConfigUtils.getPluginConfiguration(config, MailSenderConfiguration.class); - } - - public void send(@NonNull Context context, @NonNull CrashReportData errorContent) { - Intent emailIntent = new Intent("android.intent.action.SENDTO"); - emailIntent.setData(Uri.fromParts("mailto", mailConfig.getMailTo(), null)); - emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - String[] subjectBody = this.buildSubjectBody(context, errorContent); - emailIntent.putExtra("android.intent.extra.SUBJECT", subjectBody[0]); - emailIntent.putExtra("android.intent.extra.TEXT", subjectBody[1]); - context.startActivity(emailIntent); - } - - private String[] buildSubjectBody(Context context, CrashReportData errorContent) { - List fields = this.config.getReportContent(); - if (fields.isEmpty()) { - return new String[]{"No ACRA Report Fields found."}; - } - - String subject = context.getPackageName() + " Crash Report"; - StringBuilder builder = new StringBuilder(); - for (ReportField field : fields) { - builder.append(field.toString()).append('='); - builder.append(errorContent.getString(field)); - builder.append('\n'); - if ("STACK_TRACE".equals(field.toString())) { - String stackTrace = errorContent.getString(field); - if (stackTrace != null) { - subject = context.getPackageName() + ": " - + stackTrace.substring(0, stackTrace.indexOf('\n')); - if (subject.length() > 72) { - subject = subject.substring(0, 72); - } - } - } - } - - return new String[]{subject, builder.toString()}; - } -} diff --git a/app/src/main/java/org/fdroid/fdroid/acra/CrashReportSenderFactory.java b/app/src/main/java/org/fdroid/fdroid/acra/CrashReportSenderFactory.java deleted file mode 100644 index 31b7f16ce..000000000 --- a/app/src/main/java/org/fdroid/fdroid/acra/CrashReportSenderFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.fdroid.fdroid.acra; - -import android.content.Context; - -import org.acra.config.CoreConfiguration; -import org.acra.sender.ReportSender; -import org.acra.sender.ReportSenderFactory; - -import androidx.annotation.NonNull; - -public class CrashReportSenderFactory implements ReportSenderFactory { - @NonNull - @Override - public ReportSender create(@NonNull Context context, @NonNull CoreConfiguration coreConfiguration) { - return new CrashReportSender(coreConfiguration); - } -} diff --git a/app/src/main/java/org/fdroid/fdroid/compat/CursorAdapterCompat.java b/app/src/main/java/org/fdroid/fdroid/compat/CursorAdapterCompat.java deleted file mode 100644 index 0e2a535f9..000000000 --- a/app/src/main/java/org/fdroid/fdroid/compat/CursorAdapterCompat.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.fdroid.fdroid.compat; - -public class CursorAdapterCompat { - - public static final int FLAG_AUTO_REQUERY = 0x01; - -} diff --git a/app/src/main/java/org/fdroid/fdroid/data/App.java b/app/src/main/java/org/fdroid/fdroid/data/App.java index 2c501a009..edb5ce0c7 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/App.java +++ b/app/src/main/java/org/fdroid/fdroid/data/App.java @@ -545,25 +545,6 @@ public class App implements Comparable, Parcelable { } } - public boolean isValid() { - if (TextUtils.isEmpty(this.name) - || TextUtils.isEmpty(this.packageName)) { - return false; - } - - if (this.installedApk == null) { - return false; - } - - if (TextUtils.isEmpty(this.installedApk.sig)) { - return false; - } - - final File apkFile = this.installedApk.installedFile; - return !(apkFile == null || !apkFile.canRead()); - - } - public boolean isInstalled(Context context) { // First check isApk() before isMediaInstalled() because the latter is quite expensive, // hitting the database for each apk version, then the disk to check for installed media. diff --git a/app/src/main/java/org/fdroid/fdroid/data/NewRepoConfig.java b/app/src/main/java/org/fdroid/fdroid/data/NewRepoConfig.java index 71c16b022..c6c6831bd 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/NewRepoConfig.java +++ b/app/src/main/java/org/fdroid/fdroid/data/NewRepoConfig.java @@ -25,7 +25,6 @@ public class NewRepoConfig { private String uriString; private String host; - private int port = -1; private String username; private String password; private String fingerprint; @@ -62,7 +61,6 @@ public class NewRepoConfig { // scheme and host should only ever be pure ASCII aka Locale.ENGLISH String scheme = uri.getScheme(); host = uri.getHost(); - port = uri.getPort(); if (TextUtils.isEmpty(scheme) || (TextUtils.isEmpty(host) && !"file".equals(scheme))) { errorMessage = String.format(context.getString(R.string.malformed_repo_uri), uri); Log.i(TAG, errorMessage); @@ -126,10 +124,6 @@ public class NewRepoConfig { return ssid; } - public int getPort() { - return port; - } - public String getRepoUriString() { return uriString; } diff --git a/app/src/main/java/org/fdroid/fdroid/data/Repo.java b/app/src/main/java/org/fdroid/fdroid/data/Repo.java index 3c5f77aca..b415c128e 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/Repo.java +++ b/app/src/main/java/org/fdroid/fdroid/data/Repo.java @@ -44,8 +44,6 @@ import java.util.List; */ public class Repo { - public static final int PUSH_REQUEST_IGNORE = 0; - public String address; @Deprecated // not taking mirrors into account diff --git a/app/src/main/java/org/fdroid/fdroid/installer/PrivilegedInstaller.java b/app/src/main/java/org/fdroid/fdroid/installer/PrivilegedInstaller.java index 69b16f49c..9e1d733e8 100644 --- a/app/src/main/java/org/fdroid/fdroid/installer/PrivilegedInstaller.java +++ b/app/src/main/java/org/fdroid/fdroid/installer/PrivilegedInstaller.java @@ -68,67 +68,60 @@ public class PrivilegedInstaller extends Installer { private static final String TAG = "PrivilegedInstaller"; - public static final String PRIVILEGED_EXTENSION_SERVICE_INTENT + private static final String PRIVILEGED_EXTENSION_SERVICE_INTENT = "org.fdroid.fdroid.privileged.IPrivilegedService"; public static final String PRIVILEGED_EXTENSION_PACKAGE_NAME = BuildConfig.PRIVILEGED_EXTENSION_PACKAGE_NAME; - public static final int IS_EXTENSION_INSTALLED_NO = 0; + private static final int IS_EXTENSION_INSTALLED_NO = 0; public static final int IS_EXTENSION_INSTALLED_YES = 1; - public static final int IS_EXTENSION_INSTALLED_SIGNATURE_PROBLEM = 2; + private static final int IS_EXTENSION_INSTALLED_SIGNATURE_PROBLEM = 2; // From AOSP source code - public static final int ACTION_INSTALL_REPLACE_EXISTING = 2; + private static final int ACTION_INSTALL_REPLACE_EXISTING = 2; /** * Following return codes are copied from AOSP 5.1 source code */ - public static final int INSTALL_SUCCEEDED = 1; - public static final int INSTALL_FAILED_ALREADY_EXISTS = -1; - public static final int INSTALL_FAILED_INVALID_APK = -2; - public static final int INSTALL_FAILED_INVALID_URI = -3; - public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4; - public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5; - public static final int INSTALL_FAILED_NO_SHARED_USER = -6; - public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7; - public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8; - public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9; - public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10; - public static final int INSTALL_FAILED_DEXOPT = -11; - public static final int INSTALL_FAILED_OLDER_SDK = -12; - public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13; - public static final int INSTALL_FAILED_NEWER_SDK = -14; - public static final int INSTALL_FAILED_TEST_ONLY = -15; - public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16; - public static final int INSTALL_FAILED_MISSING_FEATURE = -17; - public static final int INSTALL_FAILED_CONTAINER_ERROR = -18; - public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19; - public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20; - public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21; - public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22; - public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23; - public static final int INSTALL_FAILED_UID_CHANGED = -24; - public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25; - public static final int INSTALL_PARSE_FAILED_NOT_APK = -100; - public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101; - public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; - public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; - public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104; - public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105; - public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106; - public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107; - public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108; - public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109; - public static final int INSTALL_FAILED_INTERNAL_ERROR = -110; - public static final int INSTALL_FAILED_USER_RESTRICTED = -111; - public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112; - public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113; - /** - * Internal return code for NativeLibraryHelper methods to indicate that the package - * being processed did not contain any native code. This is placed here only so that - * it can belong to the same value space as the other install failure codes. - */ - public static final int NO_NATIVE_LIBRARIES = -114; - public static final int INSTALL_FAILED_ABORTED = -115; + private static final int INSTALL_SUCCEEDED = 1; + private static final int INSTALL_FAILED_ALREADY_EXISTS = -1; + private static final int INSTALL_FAILED_INVALID_APK = -2; + private static final int INSTALL_FAILED_INVALID_URI = -3; + private static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4; + private static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5; + private static final int INSTALL_FAILED_NO_SHARED_USER = -6; + private static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7; + private static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8; + private static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9; + private static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10; + private static final int INSTALL_FAILED_DEXOPT = -11; + private static final int INSTALL_FAILED_OLDER_SDK = -12; + private static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13; + private static final int INSTALL_FAILED_NEWER_SDK = -14; + private static final int INSTALL_FAILED_TEST_ONLY = -15; + private static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16; + private static final int INSTALL_FAILED_MISSING_FEATURE = -17; + private static final int INSTALL_FAILED_CONTAINER_ERROR = -18; + private static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19; + private static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20; + private static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21; + private static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22; + private static final int INSTALL_FAILED_PACKAGE_CHANGED = -23; + private static final int INSTALL_FAILED_UID_CHANGED = -24; + private static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25; + private static final int INSTALL_PARSE_FAILED_NOT_APK = -100; + private static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101; + private static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; + private static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; + private static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104; + private static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105; + private static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106; + private static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107; + private static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108; + private static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109; + private static final int INSTALL_FAILED_INTERNAL_ERROR = -110; + private static final int INSTALL_FAILED_USER_RESTRICTED = -111; + private static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112; + private static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113; private static final HashMap INSTALL_RETURN_CODES; @@ -233,12 +226,11 @@ public class PrivilegedInstaller extends Installer { "not match any of the ABIs supported by the system."); } - public static final int DELETE_SUCCEEDED = 1; - public static final int DELETE_FAILED_INTERNAL_ERROR = -1; - public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2; - public static final int DELETE_FAILED_USER_RESTRICTED = -3; - public static final int DELETE_FAILED_OWNER_BLOCKED = -4; - public static final int DELETE_FAILED_ABORTED = -5; + private static final int DELETE_SUCCEEDED = 1; + private static final int DELETE_FAILED_INTERNAL_ERROR = -1; + private static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2; + private static final int DELETE_FAILED_USER_RESTRICTED = -3; + private static final int DELETE_FAILED_OWNER_BLOCKED = -4; private static final HashMap UNINSTALL_RETURN_CODES; @@ -259,11 +251,11 @@ public class PrivilegedInstaller extends Installer { "device owner has marked the package as uninstallable."); } - public PrivilegedInstaller(Context context, @NonNull Apk apk) { + PrivilegedInstaller(Context context, @NonNull Apk apk) { super(context, apk); } - public static boolean isExtensionInstalled(Context context) { + private static boolean isExtensionInstalled(Context context) { PackageManager pm = context.getPackageManager(); try { pm.getPackageInfo(PRIVILEGED_EXTENSION_PACKAGE_NAME, PackageManager.GET_ACTIVITIES); @@ -317,7 +309,7 @@ public class PrivilegedInstaller extends Installer { IPrivilegedCallback callback = new IPrivilegedCallback.Stub() { @Override - public void handleResult(String packageName, int returnCode) throws RemoteException { + public void handleResult(String packageName, int returnCode) { if (returnCode == INSTALL_SUCCEEDED) { sendBroadcastInstall(canonicalUri, ACTION_INSTALL_COMPLETE); } else { @@ -363,7 +355,7 @@ public class PrivilegedInstaller extends Installer { IPrivilegedCallback callback = new IPrivilegedCallback.Stub() { @Override - public void handleResult(String packageName, int returnCode) throws RemoteException { + public void handleResult(String packageName, int returnCode) { if (returnCode == DELETE_SUCCEEDED) { sendBroadcastUninstall(ACTION_UNINSTALL_COMPLETE); } else { diff --git a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsActivity.java b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsActivity.java index 3dfbe459b..094e601fd 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsActivity.java +++ b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsActivity.java @@ -119,7 +119,7 @@ public class AppDetailsActivity extends AppCompatActivity @Override protected void onCreate(@Nullable Bundle savedInstanceState) { - FDroidApp fdroidApp = (FDroidApp) getApplication(); + fdroidApp = (FDroidApp) getApplication(); fdroidApp.applyPureBlackBackgroundInDarkTheme(this); super.onCreate(savedInstanceState); diff --git a/app/src/main/java/org/fdroid/fdroid/work/FDroidMetricsWorker.java b/app/src/main/java/org/fdroid/fdroid/work/FDroidMetricsWorker.java index ddeeefbb5..9cd99b789 100644 --- a/app/src/main/java/org/fdroid/fdroid/work/FDroidMetricsWorker.java +++ b/app/src/main/java/org/fdroid/fdroid/work/FDroidMetricsWorker.java @@ -158,23 +158,11 @@ public class FDroidMetricsWorker extends Worker { return ((weekNumber * DateUtils.WEEK_IN_MILLIS) + diff) / 1000L; } - static boolean isTimestampInReportingWeek(long timestamp) { - return isTimestampInReportingWeek(getReportingWeekStart(), timestamp); - } - static boolean isTimestampInReportingWeek(long weekStart, long timestamp) { long weekEnd = weekStart + DateUtils.WEEK_IN_MILLIS; return weekStart < timestamp && timestamp < weekEnd; } - static long getVersionCode(PackageInfo packageInfo) { - if (Build.VERSION.SDK_INT < 28) { - return packageInfo.versionCode; - } else { - return packageInfo.getLongVersionCode(); - } - } - /** * Gets the most recent week that is over based on the current time. * @@ -364,7 +352,6 @@ public class FDroidMetricsWorker extends Worker { final long period_start; final long period_end; long times = 0; - String value; MatomoEvent(long timestamp) { period_end = toCleanInsightsTimestamp(timestamp); @@ -387,7 +374,6 @@ public class FDroidMetricsWorker extends Worker { json.put("period_start", period_start); json.put("period_end", period_end); json.put("times", times); - json.put("value", value); return json; } @@ -405,7 +391,7 @@ public class FDroidMetricsWorker extends Worker { @Override public int hashCode() { - return Objects.hash(category, action, name, period_start, period_end, times, value); + return Objects.hash(category, action, name, period_start, period_end, times); } } diff --git a/app/src/main/res/layout/crash_report_dialog.xml b/app/src/main/res/layout/crash_report_dialog.xml deleted file mode 100644 index e98415556..000000000 --- a/app/src/main/res/layout/crash_report_dialog.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/test/java/org/fdroid/fdroid/TestFDroidApp.java b/app/src/test/java/org/fdroid/fdroid/TestFDroidApp.java index 15bef648f..530b6bd15 100644 --- a/app/src/test/java/org/fdroid/fdroid/TestFDroidApp.java +++ b/app/src/test/java/org/fdroid/fdroid/TestFDroidApp.java @@ -8,6 +8,7 @@ import android.app.Application; * {@link Application} instead of {@link FDroidApp}. It intentionally doesn't extends {@link FDroidApp} * so that the static initialization in {@link FDroidApp#onCreate()} is not executed. */ +@SuppressWarnings("unused") public class TestFDroidApp extends Application { } diff --git a/app/src/testFull/java/org/fdroid/fdroid/data/ShadowApp.java b/app/src/testFull/java/org/fdroid/fdroid/data/ShadowApp.java deleted file mode 100644 index d76dc72fe..000000000 --- a/app/src/testFull/java/org/fdroid/fdroid/data/ShadowApp.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.fdroid.fdroid.data; - -import android.content.Context; - -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; - -@Implements(App.class) -public class ShadowApp { - - @Implementation - protected static int[] getMinTargetMaxSdkVersions(Context context, String packageName) { - return new int[]{10, 23, Apk.SDK_VERSION_MAX_VALUE}; - } -} diff --git a/app/src/testFull/java/org/fdroid/fdroid/updater/SwapRepoTest.java b/app/src/testFull/java/org/fdroid/fdroid/updater/SwapRepoTest.java index 8f8d90fa6..604c24b52 100644 --- a/app/src/testFull/java/org/fdroid/fdroid/updater/SwapRepoTest.java +++ b/app/src/testFull/java/org/fdroid/fdroid/updater/SwapRepoTest.java @@ -13,15 +13,12 @@ import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.Hasher; import org.fdroid.fdroid.Preferences; import org.fdroid.fdroid.Utils; -import org.fdroid.fdroid.data.DBHelper; import org.fdroid.fdroid.data.Repo; -import org.fdroid.fdroid.data.ShadowApp; import org.fdroid.fdroid.nearby.LocalHTTPD; import org.fdroid.fdroid.nearby.LocalRepoKeyStore; import org.fdroid.fdroid.nearby.LocalRepoManager; import org.fdroid.fdroid.nearby.LocalRepoService; import org.fdroid.fdroid.nearby.WifiStateChangeService; -import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -36,9 +33,7 @@ import java.security.cert.Certificate; import androidx.test.core.app.ApplicationProvider; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.robolectric.Shadows.shadowOf; @@ -49,7 +44,6 @@ import static org.robolectric.Shadows.shadowOf; */ @Ignore @RunWith(RobolectricTestRunner.class) -@Config(shadows = ShadowApp.class) public class SwapRepoTest { private LocalHTTPD localHttpd;