* Can still return null, as there is potentially race conditions to do with uninstalling apps * such that querying the {@link PackageManager} for a given package may throw an exception. + *
+ * The {@code PackageManagerGetSignatures} lint check is not relevant here since this is doing + * nothing related to verifying the signature. The APK signatures are just processed to + * produce the unique ID of the signer to determine compatibility. This {@code Service} does + * nothing related to checking valid APK signatures. */ + @SuppressWarnings("PackageManagerGetSignatures") @Nullable private PackageInfo getPackageInfo(Intent intent, String packageName) { PackageInfo packageInfo = intent.getParcelableExtra(EXTRA_PACKAGE_INFO); diff --git a/app/src/main/java/org/fdroid/fdroid/data/PackageProvider.java b/app/src/main/java/org/fdroid/fdroid/data/PackageProvider.java index 49fb6db1f..3b4daee34 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/PackageProvider.java +++ b/app/src/main/java/org/fdroid/fdroid/data/PackageProvider.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.UriMatcher; import android.database.Cursor; import android.net.Uri; +import android.support.annotation.NonNull; import org.fdroid.fdroid.data.Schema.PackageTable; import org.fdroid.fdroid.data.Schema.PackageTable.Cols; @@ -123,7 +124,7 @@ public class PackageProvider extends FDroidProvider { } @Override - public Cursor query(Uri uri, String[] projection, + public Cursor query(@NonNull Uri uri, String[] projection, String customSelection, String[] selectionArgs, String sortOrder) { if (MATCHER.match(uri) != CODE_SINGLE) { throw new UnsupportedOperationException("Invalid URI for content provider: " + uri); @@ -150,12 +151,12 @@ public class PackageProvider extends FDroidProvider { * F-Droid client or not. */ @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 + "."); } @Override - public Uri insert(Uri uri, ContentValues values) { + public Uri insert(@NonNull Uri uri, ContentValues values) { long rowId = db().insertOrThrow(getTableName(), null, values); getContext().getContentResolver().notifyChange(AppProvider.getCanUpdateUri(), null); return getPackageIdUri(rowId); @@ -166,7 +167,7 @@ public class PackageProvider extends FDroidProvider { * new app all together as far as Android is concerned. */ @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 + "."); } } diff --git a/app/src/main/java/org/fdroid/fdroid/data/RepoProvider.java b/app/src/main/java/org/fdroid/fdroid/data/RepoProvider.java index a60bd9415..dac4da741 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/RepoProvider.java +++ b/app/src/main/java/org/fdroid/fdroid/data/RepoProvider.java @@ -7,6 +7,7 @@ import android.content.Context; import android.content.UriMatcher; import android.database.Cursor; import android.net.Uri; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.TextUtils; import android.util.Log; @@ -360,7 +361,7 @@ public class RepoProvider extends FDroidProvider { } @Override - public Cursor query(Uri uri, String[] projection, + public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { if (TextUtils.isEmpty(sortOrder)) { @@ -393,7 +394,7 @@ public class RepoProvider extends FDroidProvider { } @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 // for making sure that newly created repositories by default have the highest priority. @@ -439,7 +440,7 @@ public class RepoProvider extends FDroidProvider { } @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); switch (MATCHER.match(uri)) { @@ -463,7 +464,7 @@ public class RepoProvider extends FDroidProvider { } @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 // key in the package table to point to the best possible record in the app metadata table. diff --git a/app/src/main/java/org/fdroid/fdroid/data/SanitizedFile.java b/app/src/main/java/org/fdroid/fdroid/data/SanitizedFile.java index 0e6d46e40..1fa5e1597 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/SanitizedFile.java +++ b/app/src/main/java/org/fdroid/fdroid/data/SanitizedFile.java @@ -42,16 +42,16 @@ public class SanitizedFile extends File { * the path to an installed .apk on disk. In such situations, we can't meaningfully * sanitize it, but will still need to pass to a function which only allows SanitizedFile's * as arguments (because they interact with, e.g. shells). - * + *
* To illustrate, imagine perfectly valid file path: "/tmp/../secret/file.txt", * one cannot distinguish between: - * - * "/tmp/" (known safe directory) + "../secret/file.txt" (suspicious looking file name) - * - * and - * - * "/tmp/../secret/" (known safe directory) + "file.txt" (known safe file name) - * + *
+ * "/tmp/" (known safe directory) + "../secret/file.txt" (suspicious looking file name) + *
+ * and + *
+ * "/tmp/../secret/" (known safe directory) + "file.txt" (known safe file name) + *
* I guess the best this method offers us is the ability to uniquely trace the different * ways in which files are created and handled. It should make it easier to find and * prevent suspect usages of methods which only expect SanitizedFile's, but are given @@ -62,7 +62,7 @@ public class SanitizedFile extends File { } /** - * @see {@link org.fdroid.fdroid.data.SanitizedFile#knownSanitized(String)} + * @see org.fdroid.fdroid.data.SanitizedFile#knownSanitized(String) */ public static SanitizedFile knownSanitized(File file) { return new SanitizedFile(file); diff --git a/app/src/main/java/org/fdroid/fdroid/installer/InstallerService.java b/app/src/main/java/org/fdroid/fdroid/installer/InstallerService.java index 7002e435f..45edcb7d3 100644 --- a/app/src/main/java/org/fdroid/fdroid/installer/InstallerService.java +++ b/app/src/main/java/org/fdroid/fdroid/installer/InstallerService.java @@ -23,12 +23,15 @@ package org.fdroid.fdroid.installer; import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.os.Build; import android.support.annotation.NonNull; import android.support.v4.app.JobIntentService; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.WildcardFileFilter; +import org.fdroid.fdroid.AppDetails2; import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.data.Apk; +import org.fdroid.fdroid.data.App; import java.io.File; import java.io.FileFilter; @@ -131,8 +134,8 @@ public class InstallerService extends JobIntentService { * is not enough to catch all possible nulls. *
* If you quickly cycle between installing an app and uninstalling it, then
- * {@link org.fdroid.fdroid.data.App#installedApk} will still be null when
- * {@link org.fdroid.fdroid.AppDetails2#startUninstall()} calls
+ * {@link App#installedApk} will still be null when
+ * {@link AppDetails2#startUninstall()} calls
* this method. It is better to crash earlier here, before the {@link Intent}
* is sent with a null {@link Apk} instance since this service is set to
* receive Sticky Intents. That means they will automatically be resent
@@ -143,7 +146,9 @@ public class InstallerService extends JobIntentService {
* @param apk {@link Apk} instance of the app that will be uninstalled
*/
public static void uninstall(Context context, @NonNull Apk apk) {
- Objects.requireNonNull(apk);
+ if (Build.VERSION.SDK_INT >= 19) {
+ Objects.requireNonNull(apk);
+ }
Installer.sendBroadcastUninstall(context, apk, Installer.ACTION_UNINSTALL_STARTED);
diff --git a/app/src/main/java/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java b/app/src/main/java/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java
index ebfb20298..fc815ab08 100644
--- a/app/src/main/java/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java
+++ b/app/src/main/java/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java
@@ -1,20 +1,20 @@
/*
-**
-** Copyright 2007, The Android Open Source Project
-** Copyright 2015 Daniel Martí
* NOTES:
- * Based on AOSP core/java/android/widget/AppSecurityPermissions.java
- * latest included commit: a3f68ef2f6811cf72f1282214c0883db5a30901d
- * Reviewed against frameworks/base/core/java/android/widget/AppSecurityPermissions.java
+ * Based on AOSP {@code core/java/android/widget/AppSecurityPermissions.java},
+ * latest included commit: a3f68ef2f6811cf72f1282214c0883db5a30901d,
+ * Reviewed against {@code frameworks/base/core/java/android/widget/AppSecurityPermissions.java},
* from commit {@code android-8.1.0_r2}
- *
* To update this file, Start from latest included commit and include changes
* until the newest commit with care:
- * github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/AppSecurityPermissions.java
- *
* This file has a different code style than the rest of fdroidclient because
* it is kept in sync with the file from AOSP. Please maintain the original
* AOSP code style so it is easy to track changes.
@@ -426,6 +426,7 @@ public class AppSecurityPermissions {
return permView;
}
+ @TargetApi(23)
private boolean isDisplayablePermission(PermissionInfo pInfo, int existingReqFlags) {
final int base = pInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
final boolean isNormal = base == PermissionInfo.PROTECTION_NORMAL;
diff --git a/app/src/main/res/values-af/strings.xml b/app/src/main/res/values-af/strings.xml
index 073160452..d4c27fbc9 100644
--- a/app/src/main/res/values-af/strings.xml
+++ b/app/src/main/res/values-af/strings.xml
@@ -25,7 +25,6 @@