mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-04-24 00:37:10 -04:00
Merge branch 'acra-crashes' into 'master'
Handle more Acra crashes Closes acra-crash-reports#182 and acra-crash-reports#183 See merge request fdroid/fdroidclient!1191
This commit is contained in:
@@ -36,6 +36,7 @@ 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;
|
||||
import androidx.core.content.ContextCompat;
|
||||
@@ -128,6 +129,7 @@ public class UpdateService extends JobIntentService {
|
||||
return intent;
|
||||
}
|
||||
|
||||
@UiThread
|
||||
public static void updateNewRepoNow(Context context, String address, @Nullable String fingerprint) {
|
||||
enqueueWork(context, getIntent(context, address, fingerprint));
|
||||
}
|
||||
@@ -137,6 +139,7 @@ public class UpdateService extends JobIntentService {
|
||||
* when the system language changes, or the underlying OS was upgraded.
|
||||
* This wipes the existing database before running the update!
|
||||
*/
|
||||
@UiThread
|
||||
public static void forceUpdateRepo(Context context) {
|
||||
Intent intent = new Intent(context, UpdateService.class);
|
||||
intent.putExtra(EXTRA_FORCED_UPDATE, true);
|
||||
@@ -152,6 +155,7 @@ public class UpdateService extends JobIntentService {
|
||||
*
|
||||
* @see JobIntentService#enqueueWork(Context, Class, int, Intent)
|
||||
*/
|
||||
@UiThread
|
||||
private static void enqueueWork(Context context, @NonNull Intent intent) {
|
||||
if (FDroidApp.networkState > 0 && !Preferences.get().isOnDemandDownloadAllowed()) {
|
||||
Toast.makeText(context, R.string.updates_disabled_by_settings, Toast.LENGTH_LONG).show();
|
||||
|
||||
@@ -3,7 +3,9 @@ package org.fdroid.fdroid.data;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteException;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.util.ObjectsCompat;
|
||||
|
||||
@@ -32,9 +34,10 @@ final class ContentProviderMigrator {
|
||||
List<Repository> repos = repoDao.getRepositories();
|
||||
int weight = repos.isEmpty() ? 0 : repos.get(repos.size() - 1).getWeight();
|
||||
|
||||
try (SQLiteDatabase oldDb = new ContentProviderDbHelper(context).getReadableDatabase()) {
|
||||
try (ContentProviderDbHelper helper = new ContentProviderDbHelper(context)) {
|
||||
String[] projection = new String[]{"name", "address", "pubkey", "inuse", "userMirrors", "disabledMirrors",
|
||||
"username", "password"};
|
||||
SQLiteDatabase oldDb = helper.getReadableDatabase();
|
||||
try (Cursor c = oldDb.query("fdroid_repo", projection, null, null, null, null, null)) {
|
||||
while (c.moveToNext()) {
|
||||
String name = c.getString(c.getColumnIndexOrThrow("name"));
|
||||
@@ -83,6 +86,10 @@ final class ContentProviderMigrator {
|
||||
repoDao.updateUsernameAndPassword(repo.getRepoId(), username, password);
|
||||
}
|
||||
}
|
||||
} catch (SQLiteException e) {
|
||||
if (e.getMessage() != null && e.getMessage().contains("disabledMirrors")) {
|
||||
Log.e("DbHelper", "disabledMirrors column missing. Can't migrate. ", e);
|
||||
} else throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
package org.fdroid.fdroid.data;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.AnyThread;
|
||||
@@ -89,7 +91,8 @@ public class DBHelper {
|
||||
Log.d(TAG, "Migrating DB...");
|
||||
migrator.migrateOldRepos(context, db);
|
||||
migrator.removeOldDb(context);
|
||||
UpdateService.forceUpdateRepo(context);
|
||||
// force update on UiThread in case we need to show Toasts
|
||||
new Handler(Looper.getMainLooper()).post(() -> UpdateService.forceUpdateRepo(context));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user