Use App/Apk parceling instead of ContentVals

The usage of ContentValues to send App/Apk objects
to services was an hack in my opinion.
This hack broke in https://gitlab.com/fdroid/fdroidclient/merge_requests/359
where the packageName has been removed from the
toContentValues() method, which leads to NPEs in
the services.
This commit is contained in:
Dominik Schürmann 2016-07-25 16:59:53 +02:00
parent 321842836c
commit 2e92dc941b
4 changed files with 8 additions and 18 deletions

View File

@ -14,7 +14,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
public class Apk extends ValueObject implements Comparable<Apk>,Parcelable {
public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
// Using only byte-range keeps it only 8-bits in the SQLite database
public static final int SDK_VERSION_MAX_VALUE = Byte.MAX_VALUE;
@ -70,10 +70,6 @@ public class Apk extends ValueObject implements Comparable<Apk>,Parcelable {
public Apk() {
}
public Apk(Parcelable parcelable) {
this(new ContentValuesCursor((ContentValues) parcelable));
}
public Apk(Cursor cursor) {
checkCursorPosition(cursor);

View File

@ -35,7 +35,7 @@ import java.util.regex.Pattern;
import org.fdroid.fdroid.data.Schema.AppTable.Cols;
public class App extends ValueObject implements Comparable<App>,Parcelable {
public class App extends ValueObject implements Comparable<App>, Parcelable {
private static final String TAG = "App";
@ -145,10 +145,6 @@ public class App extends ValueObject implements Comparable<App>,Parcelable {
public App() {
}
public App(Parcelable parcelable) {
this(new ContentValuesCursor((ContentValues) parcelable));
}
public App(Cursor cursor) {
checkCursorPosition(cursor);

View File

@ -151,8 +151,8 @@ public class InstallManagerService extends Service {
return START_NOT_STICKY;
}
App app = new App(intent.getParcelableExtra(EXTRA_APP));
Apk apk = new Apk(intent.getParcelableExtra(EXTRA_APK));
App app = intent.getParcelableExtra(EXTRA_APP);
Apk apk = intent.getParcelableExtra(EXTRA_APK);
addToActive(urlString, app, apk);
NotificationCompat.Builder builder = createNotificationBuilder(urlString, apk);
@ -454,8 +454,8 @@ public class InstallManagerService extends Service {
Intent intent = new Intent(context, InstallManagerService.class);
intent.setAction(ACTION_INSTALL);
intent.setData(Uri.parse(urlString));
intent.putExtra(EXTRA_APP, app.toContentValues());
intent.putExtra(EXTRA_APK, apk.toContentValues());
intent.putExtra(EXTRA_APP, app);
intent.putExtra(EXTRA_APK, apk);
context.startService(intent);
}

View File

@ -23,7 +23,6 @@ import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Parcelable;
import org.fdroid.fdroid.data.Apk;
@ -52,8 +51,7 @@ public class InstallerService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
Parcelable apkParcel = intent.getParcelableExtra(Installer.EXTRA_APK);
Apk apk = apkParcel == null ? null : new Apk(apkParcel);
Apk apk = intent.getParcelableExtra(Installer.EXTRA_APK);
Installer installer = InstallerFactory.create(this, apk);
@ -80,7 +78,7 @@ public class InstallerService extends IntentService {
intent.setAction(ACTION_INSTALL);
intent.setData(localApkUri);
intent.putExtra(Installer.EXTRA_DOWNLOAD_URI, downloadUri);
intent.putExtra(Installer.EXTRA_APK, apk.toContentValues());
intent.putExtra(Installer.EXTRA_APK, apk);
context.startService(intent);
}