Okay, toss BouncyCastleProvider so we can release a beta.
This commit is contained in:
parent
857f39b480
commit
bb0ea876fa
3 changed files with 9 additions and 55 deletions
|
@ -7,8 +7,8 @@ android {
|
||||||
applicationId "com.keylesspalace.tusky"
|
applicationId "com.keylesspalace.tusky"
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
versionCode 22
|
versionCode 23
|
||||||
versionName "1.1.4-beta.6"
|
versionName "1.1.4-beta.7"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables.useSupportLibrary true
|
vectorDrawables.useSupportLibrary true
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,6 @@ dependencies {
|
||||||
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.1.1') {
|
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.1.1') {
|
||||||
exclude module: 'support-v4'
|
exclude module: 'support-v4'
|
||||||
}
|
}
|
||||||
compile 'org.bouncycastle:bcprov-jdk15on:1.57'
|
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
//room
|
//room
|
||||||
compile 'android.arch.persistence.room:runtime:1.0.0-alpha3'
|
compile 'android.arch.persistence.room:runtime:1.0.0-alpha3'
|
||||||
|
|
18
app/proguard-rules.pro
vendored
18
app/proguard-rules.pro
vendored
|
@ -45,19 +45,15 @@
|
||||||
-keepattributes SourceFile,LineNumberTable
|
-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
# remove all logging from production apk
|
# remove all logging from production apk
|
||||||
-assumenosideeffects class android.util.Log {
|
#-assumenosideeffects class android.util.Log {
|
||||||
public static *** getStackTraceString(...);
|
# public static *** getStackTraceString(...);
|
||||||
public static *** d(...);
|
# public static *** d(...);
|
||||||
public static *** w(...);
|
# public static *** w(...);
|
||||||
public static *** v(...);
|
# public static *** v(...);
|
||||||
public static *** i(...);
|
# public static *** i(...);
|
||||||
}
|
#}
|
||||||
|
|
||||||
# for jsoup
|
# for jsoup
|
||||||
-keep public class org.jsoup.** {
|
-keep public class org.jsoup.** {
|
||||||
public *;
|
public *;
|
||||||
}
|
}
|
||||||
|
|
||||||
# for bouncycastle
|
|
||||||
-keep class org.bouncycastle.**
|
|
||||||
-dontwarn javax.naming.**
|
|
||||||
|
|
|
@ -18,20 +18,13 @@ package com.keylesspalace.tusky;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.arch.persistence.room.Room;
|
import android.arch.persistence.room.Room;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.jakewharton.picasso.OkHttp3Downloader;
|
import com.jakewharton.picasso.OkHttp3Downloader;
|
||||||
import com.keylesspalace.tusky.db.AppDatabase;
|
import com.keylesspalace.tusky.db.AppDatabase;
|
||||||
import com.keylesspalace.tusky.util.OkHttpUtils;
|
import com.keylesspalace.tusky.util.OkHttpUtils;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
|
||||||
|
|
||||||
import java.security.Provider;
|
|
||||||
import java.security.Security;
|
|
||||||
|
|
||||||
public class TuskyApplication extends Application {
|
public class TuskyApplication extends Application {
|
||||||
private static final String TAG = "TuskyApplication"; // logging tag
|
|
||||||
private static AppDatabase db;
|
private static AppDatabase db;
|
||||||
|
|
||||||
public static AppDatabase getDB() {
|
public static AppDatabase getDB() {
|
||||||
|
@ -59,40 +52,6 @@ public class TuskyApplication extends Application {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Install the new provider or, if there's a pre-existing older version, replace the
|
|
||||||
* existing version of it. */
|
|
||||||
final String providerName = "BC";
|
|
||||||
Provider existingProvider = Security.getProvider(providerName);
|
|
||||||
if (existingProvider == null) {
|
|
||||||
try {
|
|
||||||
int priority = Security.addProvider(new BouncyCastleProvider());
|
|
||||||
Log.i(TAG, String.format("BouncyCastleProvider was added with priority %d.",
|
|
||||||
priority));
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
Log.e(TAG, "Permission to add the security provider was denied.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Provider replacement = new BouncyCastleProvider();
|
|
||||||
if (existingProvider.getVersion() < replacement.getVersion()) {
|
|
||||||
Provider[] providers = Security.getProviders();
|
|
||||||
int priority = 1;
|
|
||||||
for (int i = 0; i < providers.length; i++) {
|
|
||||||
if (providers[i].getName().equals(providerName)) {
|
|
||||||
priority = i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Security.removeProvider(providerName);
|
|
||||||
Security.insertProviderAt(replacement, priority);
|
|
||||||
Log.i(TAG, String.format(
|
|
||||||
"BouncyCastleProvider version %f was updated to version %f.",
|
|
||||||
existingProvider.getVersion(), replacement.getVersion()));
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
Log.e(TAG, "Permission to update a security provider was denied.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "tuskyDB")
|
db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "tuskyDB")
|
||||||
.allowMainThreadQueries()
|
.allowMainThreadQueries()
|
||||||
.build();
|
.build();
|
||||||
|
|
Loading…
Reference in a new issue