Application: refuse to run on old android

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2018-07-28 18:27:45 +02:00
parent 6ceeac93bf
commit e29c21f8df
2 changed files with 13 additions and 0 deletions

View File

@ -19,6 +19,7 @@ android {
targetSdkVersion 27 targetSdkVersion 27
versionCode 437 versionCode 437
versionName '0.0.20180725' versionName '0.0.20180725'
buildConfigField 'int', 'MIN_SDK_VERSION', "$minSdkVersion.apiLevel"
} }
// If the keystore file exists // If the keystore file exists
if (keystorePropertiesFile.exists()) { if (keystorePropertiesFile.exists()) {

View File

@ -6,10 +6,12 @@
package com.wireguard.android; package com.wireguard.android;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.Signature; import android.content.pm.Signature;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
@ -97,6 +99,16 @@ public class Application extends android.app.Application {
@Override @Override
protected void attachBaseContext(final Context context) { protected void attachBaseContext(final Context context) {
super.attachBaseContext(context); super.attachBaseContext(context);
if (BuildConfig.MIN_SDK_VERSION > Build.VERSION.SDK_INT) {
final Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
System.exit(0);
}
final String installSource = getInstallSource(context); final String installSource = getInstallSource(context);
if (installSource != null) { if (installSource != null) {
ACRA.init(this); ACRA.init(this);