ApkVerifier: check targetSdkVersion

This commit is contained in:
Dominik Schürmann 2016-06-10 12:20:36 +02:00
parent 6b18ab4204
commit 174b1d108f
2 changed files with 14 additions and 7 deletions

View File

@ -24,6 +24,7 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import org.apache.commons.io.FileUtils;
import org.fdroid.fdroid.Hasher;
@ -85,8 +86,15 @@ public class ApkVerifier {
}
int localTargetSdkVersion = localApkInfo.applicationInfo.targetSdkVersion;
int expectedTargetSdkVersion = expectedApk.targetSdkVersion;
Utils.debugLog(TAG, "localTargetSdkVersion: " + localTargetSdkVersion);
// TODO: check target sdk
Utils.debugLog(TAG, "expectedTargetSdkVersion: " + expectedTargetSdkVersion);
if (expectedTargetSdkVersion == Apk.SDK_VERSION_MIN_VALUE) {
// NOTE: In old fdroidserver versions, targetSdkVersion was not stored inside the repo!
Log.w(TAG, "Skipping check for targetSdkVersion, not available in this repo!");
} else if (localTargetSdkVersion != expectedTargetSdkVersion) {
throw new ApkVerificationException("targetSdkVersion of apk not equals expected targetSdkVersion!");
}
}

View File

@ -24,6 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Build;
import android.os.PatternMatcher;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
@ -110,12 +111,10 @@ public abstract class Installer {
}
private int newPermissionCount(Apk apk) {
// TODO: requires targetSdk in Apk class/database
//boolean supportsRuntimePermissions = pkgInfo.applicationInfo.targetSdkVersion
// >= Build.VERSION_CODES.M;
//if (supportsRuntimePermissions) {
// return 0;
//}
boolean supportsRuntimePermissions = apk.targetSdkVersion >= Build.VERSION_CODES.M;
if (supportsRuntimePermissions) {
return 0;
}
AppDiff appDiff = new AppDiff(context.getPackageManager(), apk);
if (appDiff.pkgInfo == null) {