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

View File

@@ -55,13 +55,14 @@
<!-- CAMERA permission requested by ZXing library --> <!-- CAMERA permission requested by ZXing library -->
<!-- storage group --> <!-- storage group -->
<!-- <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
No need on >= Android 4.4 for WRITE_EXTERNAL_STORAGE, because we use Storage Access Framework, <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
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.READ_MEDIA_AUDIO" />
--> <!-- Replaced by the READ_MEDIA_* permissions on sdk33 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
<!-- READ_EXTERNAL_STORAGE is now dangerous on Android >= 6 --> android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<!-- other group (for free) --> <!-- other group (for free) -->
<uses-permission android:name="android.permission.INTERNET" /> <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.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_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" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<!-- android:allowBackup="false": Don't allow backup over adb backup or other apps! --> <!-- android:allowBackup="false": Don't allow backup over adb backup or other apps! -->
<application <application
@@ -848,10 +850,12 @@
<service <service
android:name=".service.PassphraseCacheService" android:name=".service.PassphraseCacheService"
android:exported="false" android:exported="false"
android:foregroundServiceType="specialUse"
android:process=":passphrase_cache" /> android:process=":passphrase_cache" />
<service <service
android:name=".remote.CryptoInputParcelCacheService" android:name=".remote.CryptoInputParcelCacheService"
android:exported="false" android:exported="false"
android:foregroundServiceType="specialUse"
android:process=":remote_api" /> android:process=":remote_api" />
<provider <provider
@@ -973,6 +977,7 @@
android:enabled="true" android:enabled="true"
android:exported="true" android:exported="true"
android:process=":remote_api" android:process=":remote_api"
android:foregroundServiceType="specialUse"
tools:ignore="ExportedService"> tools:ignore="ExportedService">
<intent-filter> <intent-filter>
<action android:name="org.openintents.openpgp.IOpenPgpService" /> <action android:name="org.openintents.openpgp.IOpenPgpService" />
@@ -986,6 +991,7 @@
android:enabled="true" android:enabled="true"
android:exported="true" android:exported="true"
android:process=":remote_api_2" android:process=":remote_api_2"
android:foregroundServiceType="specialUse"
tools:ignore="ExportedService"> tools:ignore="ExportedService">
<intent-filter> <intent-filter>
<action android:name="org.openintents.openpgp.IOpenPgpService2" /> <action android:name="org.openintents.openpgp.IOpenPgpService2" />
@@ -999,6 +1005,7 @@
android:enabled="true" android:enabled="true"
android:exported="true" android:exported="true"
android:process=":remote_ssh_api" android:process=":remote_ssh_api"
android:foregroundServiceType="specialUse"
tools:ignore="ExportedService"> tools:ignore="ExportedService">
<intent-filter> <intent-filter>
<action android:name="org.openintents.ssh.authentication.ISshAuthenticationService" /> <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.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.net.Uri; import android.net.Uri;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.os.Messenger; import android.os.Messenger;
@@ -451,7 +453,11 @@ public class OrbotHelper {
intent.getStringExtra(EXTRA_STATUS)); intent.getStringExtra(EXTRA_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)); context.registerReceiver(receiver, new IntentFilter(OrbotHelper.ACTION_STATUS));
}
requestStartTor(context); requestStartTor(context);
} }

View File

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

View File

@@ -29,6 +29,8 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.Binder; import android.os.Binder;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
@@ -36,11 +38,11 @@ import android.os.IBinder;
import android.os.Message; import android.os.Message;
import android.os.Messenger; import android.os.Messenger;
import android.os.RemoteException; import android.os.RemoteException;
import androidx.collection.LongSparseArray;
import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationCompat.Builder; import androidx.core.app.NotificationCompat.Builder;
import androidx.core.app.NotificationCompat.InboxStyle; import androidx.core.app.NotificationCompat.InboxStyle;
import androidx.collection.LongSparseArray;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Constants.NotificationIds; import org.sufficientlysecure.keychain.Constants.NotificationIds;
import org.sufficientlysecure.keychain.NotificationChannelManager; import org.sufficientlysecure.keychain.NotificationChannelManager;
@@ -318,9 +320,13 @@ public class PassphraseCacheService extends Service {
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
filter.addAction(BROADCAST_ACTION_PASSPHRASE_CACHE_SERVICE); filter.addAction(BROADCAST_ACTION_PASSPHRASE_CACHE_SERVICE);
filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_OFF);
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
registerReceiver(mIntentReceiver, filter, RECEIVER_EXPORTED);
} else {
registerReceiver(mIntentReceiver, filter); registerReceiver(mIntentReceiver, filter);
} }
} }
}
/** /**
* Build pending intent that is executed by alarm manager to time out a specific passphrase * Build pending intent that is executed by alarm manager to time out a specific passphrase

View File

@@ -18,6 +18,7 @@
package org.sufficientlysecure.keychain.ui.util; package org.sufficientlysecure.keychain.ui.util;
import android.Manifest; import android.Manifest;
import android.Manifest.permission;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.ContentResolver; import android.content.ContentResolver;
@@ -25,8 +26,12 @@ import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import android.os.Build.VERSION_CODES;
import android.widget.Toast; import android.widget.Toast;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
@@ -34,6 +39,13 @@ import org.sufficientlysecure.keychain.R;
public class PermissionsUtil { public class PermissionsUtil {
private static final int PERMISSION_READ_EXTERNAL_STORAGE = 1; 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. * 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) { public static boolean checkAndRequestReadPermission(Activity activity, Uri uri) {
boolean result = checkReadPermission(activity, uri); boolean result = checkReadPermission(activity, uri);
if (!result) { if (!result) {
activity.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, activity.requestPermissions(getReadPermissions(), PERMISSION_READ_EXTERNAL_STORAGE);
PERMISSION_READ_EXTERNAL_STORAGE);
} }
return result; return result;
} }
@@ -56,12 +67,19 @@ public class PermissionsUtil {
public static boolean checkAndRequestReadPermission(Fragment fragment, Uri uri) { public static boolean checkAndRequestReadPermission(Fragment fragment, Uri uri) {
boolean result = checkReadPermission(fragment.getContext(), uri); boolean result = checkReadPermission(fragment.getContext(), uri);
if (!result) { if (!result) {
fragment.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, fragment.requestPermissions(getReadPermissions(), PERMISSION_READ_EXTERNAL_STORAGE);
PERMISSION_READ_EXTERNAL_STORAGE);
} }
return result; 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) { public static boolean checkReadPermission(Context context, Uri uri) {
if (!ContentResolver.SCHEME_FILE.equals(uri.getScheme())) { if (!ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
return true; return true;

View File

@@ -350,11 +350,6 @@ public class Preferences {
return mSharedPreferences.getBoolean(Pref.SYNC_KEYSERVER, true); 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) { public void setKeyserverSyncScheduled(UUID uuid) {
String value = uuid != null ? uuid.toString() : null; String value = uuid != null ? uuid.toString() : null;
mSharedPreferences.edit().putString(Pref.SYNC_WORK_UUID, value).apply(); mSharedPreferences.edit().putString(Pref.SYNC_WORK_UUID, value).apply();

View File

@@ -29,5 +29,5 @@ allprojects {
// SDK Version and Build Tools used by all subprojects // SDK Version and Build Tools used by all subprojects
// See http://tools.android.com/tech-docs/new-build-system/tips#TOC-Controlling-Android-properties-of-all-your-modules-from-the-main-project. // See http://tools.android.com/tech-docs/new-build-system/tips#TOC-Controlling-Android-properties-of-all-your-modules-from-the-main-project.
ext { ext {
compileSdkVersion = 33 compileSdkVersion = 34
} }

View File

@@ -1,7 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
android { android {
compileSdkVersion 28 compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig { defaultConfig {
minSdkVersion 15 minSdkVersion 15
@@ -21,10 +21,10 @@ android {
} }
dependencies { dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.6.1'
// recycler // recycler
implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'com.beloo.widget:ChipsLayoutManager:0.3.7@aar' implementation 'com.beloo.widget:ChipsLayoutManager:0.3.7@aar'
} }