From 08b525608e634ff30a8caa8e3ae6d1bf54fa59ef Mon Sep 17 00:00:00 2001 From: jacquarg Date: Fri, 26 Jul 2024 11:02:12 +0200 Subject: [PATCH 1/3] feat:2376: Check compatibility with sdk34, allows use on android above sdk33. --- build.gradle | 2 +- .../main/java/android/app/AppOpsManager.java | 12 +++++---- .../java/android/app/NotificationChannel.java | 3 +++ .../android/content/pm/PackageManager.java | 27 ++++++++++++------- .../java/android/content/pm/UserInfo.java | 5 ++-- .../src/main/java/android/net/VpnManager.java | 14 +++++----- .../main/java/android/os/ServiceManager.java | 13 ++++++++- .../src/main/java/android/os/UserHandle.java | 14 +++++++++- .../src/main/java/android/os/UserManager.java | 15 ++++++++--- .../PermissionsPrivacyModuleImpl.kt | 20 ++++---------- 10 files changed, 79 insertions(+), 46 deletions(-) diff --git a/build.gradle b/build.gradle index 932ac0a0..95f04db3 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ buildscript { ext.buildConfig = [ 'compileSdk': 34, 'minSdk' : 30, - 'targetSdk' : 33, + 'targetSdk' : 34, 'version' : [ 'major': 2, 'minor': 2, diff --git a/permissionseos/libs/hidden-apis-stub/src/main/java/android/app/AppOpsManager.java b/permissionseos/libs/hidden-apis-stub/src/main/java/android/app/AppOpsManager.java index 753b4568..1bd64e51 100644 --- a/permissionseos/libs/hidden-apis-stub/src/main/java/android/app/AppOpsManager.java +++ b/permissionseos/libs/hidden-apis-stub/src/main/java/android/app/AppOpsManager.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 E FOUNDATION + * Copyright (C) 2022 - 2024 E FOUNDATION * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ import android.annotation.TargetApi; import androidx.annotation.DeprecatedSinceApi; import androidx.annotation.NonNull; +import androidx.annotation.RequiresPermission; // Stub based on: // https://gitlab.e.foundation/e/os/android_frameworks_base/-/blob/[SDK_VERSION]/core/java/android/app/AppOpsManager.java @@ -30,8 +31,8 @@ public class AppOpsManager { @TargetApi(29) @DeprecatedSinceApi( - api = 34, - message = "Check disponibility in SDK34" + api = 35, + message = "Check availability in SDK35" ) public static int strOpToOp(@NonNull String op) { return 0; @@ -39,8 +40,9 @@ public class AppOpsManager { @TargetApi(29) @DeprecatedSinceApi( - api = 34, - message = "Check disponibility in SDK34" + api = 35, + message = "Check availability in SDK35" ) + @RequiresPermission("android.permission.MANAGE_APP_OPS_MODES") public void setMode(int code, int uid, String packageName, int mode) {} } diff --git a/permissionseos/libs/hidden-apis-stub/src/main/java/android/app/NotificationChannel.java b/permissionseos/libs/hidden-apis-stub/src/main/java/android/app/NotificationChannel.java index 9e8d65a9..66be7183 100644 --- a/permissionseos/libs/hidden-apis-stub/src/main/java/android/app/NotificationChannel.java +++ b/permissionseos/libs/hidden-apis-stub/src/main/java/android/app/NotificationChannel.java @@ -1,4 +1,5 @@ /* + * Copyright (C) 2024 E FOUNDATION * Copyright (C) 2022 MURENA SAS * * This program is free software: you can redistribute it and/or modify @@ -21,6 +22,8 @@ import android.annotation.TargetApi; import androidx.annotation.DeprecatedSinceApi; +// Stub based on: +// https://gitlab.e.foundation/e/os/android_frameworks_base/-/blob/[SDK_VERSION]/core/java/android/app/NotificationChannel.java public class NotificationChannel { @TargetApi(29) diff --git a/permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/PackageManager.java b/permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/PackageManager.java index c6232ce3..be45c770 100644 --- a/permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/PackageManager.java +++ b/permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/PackageManager.java @@ -1,4 +1,5 @@ /* + * Copyright (C) 2024 E FOUNDATION * Copyright (C) 2022 MURENA SAS * * This program is free software: you can redistribute it and/or modify @@ -34,8 +35,8 @@ public abstract class PackageManager { @TargetApi(29) @DeprecatedSinceApi( - api = 34, - message = "Check availability in SDK34" + api = 35, + message = "Check availability in SDK35" ) public static class NameNotFoundException extends AndroidException { public NameNotFoundException() { @@ -49,8 +50,8 @@ public abstract class PackageManager { @TargetApi(29) @DeprecatedSinceApi( - api = 34, - message = "Check disponibility in SDK34" + api = 35, + message = "Check availability in SDK35" ) @RequiresPermission("android.permission.GRANT_RUNTIME_PERMISSIONS") public abstract void grantRuntimePermission( @@ -61,8 +62,8 @@ public abstract class PackageManager { @TargetApi(29) @DeprecatedSinceApi( - api = 34, - message = "Check disponibility in SDK34" + api = 35, + message = "Check availability in SDK35" ) @RequiresPermission("android.permission.REVOKE_RUNTIME_PERMISSIONS") public abstract void revokeRuntimePermission( @@ -73,8 +74,10 @@ public abstract class PackageManager { @TargetApi(29) @DeprecatedSinceApi( - api = 33, - message = "@deprecated Use {@link #getApplicationInfoAsUser(String, ApplicationInfoFlags, int)} instead." + api = 35, + message = "Check availability in SDK35, since SDK33, " + + "Use {@link #getApplicationInfoAsUser(String, ApplicationInfoFlags, int)} " + + "when long flags are needed." ) public abstract ApplicationInfo getApplicationInfoAsUser( @NonNull String packageName, @@ -85,8 +88,10 @@ public abstract class PackageManager { @TargetApi(29) @DeprecatedSinceApi( - api = 34, - message = "Check disponibility in SDK34" + api = 35, + message = "Check availability in SDK35, since SDK33, " + + "Use {@link #getInstalledPackagesAsUser(PackageInfoFlags, int)} " + + "when long flags are needed." ) @RequiresPermission("android.permission.INTERACT_ACROSS_USERS_FULL") public abstract List getInstalledPackagesAsUser(int flags, int userId); @@ -94,11 +99,13 @@ public abstract class PackageManager { // Public public abstract List getInstalledPackages(int flags); + // Public @NonNull public abstract Drawable getUserBadgedIcon( @NonNull Drawable drawable, @NonNull UserHandle user ); + // Public public static final int GET_PERMISSIONS = 0x00001000; } diff --git a/permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/UserInfo.java b/permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/UserInfo.java index 28a3732f..827fb8a8 100644 --- a/permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/UserInfo.java +++ b/permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/UserInfo.java @@ -1,4 +1,5 @@ /* + * Copyright (C) 2024 E FOUNDATION * Copyright (C) 2022 MURENA SAS * * This program is free software: you can redistribute it and/or modify @@ -27,8 +28,8 @@ public class UserInfo { @TargetApi(29) @DeprecatedSinceApi( - api = 34, - message = "Check availability in SDK34" + api = 35, + message = "Check availability in SDK35" ) public UserHandle getUserHandle() { return null; diff --git a/permissionseos/libs/hidden-apis-stub/src/main/java/android/net/VpnManager.java b/permissionseos/libs/hidden-apis-stub/src/main/java/android/net/VpnManager.java index dab21737..2854e2e6 100644 --- a/permissionseos/libs/hidden-apis-stub/src/main/java/android/net/VpnManager.java +++ b/permissionseos/libs/hidden-apis-stub/src/main/java/android/net/VpnManager.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 E FOUNDATION + * Copyright (C) 2022 - 2024 E FOUNDATION * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,8 +30,8 @@ public class VpnManager { @TargetApi(31) @DeprecatedSinceApi( - api = 34, - message = "Check disponibility in SDK34" + api = 35, + message = "Check availability in SDK35" ) public boolean prepareVpn( @Nullable String oldPackage, @@ -43,8 +43,8 @@ public class VpnManager { @TargetApi(31) @DeprecatedSinceApi( - api = 34, - message = "Check disponibility in SDK34" + api = 35, + message = "Check availability in SDK35" ) public void setVpnPackageAuthorization( String packageName, @@ -54,8 +54,8 @@ public class VpnManager { @TargetApi(31) @DeprecatedSinceApi( - api = 34, - message = "Check disponibility in SDK34" + api = 35, + message = "Check availability in SDK35" ) @RequiresPermission("android.permission.CONTROL_ALWAYS_ON_VPN") public String getAlwaysOnVpnPackageForUser(int userId) { diff --git a/permissionseos/libs/hidden-apis-stub/src/main/java/android/os/ServiceManager.java b/permissionseos/libs/hidden-apis-stub/src/main/java/android/os/ServiceManager.java index 4696b79f..901dfce6 100644 --- a/permissionseos/libs/hidden-apis-stub/src/main/java/android/os/ServiceManager.java +++ b/permissionseos/libs/hidden-apis-stub/src/main/java/android/os/ServiceManager.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 E FOUNDATION + * Copyright (C) 2022 - 2024 E FOUNDATION * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,18 @@ package android.os; +import android.annotation.TargetApi; + +import androidx.annotation.DeprecatedSinceApi; + +// Stub based on: +// https://gitlab.e.foundation/e/os/android_frameworks_base/-/blob/[SDK_VERSION]/core/java/android/os/ServiceManager.java public class ServiceManager { + @TargetApi(30) + @DeprecatedSinceApi( + api = 35, + message = "Check availability in SDK35" + ) public static IBinder getService(String name) { return null; } diff --git a/permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserHandle.java b/permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserHandle.java index df56daf3..52794413 100644 --- a/permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserHandle.java +++ b/permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserHandle.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 E FOUNDATION + * Copyright (C) 2022 - 2024 E FOUNDATION * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,19 @@ package android.os; +import android.annotation.TargetApi; + +import androidx.annotation.DeprecatedSinceApi; + +// Stub based on: +// https://gitlab.e.foundation/e/os/android_frameworks_base/-/blob/[SDK_VERSION]/core/java/android/os/ServiceManager.java public class UserHandle { + + @TargetApi(30) + @DeprecatedSinceApi( + api = 35, + message = "Check availability in SDK35" + ) public static /*@UserIdInt*/ int myUserId() { return 0; } diff --git a/permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserManager.java b/permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserManager.java index be6797ed..01410d98 100644 --- a/permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserManager.java +++ b/permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserManager.java @@ -1,4 +1,5 @@ /* + * Copyright (C) 2024 E FOUNDATION * Copyright (C) 2022 MURENA SAS * * This program is free software: you can redistribute it and/or modify @@ -24,22 +25,28 @@ import androidx.annotation.DeprecatedSinceApi; import androidx.annotation.RequiresPermission; import java.util.List; +// Stub based on: +// https://gitlab.e.foundation/e/os/android_frameworks_base/-/blob/[SDK_VERSION]/core/java/android/os/UserManager.java public class UserManager { + // Since API 33, android.permission.QUERY_USERS can be used as an alternative + // to "android.permission.MANAGE_USERS" @TargetApi(29) @DeprecatedSinceApi( - api = 34, - message = "Check availability in SDK34" + api = 35, + message = "Check availability in SDK35" ) @RequiresPermission("android.permission.MANAGE_USERS") public List getProfiles(int userHandle) { return null; } + // Since API 33, android.permission.QUERY_USERS can be used as an alternative + // to "android.permission.MANAGE_USERS" @TargetApi(29) @DeprecatedSinceApi( - api = 34, - message = "Check availability in SDK34" + api = 35, + message = "Check availability in SDK35" ) @RequiresPermission("android.permission.MANAGE_USERS") public boolean isManagedProfile(int userId) { diff --git a/permissionseos/src/main/java/foundation/e/advancedprivacy/externalinterfaces/permissions/PermissionsPrivacyModuleImpl.kt b/permissionseos/src/main/java/foundation/e/advancedprivacy/externalinterfaces/permissions/PermissionsPrivacyModuleImpl.kt index dc50b478..57bc35d9 100644 --- a/permissionseos/src/main/java/foundation/e/advancedprivacy/externalinterfaces/permissions/PermissionsPrivacyModuleImpl.kt +++ b/permissionseos/src/main/java/foundation/e/advancedprivacy/externalinterfaces/permissions/PermissionsPrivacyModuleImpl.kt @@ -1,5 +1,6 @@ /* - * Copyright (C) 2021 E FOUNDATION, 2022 MURENA SAS + * Copyright (C) 2021 - 2024 E FOUNDATION, + * Copyright (C) 2022 MURENA SAS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -121,10 +122,7 @@ class PermissionsPrivacyModuleImpl(context: Context) : PermissionsPrivacyModuleB override fun setBlockable(notificationChannel: NotificationChannel) { when (Build.VERSION.SDK_INT) { 29 -> notificationChannel.setBlockableSystem(true) - 30, 31, 32, 33 -> notificationChannel.setBlockable(true) - else -> { - Log.e("Permissions-e", "Bad android sdk version") - } + else -> notificationChannel.setBlockable(true) } } @@ -132,11 +130,7 @@ class PermissionsPrivacyModuleImpl(context: Context) : PermissionsPrivacyModuleB return when (Build.VERSION.SDK_INT) { 29 -> setVpnPackageAuthorizationSDK29(packageName) 30 -> setVpnPackageAuthorizationSDK30(packageName) - 31, 32, 33 -> setVpnPackageAuthorizationSDK32(packageName) - else -> { - Log.e("Permissions-e", "Bad android sdk version") - false - } + else -> setVpnPackageAuthorizationSDK32(packageName) } } @@ -204,11 +198,7 @@ class PermissionsPrivacyModuleImpl(context: Context) : PermissionsPrivacyModuleB override fun getAlwaysOnVpnPackage(): String? { return when (Build.VERSION.SDK_INT) { 29, 30 -> getAlwaysOnVpnPackageSDK29() - 31, 32, 33 -> getAlwaysOnVpnPackageSDK32() - else -> { - Log.e("Permissions-e", "Bad android sdk version") - null - } + else -> getAlwaysOnVpnPackageSDK32() } } -- GitLab From 3d950a9ba9eb3f3cfa7d91dd2c8d7e31c7451904 Mon Sep 17 00:00:00 2001 From: jacquarg Date: Fri, 26 Jul 2024 17:33:44 +0200 Subject: [PATCH 2/3] feat:2376: Update orbotservice to 17.2.1-2 --- gradle/libs.versions.toml | 2 +- ipscrambling/dependencies.gradle | 6 +++--- ipscrambling/orbotservice | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 310efee6..cada81bb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ kotlinx-coroutines = "1.7.3" kotlin = "1.9.21" androidx-navigation = "2.7.6" androidx-lifecycle = "2.6.2" -orbotservice = "orbot-17.2.1-1" +orbotservice = "orbot-17.2.1-2" retrofit = "2.9.0" pcap4j = "1.8.2" diff --git a/ipscrambling/dependencies.gradle b/ipscrambling/dependencies.gradle index 8d072607..ce5d82b3 100644 --- a/ipscrambling/dependencies.gradle +++ b/ipscrambling/dependencies.gradle @@ -7,11 +7,11 @@ ext { androidx_appcompat : "1.3.1", androidx_constraint : "2.1.0", androidx_coordinator : "1.1.0", - androidx_core : "1.6.0", + androidx_core : "1.13.1", androidx_leanback : "1.2.0-alpha01", androidx_leanback_paging : "1.1.0-alpha08", androidx_leanback_tab : "1.1.0-beta01", - androidx_localbroadcast : "1.0.0", + androidx_localbroadcast : "1.1.0", androidx_multidex : "2.0.1", androidx_palette : "1.0.0", androidx_recyclerview : "1.2.1", @@ -21,7 +21,7 @@ ext { fastlane_screengrab : "2.0.0", guardian_jtorctl : "0.4.5.7", ipt_proxy : "1.7.1", - orbot_service : "orbot-17.2.1-1", //libs.versions.orbotservice, + orbot_service : "orbot-17.2.1-2", //libs.versions.orbotservice, orbot_service_dependencies : "orbot-17.2.1-1", pcap_core : "1.8.2", pcap_factory : "1.8.2", diff --git a/ipscrambling/orbotservice b/ipscrambling/orbotservice index 47063de9..bd096e7e 160000 --- a/ipscrambling/orbotservice +++ b/ipscrambling/orbotservice @@ -1 +1 @@ -Subproject commit 47063de997bd00a45fdfba3a0931d9358d954538 +Subproject commit bd096e7e312e340fe046d8adc4c3abe03f0133ec -- GitLab From d627af6b1bbffbe4608120156509df18e67f6df3 Mon Sep 17 00:00:00 2001 From: jacquarg Date: Tue, 30 Jul 2024 15:54:11 +0200 Subject: [PATCH 3/3] tech:2376: Improve sdk specific method naming. --- .../permissions/PermissionsPrivacyModuleImpl.kt | 8 ++++---- settings.gradle | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/permissionseos/src/main/java/foundation/e/advancedprivacy/externalinterfaces/permissions/PermissionsPrivacyModuleImpl.kt b/permissionseos/src/main/java/foundation/e/advancedprivacy/externalinterfaces/permissions/PermissionsPrivacyModuleImpl.kt index 57bc35d9..c61912d4 100644 --- a/permissionseos/src/main/java/foundation/e/advancedprivacy/externalinterfaces/permissions/PermissionsPrivacyModuleImpl.kt +++ b/permissionseos/src/main/java/foundation/e/advancedprivacy/externalinterfaces/permissions/PermissionsPrivacyModuleImpl.kt @@ -130,7 +130,7 @@ class PermissionsPrivacyModuleImpl(context: Context) : PermissionsPrivacyModuleB return when (Build.VERSION.SDK_INT) { 29 -> setVpnPackageAuthorizationSDK29(packageName) 30 -> setVpnPackageAuthorizationSDK30(packageName) - else -> setVpnPackageAuthorizationSDK32(packageName) + else -> setVpnPackageAuthorizationSDK31AndAbove(packageName) } } @@ -177,7 +177,7 @@ class PermissionsPrivacyModuleImpl(context: Context) : PermissionsPrivacyModuleB } @TargetApi(31) - private fun setVpnPackageAuthorizationSDK32(packageName: String): Boolean { + private fun setVpnPackageAuthorizationSDK31AndAbove(packageName: String): Boolean { val vpnManager = context.getSystemService(Context.VPN_MANAGEMENT_SERVICE) as VpnManager try { @@ -198,7 +198,7 @@ class PermissionsPrivacyModuleImpl(context: Context) : PermissionsPrivacyModuleB override fun getAlwaysOnVpnPackage(): String? { return when (Build.VERSION.SDK_INT) { 29, 30 -> getAlwaysOnVpnPackageSDK29() - else -> getAlwaysOnVpnPackageSDK32() + else -> getAlwaysOnVpnPackageSDK31AndAbove() } } @@ -217,7 +217,7 @@ class PermissionsPrivacyModuleImpl(context: Context) : PermissionsPrivacyModuleB } @TargetApi(31) - private fun getAlwaysOnVpnPackageSDK32(): String? { + private fun getAlwaysOnVpnPackageSDK31AndAbove(): String? { val vpnManager = context.getSystemService(Context.VPN_MANAGEMENT_SERVICE) as VpnManager return try { vpnManager.getAlwaysOnVpnPackageForUser(UserHandle.myUserId()) diff --git a/settings.gradle b/settings.gradle index 48b05551..f3a19a4e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -16,6 +16,7 @@ include ':trackers' include ':permissionseos' include ':permissionseos:libs:hidden-apis-stub' include ':ipscrambling' +// Uncomment and check ipscrambling/README.md to upgrade orbotservice. //include ':ipscrambling:orbotservice' include ':trackersservicestandalone' include ':trackersserviceeos' -- GitLab