Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on DFU update on Android 12 - mutable flag missing on PendingIntent #315

Closed
zippert opened this issue Oct 27, 2021 · 6 comments
Closed
Labels

Comments

@zippert
Copy link

zippert commented Oct 27, 2021

DFU Bootloader version (please complete the following information):

  • SDK version: 31
  • Bonding used: yes
  • Library version: 1.11.1

Device information (please complete the following information):

  • Device: Pixel 4A
  • OS: Android 12

Describe the bug
When the app tries to trigger the flow, the app crashes as a pending intent is missing mandatory flags (see stack trace below):

private fun startDfuService(
        deviceAddress: String,
        deviceName: String?
    ) {
        DfuServiceInitiator.createDfuNotificationChannel(context.applicationContext)

        val dfuServiceInitiator = DfuServiceInitiator(deviceAddress)
                .setKeepBond(true)
                .setRestoreBond(true)
                .setPrepareDataObjectDelay(300L)
                .setNumberOfRetries(3)
                .setUnsafeExperimentalButtonlessServiceInSecureDfuEnabled(true)
                .setZip(R.raw.v3957_b01)

        if (deviceName != null) {
            dfuServiceInitiator.setDeviceName(deviceName)
        }

        dfuServiceInitiator.start(context.applicationContext, BleFirmwareUpgradeService::class.java)
        DfuServiceListenerHelper.registerProgressListener(
            context.applicationContext,
            this,
            deviceAddress
        )
        logger.logServiceStarting()
    }

Logs

10-27 13:02:39.006 26997 27424 E AndroidRuntime: FATAL EXCEPTION: IntentService[DfuBaseService]
10-27 13:02:39.006 26997 27424 E AndroidRuntime: Process: [REDACTED], PID: 26997
10-27 13:02:39.006 26997 27424 E AndroidRuntime: java.lang.IllegalArgumentException: [REDACTED]: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
10-27 13:02:39.006 26997 27424 E AndroidRuntime: Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
10-27 13:02:39.006 26997 27424 E AndroidRuntime: 	at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
10-27 13:02:39.006 26997 27424 E AndroidRuntime: 	at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458)
10-27 13:02:39.006 26997 27424 E AndroidRuntime: 	at android.app.PendingIntent.getActivity(PendingIntent.java:444)
10-27 13:02:39.006 26997 27424 E AndroidRuntime: 	at android.app.PendingIntent.getActivity(PendingIntent.java:408)
10-27 13:02:39.006 26997 27424 E AndroidRuntime: 	at no.nordicsemi.android.dfu.DfuBaseService.startForeground(DfuBaseService.java:1862)
10-27 13:02:39.006 26997 27424 E AndroidRuntime: 	at no.nordicsemi.android.dfu.DfuBaseService.onHandleIntent(DfuBaseService.java:1142)
10-27 13:02:39.006 26997 27424 E AndroidRuntime: 	at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:78)
10-27 13:02:39.006 26997 27424 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
10-27 13:02:39.006 26997 27424 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:201)
10-27 13:02:39.006 26997 27424 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:288)
10-27 13:02:39.006 26997 27424 E AndroidRuntime: 	at android.os.HandlerThread.run(HandlerThread.java:67)
@zippert zippert added the bug label Oct 27, 2021
@slobodanantonijevic
Copy link

This is a very critical issue, as Android 12 is already on the public roll out.

@philips77
Copy link
Member

The PR has already been merged, I'll release a version tomorrow. #313

@zippert
Copy link
Author

zippert commented Oct 29, 2021

@philips77 When can we expect a released version?

@philips77 philips77 mentioned this issue Oct 29, 2021
@zippert
Copy link
Author

zippert commented Oct 29, 2021

Is it publicly available? This page doesn't mention it? https://github.com/NordicSemiconductor/Android-DFU-Library

@philips77
Copy link
Member

It was released later that day. Did you try again?

@zippert
Copy link
Author

zippert commented Nov 4, 2021

It took a couple of days for it to appear in repo. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants