[app] Adapt to library changes related to non-null repo certs in the DB

This commit is contained in:
Torsten Grote 2024-04-05 18:05:44 -03:00
parent afd11f285f
commit a4b9b72d36
No known key found for this signature in database
GPG Key ID: 3E5F77D92CF891FF
4 changed files with 14 additions and 21 deletions

View File

@ -521,6 +521,7 @@ public class FDroidApp extends Application implements androidx.work.Configuratio
public static Repository createSwapRepo(String address, String certificate) {
long now = System.currentTimeMillis();
if (certificate == null) certificate = "d0ef";
return new Repository(42L, address, now, IndexFormatVersion.ONE, certificate, 20001L, 42,
now);
}

View File

@ -35,7 +35,6 @@ import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.core.app.JobIntentService;
import androidx.core.app.NotificationCompat;
@ -78,7 +77,6 @@ public class UpdateService extends JobIntentService {
public static final String LOCAL_ACTION_STATUS = "status";
private static final String EXTRA_MESSAGE = "msg";
private static final String EXTRA_REPO_FINGERPRINT = "fingerprint";
private static final String EXTRA_REPO_ERRORS = "repoErrors";
public static final String EXTRA_STATUS_CODE = "status";
private static final String EXTRA_MANUAL_UPDATE = "manualUpdate";
@ -115,14 +113,9 @@ public class UpdateService extends JobIntentService {
updateRepoNow(context, null);
}
public static void updateRepoNow(Context context, String address) {
updateNewRepoNow(context, address, null);
}
public static Intent getIntent(Context context, String address, @Nullable String fingerprint) {
public static Intent getIntent(Context context, String address) {
Intent intent = new Intent(context, UpdateService.class);
intent.putExtra(EXTRA_MANUAL_UPDATE, true);
intent.putExtra(EXTRA_REPO_FINGERPRINT, fingerprint);
if (!TextUtils.isEmpty(address)) {
intent.setData(Uri.parse(address));
}
@ -130,8 +123,8 @@ public class UpdateService extends JobIntentService {
}
@UiThread
public static void updateNewRepoNow(Context context, String address, @Nullable String fingerprint) {
enqueueWork(context, getIntent(context, address, fingerprint));
public static void updateRepoNow(Context context, String address) {
enqueueWork(context, getIntent(context, address));
}
/**
@ -396,7 +389,6 @@ public class UpdateService extends JobIntentService {
boolean manualUpdate = intent.getBooleanExtra(EXTRA_MANUAL_UPDATE, false);
boolean forcedUpdate = intent.getBooleanExtra(EXTRA_FORCED_UPDATE, false);
isForcedUpdate = forcedUpdate;
String fingerprint = intent.getStringExtra(EXTRA_REPO_FINGERPRINT);
String address = intent.getDataString();
try {
@ -465,11 +457,11 @@ public class UpdateService extends JobIntentService {
File.createTempFile("dl-", "", cacheDir);
final IndexV1Updater updater = new IndexV1Updater(db, tempFileProvider,
DownloaderFactory.INSTANCE, repoUriBuilder, compatChecker, listener);
result = updater.updateNewRepo(repo, fingerprint);
result = updater.update(repo);
} else {
final RepoUpdater updater = new RepoUpdater(cacheDir, db,
DownloaderFactory.INSTANCE, repoUriBuilder, compatChecker, listener);
result = updater.update(repo, fingerprint);
result = updater.update(repo);
}
if (result instanceof IndexUpdateResult.Unchanged) {
unchangedRepos++;

View File

@ -193,7 +193,7 @@ private fun getRepoString(repo: Repository, isPreferred: Boolean) = buildAnnotat
@Composable
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
fun RepoChooserSingleRepoPreview() {
val repo1 = Repository(1L, "1", 1L, TWO, null, 1L, 1, 1L)
val repo1 = Repository(1L, "1", 1L, TWO, "null", 1L, 1, 1L)
FDroidContent {
RepoChooser(listOf(repo1), 1L, 1L, {}, {})
}
@ -202,9 +202,9 @@ fun RepoChooserSingleRepoPreview() {
@Composable
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
fun RepoChooserPreview() {
val repo1 = Repository(1L, "1", 1L, TWO, null, 1L, 1, 1L)
val repo2 = Repository(2L, "2", 2L, TWO, null, 2L, 2, 2L)
val repo3 = Repository(3L, "2", 3L, TWO, null, 3L, 3, 3L)
val repo1 = Repository(1L, "1", 1L, TWO, "null", 1L, 1, 1L)
val repo2 = Repository(2L, "2", 2L, TWO, "null", 2L, 2, 2L)
val repo3 = Repository(3L, "2", 3L, TWO, "null", 3L, 3, 3L)
FDroidContent {
RepoChooser(listOf(repo1, repo2, repo3), 1L, 1L, {}, {})
}
@ -213,9 +213,9 @@ fun RepoChooserPreview() {
@Composable
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
fun RepoChooserNightPreview() {
val repo1 = Repository(1L, "1", 1L, TWO, null, 1L, 1, 1L)
val repo2 = Repository(2L, "2", 2L, TWO, null, 2L, 2, 2L)
val repo3 = Repository(3L, "2", 3L, TWO, null, 3L, 3, 3L)
val repo1 = Repository(1L, "1", 1L, TWO, "null", 1L, 1, 1L)
val repo2 = Repository(2L, "2", 2L, TWO, "null", 2L, 2, 2L)
val repo3 = Repository(3L, "2", 3L, TWO, "null", 3L, 3, 3L)
FDroidContent {
RepoChooser(listOf(repo1, repo2, repo3), 1L, 2L, {}, {})
}

View File

@ -143,7 +143,7 @@ public class UpdateServiceTest {
.putInt(Preferences.PREF_OVER_DATA, Preferences.OVER_NETWORK_ALWAYS)
.putInt(Preferences.PREF_OVER_WIFI, Preferences.OVER_NETWORK_ALWAYS)
.commit();
final Intent intent = UpdateService.getIntent(context, address, fingerprint);
final Intent intent = UpdateService.getIntent(context, address);
final TestUpdateService testUpdateService = Robolectric.buildService(TestUpdateService.class,
intent).bind().get();
Thread t = new Thread() {