Update to targetSdk 34

This commit is contained in:
Vincent Breitmoser
2024-01-10 17:48:10 +01:00
parent 5d84bd8387
commit 6f3ce7aadb
9 changed files with 72 additions and 34 deletions

View File

@@ -7,13 +7,13 @@ plugins {
dependencies {
// from local Android SDK
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.annotation:annotation:1.5.0'
implementation 'androidx.annotation:annotation:1.7.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.sqlite:sqlite-framework:2.2.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.sqlite:sqlite-framework:2.4.0'
implementation 'com.google.android.material:material:1.11.0'
// JCenter etc.
implementation 'com.journeyapps:zxing-android-embedded:3.4.0'
@@ -61,7 +61,7 @@ dependencies {
implementation project(':extern:bouncycastle:pg')
// implementation project(':openkeychain:extern:bouncycastle:prov')
implementation 'androidx.work:work-runtime:2.7.1'
implementation 'androidx.work:work-runtime:2.9.0'
// Unit tests in the local JVM with Robolectric
// https://developer.android.com/training/testing/unit-testing/local-unit-tests.html
@@ -76,8 +76,8 @@ dependencies {
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'org.glassfish:javax.annotation:10.0-b28'
api "com.google.auto.value:auto-value-annotations:1.6.5"
annotationProcessor "com.google.auto.value:auto-value:1.6.2"
api 'com.google.auto.value:auto-value-annotations:1.10.4'
annotationProcessor 'com.google.auto.value:auto-value:1.6.2'
implementation 'com.ryanharter.auto.value:auto-value-parcel-adapter:0.2.6'
annotationProcessor "com.ryanharter.auto.value:auto-value-parcel:0.2.6"
@@ -94,7 +94,7 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 31
targetSdkVersion 34
versionCode 58902 // inconsistent at the moment - set to 59000 for 5.9.0!
versionName "5.8.2"
applicationId "org.sufficientlysecure.keychain"

View File

@@ -55,13 +55,14 @@
<!-- CAMERA permission requested by ZXing library -->
<!-- storage group -->
<!--
No need on >= Android 4.4 for WRITE_EXTERNAL_STORAGE, because we use Storage Access Framework,
but better not use maxSdkVersion as it causes problems: https://code.google.com/p/android/issues/detail?id=63895
-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- READ_EXTERNAL_STORAGE is now dangerous on Android >= 6 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<!-- Replaced by the READ_MEDIA_* permissions on sdk33 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<!-- other group (for free) -->
<uses-permission android:name="android.permission.INTERNET" />
@@ -71,6 +72,7 @@
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<!-- android:allowBackup="false": Don't allow backup over adb backup or other apps! -->
<application
@@ -848,10 +850,12 @@
<service
android:name=".service.PassphraseCacheService"
android:exported="false"
android:foregroundServiceType="specialUse"
android:process=":passphrase_cache" />
<service
android:name=".remote.CryptoInputParcelCacheService"
android:exported="false"
android:foregroundServiceType="specialUse"
android:process=":remote_api" />
<provider
@@ -973,6 +977,7 @@
android:enabled="true"
android:exported="true"
android:process=":remote_api"
android:foregroundServiceType="specialUse"
tools:ignore="ExportedService">
<intent-filter>
<action android:name="org.openintents.openpgp.IOpenPgpService" />
@@ -986,6 +991,7 @@
android:enabled="true"
android:exported="true"
android:process=":remote_api_2"
android:foregroundServiceType="specialUse"
tools:ignore="ExportedService">
<intent-filter>
<action android:name="org.openintents.openpgp.IOpenPgpService2" />
@@ -999,6 +1005,7 @@
android:enabled="true"
android:exported="true"
android:process=":remote_ssh_api"
android:foregroundServiceType="specialUse"
tools:ignore="ExportedService">
<intent-filter>
<action android:name="org.openintents.ssh.authentication.ISshAuthenticationService" />

View File

@@ -58,6 +58,8 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
@@ -451,7 +453,11 @@ public class OrbotHelper {
intent.getStringExtra(EXTRA_STATUS));
}
};
context.registerReceiver(receiver, new IntentFilter(OrbotHelper.ACTION_STATUS));
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
context.registerReceiver(receiver, new IntentFilter(OrbotHelper.ACTION_STATUS), Context.RECEIVER_EXPORTED);
} else {
context.registerReceiver(receiver, new IntentFilter(OrbotHelper.ACTION_STATUS));
}
requestStartTor(context);
}

View File

@@ -24,6 +24,8 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import org.sufficientlysecure.keychain.BuildConfig;
import org.sufficientlysecure.keychain.Constants;
@@ -71,7 +73,11 @@ public class UsbConnectionDispatcher {
final IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ACTION_USB_PERMISSION);
context.registerReceiver(usbBroadcastReceiver, intentFilter);
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
context.registerReceiver(usbBroadcastReceiver, intentFilter, Context.RECEIVER_EXPORTED);
} else {
context.registerReceiver(usbBroadcastReceiver, intentFilter);
}
}
public void onStop() {

View File

@@ -29,6 +29,8 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Binder;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
@@ -36,11 +38,11 @@ import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import androidx.collection.LongSparseArray;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationCompat.Builder;
import androidx.core.app.NotificationCompat.InboxStyle;
import androidx.collection.LongSparseArray;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Constants.NotificationIds;
import org.sufficientlysecure.keychain.NotificationChannelManager;
@@ -318,7 +320,11 @@ public class PassphraseCacheService extends Service {
IntentFilter filter = new IntentFilter();
filter.addAction(BROADCAST_ACTION_PASSPHRASE_CACHE_SERVICE);
filter.addAction(Intent.ACTION_SCREEN_OFF);
registerReceiver(mIntentReceiver, filter);
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
registerReceiver(mIntentReceiver, filter, RECEIVER_EXPORTED);
} else {
registerReceiver(mIntentReceiver, filter);
}
}
}

View File

@@ -18,6 +18,7 @@
package org.sufficientlysecure.keychain.ui.util;
import android.Manifest;
import android.Manifest.permission;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ContentResolver;
@@ -25,8 +26,12 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;
import androidx.core.content.ContextCompat;
import android.os.Build.VERSION_CODES;
import android.widget.Toast;
import org.sufficientlysecure.keychain.R;
@@ -34,6 +39,13 @@ import org.sufficientlysecure.keychain.R;
public class PermissionsUtil {
private static final int PERMISSION_READ_EXTERNAL_STORAGE = 1;
public static final String[] READ_PERMISSIONS = { permission.READ_EXTERNAL_STORAGE };
@RequiresApi(api = VERSION_CODES.TIRAMISU)
public static final String[] READ_PERMISSIONS_TIRAMISU = {
permission.READ_MEDIA_IMAGES,
permission.READ_MEDIA_AUDIO,
permission.READ_MEDIA_VIDEO
};
/**
* Request READ_EXTERNAL_STORAGE permission on Android >= 6.0 to read content from "file" Uris.
@@ -47,8 +59,7 @@ public class PermissionsUtil {
public static boolean checkAndRequestReadPermission(Activity activity, Uri uri) {
boolean result = checkReadPermission(activity, uri);
if (!result) {
activity.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
PERMISSION_READ_EXTERNAL_STORAGE);
activity.requestPermissions(getReadPermissions(), PERMISSION_READ_EXTERNAL_STORAGE);
}
return result;
}
@@ -56,12 +67,19 @@ public class PermissionsUtil {
public static boolean checkAndRequestReadPermission(Fragment fragment, Uri uri) {
boolean result = checkReadPermission(fragment.getContext(), uri);
if (!result) {
fragment.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
PERMISSION_READ_EXTERNAL_STORAGE);
fragment.requestPermissions(getReadPermissions(), PERMISSION_READ_EXTERNAL_STORAGE);
}
return result;
}
private static String[] getReadPermissions() {
if (Build.VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
return READ_PERMISSIONS_TIRAMISU;
} else {
return READ_PERMISSIONS;
}
}
public static boolean checkReadPermission(Context context, Uri uri) {
if (!ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
return true;

View File

@@ -350,11 +350,6 @@ public class Preferences {
return mSharedPreferences.getBoolean(Pref.SYNC_KEYSERVER, true);
}
public UUID getKeyserverSyncWorkUuid() {
String uuidString = mSharedPreferences.getString(Pref.SYNC_WORK_UUID, null);
return uuidString != null ? UUID.fromString(uuidString) : null;
}
public void setKeyserverSyncScheduled(UUID uuid) {
String value = uuid != null ? uuid.toString() : null;
mSharedPreferences.edit().putString(Pref.SYNC_WORK_UUID, value).apply();