Commit 9654a23f authored by Ricki Hirner's avatar Ricki Hirner 🐑

Require SDK level 16

In Android < 4.1 (< level 16), android.database.Cursor doesn't implement Closeable,
although it provides close(). Since we now use the Kotlin .use() idiom (which requires
a Closeable) instead of calling close() manually or via Lombok, we need Closeable
Cursors and it's not worth to work around this because Android 4.0.4 is now very old.
parent 4f8031a3
......@@ -15,7 +15,7 @@ android {
defaultConfig {
applicationId "at.bitfire.davdroid"
minSdkVersion 15
minSdkVersion 16
targetSdkVersion 25
versionCode 152
......
......@@ -8,13 +8,9 @@
package at.bitfire.davdroid;
import android.os.Build;
import android.support.test.runner.AndroidJUnit4;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.IOException;
import java.net.Socket;
......@@ -26,6 +22,7 @@ import okhttp3.mockwebserver.MockWebServer;
import static android.support.test.InstrumentationRegistry.getTargetContext;
import static junit.framework.TestCase.assertFalse;
import static org.apache.commons.lang3.ArrayUtils.contains;
import static org.junit.Assert.assertTrue;
public class SSLSocketFactoryCompatTest {
......@@ -51,13 +48,10 @@ public class SSLSocketFactoryCompatTest {
assertTrue(s instanceof SSLSocket);
SSLSocket ssl = (SSLSocket)s;
assertFalse(org.apache.commons.lang3.ArrayUtils.contains(ssl.getEnabledProtocols(), "SSLv3"));
assertTrue(org.apache.commons.lang3.ArrayUtils.contains(ssl.getEnabledProtocols(), "TLSv1"));
if (Build.VERSION.SDK_INT >= 16) {
assertTrue(org.apache.commons.lang3.ArrayUtils.contains(ssl.getEnabledProtocols(), "TLSv1.1"));
assertTrue(org.apache.commons.lang3.ArrayUtils.contains(ssl.getEnabledProtocols(), "TLSv1.2"));
}
assertFalse(contains(ssl.getEnabledProtocols(), "SSLv3"));
assertTrue(contains(ssl.getEnabledProtocols(), "TLSv1"));
assertTrue(contains(ssl.getEnabledProtocols(), "TLSv1.1"));
assertTrue(contains(ssl.getEnabledProtocols(), "TLSv1.2"));
}
}
......@@ -14,9 +14,7 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import at.bitfire.davdroid.App;
import lombok.Cleanup;
......@@ -78,13 +76,6 @@ public class ServiceDB {
}
@Override
public void onOpen(SQLiteDatabase db) {
if (Build.VERSION.SDK_INT < 16)
db.execSQL("PRAGMA foreign_keys=ON;");
}
@Override
@RequiresApi(16)
public void onConfigure(SQLiteDatabase db) {
setWriteAheadLoggingEnabled(true);
db.setForeignKeyConstraintsEnabled(true);
......
......@@ -93,37 +93,23 @@ public class DebugInfoActivity extends AppCompatActivity implements LoaderManage
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME + " debug info");
// since Android 4.1, FileProvider permissions are handled in a useful way (using ClipData)
boolean asAttachment = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
try {
File debugInfoDir = new File(getCacheDir(), "debug-info");
debugInfoDir.mkdir();
if (asAttachment)
try {
File debugInfoDir = new File(getCacheDir(), "debug-info");
debugInfoDir.mkdir();
reportFile = new File(debugInfoDir, "debug.txt");
App.log.fine("Writing debug info to " + reportFile.getAbsolutePath());
FileWriter writer = new FileWriter(reportFile);
writer.write(report);
writer.close();
sendIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, getString(R.string.authority_log_provider), reportFile));
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} catch(IOException e) {
// creating an attachment failed, so send it inline
asAttachment = false;
StringBuilder builder = new StringBuilder();
builder .append("Couldn't write debug info file:\n")
.append(ExceptionUtils.getStackTrace(e))
.append("\n\n")
.append(report);
report = builder.toString();
}
reportFile = new File(debugInfoDir, "debug.txt");
App.log.fine("Writing debug info to " + reportFile.getAbsolutePath());
FileWriter writer = new FileWriter(reportFile);
writer.write(report);
writer.close();
if (!asAttachment)
sendIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, getString(R.string.authority_log_provider), reportFile));
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} catch(IOException e) {
// creating an attachment failed, so send it inline
sendIntent.putExtra(Intent.EXTRA_TEXT, report);
}
startActivity(Intent.createChooser(sendIntent, null));
}
......
Subproject commit fa232f72528d561066a0bdc9640969ee8ce5a199
Subproject commit b9bc6816038735b241f95d83561c5177f8041b35
Subproject commit 4df7fb10d07de0d1c466600f1c87747c060aebe0
Subproject commit fb1443322663e5d06dbd2288c53b0b7ae8296af1
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment