drop Android 4.3, new min version is Android 4.4

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2020-09-28 17:15:05 +02:00
parent 64659dae12
commit d6a02ce765
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
19 changed files with 37 additions and 129 deletions

View file

@ -127,7 +127,7 @@ android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 18
minSdkVersion 19
targetSdkVersion 29
// arguments to be passed to functional tests

View file

@ -21,7 +21,6 @@
package com.owncloud.android.util;
import android.os.Build;
import android.text.TextUtils;
import com.google.gson.JsonElement;
@ -53,7 +52,6 @@ import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import androidx.annotation.RequiresApi;
import androidx.test.runner.AndroidJUnit4;
import static androidx.test.InstrumentationRegistry.getInstrumentation;
@ -82,7 +80,6 @@ import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@RunWith(AndroidJUnit4.class)
public class EncryptionTestIT {
private String privateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAo" +

View file

@ -257,7 +257,7 @@
android:exported="true"
android:grantUriPermissions="true"
android:permission="android.permission.MANAGE_DOCUMENTS"
android:enabled="@bool/atLeastKitKat">
android:enabled="true">
<intent-filter>
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
</intent-filter>

View file

@ -22,7 +22,6 @@
package com.owncloud.android.operations;
import android.content.Context;
import android.os.Build;
import android.util.Pair;
import com.nextcloud.client.account.User;
@ -47,8 +46,6 @@ import com.owncloud.android.utils.MimeType;
import java.io.File;
import java.util.UUID;
import androidx.annotation.RequiresApi;
import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
import static com.owncloud.android.datamodel.OCFile.ROOT_PATH;
@ -98,18 +95,12 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(parent, getStorageManager());
if (encryptedAncestor) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return encryptedCreate(parent, remoteParentPath, client);
} else {
Log_OC.e(TAG, "Encrypted upload on old Android API");
return new RemoteOperationResult(RemoteOperationResult.ResultCode.OLD_ANDROID_API);
}
return encryptedCreate(parent, remoteParentPath, client);
} else {
return normalCreate(client);
}
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private RemoteOperationResult encryptedCreate(OCFile parent, String remoteParentPath, OwnCloudClient client) {
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
String privateKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PRIVATE_KEY);

View file

@ -176,7 +176,7 @@ public class DownloadFileOperation extends RemoteOperation {
}
// decrypt file
if (file.isEncrypted() && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
if (file.isEncrypted()) {
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(account, context.getContentResolver());
OCFile parent = fileDataStorageManager.getFileByPath(file.getParentRemotePath());

View file

@ -500,7 +500,7 @@ public class RefreshFolderOperation extends RemoteOperation {
Account account,
Context context) {
DecryptedFolderMetadata metadata;
if (encryptedAncestor && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
if (encryptedAncestor) {
metadata = EncryptionUtils.downloadFolderMetadata(localFolder, client, context, account);
} else {
metadata = null;

View file

@ -97,8 +97,7 @@ public class RemoveFileOperation extends SyncOperation {
boolean localRemovalFailed = false;
if (!onlyLocalCopy) {
if (fileToRemove.isEncrypted() &&
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
if (fileToRemove.isEncrypted()) {
OCFile parent = getStorageManager().getFileByPath(fileToRemove.getParentRemotePath());
operation = new RemoveRemoteEncryptedFileOperation(fileToRemove.getRemotePath(),
parent.getLocalId(),

View file

@ -23,7 +23,6 @@ package com.owncloud.android.operations;
import android.accounts.Account;
import android.content.Context;
import android.os.Build;
import com.google.gson.reflect.TypeToken;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
@ -54,12 +53,9 @@ import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import androidx.annotation.RequiresApi;
/**
* Remote operation performing the removal of a remote encrypted file or folder
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
private static final String TAG = RemoveRemoteEncryptedFileOperation.class.getSimpleName();

View file

@ -430,12 +430,7 @@ public class UploadFileOperation extends SyncOperation {
if (encryptedAncestor) {
Log_OC.d(TAG, "encrypted upload");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return encryptedUpload(client, parent);
} else {
Log_OC.e(TAG, "Encrypted upload on old Android API");
return new RemoteOperationResult(ResultCode.OLD_ANDROID_API);
}
return encryptedUpload(client, parent);
} else {
Log_OC.d(TAG, "normal upload");
return normalUpload(client);
@ -443,7 +438,6 @@ public class UploadFileOperation extends SyncOperation {
}
@SuppressLint("AndroidLintUseSparseArrays") // gson cannot handle sparse arrays easily, therefore use hashmap
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private RemoteOperationResult encryptedUpload(OwnCloudClient client, OCFile parentFile) {
RemoteOperationResult result = null;
File temporalFile = null;

View file

@ -96,7 +96,6 @@ import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
import static com.owncloud.android.datamodel.OCFile.ROOT_PATH;
import static com.owncloud.android.files.services.FileUploader.LOCAL_BEHAVIOUR_MOVE;
@TargetApi(Build.VERSION_CODES.KITKAT)
public class DocumentsStorageProvider extends DocumentsProvider {
private static final String TAG = DocumentsStorageProvider.class.getSimpleName();
@ -135,11 +134,9 @@ public class DocumentsStorageProvider extends DocumentsProvider {
}
public static void notifyRootsChanged(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
String authority = context.getString(R.string.document_provider_authority);
Uri rootsUri = DocumentsContract.buildRootsUri(authority);
context.getContentResolver().notifyChange(rootsUri, null);
}
String authority = context.getString(R.string.document_provider_authority);
Uri rootsUri = DocumentsContract.buildRootsUri(authority);
context.getContentResolver().notifyChange(rootsUri, null);
}
@Override

View file

@ -23,7 +23,6 @@ package com.owncloud.android.ui.activity;
import android.annotation.SuppressLint;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.MenuItem;
@ -99,9 +98,8 @@ public class ExternalSiteWebView extends FileActivity {
// allow debugging (when building the debug version); see details in
// https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 ||
getResources().getBoolean(R.bool.is_beta))) {
if ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 ||
getResources().getBoolean(R.bool.is_beta)) {
Log_OC.d(this, "Enable debug for webView");
WebView.setWebContentsDebuggingEnabled(true);
}

View file

@ -918,13 +918,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
resetHeaderScrollingState();
if (file.isEncrypted()) {
// check if API >= 19
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
Snackbar.make(getRecyclerView(), R.string.end_to_end_encryption_not_supported,
Snackbar.LENGTH_LONG).show();
return;
}
User user = ((FileActivity) mContainerActivity).getUser().orElseThrow(RuntimeException::new);
// check if e2e app is enabled

View file

@ -23,7 +23,6 @@ package com.owncloud.android.utils;
import android.accounts.Account;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Pair;
@ -92,7 +91,6 @@ import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@ -144,7 +142,6 @@ public final class EncryptionUtils {
* @param decryptedFolderMetadata folder metaData to encrypt
* @return EncryptedFolderMetadata encrypted folder metadata
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static EncryptedFolderMetadata encryptFolderMetadata(DecryptedFolderMetadata decryptedFolderMetadata,
String privateKey)
throws NoSuchAlgorithmException, InvalidKeyException,
@ -183,7 +180,6 @@ public final class EncryptionUtils {
/*
* decrypt folder metaData with private key
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static DecryptedFolderMetadata decryptFolderMetaData(EncryptedFolderMetadata encryptedFolderMetadata,
String privateKey)
throws NoSuchAlgorithmException, InvalidKeyException,
@ -225,7 +221,6 @@ public final class EncryptionUtils {
*
* @return decrypted metadata or null
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static @Nullable
DecryptedFolderMetadata downloadFolderMetadata(OCFile folder, OwnCloudClient client,
Context context, Account account) {
@ -291,7 +286,6 @@ public final class EncryptionUtils {
* @param iv initialization vector, either from metadata or {@link EncryptionUtils#randomBytes(int)}
* @return encryptedFile with encryptedBytes and authenticationTag
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static EncryptedFile encryptFile(OCFile ocFile, byte[] encryptionKeyBytes, byte[] iv)
throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException, NoSuchPaddingException, InvalidKeyException,
@ -307,7 +301,6 @@ public final class EncryptionUtils {
* @param iv initialization vector, either from metadata or {@link EncryptionUtils#randomBytes(int)}
* @return encryptedFile with encryptedBytes and authenticationTag
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static EncryptedFile encryptFile(File file, byte[] encryptionKeyBytes, byte[] iv)
throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException, NoSuchPaddingException, InvalidKeyException,
@ -338,7 +331,6 @@ public final class EncryptionUtils {
* @param authenticationTag authenticationTag from metadata
* @return decrypted byte[]
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static byte[] decryptFile(File file, byte[] encryptionKeyBytes, byte[] iv, byte[] authenticationTag)
throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException, NoSuchPaddingException, InvalidKeyException,
@ -383,7 +375,6 @@ public final class EncryptionUtils {
* @param cert contains public key in it
* @return encrypted string
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static String encryptStringAsymmetric(String string, String cert)
throws NoSuchAlgorithmException,
NoSuchPaddingException, InvalidKeyException,
@ -419,7 +410,6 @@ public final class EncryptionUtils {
* @param privateKeyString private key
* @return decrypted string
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static String decryptStringAsymmetric(String string, String privateKeyString)
throws NoSuchAlgorithmException,
NoSuchPaddingException, InvalidKeyException,
@ -449,7 +439,6 @@ public final class EncryptionUtils {
* @param encryptionKeyBytes key, either from metadata or {@link EncryptionUtils#generateKey()}
* @return encrypted string
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static String encryptStringSymmetric(String string, byte[] encryptionKeyBytes)
throws NoSuchPaddingException,
InvalidKeyException,
@ -460,7 +449,6 @@ public final class EncryptionUtils {
return encryptStringSymmetric(string, encryptionKeyBytes, ivDelimiter);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@VisibleForTesting
public static String encryptStringSymmetricOld(String string, byte[] encryptionKeyBytes)
throws NoSuchPaddingException,
@ -472,7 +460,6 @@ public final class EncryptionUtils {
return encryptStringSymmetric(string, encryptionKeyBytes, ivDelimiterOld);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private static String encryptStringSymmetric(String string,
byte[] encryptionKeyBytes,
String delimiter)
@ -508,7 +495,6 @@ public final class EncryptionUtils {
* @param encryptionKeyBytes key from metadata
* @return decrypted string
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static String decryptStringSymmetric(String string, byte[] encryptionKeyBytes)
throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException, NoSuchPaddingException, InvalidKeyException,
@ -805,7 +791,6 @@ public final class EncryptionUtils {
* @param parentFile file metadata should be retrieved for
* @return Pair: boolean: true: metadata already exists, false: metadata new created
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static Pair<Boolean, DecryptedFolderMetadata> retrieveMetadata(OCFile parentFile,
OwnCloudClient client,
String privateKey,

View file

@ -526,14 +526,13 @@ public final class FileStorageUtils {
if (SDK_INT >= Build.VERSION_CODES.M && checkStoragePermission(context)) {
rv.clear();
}
if (SDK_INT >= Build.VERSION_CODES.KITKAT) {
String strings[] = getExtSdCardPathsForActivity(context);
File f;
for (String s : strings) {
f = new File(s);
if (!rv.contains(s) && canListFiles(f)) {
rv.add(s);
}
String[] extSdCardPaths = getExtSdCardPathsForActivity(context);
File f;
for (String extSdCardPath : extSdCardPaths) {
f = new File(extSdCardPath);
if (!rv.contains(extSdCardPath) && canListFiles(f)) {
rv.add(extSdCardPath);
}
}
@ -601,7 +600,6 @@ public final class FileStorageUtils {
* Taken from https://github.com/TeamAmaze/AmazeFileManager/blob/616f2a696823ab0e64ea7a017602dc08e783162e/app/src
* /main/java/com/amaze/filemanager/filesystem/FileUtil.java#L764 on 14.02.2019
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
private static String[] getExtSdCardPathsForActivity(Context context) {
List<String> paths = new ArrayList<>();
for (File file : context.getExternalFilesDirs("external")) {
@ -652,15 +650,11 @@ public final class FileStorageUtils {
public static final StandardDirectory DOCUMENTS;
static {
if (SDK_INT > Build.VERSION_CODES.KITKAT) {
DOCUMENTS = new StandardDirectory(
Environment.DIRECTORY_DOCUMENTS,
R.string.storage_documents,
R.drawable.ic_document_grey600
);
} else {
DOCUMENTS = null;
}
DOCUMENTS = new StandardDirectory(
Environment.DIRECTORY_DOCUMENTS,
R.string.storage_documents,
R.drawable.ic_document_grey600
);
}
public static final StandardDirectory DOWNLOADS = new StandardDirectory(

View file

@ -293,16 +293,12 @@ public final class ThemeUtils {
*/
public static void setColoredTitle(@Nullable ActionBar actionBar, String title, Context context) {
if (actionBar != null) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
actionBar.setTitle(title);
} else {
Spannable text = new SpannableString(title);
text.setSpan(new ForegroundColorSpan(appBarPrimaryFontColor(context)),
0,
text.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
actionBar.setTitle(text);
}
Spannable text = new SpannableString(title);
text.setSpan(new ForegroundColorSpan(appBarPrimaryFontColor(context)),
0,
text.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
actionBar.setTitle(text);
}
}
@ -318,16 +314,12 @@ public final class ThemeUtils {
*/
public static void setColoredSubtitle(@Nullable ActionBar actionBar, String title, Context context) {
if (actionBar != null) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
actionBar.setSubtitle(title);
} else {
Spannable text = new SpannableString(title);
text.setSpan(new ForegroundColorSpan(appBarSecondaryFontColor(context)),
0,
text.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
actionBar.setSubtitle(text);
}
Spannable text = new SpannableString(title);
text.setSpan(new ForegroundColorSpan(appBarSecondaryFontColor(context)),
0,
text.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
actionBar.setSubtitle(text);
}
}

View file

@ -20,7 +20,6 @@
package org.nextcloud.providers.cursors;
import android.annotation.TargetApi;
import android.database.MatrixCursor;
import android.os.AsyncTask;
import android.os.Build;
@ -31,7 +30,6 @@ import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.providers.DocumentsStorageProvider;
import com.owncloud.android.utils.MimeTypeUtil;
@TargetApi(Build.VERSION_CODES.KITKAT)
public class FileCursor extends MatrixCursor {
static final String[] DEFAULT_DOCUMENT_PROJECTION = new String[]{

View file

@ -21,17 +21,13 @@
package org.nextcloud.providers.cursors;
import android.accounts.Account;
import android.annotation.TargetApi;
import android.content.Context;
import android.database.MatrixCursor;
import android.os.Build;
import android.provider.DocumentsContract.Root;
import com.owncloud.android.R;
import com.owncloud.android.providers.DocumentsStorageProvider;
@TargetApi(Build.VERSION_CODES.KITKAT)
public class RootCursor extends MatrixCursor {
private static final String[] DEFAULT_ROOT_PROJECTION = new String[] {

View file

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
nextCloud Android client application
Copyright (C) 2016 Bartosz Przybylski <bart.p.pl@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2,
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<bool name="atLeastKitKat">true</bool>
</resources>

View file

@ -19,5 +19,4 @@
<!-- Default boolean values -->
<resources>
<bool name="large_land_layout">false</bool>
<bool name="atLeastKitKat">false</bool>
</resources>
</resources>