Skip to content

Commit

Permalink
Target SDK 34
Browse files Browse the repository at this point in the history
Build tools 34.0.0.
Update pending intents to support mutability flag.
  • Loading branch information
pranavpandey committed Jun 15, 2023
1 parent 8c10992 commit fcd07e9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Expand Up @@ -16,10 +16,10 @@

buildscript {
ext.versions = [
'compileSdk': 33,
'compileSdk': 34,
'minSdk' : 14,
'targetSdk' : 33,
'buildTools': '33.0.2',
'targetSdk' : 34,
'buildTools': '34.0.0',
'androidx' : '1.9.0'
]

Expand Down
Expand Up @@ -264,12 +264,20 @@ public static boolean isFilePicker(@Nullable Context context) {
* @return The updated flags.
*
* @see PendingIntent#FLAG_IMMUTABLE
* @see PendingIntent#FLAG_MUTABLE
* @see PendingIntent#FLAG_NO_CREATE
* @see PendingIntent#FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT
*/
@TargetApi(Build.VERSION_CODES.S)
@TargetApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
public static int addMutabilityFlag(int flags, boolean mutable) {
if (DynamicSdkUtils.is23() && !mutable) {
return flags | PendingIntent.FLAG_IMMUTABLE;
} else if (DynamicSdkUtils.is31() && mutable) {
if (DynamicSdkUtils.is34()) {
flags = flags | PendingIntent.FLAG_NO_CREATE
| PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT;
}

return flags | PendingIntent.FLAG_MUTABLE;
}

Expand Down Expand Up @@ -297,7 +305,6 @@ public static int addMutableFlag(int flags) {
* @return The updated flags.
*
* @see #addMutabilityFlag(int, boolean)
* @see PendingIntent#FLAG_IMMUTABLE
*/
public static int addImmutableFlag(int flags) {
return addMutabilityFlag(flags, false);
Expand Down
Expand Up @@ -477,6 +477,28 @@ public static boolean is33() {
return is33(false);
}

/**
* Detects if the current API version is 34 or above.
*
* @param equals {@code true} to check for equality.
* <p>{@code false} to match greater than or equal.
*
* @return {@code true} if the current API version is 34 or above.
*/
public static boolean is34(boolean equals) {
return equals ? Build.VERSION.SDK_INT == Build.VERSION_CODES.UPSIDE_DOWN_CAKE
: Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
}

/**
* Detects if the current API version is 34 or above.
*
* @return {@code true} if the current API version is 34 or above.
*/
public static boolean is34() {
return is34(false);
}

/**
* Detects if the current API version is U or above.
*
Expand All @@ -486,7 +508,7 @@ public static boolean is33() {
* @return {@code true} if the current API version is U or above.
*/
public static boolean isU(boolean equals) {
return is33(equals) && isPreview();
return is34() || (is33(equals) && isPreview());
}

/**
Expand Down

0 comments on commit fcd07e9

Please sign in to comment.