diff --git a/CHANGELOG.md b/CHANGELOG.md index cdcb4b655..4946e1ece 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## Version 5.0.3 (In development) +### App Center Distribute + +* **[Fix]** Add RECEIVER_EXPORTED flag for install receiver +* **[Fix]** Add FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT flag for broadcast pending intent + ## Version 5.0.2 ### AppCenter diff --git a/sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/install/session/InstallStatusReceiver.java b/sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/install/session/InstallStatusReceiver.java index 5bd0a99ee..69b5d5238 100644 --- a/sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/install/session/InstallStatusReceiver.java +++ b/sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/install/session/InstallStatusReceiver.java @@ -34,8 +34,9 @@ class InstallStatusReceiver extends BroadcastReceiver { static final String INSTALL_STATUS_ACTION = "com.microsoft.appcenter.action.INSTALL_STATUS"; /** - * Raw value of PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT which will appear only in - * Android target SDK 34. + * Raw value of PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT + * https://developer.android.com/reference/android/app/PendingIntent#FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT + * which will appear only in Android target SDK 34. */ @VisibleForTesting private static final int FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT_VALUE = 16777216; @@ -54,7 +55,7 @@ static IntentFilter getInstallerReceiverFilter() { * @param requestCode request code for the sender. * @return IntentSender with receiver. */ - static IntentSender getInstallStatusIntentSender(Context context, int requestCode) throws NoSuchFieldException, IllegalAccessException { + static IntentSender getInstallStatusIntentSender(Context context, int requestCode) { int broadcastFlags = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { broadcastFlags = PendingIntent.FLAG_MUTABLE; diff --git a/sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/install/session/SessionReleaseInstaller.java b/sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/install/session/SessionReleaseInstaller.java index 1651a2547..1e40d2b4d 100644 --- a/sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/install/session/SessionReleaseInstaller.java +++ b/sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/install/session/SessionReleaseInstaller.java @@ -208,7 +208,7 @@ private synchronized void startInstallSession(@NonNull Uri localUri) { IntentSender statusReceiver = InstallStatusReceiver.getInstallStatusIntentSender(mContext, mSessionId); session.commit(statusReceiver); session.close(); - } catch (IOException | RuntimeException | NoSuchFieldException | IllegalAccessException e) { + } catch (IOException | RuntimeException e) { if (session != null) { session.abandon(); } diff --git a/sdk/appcenter-distribute/src/test/java/com/microsoft/appcenter/distribute/install/session/InstallStatusReceiverTest.java b/sdk/appcenter-distribute/src/test/java/com/microsoft/appcenter/distribute/install/session/InstallStatusReceiverTest.java index 9881d6fca..c7ead5c86 100644 --- a/sdk/appcenter-distribute/src/test/java/com/microsoft/appcenter/distribute/install/session/InstallStatusReceiverTest.java +++ b/sdk/appcenter-distribute/src/test/java/com/microsoft/appcenter/distribute/install/session/InstallStatusReceiverTest.java @@ -218,7 +218,7 @@ public void installerReceiverFilter() throws Exception { } @Test - public void createIntentSenderOnAndroid34() throws NoSuchFieldException, IllegalAccessException { + public void createIntentSenderOnAndroid34() { /* Mock SDK_INT to 34 target SDK. */ Whitebox.setInternalState(Build.VERSION.class, "SDK_INT", 34); @@ -226,7 +226,7 @@ public void createIntentSenderOnAndroid34() throws NoSuchFieldException, Illegal } @Test - public void createIntentSenderOnAndroidS() throws NoSuchFieldException, IllegalAccessException { + public void createIntentSenderOnAndroidS() { /* Mock SDK_INT to S. */ Whitebox.setInternalState(Build.VERSION.class, "SDK_INT", Build.VERSION_CODES.S); @@ -234,14 +234,14 @@ public void createIntentSenderOnAndroidS() throws NoSuchFieldException, IllegalA } @Test - public void createIntentSenderOnAndroidLowS() throws NoSuchFieldException, IllegalAccessException { + public void createIntentSenderOnAndroidLowS() { /* Mock SDK_INT to M. */ Whitebox.setInternalState(Build.VERSION.class, "SDK_INT", Build.VERSION_CODES.M); createIntentSender(0); } - private void createIntentSender(int expectedFlag) throws NoSuchFieldException, IllegalAccessException { + private void createIntentSender(int expectedFlag) { mockStatic(PendingIntent.class); PendingIntent intent = mock(PendingIntent.class); IntentSender sender = mock(IntentSender.class);