Skip to content

Commit 9966d2e

Browse files
authored
Update to TargetSdk 35, Fixes AB#3291158 (#2713)
[AB#3291158](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/3291158) Bump - TargetSdk/CompileSdk/buildTools to 35 - minSdk to 24 - AGP to 8.10.0 - Kotlin, Mockito, lombok, Robolectric (to the compatible versions) - JVM to 1.8 Removed desugaring and migrated test code away from new Java API. This is because AGP 8.6+ added a compile time check, and we don't want to force our consuming app to desugar (which will increase APK size) already validated with weekly/monthly pipeline.
1 parent f7747f2 commit 9966d2e

File tree

35 files changed

+327
-289
lines changed

35 files changed

+327
-289
lines changed

LabApiUtilities/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,6 @@ publishing {
115115
}
116116
}
117117
}
118+
119+
sourceCompatibility = "1.8"
120+
targetCompatibility = "1.8"

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
vNext
22
----------
3+
- [MAJOR] Bump TargetSdk to 35, minSdk to 24, AGP to 8.10.0 (#2713)
34
- [Minor] Improve tenant-based flighting for broker supporting code (#2717)
45
- [PATCH] Fix caching of secret key and add retries for InvalidKeyException during unwrap (#2659)
56
- [MINOR] Replace AbstractSecretKeyLoader with ISecretKeyProvider (#2666)

common/build.gradle

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,8 @@ plugins {
99

1010
apply from: '../versioning/version_tasks.gradle'
1111

12-
def desugarCode = false
13-
14-
if (project.hasProperty("sugar")) {
15-
desugarCode = sugar.toBoolean()
16-
}
17-
1812
buildSystem {
19-
desugar = desugarCode
13+
desugar = false
2014
}
2115

2216
def enableCodeCoverage = false
@@ -84,6 +78,10 @@ android {
8478
targetCompatibility JavaVersion.VERSION_1_8
8579
}
8680

81+
kotlinOptions {
82+
jvmTarget = "1.8"
83+
}
84+
8785
lintOptions {
8886
abortOnError true
8987
disable 'MissingPermission'
@@ -139,8 +137,6 @@ android {
139137

140138
dependencies {
141139
testImplementation project(path: ':testutils')
142-
//Java 8 - Desugaring - Enabled/Disabled via plugin
143-
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:$rootProject.ext.coreLibraryDesugaringVersion"
144140

145141
localApi(project(":common4j")) {
146142
transitive = false
@@ -196,7 +192,6 @@ dependencies {
196192
testImplementation "junit:junit:$rootProject.ext.junitVersion"
197193
testImplementation "org.mockito:mockito-core:$rootProject.ext.mockitoCoreVersion"
198194
testImplementation "org.mockito.kotlin:mockito-kotlin:$rootProject.ext.mockitoKotlinVersion"
199-
testImplementation "org.mockito:mockito-inline:$rootProject.ext.mockitoCoreVersion"
200195
testImplementation "io.mockk:mockk:1.11.0"
201196

202197
testImplementation "org.powermock:powermock-module-junit4:$rootProject.ext.powerMockVersion"

common/src/androidTest/java/com/microsoft/identity/common/crypto/AndroidWrappedKeyProviderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public void testPerf_WithCachedKey() throws ClientException {
222222

223223
// 23s With Google Pixel XL, OS Version 29 (100 loop)
224224
@Test
225-
@Ignore
225+
@Ignore("Performance test, ignore in normal test run")
226226
public void testPerf_NoCachedKey() throws ClientException {
227227
final AndroidWrappedKeyProvider keyProvider = new AndroidWrappedKeyProvider(MOCK_KEY_ALIAS, MOCK_KEY_FILE_PATH, context);
228228

common/src/androidTest/java/com/microsoft/identity/common/internal/platform/AndroidDevicePoPManagerTests.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,13 @@
2323
package com.microsoft.identity.common.internal.platform;
2424

2525
import android.content.Context;
26-
import android.os.Build;
2726
import android.util.Base64;
2827

29-
import androidx.annotation.RequiresApi;
3028
import androidx.test.InstrumentationRegistry;
3129
import androidx.test.core.app.ApplicationProvider;
3230
import androidx.test.ext.junit.runners.AndroidJUnit4;
3331

3432
import com.google.gson.Gson;
35-
import com.google.gson.JsonElement;
36-
import com.google.gson.JsonObject;
37-
import com.google.gson.JsonParser;
3833
import com.microsoft.identity.common.java.exception.ClientException;
3934
import com.microsoft.identity.common.java.crypto.IDevicePopManager;
4035
import com.google.gson.reflect.TypeToken;
@@ -457,7 +452,6 @@ public void testGenerateShr() throws ClientException, MalformedURLException, Par
457452
}
458453

459454
@Test
460-
@RequiresApi(Build.VERSION_CODES.N)
461455
public void testHasCertificateChain24() throws ClientException {
462456
Assert.assertFalse(mDevicePopManager.asymmetricKeyExists());
463457
mDevicePopManager.generateAsymmetricKey();
@@ -474,7 +468,6 @@ public void testHasCertificateChain24() throws ClientException {
474468
}
475469

476470
@Test
477-
@RequiresApi(Build.VERSION_CODES.N)
478471
public void testNullWhenQueryingNonexistentChain24() throws ClientException {
479472
Assert.assertFalse(mDevicePopManager.asymmetricKeyExists());
480473
// Returns null for nonexistent key

common/src/main/java/com/microsoft/identity/common/adal/internal/ADALError.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
package com.microsoft.identity.common.adal.internal;
2525

26+
import android.annotation.SuppressLint;
2627
import android.content.Context;
2728
import android.content.res.Configuration;
2829
import android.content.res.Resources;
@@ -676,6 +677,7 @@ public String getDescription() {
676677
* @param context {@link Context}
677678
* @return Error description
678679
*/
680+
@SuppressLint("DiscouragedApi")
679681
public String getLocalizedDescription(Context context) {
680682
// Optional overwrite to error descriptions from resource files.
681683
// Application can repeat the resource entries from libraries.
@@ -684,7 +686,6 @@ public String getLocalizedDescription(Context context) {
684686
// order.
685687
if (context != null) {
686688
Configuration conf = context.getResources().getConfiguration();
687-
@SuppressWarnings("deprecation")
688689
Resources resources = new Resources(context.getAssets(), context.getResources()
689690
.getDisplayMetrics(), conf);
690691
return resources.getString(resources.getIdentifier(this.name(), "string",

common/src/main/java/com/microsoft/identity/common/adal/internal/PowerManagerWrapper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
// THE SOFTWARE.
2323
package com.microsoft.identity.common.adal.internal;
2424

25-
import android.annotation.TargetApi;
2625
import android.content.Context;
2726
import android.os.Build;
2827
import android.os.PowerManager;
2928

3029
import androidx.annotation.NonNull;
30+
import androidx.annotation.RequiresApi;
3131

3232
/**
3333
* Wrapper class for PowerManager.
@@ -65,7 +65,7 @@ public static synchronized PowerManagerWrapper getInstance() {
6565
* @param connectionContext Context used to query if app is in idle mode.
6666
* @return true if the device is in doze/idle mode.
6767
*/
68-
@TargetApi(Build.VERSION_CODES.M)
68+
@RequiresApi(Build.VERSION_CODES.M)
6969
public boolean isDeviceIdleMode(final Context connectionContext) {
7070
return ((PowerManager) connectionContext.getSystemService(Context.POWER_SERVICE)).isDeviceIdleMode();
7171
}
@@ -130,7 +130,7 @@ public String getPowerOptimizationSettings(@NonNull final Context context){
130130
* @param connectionContext Context used to query if app is ignoring battery optimizations.
131131
* @return true if the given application package name is on the device's power allow list.
132132
*/
133-
@TargetApi(Build.VERSION_CODES.M)
133+
@RequiresApi(Build.VERSION_CODES.M)
134134
public boolean isIgnoringBatteryOptimizations(final Context connectionContext) {
135135
return ((PowerManager) connectionContext.getSystemService(Context.POWER_SERVICE)).isIgnoringBatteryOptimizations(connectionContext.getPackageName());
136136
}

common/src/main/java/com/microsoft/identity/common/adal/internal/UsageStatsManagerWrapper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
// THE SOFTWARE.
2323
package com.microsoft.identity.common.adal.internal;
2424

25-
import android.annotation.TargetApi;
2625
import android.app.usage.UsageStatsManager;
2726
import android.content.Context;
2827
import android.os.Build;
2928

29+
import androidx.annotation.RequiresApi;
30+
3031
/**
3132
* Wrapper class for UsageStatsManager.
3233
*/
@@ -62,7 +63,7 @@ public static synchronized UsageStatsManagerWrapper getInstance() {
6263
* @param connectionContext Context used to query app active state.
6364
* @return true if the app is inactive.
6465
*/
65-
@TargetApi(Build.VERSION_CODES.M)
66+
@RequiresApi(Build.VERSION_CODES.M)
6667
public boolean isAppInactive(final Context connectionContext) {
6768
return ((UsageStatsManager) connectionContext.getSystemService(Context.USAGE_STATS_SERVICE)).isAppInactive(connectionContext.getPackageName());
6869
}

common/src/main/java/com/microsoft/identity/common/adal/internal/net/DefaultConnectionService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
// THE SOFTWARE.
2323
package com.microsoft.identity.common.adal.internal.net;
2424

25-
import android.annotation.TargetApi;
2625
import android.content.Context;
2726
import android.net.ConnectivityManager;
2827
import android.net.NetworkCapabilities;
@@ -107,7 +106,6 @@ public boolean isConnectionAvailable() {
107106
* @return true if the device is API23 and one or both of the following is true: the device is in doze or the company
108107
* portal is in standby, false otherwise.
109108
*/
110-
@TargetApi(Build.VERSION_CODES.M)
111109
public boolean isNetworkDisabledFromOptimizations() {
112110
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
113111
final PowerManagerWrapper powerManagerWrapper = PowerManagerWrapper.getInstance();

common/src/main/java/com/microsoft/identity/common/internal/broker/SDMBroadcastReceiver.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import static com.microsoft.identity.common.java.cache.SharedPreferencesAccountCredentialCache.DEFAULT_ACCOUNT_CREDENTIAL_SHARED_PREFERENCES;
2626

27+
import android.annotation.SuppressLint;
2728
import android.content.BroadcastReceiver;
2829
import android.content.Context;
2930
import android.content.Intent;
@@ -58,8 +59,9 @@ public class SDMBroadcastReceiver {
5859
* @param context application context.
5960
* @param sharedDeviceModeCallback a callback to be called when SDM broadcast is received.
6061
*/
61-
synchronized public static void initialize( @NonNull final Context context,
62-
@NonNull final SharedDeviceModeCallback sharedDeviceModeCallback) {
62+
@SuppressLint("UnspecifiedRegisterReceiverFlag")
63+
synchronized public static void initialize(@NonNull final Context context,
64+
@NonNull final SharedDeviceModeCallback sharedDeviceModeCallback) {
6365
if (sSDMBroadcastReceiver == null) {
6466
sSDMBroadcastReceiver = new BroadcastReceiver() {
6567
@Override
@@ -69,7 +71,7 @@ public void onReceive(final Context context, final Intent intent) {
6971
};
7072

7173
final IntentFilter filter = new IntentFilter(SharedDeviceModeConstants.CURRENT_ACCOUNT_CHANGED_BROADCAST_IDENTIFIER);
72-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
74+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
7375
context.registerReceiver(sSDMBroadcastReceiver, filter, Context.RECEIVER_EXPORTED);
7476
} else {
7577
context.registerReceiver(sSDMBroadcastReceiver, filter);

0 commit comments

Comments
 (0)