set @NotNull properly when overriding methods

fdroid/fdroidclient!543
This commit is contained in:
Hans-Christoph Steiner 2018-08-08 12:08:33 +02:00
parent ae56d5c97c
commit 32296910df
6 changed files with 25 additions and 22 deletions

View File

@ -22,8 +22,7 @@ public class CrashReportSender implements ReportSender {
this.config = config; this.config = config;
} }
public void send(@NonNull Context context, @NonNull CrashReportData errorContent) public void send(@NonNull Context context, @NonNull CrashReportData errorContent) {
throws ReportSenderException {
Intent emailIntent = new Intent("android.intent.action.SENDTO"); Intent emailIntent = new Intent("android.intent.action.SENDTO");
emailIntent.setData(Uri.fromParts("mailto", this.config.mailTo(), (String) null)); emailIntent.setData(Uri.fromParts("mailto", this.config.mailTo(), (String) null));
emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

View File

@ -117,7 +117,7 @@ public class AppPrefsProvider extends FDroidProvider {
} }
@Override @Override
public Cursor query(Uri uri, String[] projection, public Cursor query(@NonNull Uri uri, String[] projection,
String customSelection, String[] selectionArgs, String sortOrder) { String customSelection, String[] selectionArgs, String sortOrder) {
if (MATCHER.match(uri) != CODE_SINGLE) { if (MATCHER.match(uri) != CODE_SINGLE) {
throw new UnsupportedOperationException("Invalid URI for app content provider: " + uri); throw new UnsupportedOperationException("Invalid URI for app content provider: " + uri);
@ -137,19 +137,19 @@ public class AppPrefsProvider extends FDroidProvider {
} }
@Override @Override
public int delete(Uri uri, String where, String[] whereArgs) { public int delete(@NonNull Uri uri, String where, String[] whereArgs) {
throw new UnsupportedOperationException("Delete not supported for " + uri + "."); throw new UnsupportedOperationException("Delete not supported for " + uri + ".");
} }
@Override @Override
public Uri insert(Uri uri, ContentValues values) { public Uri insert(@NonNull Uri uri, ContentValues values) {
db().insertOrThrow(getTableName(), null, values); db().insertOrThrow(getTableName(), null, values);
getContext().getContentResolver().notifyChange(AppProvider.getCanUpdateUri(), null); getContext().getContentResolver().notifyChange(AppProvider.getCanUpdateUri(), null);
return getAppUri(values.getAsString(Cols.PACKAGE_NAME)); return getAppUri(values.getAsString(Cols.PACKAGE_NAME));
} }
@Override @Override
public int update(Uri uri, ContentValues values, String where, String[] whereArgs) { public int update(@NonNull Uri uri, ContentValues values, String where, String[] whereArgs) {
if (MATCHER.match(uri) != CODE_SINGLE) { if (MATCHER.match(uri) != CODE_SINGLE) {
throw new UnsupportedOperationException("Update not supported for " + uri + "."); throw new UnsupportedOperationException("Update not supported for " + uri + ".");
} }

View File

@ -6,6 +6,7 @@ import android.content.Context;
import android.content.UriMatcher; import android.content.UriMatcher;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
@ -767,7 +768,7 @@ public class AppProvider extends FDroidProvider {
} }
@Override @Override
public Cursor query(Uri uri, String[] projection, String customSelection, String[] selectionArgs, String sortOrder) { public Cursor query(@NonNull Uri uri, String[] projection, String customSelection, String[] selectionArgs, String sortOrder) {
AppQuerySelection selection = new AppQuerySelection(customSelection, selectionArgs); AppQuerySelection selection = new AppQuerySelection(customSelection, selectionArgs);
// Queries which are for the main list of apps should not include swap apps. // Queries which are for the main list of apps should not include swap apps.
@ -910,7 +911,7 @@ public class AppProvider extends FDroidProvider {
} }
@Override @Override
public int delete(Uri uri, String where, String[] whereArgs) { public int delete(@NonNull Uri uri, String where, String[] whereArgs) {
if (MATCHER.match(uri) != REPO) { if (MATCHER.match(uri) != REPO) {
throw new UnsupportedOperationException("Delete not supported for " + uri + "."); throw new UnsupportedOperationException("Delete not supported for " + uri + ".");
} }
@ -934,7 +935,7 @@ public class AppProvider extends FDroidProvider {
} }
@Override @Override
public Uri insert(Uri uri, ContentValues values) { public Uri insert(@NonNull Uri uri, ContentValues values) {
long packageId = PackageProvider.Helper.ensureExists(getContext(), values.getAsString(Cols.Package.PACKAGE_NAME)); long packageId = PackageProvider.Helper.ensureExists(getContext(), values.getAsString(Cols.Package.PACKAGE_NAME));
values.remove(Cols.Package.PACKAGE_NAME); values.remove(Cols.Package.PACKAGE_NAME);
values.put(Cols.PACKAGE_ID, packageId); values.put(Cols.PACKAGE_ID, packageId);
@ -994,7 +995,7 @@ public class AppProvider extends FDroidProvider {
} }
@Override @Override
public int update(Uri uri, ContentValues values, String where, String[] whereArgs) { public int update(@NonNull Uri uri, ContentValues values, String where, String[] whereArgs) {
if (MATCHER.match(uri) != CALC_SUGGESTED_APKS) { if (MATCHER.match(uri) != CALC_SUGGESTED_APKS) {
throw new UnsupportedOperationException("Update not supported for " + uri + "."); throw new UnsupportedOperationException("Update not supported for " + uri + ".");
} }

View File

@ -9,6 +9,7 @@ import android.content.pm.PackageManager;
import android.content.res.Resources; import android.content.res.Resources;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
@ -221,7 +222,7 @@ public class InstalledAppProvider extends FDroidProvider {
} }
@Override @Override
public Cursor query(Uri uri, String[] projection, public Cursor query(@NonNull Uri uri, String[] projection,
String customSelection, String[] selectionArgs, String sortOrder) { String customSelection, String[] selectionArgs, String sortOrder) {
if (sortOrder == null) { if (sortOrder == null) {
sortOrder = Cols.APPLICATION_LABEL; sortOrder = Cols.APPLICATION_LABEL;
@ -261,7 +262,7 @@ public class InstalledAppProvider extends FDroidProvider {
} }
@Override @Override
public int delete(Uri uri, String where, String[] whereArgs) { public int delete(@NonNull Uri uri, String where, String[] whereArgs) {
if (MATCHER.match(uri) != CODE_SINGLE) { if (MATCHER.match(uri) != CODE_SINGLE) {
throw new UnsupportedOperationException("Delete not supported for " + uri + "."); throw new UnsupportedOperationException("Delete not supported for " + uri + ".");
@ -279,7 +280,7 @@ public class InstalledAppProvider extends FDroidProvider {
} }
@Override @Override
public Uri insert(Uri uri, ContentValues values) { public Uri insert(@NonNull Uri uri, ContentValues values) {
if (MATCHER.match(uri) != CODE_LIST) { if (MATCHER.match(uri) != CODE_LIST) {
throw new UnsupportedOperationException("Insert not supported for " + uri + "."); throw new UnsupportedOperationException("Insert not supported for " + uri + ".");
@ -309,7 +310,7 @@ public class InstalledAppProvider extends FDroidProvider {
* row, if one exists. This just throws {@link UnsupportedOperationException} * row, if one exists. This just throws {@link UnsupportedOperationException}
*/ */
@Override @Override
public int update(Uri uri, ContentValues values, String where, String[] whereArgs) { public int update(@NonNull Uri uri, ContentValues values, String where, String[] whereArgs) {
throw new UnsupportedOperationException("\"Update' not supported for installed appp provider." throw new UnsupportedOperationException("\"Update' not supported for installed appp provider."
+ " Instead, you should insert, and it will overwrite the relevant rows if one exists."); + " Instead, you should insert, and it will overwrite the relevant rows if one exists.");
} }

View File

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.UriMatcher; import android.content.UriMatcher;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.NonNull;
import org.fdroid.fdroid.data.Schema.PackageTable; import org.fdroid.fdroid.data.Schema.PackageTable;
import org.fdroid.fdroid.data.Schema.PackageTable.Cols; import org.fdroid.fdroid.data.Schema.PackageTable.Cols;
@ -123,7 +124,7 @@ public class PackageProvider extends FDroidProvider {
} }
@Override @Override
public Cursor query(Uri uri, String[] projection, public Cursor query(@NonNull Uri uri, String[] projection,
String customSelection, String[] selectionArgs, String sortOrder) { String customSelection, String[] selectionArgs, String sortOrder) {
if (MATCHER.match(uri) != CODE_SINGLE) { if (MATCHER.match(uri) != CODE_SINGLE) {
throw new UnsupportedOperationException("Invalid URI for content provider: " + uri); throw new UnsupportedOperationException("Invalid URI for content provider: " + uri);
@ -150,12 +151,12 @@ public class PackageProvider extends FDroidProvider {
* F-Droid client or not. * F-Droid client or not.
*/ */
@Override @Override
public int delete(Uri uri, String where, String[] whereArgs) { public int delete(@NonNull Uri uri, String where, String[] whereArgs) {
throw new UnsupportedOperationException("Delete not supported for " + uri + "."); throw new UnsupportedOperationException("Delete not supported for " + uri + ".");
} }
@Override @Override
public Uri insert(Uri uri, ContentValues values) { public Uri insert(@NonNull Uri uri, ContentValues values) {
long rowId = db().insertOrThrow(getTableName(), null, values); long rowId = db().insertOrThrow(getTableName(), null, values);
getContext().getContentResolver().notifyChange(AppProvider.getCanUpdateUri(), null); getContext().getContentResolver().notifyChange(AppProvider.getCanUpdateUri(), null);
return getPackageIdUri(rowId); return getPackageIdUri(rowId);
@ -166,7 +167,7 @@ public class PackageProvider extends FDroidProvider {
* new app all together as far as Android is concerned. * new app all together as far as Android is concerned.
*/ */
@Override @Override
public int update(Uri uri, ContentValues values, String where, String[] whereArgs) { public int update(@NonNull Uri uri, ContentValues values, String where, String[] whereArgs) {
throw new UnsupportedOperationException("Update not supported for " + uri + "."); throw new UnsupportedOperationException("Update not supported for " + uri + ".");
} }
} }

View File

@ -7,6 +7,7 @@ import android.content.Context;
import android.content.UriMatcher; import android.content.UriMatcher;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
@ -360,7 +361,7 @@ public class RepoProvider extends FDroidProvider {
} }
@Override @Override
public Cursor query(Uri uri, String[] projection, public Cursor query(@NonNull Uri uri, String[] projection,
String selection, String[] selectionArgs, String sortOrder) { String selection, String[] selectionArgs, String sortOrder) {
if (TextUtils.isEmpty(sortOrder)) { if (TextUtils.isEmpty(sortOrder)) {
@ -393,7 +394,7 @@ public class RepoProvider extends FDroidProvider {
} }
@Override @Override
public Uri insert(Uri uri, ContentValues values) { public Uri insert(@NonNull Uri uri, ContentValues values) {
// Don't let people specify arbitrary priorities. Instead, we are responsible // Don't let people specify arbitrary priorities. Instead, we are responsible
// for making sure that newly created repositories by default have the highest priority. // for making sure that newly created repositories by default have the highest priority.
@ -439,7 +440,7 @@ public class RepoProvider extends FDroidProvider {
} }
@Override @Override
public int delete(Uri uri, String where, String[] whereArgs) { public int delete(@NonNull Uri uri, String where, String[] whereArgs) {
QuerySelection selection = new QuerySelection(where, whereArgs); QuerySelection selection = new QuerySelection(where, whereArgs);
switch (MATCHER.match(uri)) { switch (MATCHER.match(uri)) {
@ -463,7 +464,7 @@ public class RepoProvider extends FDroidProvider {
} }
@Override @Override
public int update(Uri uri, ContentValues values, String where, String[] whereArgs) { public int update(@NonNull Uri uri, ContentValues values, String where, String[] whereArgs) {
// When the priority of a repo changes, we need to update the "preferred metadata" foreign // When the priority of a repo changes, we need to update the "preferred metadata" foreign
// key in the package table to point to the best possible record in the app metadata table. // key in the package table to point to the best possible record in the app metadata table.